file stringlengths 16 94 | text stringlengths 32 24.4k | vector list |
|---|---|---|
javascript/reference/global_objects/uint32array/index.md | JavaScript - Global Objects - Uint32Array:
The `Uint32Array` typed array represents an array of 32-bit unsigned integers in the platform byte order. If control over byte order is needed, use `DataView` instead. The contents are initialized to `0` unless initialization data is explicitly provided. Once established, you... | [
-0.7712491154670715,
-0.36855795979499817,
-0.9413403868675232,
0.81029212474823,
0.23410692811012268,
-0.724648118019104,
0.28198763728141785,
1.4884531497955322,
-0.001358437817543745,
0.28342798352241516,
-0.42312341928482056,
0.1568470299243927,
0.39827442169189453,
-0.0706095322966575... |
javascript/reference/global_objects/uint32array/index.md | JavaScript - Global Objects - Uint32Array - Constructor:
- `Uint32Array()`: Creates a new `Uint32Array` object. | [
-0.8113806843757629,
0.3697992265224457,
-0.9927581548690796,
1.0168567895889282,
-0.2082473784685135,
-1.0539528131484985,
-0.90982586145401,
1.1436209678649902,
-0.05303141102194786,
0.16306520998477936,
-0.18142712116241455,
-0.2752051055431366,
0.31313684582710266,
0.00983321014791727,... |
javascript/reference/global_objects/uint32array/index.md | JavaScript - Global Objects - Uint32Array - Static properties:
Also inherits static properties from its parent `TypedArray`.
- `Uint32Array.BYTES_PER_ELEMENT`: Returns a number value of the element size. `4` in the case of `Uint32Array`. | [
-0.810036301612854,
0.7437837719917297,
-0.9847281575202942,
0.5875536203384399,
-0.06428810954093933,
-1.4712761640548706,
0.2996089458465576,
1.0934779644012451,
-0.28081920742988586,
0.020710961893200874,
-0.41928616166114807,
0.7281789779663086,
-0.26954787969589233,
-0.098600551486015... |
javascript/reference/global_objects/uint32array/index.md | JavaScript - Global Objects - Uint32Array - Static methods:
Inherits static methods from its parent `TypedArray`. | [
-0.6287751793861389,
0.35101747512817383,
-1.0586354732513428,
0.3282117247581482,
0.08144673705101013,
-1.368084192276001,
0.26610228419303894,
1.8978184461593628,
-0.5814005732536316,
0.11425771564245224,
-0.5412054657936096,
-0.32619404792785645,
-0.27954745292663574,
0.0515058934688568... |
javascript/reference/global_objects/uint32array/index.md | JavaScript - Global Objects - Uint32Array - Instance properties:
Also inherits instance properties from its parent `TypedArray`.
These properties are defined on `Uint32Array.prototype` and shared by all `Uint32Array` instances.
- `Uint32Array.prototype.BYTES_PER_ELEMENT`: Returns a number value of the element size. ... | [
-0.3358324468135834,
0.27406537532806396,
-0.8742288947105408,
0.542017936706543,
-0.0030544877517968416,
-1.3300819396972656,
-0.19194969534873962,
0.93427574634552,
0.10282190889120102,
0.12043216824531555,
-0.5757842063903809,
0.6091287136077881,
-0.5580394268035889,
0.4302252233028412,... |
javascript/reference/global_objects/uint32array/index.md | JavaScript - Global Objects - Uint32Array - Instance methods:
Inherits instance methods from its parent `TypedArray`. | [
-0.13377954065799713,
0.17048627138137817,
-0.6485550999641418,
0.5060611963272095,
-0.24169574677944183,
-1.2366588115692139,
0.311269611120224,
1.2436554431915283,
-0.600561261177063,
-0.36028170585632324,
-0.30365249514579773,
-0.044897764921188354,
-0.21372275054454803,
0.3818627297878... |
javascript/reference/global_objects/uint32array/index.md | JavaScript - Global Objects - Uint32Array - Examples - Different ways to create a Uint32Array:
Example:
// From a length
const uint32 = new Uint32Array(2);
uint32[0] = 42;
console.log(uint32[0]); // 42
console.log(uint32.length); // 2
console.log(uint32.BYTES_PER_ELEMENT); // 4
// From an array
const x = new Uint32A... | [
-0.20291392505168915,
0.20590339601039886,
-0.8099584579467773,
0.9469402432441711,
0.23655050992965698,
-0.7855072617530823,
-1.004544973373413,
0.6137969493865967,
-0.0746329054236412,
0.16017301380634308,
0.2318454533815384,
0.3980349600315094,
-0.39733532071113586,
0.14230391383171082,... |
javascript/reference/global_objects/uint32array/uint32array/index.md | JavaScript - Global Objects - Uint32Array:
The `Uint32Array()` constructor creates `Uint32Array` objects. The contents are initialized to `0` unless initialization data is explicitly provided. | [
-0.3923014998435974,
0.4135628640651703,
-0.7032381892204285,
1.3871650695800781,
-0.3246534764766693,
-1.200812578201294,
-0.49456655979156494,
1.07476806640625,
-0.3873046040534973,
0.3055679500102997,
-0.29137375950813293,
-0.32870006561279297,
-0.022501565515995026,
-0.2700836360454559... |
javascript/reference/global_objects/uint32array/uint32array/index.md | JavaScript - Global Objects - Uint32Array - Syntax:
Example:
new Uint32Array()
new Uint32Array(length)
new Uint32Array(typedArray)
new Uint32Array(object)
new Uint32Array(buffer)
new Uint32Array(buffer, byteOffset)
new Uint32Array(buffer, byteOffset, length)
Note: `Uint32Array()` can only be constructed with `new`.... | [
-0.6964799165725708,
0.2921023666858673,
-0.9061956405639648,
0.4017382264137268,
-0.03178487345576286,
-1.3116883039474487,
-0.972857654094696,
1.4141275882720947,
0.1971360445022583,
0.018785249441862106,
-0.015468435361981392,
0.4473796784877777,
0.5053043961524963,
0.3863396644592285,
... |
javascript/reference/global_objects/uint32array/uint32array/index.md | JavaScript - Global Objects - Uint32Array - Syntax - Parameters:
See `TypedArray`. | [
0.04678213223814964,
0.3645036816596985,
-0.85948646068573,
0.4179389774799347,
-0.28519317507743835,
-1.041603446006775,
-0.07055237144231796,
1.2285596132278442,
-0.22238656878471375,
0.3809792399406433,
-0.15669724345207214,
0.03225727379322052,
0.5691290497779846,
0.41725972294807434,
... |
javascript/reference/global_objects/uint32array/uint32array/index.md | JavaScript - Global Objects - Uint32Array - Syntax - Exceptions:
See `TypedArray`. | [
-0.3219316899776459,
0.04641936346888542,
-0.5658465027809143,
0.7064694166183472,
-0.42486926913261414,
-1.4880857467651367,
-0.47881606221199036,
1.3448479175567627,
-0.4140673577785492,
0.19099096953868866,
0.12066664546728134,
-0.30524128675460815,
0.30784091353416443,
0.39013731479644... |
javascript/reference/global_objects/uint32array/uint32array/index.md | JavaScript - Global Objects - Uint32Array - Examples - Different ways to create a Uint32Array:
Example:
// From a length
const uint32 = new Uint32Array(2);
uint32[0] = 42;
console.log(uint32[0]); // 42
console.log(uint32.length); // 2
console.log(uint32.BYTES_PER_ELEMENT); // 4
// From an array
const x = new Uint32A... | [
-0.20291392505168915,
0.20590339601039886,
-0.8099584579467773,
0.9469402432441711,
0.23655050992965698,
-0.7855072617530823,
-1.004544973373413,
0.6137969493865967,
-0.0746329054236412,
0.16017301380634308,
0.2318454533815384,
0.3980349600315094,
-0.39733532071113586,
0.14230391383171082,... |
javascript/reference/global_objects/promise/symbol.species/index.md | JavaScript - Global Objects - Promise - Symbol.species:
The `Promise[Symbol.species]` static accessor property returns the constructor used to construct return values from promise methods.
Warning: The existence of `[Symbol.species]` allows execution of arbitrary code and may create security vulnerabilities. It also ... | [
-1.8605948686599731,
-0.42411988973617554,
-0.9052785038948059,
-0.036990441381931305,
-0.7915984392166138,
-1.7973167896270752,
1.2098277807235718,
1.1794583797454834,
-0.5556712746620178,
0.24714027345180511,
-0.9822084307670593,
0.633173406124115,
-0.029744187369942665,
0.44791713356971... |
javascript/reference/global_objects/promise/symbol.species/index.md | JavaScript - Global Objects - Promise - Symbol.species - Syntax:
Example:
Promise[Symbol.species] | [
-0.8135465979576111,
0.4224451184272766,
-0.7233565449714661,
-1.2900736331939697,
-1.4383045434951782,
-1.939441204071045,
0.09013894945383072,
1.315628170967102,
-0.5624501705169678,
-0.64860999584198,
-0.16022342443466187,
0.493798166513443,
-0.5975339412689209,
0.5140321850776672,
1.... |
javascript/reference/global_objects/promise/symbol.species/index.md | JavaScript - Global Objects - Promise - Symbol.species - Syntax - Return value:
The value of the constructor (`this`) on which `get [Symbol.species]` was called. The return value is used to construct return values from promise chaining methods that create new promises. | [
-1.1870657205581665,
0.3183840811252594,
-0.8720986247062683,
0.048077668994665146,
-1.014583706855774,
-1.7809484004974365,
0.2975861430168152,
1.4887889623641968,
-0.6881006956100464,
-0.03773331642150879,
-0.849030077457428,
0.9692263007164001,
-0.4240513741970062,
1.2635490894317627,
... |
javascript/reference/global_objects/promise/symbol.species/index.md | JavaScript - Global Objects - Promise - Symbol.species - Description:
The `[Symbol.species]` accessor property returns the default constructor for `Promise` objects. Subclass constructors may override it to change the constructor assignment. The default implementation is basically:
Example:
// Hypothetical underlyin... | [
-0.6941730380058289,
0.1524498015642166,
-0.02018999680876732,
0.3238990604877472,
0.6077746152877808,
-1.068175196647644,
0.45318204164505005,
0.9617087841033936,
-0.8295469880104065,
-0.010555391199886799,
-0.7391235828399658,
0.37062588334083557,
0.2347249686717987,
0.2582067847251892,
... |
javascript/reference/global_objects/promise/symbol.species/index.md | JavaScript - Global Objects - Promise - Symbol.species - Examples - Species in ordinary objects:
The `Symbol.species` property returns the default constructor function, which is the `Promise` constructor for `Promise`.
Example:
Promise[Symbol.species]; // [Function: Promise] | [
-1.5301791429519653,
0.3462193012237549,
-1.18949294090271,
-0.48552659153938293,
-0.7078980207443237,
-1.8953498601913452,
-0.10173536837100983,
0.8634065985679626,
-0.6065688133239746,
-0.22046281397342682,
-0.4980236291885376,
0.4276914894580841,
-0.20773568749427795,
0.3484189212322235... |
javascript/reference/global_objects/promise/symbol.species/index.md | JavaScript - Global Objects - Promise - Symbol.species - Examples - Species in derived objects:
In an instance of a custom `Promise` subclass, such as `MyPromise`, the `MyPromise` species is the `MyPromise` constructor. However, you might want to override this, in order to return parent `Promise` objects in your deriv... | [
-0.907279908657074,
-0.31836172938346863,
-1.0059481859207153,
-0.2333163619041443,
-0.2664838433265686,
-2.040487051010132,
-0.008505476638674736,
1.1979351043701172,
-0.38910821080207825,
-0.31767919659614563,
-0.8109716176986694,
0.7225146889686584,
-1.3312709331512451,
0.20910516381263... |
javascript/reference/global_objects/promise/finally/index.md | JavaScript - Global Objects - Promise - finally:
The `finally()` method of `Promise` instances schedules a function to be called when the promise is settled (either fulfilled or rejected). It immediately returns another `Promise` object, allowing you to chain calls to other promise methods.
Like the `finally` block, ... | [
-1.3066266775131226,
0.34513333439826965,
-0.416051983833313,
-0.7553720474243164,
-0.3836418390274048,
-1.4221135377883911,
-0.11547552049160004,
-0.016296587884426117,
-0.8105188012123108,
0.7939484119415283,
-0.29549115896224976,
0.781936764717102,
0.14773009717464447,
0.993756353855133... |
javascript/reference/global_objects/promise/finally/index.md | JavaScript - Global Objects - Promise - finally - Syntax:
Example:
promiseInstance.finally(onFinally) | [
-0.5485479235649109,
0.660778284072876,
0.014682384207844734,
-1.078593134880066,
-0.8738800883293152,
-1.5143553018569946,
0.3794873058795929,
0.5452920198440552,
-0.7534784078598022,
-0.15131090581417084,
0.060110948979854584,
0.8600841760635376,
0.25251197814941406,
0.4262229800224304,
... |
javascript/reference/global_objects/promise/finally/index.md | JavaScript - Global Objects - Promise - finally - Syntax - Parameters:
- `onFinally`: A function to asynchronously execute when this promise becomes settled. If the function returns a promise, the resulting promise will wait for that promise to settle before continuing. If the returned promise is rejected, the resulti... | [
-0.8034266829490662,
1.1330626010894775,
0.20288769900798798,
-0.911588728427887,
-0.4240529239177704,
-1.0053329467773438,
0.4252070188522339,
0.31222400069236755,
-0.554140567779541,
0.22435978055000305,
-0.3799043595790863,
0.6475700736045837,
0.13704191148281097,
0.870164692401886,
0... |
javascript/reference/global_objects/promise/finally/index.md | JavaScript - Global Objects - Promise - finally - Syntax - Return value:
Returns a new `Promise` immediately. This new promise is always pending when returned, regardless of the current promise's status. If `onFinally` throws an error or returns a rejected promise, the new promise will reject with that value. Otherwis... | [
-0.9227266311645508,
0.720709502696991,
0.3683258295059204,
-0.5799222588539124,
-0.5504932999610901,
-0.8171575665473938,
0.5172244310379028,
0.4530174434185028,
-0.4380381405353546,
0.12009838223457336,
-0.6091415882110596,
1.1513310670852661,
-0.07044567912817001,
1.2040985822677612,
... |
javascript/reference/global_objects/promise/finally/index.md | JavaScript - Global Objects - Promise - finally - Description:
The `finally()` method can be useful if you want to do some processing or cleanup once the promise is settled, regardless of its outcome.
The `finally()` method is very similar to calling `then(onFinally, onFinally)`. However, there are a couple of differ... | [
-0.29326650500297546,
0.9853795170783997,
-0.3857421576976776,
-0.3100007474422455,
0.9706133604049683,
-0.750988245010376,
-0.060085803270339966,
0.6703882217407227,
-0.88801109790802,
0.21154876053333282,
-0.33139529824256897,
0.7662880420684814,
-0.1518910974264145,
0.2782515585422516,
... |
javascript/reference/global_objects/promise/finally/index.md | JavaScript - Global Objects - Promise - finally - Examples - Using finally():
Example:
let isLoading = true;
fetch(myRequest)
.then((response) => {
const contentType = response.headers.get("content-type");
if (contentType && contentType.includes("application/json")) {
return response.json();
}
... | [
-0.9771639108657837,
-0.1880231499671936,
-0.16802163422107697,
0.009950915351510048,
-0.3901347517967224,
-1.1558340787887573,
0.29943010210990906,
0.12065476924180984,
-0.9904780983924866,
-0.0074120331555604935,
0.015932723879814148,
0.4683542251586914,
0.0902218222618103,
-0.2086905688... |
javascript/reference/global_objects/promise/promise/index.md | JavaScript - Global Objects - Promise:
The `Promise()` constructor creates `Promise` objects. It is primarily used to wrap callback-based APIs that do not already support promises.
Example:
const promise1 = new Promise((resolve, reject) => {
setTimeout(() => {
resolve("foo");
}, 300);
});
promise1.then((val... | [
-1.1864651441574097,
-0.16930729150772095,
-0.8464205861091614,
0.3517730236053467,
-0.13143710792064667,
-1.7292897701263428,
-0.5270071029663086,
0.498727411031723,
-0.5108928084373474,
0.688606321811676,
-0.9690020084381104,
0.3074672520160675,
0.034419409930706024,
0.43192169070243835,... |
javascript/reference/global_objects/promise/promise/index.md | JavaScript - Global Objects - Promise - Syntax:
Example:
new Promise(executor)
Note: `Promise()` can only be constructed with `new`. Attempting to call it without `new` throws a `TypeError`. | [
-1.3601033687591553,
0.4205862283706665,
-0.12808440625667572,
-0.4555979371070862,
-0.458426296710968,
-1.50969398021698,
-0.29179444909095764,
1.630732774734497,
-0.3239484131336212,
-0.32294195890426636,
-0.01391943171620369,
-0.08142878115177155,
-0.05125780031085014,
0.058179430663585... |
javascript/reference/global_objects/promise/promise/index.md | JavaScript - Global Objects - Promise - Syntax - Parameters:
- `executor`: A `function` to be executed by the constructor. It receives two functions as parameters: `resolveFunc` and `rejectFunc`. Any errors thrown in the `executor` will cause the promise to be rejected, and the return value will be neglected. The sema... | [
-1.529597520828247,
-0.19110620021820068,
-0.4709091782569885,
-0.314069926738739,
-0.07870263606309891,
-1.4071117639541626,
-0.06590801477432251,
0.5430766344070435,
-0.43829983472824097,
0.2892962098121643,
-0.8056588768959045,
0.3926597237586975,
-0.511483371257782,
0.7268770337104797,... |
javascript/reference/global_objects/promise/promise/index.md | JavaScript - Global Objects - Promise - Syntax - Return value:
When called via `new`, the `Promise` constructor returns a promise object. The promise object will become resolved when either of the functions `resolveFunc` or `rejectFunc` are invoked. Note that if you call `resolveFunc` and pass another promise object a... | [
-0.7085967659950256,
0.5592212080955505,
-0.2900274991989136,
-0.17794595658779144,
-0.032383136451244354,
-1.5487008094787598,
0.40271368622779846,
0.6837867498397827,
-0.3672916293144226,
0.36434513330459595,
-0.3688277304172516,
0.2506464421749115,
-0.06636514514684677,
1.03956699371337... |
javascript/reference/global_objects/promise/promise/index.md | JavaScript - Global Objects - Promise - Description:
Traditionally (before promises), asynchronous tasks were designed as callbacks.
Example:
readFile("./data.txt", (error, result) => {
// This callback will be called when the task is done, with the
// final `error` or `result`. Any operation dependent on the
... | [
0.13610556721687317,
0.4056946933269501,
-0.3358842730522156,
-0.06819760799407959,
1.199318528175354,
-0.4195312559604645,
0.5675943493843079,
1.4087014198303223,
-0.7243338227272034,
0.02310243435204029,
-0.49371829628944397,
0.9863110780715942,
0.04369746893644333,
0.8416688442230225,
... |
javascript/reference/global_objects/promise/promise/index.md | JavaScript - Global Objects - Promise - Description - The resolve function:
The `resolve` function has the following behaviors:
- If it's called with the same value as the newly created promise (the promise it's "tethered to"), the promise is rejected with a `TypeError`.
- If it's called with a non-thenable value (a ... | [
-0.6832670569419861,
0.8612223863601685,
-0.15910384058952332,
-0.08328300714492798,
0.4876714050769806,
-0.7052381038665771,
0.7643482089042664,
1.2792670726776123,
-0.869228720664978,
0.30342915654182434,
-0.8092532753944397,
0.30452144145965576,
-0.2262754589319229,
0.5680971145629883,
... |
javascript/reference/global_objects/promise/promise/index.md | JavaScript - Global Objects - Promise - Examples - Turning a callback-based API into a promise-based one:
To provide a function with promise functionality, have it return a promise by calling the `resolve` and `reject` functions at the correct times.
Example:
function myAsyncFunction(url) {
return new Promise((res... | [
-1.3220521211624146,
0.583012580871582,
0.03198130056262016,
-0.07193103432655334,
-0.961875855922699,
-1.081487774848938,
0.45047467947006226,
0.015097779221832752,
-0.53740394115448,
0.11846408247947693,
-0.6634812951087952,
0.40159836411476135,
0.5173819661140442,
0.7485361099243164,
... |
javascript/reference/global_objects/promise/promise/index.md | JavaScript - Global Objects - Promise - Examples - Effect of calling resolveFunc:
Calling `resolveFunc` causes the promise to become resolved, so that calling `resolveFunc` or `rejectFunc` again has no effect. However, the promise may be in any of the states: pending, fulfilled, or rejected.
This `pendingResolved` pr... | [
-0.4100121855735779,
1.0810261964797974,
-0.38138124346733093,
-0.41688987612724304,
0.37589818239212036,
-0.21632373332977295,
0.16201156377792358,
0.3639867603778839,
-0.7631385326385498,
-0.016424760222434998,
-0.8341389298439026,
0.45577412843704224,
-0.7877187728881836,
0.818805813789... |
javascript/reference/global_objects/promise/try/index.md | JavaScript - Global Objects - Promise - try:
The `Promise.try()` static method takes a callback of any kind (returns or throws, synchronously or asynchronously) and wraps its result in a `Promise`. | [
-0.8864806294441223,
0.3452993631362915,
-0.6456013321876526,
-0.4099707305431366,
-0.640498161315918,
-0.6413664221763611,
0.7072464823722839,
0.35819876194000244,
-0.8512091040611267,
0.49147287011146545,
-0.7943708300590515,
0.27345484495162964,
0.12054211646318436,
0.5450703501701355,
... |
javascript/reference/global_objects/promise/try/index.md | JavaScript - Global Objects - Promise - try - Syntax:
Example:
Promise.try(func)
Promise.try(func, arg1)
Promise.try(func, arg1, arg2)
Promise.try(func, arg1, arg2, /* …, */ argN) | [
-1.3229165077209473,
0.9697100520133972,
0.4146907329559326,
-0.8949135541915894,
-0.5341787934303284,
-1.3880321979522705,
0.3926875591278076,
0.6032666563987732,
-0.7683475017547607,
-0.20542758703231812,
-0.3228713274002075,
-0.31732413172721863,
-0.766387939453125,
0.6359631419181824,
... |
javascript/reference/global_objects/promise/try/index.md | JavaScript - Global Objects - Promise - try - Syntax - Parameters:
- `func`: A function that is called synchronously with the arguments provided (`arg1`, `arg2`, …, `argN`). It can do anything—either return a value, throw an error, or return a promise.
- `arg1`, `arg2`, …, `argN`: Arguments to pass to `func`. | [
-1.0458649396896362,
0.6486613750457764,
0.02134374901652336,
-0.7770848870277405,
-0.5817249417304993,
-1.4211429357528687,
-0.08785584568977356,
0.07292276620864868,
-0.5383589863777161,
0.07477347552776337,
-0.48320525884628296,
0.17302365601062775,
-1.0854228734970093,
1.24615311622619... |
javascript/reference/global_objects/promise/try/index.md | JavaScript - Global Objects - Promise - try - Syntax - Return value:
A `Promise` that is:
- Already fulfilled, if `func` synchronously returns a value.
- Already rejected, if `func` synchronously throws an error.
- Asynchronously fulfilled or rejected, if `func` returns a promise. | [
-0.7515819072723389,
0.8839192390441895,
-0.008976646699011326,
-0.5737717151641846,
-0.5969510078430176,
-1.025148868560791,
1.0295559167861938,
0.6524131298065186,
-0.8704836368560791,
0.4968325197696686,
-0.010998470708727837,
0.2656647264957428,
-0.4127175509929657,
1.2219325304031372,... |
javascript/reference/global_objects/promise/try/index.md | JavaScript - Global Objects - Promise - try - Description:
You may have an API that takes a callback. The callback may be synchronous or asynchronous. You want to handle everything uniformly by wrapping the result in a promise. The most straightforward way might be `Promise.resolve(func())`. The problem is that if `fu... | [
-0.6214842796325684,
0.7023029327392578,
-0.8963263630867004,
-0.11169324815273285,
-0.3649982810020447,
-0.6014125943183899,
0.006168929394334555,
0.49831071496009827,
-0.4757801592350006,
0.8038891553878784,
-0.839123010635376,
0.06894132494926453,
0.5179117321968079,
1.4818869829177856,... |
javascript/reference/global_objects/promise/try/index.md | JavaScript - Global Objects - Promise - try - Examples - Using Promise.try():
The following example takes a callback, "lifts" it into a promise, handles the result, and does some error handling:
Example:
function doSomething(action) {
return Promise.try(action)
.then((result) => console.log(result))
.catch... | [
-0.198665589094162,
0.6799917817115784,
-1.0028444528579712,
-0.4764114022254944,
-0.501491129398346,
-0.9893217086791992,
0.813920795917511,
0.8355436325073242,
-0.8979576230049133,
0.39233332872390747,
-0.1744491159915924,
0.4552057683467865,
-0.15646283328533173,
0.2618626058101654,
0... |
javascript/reference/global_objects/promise/try/index.md | JavaScript - Global Objects - Promise - try - Examples - Calling try() on a non-Promise constructor:
`Promise.try()` is a generic method. It can be called on any constructor that implements the same signature as the `Promise()` constructor.
The following is a slightly more faithful approximation of the actual `Promis... | [
-0.6682422757148743,
0.8379491567611694,
-0.6427331566810608,
0.03717881813645363,
0.11652510613203049,
-1.4498034715652466,
0.0809067040681839,
0.47295311093330383,
-1.1639037132263184,
0.6268583536148071,
-0.3358251452445984,
-0.12404944002628326,
-0.16428115963935852,
0.3486508727073669... |
javascript/reference/global_objects/promise/catch/index.md | JavaScript - Global Objects - Promise - catch:
The `catch()` method of `Promise` instances schedules a function to be called when the promise is rejected. It immediately returns another `Promise` object, allowing you to chain calls to other promise methods. It is a shortcut for `then(undefined, onRejected)`.
Example:... | [
-0.8806838989257812,
0.002707949373871088,
-1.0460035800933838,
-0.6689143776893616,
-0.007252471521496773,
-1.3815720081329346,
0.5051908493041992,
0.6632240414619446,
-1.1680740118026733,
0.35754281282424927,
-0.5294883847236633,
-0.2988479733467102,
0.09336086362600327,
1.14907515048980... |
javascript/reference/global_objects/promise/catch/index.md | JavaScript - Global Objects - Promise - catch - Syntax:
Example:
promiseInstance.catch(onRejected) | [
-0.9941022992134094,
0.7155837416648865,
-0.24815838038921356,
-0.953093945980072,
-0.45498958230018616,
-1.5992202758789062,
1.029990315437317,
0.7052684426307678,
-1.3275233507156372,
-0.37850654125213623,
-0.33233150839805603,
-0.23935014009475708,
-0.38929319381713867,
0.93467062711715... |
javascript/reference/global_objects/promise/catch/index.md | JavaScript - Global Objects - Promise - catch - Syntax - Parameters:
- `onRejected`: A function to asynchronously execute when this promise becomes rejected. Its return value becomes the fulfillment value of the promise returned by `catch()`. The function is called with the following arguments:
- `reason`: The value... | [
-0.8885791897773743,
0.9403911232948303,
0.11807891726493835,
-0.8094955086708069,
0.12846602499485016,
-1.4207271337509155,
0.835011899471283,
0.3991539776325226,
-1.0593183040618896,
0.17300623655319214,
-0.5834978222846985,
-0.5015091300010681,
-0.881039023399353,
1.0900678634643555,
... |
javascript/reference/global_objects/promise/catch/index.md | JavaScript - Global Objects - Promise - catch - Syntax - Return value:
Returns a new `Promise`. This new promise is always pending when returned, regardless of the current promise's status. If `onRejected` is called, the returned promise will resolve based on the return value of this call, or reject with the thrown er... | [
-0.8792352676391602,
0.6072754859924316,
-0.3777238428592682,
-0.506830632686615,
-0.20771794021129608,
-1.015526533126831,
0.9189972281455994,
0.5459086298942566,
-1.0840563774108887,
0.07561009377241135,
-0.5856021046638489,
0.22630390524864197,
-0.518531084060669,
1.6864715814590454,
... |
javascript/reference/global_objects/promise/catch/index.md | JavaScript - Global Objects - Promise - catch - Description:
The `catch` method is used for error handling in promise composition. Since it returns a `Promise`, it can be chained in the same way as its sister method, `then()`.
If a promise becomes rejected, and there are no rejection handlers to call (a handler can b... | [
0.08154552429914474,
0.4325474500656128,
-0.8568018078804016,
0.18482977151870728,
0.7584800124168396,
-0.644315242767334,
0.3371775150299072,
0.7436848878860474,
-0.846219539642334,
-0.051669999957084656,
-0.7497101426124573,
-0.24516135454177856,
-0.02487313374876976,
0.9185901880264282,... |
javascript/reference/global_objects/promise/catch/index.md | JavaScript - Global Objects - Promise - catch - Examples - Using and chaining the catch() method:
Example:
const p1 = new Promise((resolve, reject) => {
resolve("Success");
});
p1.then((value) => {
console.log(value); // "Success!"
throw new Error("oh, no!");
})
.catch((e) => {
console.error(e.message); ... | [
-0.6079046130180359,
0.1498836874961853,
-1.1689645051956177,
-0.4182371199131012,
-0.42224982380867004,
-1.3352586030960083,
0.8569756746292114,
0.8855198621749878,
-1.264438509941101,
0.459049791097641,
-0.2878851890563965,
-0.200919508934021,
-0.14136482775211334,
0.38684341311454773,
... |
javascript/reference/global_objects/promise/catch/index.md | JavaScript - Global Objects - Promise - catch - Examples - Gotchas when throwing errors:
Throwing an error will call the `catch()` method most of the time:
Example:
const p1 = new Promise((resolve, reject) => {
throw new Error("Uh-oh!");
});
p1.catch((e) => {
console.error(e); // "Uh-oh!"
});
Errors thrown ins... | [
0.0992111936211586,
0.22605744004249573,
-1.0708695650100708,
-0.24269959330558777,
-0.3693132698535919,
-1.0454977750778198,
0.504292905330658,
0.8060287237167358,
-0.8346320390701294,
0.16104929149150848,
-0.3639669418334961,
-0.10772255808115005,
-0.07073957473039627,
0.3818380236625671... |
javascript/reference/global_objects/promise/catch/index.md | JavaScript - Global Objects - Promise - catch - Examples - catch() is not called if the promise is fulfilled:
Example:
// Create a promise which would not call onReject
const p1 = Promise.resolve("calling next");
const p2 = p1.catch((reason) => {
// This is never called
console.error("catch p1!");
console.erro... | [
-0.3111741840839386,
0.5937484502792358,
-0.9491651058197021,
-0.33344683051109314,
-0.4039435386657715,
-1.4441862106323242,
0.41662633419036865,
0.2292783111333847,
-1.1023133993148804,
0.09747831523418427,
0.13673615455627441,
-0.38731905817985535,
-0.44898200035095215,
0.34843221306800... |
javascript/reference/global_objects/promise/allsettled/index.md | JavaScript - Global Objects - Promise - allSettled:
The `Promise.allSettled()` static method takes an iterable of promises as input and returns a single `Promise`. This returned promise fulfills when all of the input's promises settle (including when an empty iterable is passed), with an array of objects that describe... | [
-0.8780059814453125,
0.18613965809345245,
-0.6280692219734192,
-0.14090925455093384,
-0.09039609134197235,
-1.6999741792678833,
0.498984694480896,
0.3223447799682617,
-0.5999080538749695,
0.6250156760215759,
-0.7500729560852051,
0.6392487287521362,
0.4604581296443939,
0.8495734333992004,
... |
javascript/reference/global_objects/promise/allsettled/index.md | JavaScript - Global Objects - Promise - allSettled - Syntax:
Example:
Promise.allSettled(iterable) | [
-0.33315590023994446,
0.3561747074127197,
-0.3561207354068756,
-0.6554009914398193,
-0.9367209076881409,
-1.7275327444076538,
0.4027281701564789,
1.080240249633789,
-0.1511087566614151,
-0.197671040892601,
-0.41188234090805054,
0.4564645290374756,
-0.07400692254304886,
0.7260393500328064,
... |
javascript/reference/global_objects/promise/allsettled/index.md | JavaScript - Global Objects - Promise - allSettled - Syntax - Parameters:
- `iterable`: An iterable (such as an `Array`) of promises. | [
0.1578812152147293,
0.35816097259521484,
-0.4430811405181885,
-0.1190076470375061,
-0.48602524399757385,
-1.1934404373168945,
0.16925132274627686,
1.1875176429748535,
-0.31607577204704285,
-0.1908777505159378,
-0.8653839826583862,
0.4239782989025116,
-0.4804425835609436,
0.9190798401832581... |
javascript/reference/global_objects/promise/allsettled/index.md | JavaScript - Global Objects - Promise - allSettled - Syntax - Return value:
A `Promise` that is:
- Already fulfilled, if the `iterable` passed is empty.
- Asynchronously fulfilled, when all promises in the given `iterable` have settled (either fulfilled or rejected). The fulfillment value is an array of objects, each... | [
-0.5607364177703857,
0.5008490681648254,
-0.21242472529411316,
-0.14421428740024567,
-0.19229359924793243,
-1.2610419988632202,
0.8877570033073425,
0.4438249170780182,
-0.4494781494140625,
0.5506939888000488,
-0.5477724075317383,
0.47003164887428284,
-0.2666003108024597,
1.4947160482406616... |
javascript/reference/global_objects/promise/allsettled/index.md | JavaScript - Global Objects - Promise - allSettled - Description:
The `Promise.allSettled()` method is one of the promise concurrency methods. `Promise.allSettled()` is typically used when you have multiple asynchronous tasks that are not dependent on one another to complete successfully, or you'd always like to know ... | [
-1.0711647272109985,
0.4670071601867676,
-0.9730848073959351,
-0.5366523265838623,
-0.5977519154548645,
-0.8929821848869324,
0.5555152893066406,
0.7638173699378967,
0.038833823055028915,
0.23916447162628174,
-1.3104567527770996,
0.6288580894470215,
0.16182994842529297,
0.9611782431602478,
... |
javascript/reference/global_objects/promise/allsettled/index.md | JavaScript - Global Objects - Promise - allSettled - Examples - Using Promise.allSettled():
Example:
Promise.allSettled([
Promise.resolve(33),
new Promise((resolve) => setTimeout(() => resolve(66), 0)),
99,
Promise.reject(new Error("an error")),
]).then((values) => console.log(values));
// [
// { status: '... | [
-0.44175392389297485,
0.30539652705192566,
-0.23458705842494965,
-0.9888312816619873,
-0.6902048587799072,
-1.446039080619812,
0.6316344141960144,
0.4018290638923645,
0.04116474837064743,
0.0360458567738533,
-0.28015241026878357,
0.1309315711259842,
0.1791793406009674,
0.983013927936554,
... |
javascript/reference/global_objects/promise/withresolvers/index.md | JavaScript - Global Objects - Promise - withResolvers:
The `Promise.withResolvers()` static method returns an object containing a new `Promise` object and two functions to resolve or reject it, corresponding to the two parameters passed to the executor of the `Promise()` constructor. | [
-1.1934177875518799,
-0.47696271538734436,
-0.3800024092197418,
0.030267897993326187,
-0.5720792412757874,
-0.982475996017456,
0.5506266951560974,
0.21973183751106262,
-0.35157355666160583,
0.13552339375019073,
-0.9042242169380188,
0.29273784160614014,
0.3735155761241913,
0.346700102090835... |
javascript/reference/global_objects/promise/withresolvers/index.md | JavaScript - Global Objects - Promise - withResolvers - Syntax:
Example:
Promise.withResolvers() | [
-0.7119895815849304,
0.001562584424391389,
-0.2314663678407669,
-0.757445216178894,
-1.4242891073226929,
-0.9692366123199463,
0.8438795804977417,
0.4022608995437622,
-0.2919008731842041,
-0.5101354122161865,
-0.26448318362236023,
0.41501155495643616,
-0.16578835248947144,
0.532607555389404... |
javascript/reference/global_objects/promise/withresolvers/index.md | JavaScript - Global Objects - Promise - withResolvers - Syntax - Parameters:
None. | [
-0.5244386792182922,
0.1380361169576645,
-0.7451242208480835,
-1.2555700540542603,
-1.1337321996688843,
-0.7817345261573792,
1.3016597032546997,
0.7625294923782349,
-0.26019975543022156,
-0.6016257405281067,
-0.42466169595718384,
-0.21571363508701324,
0.021667996421456337,
0.38213101029396... |
javascript/reference/global_objects/promise/withresolvers/index.md | JavaScript - Global Objects - Promise - withResolvers - Syntax - Return value:
A plain object containing the following properties:
- `promise`: A `Promise` object.
- `resolve`: A function that resolves the promise. For its semantics, see the `Promise()` constructor reference.
- `reject`: A function that rejects the p... | [
-0.9110450744628906,
0.5496618747711182,
-0.036867521703243256,
-0.5309042930603027,
-0.3668961524963379,
-1.097174882888794,
0.6842391490936279,
0.8090510368347168,
-0.202165424823761,
0.1613239049911499,
-0.5136660933494568,
0.7829833626747131,
-0.2312173694372177,
0.9214188456535339,
... |
javascript/reference/global_objects/promise/withresolvers/index.md | JavaScript - Global Objects - Promise - withResolvers - Description:
`Promise.withResolvers()` is exactly equivalent to the following code:
Example:
let resolve, reject;
const promise = new Promise((res, rej) => {
resolve = res;
reject = rej;
});
Except that it is more concise and does not require the use of `l... | [
-1.256414532661438,
-0.2701209783554077,
-0.33929017186164856,
-0.10742615908384323,
-0.1541876643896103,
-0.8613321781158447,
-0.2269826978445053,
0.36637958884239197,
0.0749741867184639,
0.21199624240398407,
-1.2673652172088623,
-0.0633079931139946,
-0.11748383939266205,
0.63889926671981... |
javascript/reference/global_objects/promise/withresolvers/index.md | JavaScript - Global Objects - Promise - withResolvers - Examples - Transforming a stream to an async iterable:
The use case of `Promise.withResolvers()` is when you have a promise that should be resolved or rejected by some event listener that cannot be wrapped inside the promise executor. The following example transf... | [
-0.5379023551940918,
0.8268270492553711,
-0.110969178378582,
0.04441026970744133,
-0.16976787149906158,
-0.3861232399940491,
0.01855708472430706,
-0.18295858800411224,
-0.1602725237607956,
0.41862043738365173,
-0.1975695639848709,
-0.077182337641716,
-0.38423940539360046,
0.332263171672821... |
javascript/reference/global_objects/promise/withresolvers/index.md | JavaScript - Global Objects - Promise - withResolvers - Examples - Calling withResolvers() on a non-Promise constructor:
`Promise.withResolvers()` is a generic method. It can be called on any constructor that implements the same signature as the `Promise()` constructor. For example, we can call it on a constructor tha... | [
-0.924296498298645,
0.39704063534736633,
-0.384443074464798,
0.10213454812765121,
-0.27674049139022827,
-0.8113532662391663,
-0.03339345008134842,
-0.02608722262084484,
-0.4238305687904358,
0.19778116047382355,
-0.1790153682231903,
0.21672947704792023,
0.385758638381958,
0.1332095414400100... |
javascript/reference/global_objects/promise/resolve/index.md | JavaScript - Global Objects - Promise - resolve:
The `Promise.resolve()` static method "resolves" a given value to a `Promise`. If the value is a promise, that promise is returned; if the value is a thenable, `Promise.resolve()` will call the `then()` method with two callbacks it prepared; otherwise the returned promi... | [
-0.8433473110198975,
0.6153793334960938,
-0.10036452859640121,
-0.6893961429595947,
-0.27559027075767517,
-0.8827717900276184,
0.7053727507591248,
1.373652696609497,
-0.49567699432373047,
0.3681566119194031,
-0.4774564504623413,
0.4797306954860687,
0.178583025932312,
0.4456947445869446,
... |
javascript/reference/global_objects/promise/resolve/index.md | JavaScript - Global Objects - Promise - resolve - Syntax:
Example:
Promise.resolve(value) | [
0.023798774927854538,
0.39526861906051636,
-0.07026077061891556,
-1.0844876766204834,
-1.0978727340698242,
-1.1710690259933472,
1.262559413909912,
1.118898868560791,
-0.10520511120557785,
-0.6086937189102173,
0.09789589047431946,
0.4481809735298157,
-0.5581568479537964,
0.7277887463569641,... |
javascript/reference/global_objects/promise/resolve/index.md | JavaScript - Global Objects - Promise - resolve - Syntax - Parameters:
- `value`: Argument to be resolved by this `Promise`. Can also be a `Promise` or a thenable to resolve. | [
0.40041640400886536,
0.5052520632743835,
0.11679138988256454,
-0.8884849548339844,
-0.6368124485015869,
-1.3732880353927612,
1.1653693914413452,
1.2732741832733154,
0.05782957747578621,
-0.35687074065208435,
-0.3470425009727478,
0.5089311599731445,
-0.6918373107910156,
0.8867902159690857,
... |
javascript/reference/global_objects/promise/resolve/index.md | JavaScript - Global Objects - Promise - resolve - Syntax - Return value:
A `Promise` that is resolved with the given value, or the promise passed as value, if the value was a promise object. A resolved promise can be in any of the states — fulfilled, rejected, or pending. For example, resolving a rejected promise will... | [
-0.13190612196922302,
0.5890242457389832,
0.27492573857307434,
-0.34122857451438904,
-0.6241587996482849,
-1.252020239830017,
1.0454139709472656,
1.0171785354614258,
-0.48264047503471375,
-0.13643485307693481,
-0.5498377680778503,
0.7976781129837036,
-0.7970035076141357,
1.322271466255188,... |
javascript/reference/global_objects/promise/resolve/index.md | JavaScript - Global Objects - Promise - resolve - Description:
`Promise.resolve()` resolves a promise, which is not the same as fulfilling or rejecting the promise. See Promise description for definitions of the terminology. In brief, `Promise.resolve()` returns a promise whose eventual state depends on another promis... | [
-0.6898605227470398,
0.9574092030525208,
0.4214567542076111,
-0.08494444936513901,
0.7943856716156006,
-0.36352166533470154,
0.5523043274879456,
0.8227475881576538,
-0.6820185780525208,
-0.053750764578580856,
-0.43200844526290894,
0.29415613412857056,
-0.18009869754314423,
0.63766109943389... |
javascript/reference/global_objects/promise/resolve/index.md | JavaScript - Global Objects - Promise - resolve - Examples - Using the static Promise.resolve method:
Example:
Promise.resolve("Success").then(
(value) => {
console.log(value); // "Success"
},
(reason) => {
// not called
},
); | [
-0.6401568651199341,
0.5592857003211975,
-0.04012857377529144,
-0.5680335760116577,
-0.6154909133911133,
-0.6591695547103882,
1.288228154182434,
0.4499635696411133,
-0.28700870275497437,
-0.05778113007545471,
0.0510680265724659,
0.4388028383255005,
0.0977790430188179,
0.23134538531303406,
... |
javascript/reference/global_objects/promise/resolve/index.md | JavaScript - Global Objects - Promise - resolve - Examples - Resolving an array:
Example:
const p = Promise.resolve([1, 2, 3]);
p.then((v) => {
console.log(v[0]); // 1
}); | [
-0.0018431878415867686,
-0.08249703049659729,
-0.3968374729156494,
-0.47771990299224854,
-0.7940722107887268,
-1.090049386024475,
0.9588848948478699,
0.6830415725708008,
-0.1698707789182663,
-0.22365987300872803,
0.17011024057865143,
0.1800522804260254,
-0.2915765047073364,
0.1014680266380... |
javascript/reference/global_objects/promise/resolve/index.md | JavaScript - Global Objects - Promise - resolve - Examples - Resolving another Promise:
`Promise.resolve()` reuses existing `Promise` instances. If it's resolving a native promise, it returns the same promise instance without creating a wrapper.
Example:
const original = Promise.resolve(33);
const cast = Promise.res... | [
-0.7506668567657471,
0.3984018862247467,
-0.31823378801345825,
0.29980847239494324,
-0.7852072715759277,
-0.7309734225273132,
0.8195450305938721,
0.5037393569946289,
-0.3175462484359741,
0.1888151913881302,
-0.28235509991645813,
0.12465572357177734,
-0.28330981731414795,
0.7815709710121155... |
javascript/reference/global_objects/promise/resolve/index.md | JavaScript - Global Objects - Promise - resolve - Examples - Resolving thenables and throwing Errors:
Example:
// Resolving a thenable object
const p1 = Promise.resolve({
then(onFulfill, onReject) {
onFulfill("fulfilled!");
},
});
console.log(p1 instanceof Promise); // true, object casted to a Promise
p1.the... | [
0.3955305516719818,
0.48199015855789185,
-0.03549303859472275,
0.33903127908706665,
0.3607807755470276,
-0.48515957593917847,
0.347023606300354,
0.5923208594322205,
-1.0681722164154053,
0.09396844357252121,
-0.5954695343971252,
-0.013776222243905067,
-0.45846548676490784,
0.450273543596267... |
javascript/reference/global_objects/promise/resolve/index.md | JavaScript - Global Objects - Promise - resolve - Examples - Calling resolve() on a non-Promise constructor:
`Promise.resolve()` is a generic method. It can be called on any constructor that implements the same signature as the `Promise()` constructor. For example, we can call it on a constructor that passes it `conso... | [
0.2633453607559204,
0.36740556359291077,
-0.4987603724002838,
0.4257371425628662,
0.4733255207538605,
-0.7385637164115906,
0.8449030518531799,
0.5259507894515991,
-0.8444138765335083,
0.2860479950904846,
-0.5136670470237732,
0.07373692840337753,
-0.12920808792114258,
0.06500985473394394,
... |
javascript/reference/global_objects/promise/then/index.md | JavaScript - Global Objects - Promise - then:
The `then()` method of `Promise` instances takes up to two arguments: callback functions for the fulfilled and rejected cases of the `Promise`. It stores the callbacks within the promise it is called on and immediately returns another `Promise` object, allowing you to chai... | [
-0.805163562297821,
0.25833308696746826,
-0.4402450621128082,
0.17719429731369019,
-0.018552668392658234,
-1.3087941408157349,
-0.10341371595859528,
0.22308269143104553,
-0.9647725820541382,
0.30681630969047546,
-0.6172603964805603,
-0.008452317677438259,
0.1831180453300476,
0.504170775413... |
javascript/reference/global_objects/promise/then/index.md | JavaScript - Global Objects - Promise - then - Syntax:
Example:
then(onFulfilled)
then(onFulfilled, onRejected) | [
-0.5339981317520142,
0.720588207244873,
0.41249457001686096,
-0.6015178561210632,
-0.6726533770561218,
-2.436908006668091,
1.2597732543945312,
0.2678823173046112,
-1.3686013221740723,
-0.21738380193710327,
0.022610435262322426,
0.012207402847707272,
-0.38053596019744873,
0.3277998864650726... |
javascript/reference/global_objects/promise/then/index.md | JavaScript - Global Objects - Promise - then - Syntax - Parameters:
- `onFulfilled`: A function to asynchronously execute when this promise becomes fulfilled. Its return value becomes the fulfillment value of the promise returned by `then()`. The function is called with the following arguments: - `value`: The value t... | [
-0.44572821259498596,
0.9572962522506714,
-0.2999385595321655,
-0.7887061238288879,
-0.5208973288536072,
-1.6240049600601196,
0.6075452566146851,
0.24621398746967316,
-0.4714313745498657,
0.26521775126457214,
-0.3043825626373291,
-0.1742720901966095,
-0.769877016544342,
0.489780455827713,
... |
javascript/reference/global_objects/promise/then/index.md | JavaScript - Global Objects - Promise - then - Syntax - Return value:
Returns a new `Promise` immediately. This returned promise is always pending when returned, regardless of the current promise's status.
One of the `onFulfilled` and `onRejected` handlers will be executed to handle the current promise's fulfillment ... | [
-1.4212157726287842,
0.7178114056587219,
-0.32262131571769714,
0.027218710631132126,
-0.39921835064888,
-0.9586360454559326,
0.920586884021759,
0.7197187542915344,
-0.6718421578407288,
0.21762269735336304,
-0.5456744432449341,
0.2971944212913513,
-0.31010955572128296,
0.9861776828765869,
... |
javascript/reference/global_objects/promise/then/index.md | JavaScript - Global Objects - Promise - then - Description:
The `then()` method schedules callback functions for the eventual completion of a Promise — either fulfillment or rejection. It is the primitive method of promises: the thenable protocol expects all promise-like objects to expose a `then()` method, and the `c... | [
-0.6941868662834167,
0.5222057700157166,
-0.32445937395095825,
0.6583283543586731,
0.567319393157959,
-0.6941671967506409,
0.6139331459999084,
1.1699036359786987,
-0.8535900115966797,
0.36481598019599915,
-0.7873576879501343,
0.5321698188781738,
-0.3900297284126282,
0.5420312285423279,
0... |
javascript/reference/global_objects/promise/then/index.md | JavaScript - Global Objects - Promise - then - Examples - Using the then() method:
Example:
const p1 = new Promise((resolve, reject) => {
resolve("Success!");
// or
// reject(new Error("Error!"));
});
p1.then(
(value) => {
console.log(value); // Success!
},
(reason) => {
console.error(reason); //... | [
-0.6429802179336548,
0.32019224762916565,
-0.31732481718063354,
0.12896469235420227,
-0.13347332179546356,
-1.4107646942138672,
0.6581751108169556,
0.15308263897895813,
-0.4140966832637787,
0.18841953575611115,
-0.2542012929916382,
-0.033579181879758835,
-0.04585063457489014,
-0.1305803358... |
javascript/reference/global_objects/promise/then/index.md | JavaScript - Global Objects - Promise - then - Examples - Having a non-function as either parameter:
Example:
Promise.resolve(1).then(2).then(console.log); // 1
Promise.reject(new Error("failed")).then(2, 2).then(console.log, console.log); // Error: failed | [
-0.9188070297241211,
0.2812732756137848,
-0.37206074595451355,
-0.14987367391586304,
-0.5315331816673279,
-1.3548139333724976,
0.7534859776496887,
0.3999873995780945,
-0.7879506349563599,
-0.23574064671993256,
0.38444051146507263,
-0.13031230866909027,
0.16707022488117218,
0.23251472413539... |
javascript/reference/global_objects/promise/then/index.md | JavaScript - Global Objects - Promise - then - Examples - Chaining:
The `then` method returns a new `Promise`, which allows for method chaining.
If the function passed as handler to `then` returns a `Promise`, an equivalent `Promise` will be exposed to the subsequent `then` in the method chain. The below snippet simu... | [
0.334826797246933,
0.47619006037712097,
-0.24326469004154205,
0.0616573765873909,
0.9247877597808838,
-0.8365874290466309,
0.27013155817985535,
1.3291932344436646,
-0.7098454833030701,
0.14234185218811035,
0.020717257633805275,
0.04339674487709999,
-0.44764938950538635,
0.15083372592926025... |
javascript/reference/global_objects/promise/then/index.md | JavaScript - Global Objects - Promise - then - Examples - Asynchronicity of then():
The following is an example to demonstrate the asynchronicity of the `then` method.
Example:
// Using a resolved promise 'resolvedProm' for example,
// the function call 'resolvedProm.then(...)' returns a new promise immediately,
// ... | [
-0.7098522782325745,
0.44255000352859497,
-0.6974262595176697,
-0.12880666553974152,
-0.604163408279419,
-0.980415403842926,
-0.23018714785575867,
1.0012050867080688,
-0.45178595185279846,
0.3832850456237793,
0.21545903384685516,
0.05015406012535095,
0.23710936307907104,
0.6701576113700867... |
javascript/reference/global_objects/promise/reject/index.md | JavaScript - Global Objects - Promise - reject:
The `Promise.reject()` static method returns a `Promise` object that is rejected with a given reason.
Example:
function resolved(result) {
console.log("Resolved");
}
function rejected(result) {
console.error(result);
}
Promise.reject(new Error("fail")).then(resol... | [
-1.3039281368255615,
0.3614920973777771,
-0.23564232885837555,
-0.9527338743209839,
0.029474914073944092,
-1.623906135559082,
0.6985551118850708,
0.4091722369194031,
-0.7581619024276733,
0.394307017326355,
-0.49428480863571167,
0.042973484843969345,
0.04610332474112511,
0.8606580495834351,... |
javascript/reference/global_objects/promise/reject/index.md | JavaScript - Global Objects - Promise - reject - Syntax:
Example:
Promise.reject(reason) | [
-0.7231175899505615,
0.9246337413787842,
0.04347226396203041,
-1.701535701751709,
-0.960151195526123,
-1.9787468910217285,
0.5151941776275635,
0.45780906081199646,
-0.517319917678833,
-0.330046147108078,
-0.3866487443447113,
0.05331671983003616,
-0.7426822781562805,
0.45087140798568726,
... |
javascript/reference/global_objects/promise/reject/index.md | JavaScript - Global Objects - Promise - reject - Syntax - Parameters:
- `reason`: Reason why this `Promise` rejected. | [
-0.5593394041061401,
0.939708948135376,
0.06087178364396095,
-1.820101261138916,
-0.8480082154273987,
-1.9383200407028198,
0.37087684869766235,
0.5368430614471436,
-0.21460694074630737,
-0.22944723069667816,
-0.7340289950370789,
0.29418522119522095,
-0.8215534687042236,
0.8146023154258728,... |
javascript/reference/global_objects/promise/reject/index.md | JavaScript - Global Objects - Promise - reject - Syntax - Return value:
A `Promise` that is rejected with the given reason. | [
-0.6575658917427063,
0.7520102858543396,
0.048336610198020935,
-1.3115483522415161,
-0.40665963292121887,
-1.2895565032958984,
0.6068893074989319,
0.6569613218307495,
-0.39267244935035706,
0.18685775995254517,
-0.7892927527427673,
0.5692217350006104,
-0.863175094127655,
1.1087725162506104,... |
javascript/reference/global_objects/promise/reject/index.md | JavaScript - Global Objects - Promise - reject - Description:
The static `Promise.reject` function returns a `Promise` that is rejected. For debugging purposes and selective error catching, it is useful to make `reason` an `instanceof` `Error`.
`Promise.reject()` is generic and supports subclassing, which means it ca... | [
-1.6656922101974487,
0.009998039342463017,
-0.4743848145008087,
-0.6638561487197876,
0.4230237603187561,
-1.3255542516708374,
0.4686216711997986,
0.20132805407047272,
-0.31903669238090515,
0.49596962332725525,
-1.2473582029342651,
-0.22735461592674255,
0.3346889615058899,
0.852221608161926... |
javascript/reference/global_objects/promise/reject/index.md | JavaScript - Global Objects - Promise - reject - Examples - Using the static Promise.reject() method:
Example:
Promise.reject(new Error("fail")).then(
() => {
// not called
},
(error) => {
console.error(error); // Stacktrace
},
); | [
-1.0766874551773071,
0.4991716742515564,
-0.10600460320711136,
-0.7202712893486023,
-0.5030773878097534,
-1.6502368450164795,
1.212752342224121,
-0.018285181373357773,
-0.9521754384040833,
0.17763200402259827,
-0.6998083591461182,
-0.34633108973503113,
0.22093777358531952,
0.46327900886535... |
javascript/reference/global_objects/promise/reject/index.md | JavaScript - Global Objects - Promise - reject - Examples - Rejecting with a promise:
Unlike `Promise.resolve`, the `Promise.reject` method does not reuse existing `Promise` instances. It always returns a new `Promise` instance that wraps `reason`.
Example:
const p = Promise.resolve(1);
const rejected = Promise.reje... | [
-0.33542242646217346,
0.48161259293556213,
0.09244509786367416,
0.2238234430551529,
0.32029104232788086,
-1.177494764328003,
0.5895591378211975,
0.2591405212879181,
-0.941569983959198,
-0.03875412419438362,
-0.5446179509162903,
0.2684076428413391,
0.1441870778799057,
0.40547963976860046,
... |
javascript/reference/global_objects/promise/reject/index.md | JavaScript - Global Objects - Promise - reject - Examples - Calling reject() on a non-Promise constructor:
`Promise.reject()` is a generic method. It can be called on any constructor that implements the same signature as the `Promise()` constructor. For example, we can call it on a constructor that passes it `console.... | [
0.3306519687175751,
0.6839113235473633,
-0.4947759509086609,
0.3315509855747223,
0.6571579575538635,
-1.429351806640625,
0.683097779750824,
0.4799182415008545,
-1.0805201530456543,
0.33023500442504883,
-0.8101542592048645,
-0.16238516569137573,
0.20344528555870056,
-0.07975861430168152,
... |
javascript/reference/global_objects/arraybuffer/index.md | JavaScript - Global Objects - ArrayBuffer:
The `ArrayBuffer` object is used to represent a generic raw binary data buffer.
It is an array of bytes, often referred to in other languages as a "byte array". You cannot directly manipulate the contents of an `ArrayBuffer`; instead, you create one of the typed array object... | [
0.08328451216220856,
-0.2671191394329071,
-2.040494918823242,
0.5594884753227234,
-0.06118836626410484,
-1.7550729513168335,
0.2799217700958252,
0.9128311276435852,
0.7519124150276184,
-0.1705579310655594,
-1.1647753715515137,
0.058815017342567444,
-0.13950243592262268,
0.6961683630943298,... |
javascript/reference/global_objects/arraybuffer/index.md | JavaScript - Global Objects - ArrayBuffer - Description - Resizing ArrayBuffers:
`ArrayBuffer` objects can be made resizable by including the `maxByteLength` option when calling the `ArrayBuffer()` constructor. You can query whether an `ArrayBuffer` is resizable and what its maximum size is by accessing its `resizable... | [
0.316938191652298,
0.3728281557559967,
-0.510469913482666,
0.5905970335006714,
0.21698035299777985,
-0.38236334919929504,
0.4696080982685089,
0.742751955986023,
-0.1055479496717453,
-0.4303737282752991,
-0.9200214147567749,
0.1807195544242859,
-0.49120715260505676,
0.44144684076309204,
0... |
javascript/reference/global_objects/arraybuffer/index.md | JavaScript - Global Objects - ArrayBuffer - Description - Transferring ArrayBuffers:
`ArrayBuffer` objects can be transferred between different execution contexts, like Web Workers or Service Workers, using the structured clone algorithm. This is done by passing the `ArrayBuffer` as a transferable object in a call to ... | [
-0.0037613241001963615,
-0.2378016710281372,
-1.135807991027832,
1.1118674278259277,
0.5988240242004395,
-0.316235214471817,
0.15810774266719818,
1.0900884866714478,
0.13700872659683228,
-0.3757929801940918,
-0.6103553771972656,
0.5202013254165649,
0.05669490993022919,
1.1262694597244263,
... |
javascript/reference/global_objects/arraybuffer/index.md | JavaScript - Global Objects - ArrayBuffer - Constructor:
- `ArrayBuffer()`: Creates a new `ArrayBuffer` object. | [
-0.35078486800193787,
-0.2158619463443756,
-1.4617515802383423,
0.5411051511764526,
-0.5778188705444336,
-1.7620677947998047,
-0.05947200581431389,
1.2277299165725708,
0.3263339400291443,
-0.132559135556221,
-0.8279675245285034,
-0.5359225273132324,
-0.3101711571216583,
0.23231028020381927... |
javascript/reference/global_objects/arraybuffer/index.md | JavaScript - Global Objects - ArrayBuffer - Static properties:
- `ArrayBuffer[Symbol.species]`: The constructor function that is used to create derived objects. | [
0.17179711163043976,
0.04125058278441429,
-1.2782998085021973,
0.8568043112754822,
-0.32611507177352905,
-2.1036746501922607,
0.04834527522325516,
1.380419373512268,
0.5238028168678284,
0.03378160297870636,
-1.5377631187438965,
-0.24186553061008453,
-0.5851275324821472,
0.7863699197769165,... |
javascript/reference/global_objects/arraybuffer/index.md | JavaScript - Global Objects - ArrayBuffer - Static methods:
- `ArrayBuffer.isView()`: Returns `true` if `arg` is one of the ArrayBuffer views, such as typed array objects or a `DataView`. Returns `false` otherwise. | [
-0.5504060983657837,
-0.03905678912997246,
-0.45656636357307434,
0.4219232201576233,
-0.8013842701911926,
-1.7517613172531128,
1.174149513244629,
0.7532272338867188,
-0.05142957717180252,
0.2848312258720398,
-1.166243314743042,
-1.1095441579818726,
0.8106347918510437,
0.3795795440673828,
... |
javascript/reference/global_objects/arraybuffer/index.md | JavaScript - Global Objects - ArrayBuffer - Instance properties:
These properties are defined on `ArrayBuffer.prototype` and shared by all `ArrayBuffer` instances.
- `ArrayBuffer.prototype.byteLength`: The size, in bytes, of the `ArrayBuffer`. This is established when the array is constructed and can only be changed ... | [
-0.09274753928184509,
-0.3073004186153412,
-0.4129270315170288,
0.8254431486129761,
0.09404456615447998,
-0.6392449736595154,
0.685401976108551,
1.293886423110962,
0.19666539132595062,
-0.03171401470899582,
-1.383000373840332,
0.3938148319721222,
0.0604231096804142,
0.08243901282548904,
... |
javascript/reference/global_objects/arraybuffer/index.md | JavaScript - Global Objects - ArrayBuffer - Instance methods:
- `ArrayBuffer.prototype.resize()`: Resizes the `ArrayBuffer` to the specified size, in bytes.
- `ArrayBuffer.prototype.slice()`: Returns a new `ArrayBuffer` whose contents are a copy of this `ArrayBuffer`'s bytes from `begin` (inclusive) up to `end` (exclu... | [
-0.28472498059272766,
-0.25747862458229065,
-1.0205570459365845,
0.5642392635345459,
-0.15922701358795166,
-0.7392380237579346,
0.7231813073158264,
0.7030300498008728,
0.5050786137580872,
0.5000723004341125,
-1.6115673780441284,
0.24007053673267365,
-0.2734493613243103,
0.41567036509513855... |
javascript/reference/global_objects/arraybuffer/index.md | JavaScript - Global Objects - ArrayBuffer - Examples - Creating an ArrayBuffer:
In this example, we create a 8-byte buffer with an `Int32Array` view referring to the buffer:
Example:
const buffer = new ArrayBuffer(8);
const view = new Int32Array(buffer); | [
0.3821255564689636,
0.03363347798585892,
-1.1021833419799805,
0.9242686033248901,
-0.3028046488761902,
-1.4691466093063354,
-0.22991332411766052,
0.9981175661087036,
0.809965968132019,
-0.20292775332927704,
-0.2638853192329407,
0.1713094413280487,
-0.10700333118438721,
0.1976800411939621,
... |
javascript/reference/global_objects/arraybuffer/transfertofixedlength/index.md | JavaScript - Global Objects - ArrayBuffer - transferToFixedLength:
The `transferToFixedLength()` method of `ArrayBuffer` instances creates a new non-resizable `ArrayBuffer` with the same byte content as this buffer, then detaches this buffer. | [
0.09783302247524261,
-0.26904281973838806,
-1.360724687576294,
1.3981530666351318,
-0.4802283048629761,
-1.8043482303619385,
0.4185578525066376,
0.8047834038734436,
-0.2446025013923645,
-0.18853725492954254,
-1.3830664157867432,
-0.03241284191608429,
-0.6555198431015015,
0.8736076354980469... |
javascript/reference/global_objects/arraybuffer/transfertofixedlength/index.md | JavaScript - Global Objects - ArrayBuffer - transferToFixedLength - Syntax:
Example:
transferToFixedLength()
transferToFixedLength(newByteLength) | [
-0.8695656657218933,
0.23369230329990387,
-1.081693172454834,
0.5711681246757507,
-0.7052643299102783,
-1.9894143342971802,
0.07154291123151779,
0.6190558671951294,
-0.2207459658384323,
-0.5903332233428955,
-0.9454048275947571,
0.6207739114761353,
-0.16757647693157196,
0.46228164434432983,... |
javascript/reference/global_objects/arraybuffer/transfertofixedlength/index.md | JavaScript - Global Objects - ArrayBuffer - transferToFixedLength - Syntax - Parameters:
- `newByteLength`: The `byteLength` of the new `ArrayBuffer`. Defaults to the `byteLength` of this `ArrayBuffer`.
- If `newByteLength` is smaller than the `byteLength` of this `ArrayBuffer`, the "overflowing" bytes are dropped.
... | [
-0.5869302749633789,
-0.5221549272537231,
-1.8693630695343018,
0.6603108644485474,
-0.0033958659041672945,
-2.3878657817840576,
0.5356696844100952,
0.7761526107788086,
0.2967805564403534,
-0.24834416806697845,
-1.3359099626541138,
0.1853642761707306,
-0.11101370304822922,
0.775445222854614... |
javascript/reference/global_objects/arraybuffer/transfertofixedlength/index.md | JavaScript - Global Objects - ArrayBuffer - transferToFixedLength - Syntax - Return value:
A new `ArrayBuffer` object. Its contents are initialized to the contents of this `ArrayBuffer`, and extra bytes, if any, are filled with zeros. The new `ArrayBuffer` is always non-resizable. The original `ArrayBuffer` is detache... | [
-0.0023184630554169416,
-0.32834941148757935,
-1.193315863609314,
1.0047253370285034,
-0.6482684016227722,
-1.7506842613220215,
0.9129186868667603,
0.8792051672935486,
0.18891601264476776,
0.1809656023979187,
-0.9901508092880249,
0.14773716032505035,
-0.43855419754981995,
1.341964244842529... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.