file
stringlengths
16
94
text
stringlengths
32
24.4k
vector
list
javascript/reference/global_objects/isfinite/index.md
JavaScript - Global Objects - isFinite: The `isFinite()` function determines whether a value is finite, first converting the value to a number if necessary. A finite number is one that's not `NaN` or ±`Infinity`. Because coercion inside the `isFinite()` function can be surprising, you may prefer to use `Number.isFinit...
[ -1.473564863204956, -0.6089397072792053, -0.6177193522453308, -0.08599098771810532, -0.5111756324768066, -1.4508869647979736, 0.7627633213996887, -0.28189733624458313, -0.0954028069972992, 0.61314857006073, -0.7602981328964233, -0.7421636581420898, -0.26266780495643616, 0.2630895674228668,...
javascript/reference/global_objects/isfinite/index.md
JavaScript - Global Objects - isFinite - Syntax: Example: isFinite(value)
[ -0.041140515357255936, 0.20241956412792206, -0.2974089980125427, -0.10634107887744904, -0.8277244567871094, -1.7502204179763794, 1.277360200881958, 0.473581463098526, -0.4388420879840851, -0.20937146246433258, -0.576988160610199, 0.05718596279621124, 0.4183809757232666, 0.5936912298202515,...
javascript/reference/global_objects/isfinite/index.md
JavaScript - Global Objects - isFinite - Syntax - Parameters: - `value`: The value to be tested.
[ 0.0026857417542487383, 0.32256901264190674, -0.2733837962150574, -0.5870892405509949, -0.3883313536643982, -1.5202765464782715, 1.1659654378890991, 0.2966957092285156, -0.21629412472248077, 0.07982227206230164, -0.9348310232162476, 0.09444447606801987, 0.12799318134784698, 0.94216442108154...
javascript/reference/global_objects/isfinite/index.md
JavaScript - Global Objects - isFinite - Syntax - Return value: `false` if the given value is `NaN`, `Infinity`, or `-Infinity` after being converted to a number; otherwise, `true`.
[ -1.216483235359192, 0.0357668474316597, -0.0190886240452528, -0.16915223002433777, -1.0669699907302856, -1.7871694564819336, 1.0400645732879639, 0.15751080214977264, -0.88211989402771, 0.30513864755630493, -1.0667929649353027, -0.6132517457008362, 0.5524358153343201, 0.18176309764385223, ...
javascript/reference/global_objects/isfinite/index.md
JavaScript - Global Objects - isFinite - Description: `isFinite()` is a function property of the global object. When the argument to the `isFinite()` function is not of type Number, the value is first coerced to a number, and the resulting value is then compared against `NaN` and ±Infinity. This is as confusing as th...
[ -1.4469761848449707, -0.3177221119403839, -0.39259135723114014, -0.08355701714754105, -0.4788089096546173, -1.7467421293258667, 0.7218907475471497, 0.03279930353164673, -0.3427596688270569, 0.535033106803894, -1.4027612209320068, -0.7228162884712219, 0.142379492521286, 0.3087424337863922, ...
javascript/reference/global_objects/isfinite/index.md
JavaScript - Global Objects - isFinite - Examples - Using isFinite(): Example: isFinite(Infinity); // false isFinite(NaN); // false isFinite(-Infinity); // false isFinite(0); // true isFinite(2e64); // true isFinite(910); // true // Would've been false with the more robust Number.isFinite(): isFinite(null); // true...
[ -1.0334064960479736, 0.26376405358314514, 0.08763831108808517, 0.04168049618601799, -0.7156063318252563, -1.7592458724975586, 1.3122828006744385, 0.24632227420806885, -0.6631408333778381, 0.06561753153800964, -1.4330151081085205, -0.43022438883781433, 0.1434853971004486, -0.097294434905052...
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/index.md
JavaScript - Global Objects - Promise: The `Promise` object represents the eventual completion (or failure) of an asynchronous operation and its resulting value. To learn about the way promises work and how you can use them, we advise you to read Using promises first.
[ -0.9334505796432495, 0.41723912954330444, -0.7459787130355835, -0.2236388921737671, -0.4916227459907532, -1.4924019575119019, 0.2752935290336609, 0.6086298823356628, -0.05612568184733391, 0.5179607272148132, -0.9236085414886475, 0.011907446198165417, 0.3090009093284607, 0.778436005115509, ...
javascript/reference/global_objects/promise/index.md
JavaScript - Global Objects - Promise - Description: A `Promise` is a proxy for a value not necessarily known when the promise is created. It allows you to associate handlers with an asynchronous action's eventual success value or failure reason. This lets asynchronous methods return values like synchronous methods: i...
[ -0.10558657348155975, 0.853333592414856, -0.3379879295825958, -0.3263140022754669, 0.9167369604110718, 0.40747398138046265, 0.2542739808559418, 0.6961018443107605, -0.6685208082199097, 0.1435452550649643, -1.1593400239944458, 0.4311569333076477, -0.2882287800312042, 1.0253851413726807, 0...
javascript/reference/global_objects/promise/index.md
JavaScript - Global Objects - Promise - Description - Chained Promises: The promise methods `then()`, `catch()`, and `finally()` are used to associate further action with a promise that becomes settled. The `then()` method takes up to two arguments; the first argument is a callback function for the fulfilled case of t...
[ -0.6080858111381531, 0.5790703296661377, -0.36596301198005676, -0.16047216951847076, 0.670537531375885, -0.3784928321838379, 0.36350497603416443, 1.3266273736953735, -0.8228183388710022, -0.12766222655773163, -0.6265823841094971, 0.1510736644268036, -0.2832142114639282, 0.7765559554100037,...
javascript/reference/global_objects/promise/index.md
JavaScript - Global Objects - Promise - Description - Thenables: The JavaScript ecosystem had made multiple Promise implementations long before it became part of the language. Despite being represented differently internally, at the minimum, all Promise-like objects implement the Thenable interface. A thenable impleme...
[ -0.3775133788585663, 0.8066785335540771, -0.46127191185951233, 0.31580546498298645, -0.3029509484767914, -1.1792207956314087, 0.17293164134025574, 0.7574571967124939, -1.4561764001846313, 0.2976669371128082, -0.13454106450080872, -0.29758843779563904, -0.0052213724702596664, 0.399035602807...
javascript/reference/global_objects/promise/index.md
JavaScript - Global Objects - Promise - Description - Promise concurrency: The `Promise` class offers four static methods to facilitate async task concurrency: - `Promise.all()`: Fulfills when all of the promises fulfill; rejects when any of the promises rejects. - `Promise.allSettled()`: Fulfills when all promises s...
[ -1.384475588798523, 0.23329932987689972, -0.7032157182693481, -0.24123194813728333, 0.34597674012184143, -0.26377445459365845, 0.6223778128623962, 0.5863101482391357, -0.23561318218708038, 0.6096605062484741, -1.3095417022705078, -0.2520703375339508, 0.0897466316819191, 0.2805011570453644,...
javascript/reference/global_objects/promise/index.md
JavaScript - Global Objects - Promise - Constructor: - `Promise()`: Creates a new `Promise` object. The constructor is primarily used to wrap functions that do not already support promises.
[ -1.5088140964508057, -0.13740570843219757, -0.5672990679740906, 0.20501954853534698, 0.031207498162984848, -1.8862217664718628, -0.35683321952819824, 0.9775809645652771, -0.6639400720596313, 0.06827734410762787, -1.001377820968628, -0.0013944600941613317, -0.2978196144104004, 0.40201434493...
javascript/reference/global_objects/promise/index.md
JavaScript - Global Objects - Promise - Static properties: - `Promise[Symbol.species]`: Returns the constructor used to construct return values from promise methods.
[ -1.5791430473327637, 0.215481236577034, -0.6169500350952148, -0.5223263502120972, -0.5668084621429443, -1.9107415676116943, 0.5948302745819092, 1.4213629961013794, -0.8200584053993225, 0.3213087320327759, -1.0891022682189941, 0.6000921726226807, 0.27537408471107483, 0.5995598435401917, 0...
javascript/reference/global_objects/promise/index.md
JavaScript - Global Objects - Promise - Static methods: - `Promise.all()`: Takes an iterable of promises as input and returns a single `Promise`. This returned promise fulfills when all of the input's promises fulfill (including when an empty iterable is passed), with an array of the fulfillment values. It rejects whe...
[ -0.6719651818275452, 0.6871363520622253, -0.29625508189201355, -0.1548558622598648, 0.5368876457214355, -0.05592609569430351, 0.42702195048332214, 0.740930438041687, -0.5647698640823364, -0.08956786245107651, -0.768664538860321, 0.1928788125514984, -0.08973436057567596, 0.2169809639453888,...
javascript/reference/global_objects/promise/index.md
JavaScript - Global Objects - Promise - Instance properties: These properties are defined on `Promise.prototype` and shared by all `Promise` instances. - `Promise.prototype.constructor`: The constructor function that created the instance object. For `Promise` instances, the initial value is the `Promise` constructor....
[ -0.8890538215637207, -0.13972914218902588, -0.43528106808662415, 0.08087687194347382, 0.08323060721158981, -2.1175177097320557, 0.1085435077548027, 1.056469440460205, 0.12167537212371826, -0.009592773392796516, -1.0617609024047852, 0.08727549016475677, -0.3902314007282257, 0.18248960375785...
javascript/reference/global_objects/promise/index.md
JavaScript - Global Objects - Promise - Instance methods: - `Promise.prototype.catch()`: Appends a rejection handler callback to the promise, and returns a new promise resolving to the return value of the callback if it is called, or to its original fulfillment value if the promise is instead fulfilled. - `Promise.pro...
[ -0.9564880132675171, 0.04715651273727417, -0.31891077756881714, -0.1545107513666153, -0.2901419997215271, -1.0447041988372803, 0.7948523759841919, 0.348574161529541, -0.8191415667533875, 0.19819091260433197, -1.0727914571762085, 0.495286226272583, 0.16850584745407104, 0.8512665033340454, ...
javascript/reference/global_objects/promise/index.md
JavaScript - Global Objects - Promise - Examples - Basic Example: In this example, we use `setTimeout(...)` to simulate async code. In reality, you will probably be using something like XHR or an HTML API. Example: const myFirstPromise = new Promise((resolve, reject) => { // We call resolve(...) when what we were ...
[ -0.8367363810539246, 0.28857091069221497, -0.17480438947677612, -0.12620040774345398, -0.3366261124610901, -0.8668870329856873, 0.6300444602966309, 0.5121713876724243, 0.13367950916290283, 0.6028016805648804, -0.4534572958946228, -0.1859510838985443, -0.3204760253429413, 0.1773806214332580...
javascript/reference/global_objects/promise/index.md
JavaScript - Global Objects - Promise - Examples - Example with diverse situations: This example shows diverse techniques for using Promise capabilities and diverse situations that can occur. To understand this, start by scrolling to the bottom of the code block, and examine the promise chain. Upon provision of an ini...
[ -0.27569451928138733, 0.47083622217178345, 0.15544502437114716, -0.20082201063632965, 0.47914645075798035, -0.9870478510856628, 0.5911963582038879, 1.3844292163848877, -0.21697485446929932, -0.30752310156822205, -0.6140693426132202, 0.6030693650245667, -0.37863004207611084, 0.3213179409503...
javascript/reference/global_objects/promise/index.md
JavaScript - Global Objects - Promise - Examples - Advanced Example: This small example shows the mechanism of a `Promise`. The `testPromise()` method is called each time the `button` is clicked. It creates a promise that will be fulfilled, using `setTimeout()`, to the promise count (number starting from 1) every 1-3 ...
[ -0.5952674746513367, 0.681168794631958, -0.6140592694282532, -0.12487638741731644, -0.2887739837169647, -1.3056418895721436, 0.9610204100608826, 0.4664272665977478, -1.2715808153152466, 0.5580335855484009, -0.7038006782531738, 0.34518611431121826, -0.35766246914863586, 0.9272194504737854, ...
javascript/reference/global_objects/promise/index.md
JavaScript - Global Objects - Promise - Examples - Advanced Example - HTML: Example: <button id="make-promise">Make a promise!</button> <div id="log"></div>
[ -0.649109423160553, 0.6292919516563416, -0.3892839848995209, -0.5525336265563965, -0.7759095430374146, -1.3871897459030151, 1.0900790691375732, 0.7043768167495728, -0.9459571838378906, -0.2233622670173645, -0.3587939441204071, 0.28107547760009766, -0.9293602705001831, 0.4375840723514557, ...
javascript/reference/global_objects/promise/index.md
JavaScript - Global Objects - Promise - Examples - Advanced Example - JavaScript: Example: "use strict"; let promiseCount = 0; function testPromise() { const thisPromiseCount = ++promiseCount; const log = document.getElementById("log"); // begin log.insertAdjacentHTML("beforeend", `${thisPromiseCount}) Star...
[ 0.16000701487064362, 0.4477984309196472, -0.4219275414943695, -0.11106730252504349, 0.7009218335151672, -0.4901241362094879, 0.1441497504711151, 0.5633878707885742, -1.116515040397644, 0.2922927439212799, -0.4874074459075928, 0.20445923507213593, -0.19274592399597168, 0.6374318599700928, ...
javascript/reference/global_objects/promise/index.md
JavaScript - Global Objects - Promise - Examples - Loading an image with XHR: Another example using `Promise` and `XMLHttpRequest` to load an image is shown below. Each step is commented on and allows you to follow the Promise and XHR architecture closely. Example: <h1>Promise example</h1> Example: function imgLoa...
[ -0.788578987121582, 0.32302334904670715, -0.18690259754657745, 0.11656147986650467, 0.598908007144928, -0.623148500919342, 0.31696653366088867, 0.5002606511116028, -0.8113670349121094, -0.42857131361961365, -0.19988833367824554, -0.21320044994354248, -1.121841311454773, 1.242112398147583, ...
javascript/reference/global_objects/promise/index.md
JavaScript - Global Objects - Promise - Examples - Incumbent settings object tracking: A settings object is an environment that provides additional information when JavaScript code is running. This includes the realm and module map, as well as HTML specific information such as the origin. The incumbent settings object...
[ -0.28595542907714844, -0.36388808488845825, -0.8766669034957886, 0.13783356547355652, 0.5802642703056335, -1.2694073915481567, -0.1794419288635254, 0.8901888132095337, -0.44094163179397583, 0.03215407580137253, -0.5863168835639954, 0.9126172661781311, 0.4655072093009949, 0.902336061000824,...
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/race/index.md
JavaScript - Global Objects - Promise - race: The `Promise.race()` static method takes an iterable of promises as input and returns a single `Promise`. This returned promise settles with the eventual state of the first promise that settles. Example: const promise1 = new Promise((resolve, reject) => { setTimeout(re...
[ -1.51115882396698, 0.12218247354030609, -0.18673673272132874, 0.17446641623973846, -0.36454761028289795, -0.7437060475349426, 0.022067150101065636, 1.3345210552215576, -0.573090136051178, 0.49435245990753174, -1.1908833980560303, 0.4778904914855957, 0.26355013251304626, 0.564060389995575, ...
javascript/reference/global_objects/promise/race/index.md
JavaScript - Global Objects - Promise - race - Syntax: Example: Promise.race(iterable)
[ -0.7871894240379333, 0.3860379159450531, 0.13390247523784637, -0.49242135882377625, -1.0924168825149536, -1.1754639148712158, -0.11336161196231842, 1.5336363315582275, -0.8600566387176514, -0.5138895511627197, -0.5594669580459595, 0.31321460008621216, -0.2753153443336487, 0.748409330844879...
javascript/reference/global_objects/promise/race/index.md
JavaScript - Global Objects - Promise - race - Syntax - Parameters: - `iterable`: An iterable (such as an `Array`) of promises.
[ -0.2767230272293091, 0.38116979598999023, -0.14805375039577484, -0.10603931546211243, -0.6564056873321533, -0.820971667766571, -0.004518380854278803, 1.5946139097213745, -0.8313403129577637, -0.384391725063324, -1.0712268352508545, 0.4287457764148712, -0.4644988775253296, 0.917897522449493...
javascript/reference/global_objects/promise/race/index.md
JavaScript - Global Objects - Promise - race - Syntax - Return value: A `Promise` that asynchronously settles with the eventual state of the first promise in the `iterable` to settle. In other words, it fulfills if the first promise to settle is fulfilled, and rejects if the first promise to settle is rejected. The re...
[ -1.262419581413269, 0.7927906513214111, 0.07777102291584015, 0.1754504293203354, -0.6589162945747375, -0.6780295372009277, 0.8707068562507629, 1.2827718257904053, -0.5361747741699219, 0.5044832229614258, -0.5000700950622559, 0.5597987771034241, -0.26566651463508606, 1.3817288875579834, -...
javascript/reference/global_objects/promise/race/index.md
JavaScript - Global Objects - Promise - race - Description: The `Promise.race()` method is one of the promise concurrency methods. It's useful when you want the first async task to complete, but do not care about its eventual state (i.e., it can either succeed or fail). If the iterable contains one or more non-promis...
[ -1.7688257694244385, 0.23499390482902527, -0.1428799033164978, 0.16282868385314941, -0.7200554013252258, -0.4271048307418823, 0.8580731749534607, 1.0360615253448486, -0.47520917654037476, -0.11740315705537796, -1.1715466976165771, 0.158413365483284, 0.12480507045984268, 0.4507732093334198,...
javascript/reference/global_objects/promise/race/index.md
JavaScript - Global Objects - Promise - race - Examples - Using Promise.race(): This example shows how `Promise.race()` can be used to race several timers implemented with `setTimeout()`. The timer with the shortest time always wins the race and becomes the resulting promise's state. Example: function sleep(time, va...
[ -0.43212589621543884, 0.4120718240737915, 0.1146787628531456, -0.06895525753498077, -0.21655237674713135, 0.09846018999814987, 0.4999673366546631, 0.6822167038917542, -0.85917067527771, -0.3281552195549011, -0.9610509276390076, 0.2259301394224167, -0.33102473616600037, 0.2327779233455658, ...
javascript/reference/global_objects/promise/race/index.md
JavaScript - Global Objects - Promise - race - Examples - Asynchronicity of Promise.race: This following example demonstrates the asynchronicity of `Promise.race`. Unlike other promise concurrency methods, `Promise.race` is always asynchronous: it never settles synchronously, even when the `iterable` is empty. Exampl...
[ -0.6810446381568909, -0.08744131773710251, 0.02388259395956993, -0.10786829143762589, 0.41425326466560364, -0.08239949494600296, 0.36371496319770813, 1.0007270574569702, -0.25194185972213745, 0.11390063166618347, -0.2332313060760498, 0.08974196761846542, -0.36735838651657104, 0.71177929639...
javascript/reference/global_objects/promise/race/index.md
JavaScript - Global Objects - Promise - race - Examples - Using Promise.race() to implement request timeout: You can race a potentially long-lasting request with a timer that rejects, so that when the time limit has elapsed, the resulting promise automatically rejects. Example: const data = Promise.race([ fetch("/...
[ -1.680487036705017, 0.09541446715593338, -0.03183778002858162, 0.7045878767967224, -0.5068140625953674, -1.2436397075653076, -0.2847846448421478, 0.49223801493644714, -0.9581212401390076, 0.35456106066703796, -1.0747817754745483, 0.39431118965148926, -0.2414878010749817, 1.0988876819610596...
javascript/reference/global_objects/promise/race/index.md
JavaScript - Global Objects - Promise - race - Examples - Using Promise.race() to detect the status of a promise: Because `Promise.race()` resolves to the first non-pending promise in the iterable, we can check a promise's state, including if it's pending. This example is adapted from `promise-status-async`. Example:...
[ -0.40476131439208984, 0.1804213970899582, 0.1697787642478943, -0.6862127184867859, 0.7868537306785583, 0.055135950446128845, 0.5843877196311951, 1.1467231512069702, -0.07901887595653534, 0.18452921509742737, -0.5983022451400757, 0.137199267745018, -0.2033538669347763, 0.9551064968109131, ...
javascript/reference/global_objects/promise/race/index.md
JavaScript - Global Objects - Promise - race - Examples - Comparison with Promise.any(): `Promise.race` takes the first settled `Promise`. Example: const promise1 = new Promise((resolve, reject) => { setTimeout(resolve, 500, "one"); }); const promise2 = new Promise((resolve, reject) => { setTimeout(reject, 100,...
[ -0.5333971977233887, -0.174696147441864, -0.0613659992814064, 0.030788986012339592, 0.49821603298187256, -0.6843103170394897, 0.3543088138103485, 0.8496546745300293, -0.601590633392334, -0.0847647488117218, -0.679419994354248, -0.18196024000644684, -0.36530622839927673, 0.14352953433990479...
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/any/index.md
JavaScript - Global Objects - Promise - any: The `Promise.any()` static method takes an iterable of promises as input and returns a single `Promise`. This returned promise fulfills when any of the input's promises fulfills, with this first fulfillment value. It rejects when all of the input's promises reject (includin...
[ -1.2742732763290405, 0.47692257165908813, -0.3309882581233978, -0.23697148263454437, -0.17357555031776428, -1.586835503578186, 0.16924375295639038, 0.38925039768218994, -0.6937981843948364, 0.657263994216919, -0.9771080017089844, 0.11832108348608017, -0.07337018102407455, 0.597014784812927...
javascript/reference/global_objects/promise/any/index.md
JavaScript - Global Objects - Promise - any - Syntax: Example: Promise.any(iterable)
[ -0.25511762499809265, 0.715770423412323, 0.004404590465128422, -0.8175790905952454, -1.0735937356948853, -1.5941883325576782, 0.12835077941417694, 1.388367772102356, -0.274799644947052, -0.5395195484161377, -0.3264705538749695, 0.3094482123851776, -0.5702615976333618, 0.48066794872283936, ...
javascript/reference/global_objects/promise/any/index.md
JavaScript - Global Objects - Promise - any - Syntax - Parameters: - `iterable`: An iterable (such as an `Array`) of promises.
[ 0.18236218392848969, 0.5851811766624451, -0.3125861585140228, -0.2934993803501129, -0.6031098365783691, -1.0318690538406372, 0.259218692779541, 1.4428095817565918, -0.5571881532669067, -0.2873373329639435, -0.7928508520126343, 0.32076799869537354, -0.5960694551467896, 0.8492371439933777, ...
javascript/reference/global_objects/promise/any/index.md
JavaScript - Global Objects - Promise - any - Syntax - Return value: A `Promise` that is: - Already rejected, if the `iterable` passed is empty. - Asynchronously fulfilled, when any of the promises in the given `iterable` fulfills. The fulfillment value is the fulfillment value of the first promise that was fulfilled...
[ -0.858846127986908, 0.6542702913284302, 0.15602806210517883, -0.27127161622047424, -0.43344447016716003, -1.203376293182373, 1.1121686697006226, 0.3430876135826111, -0.7550361156463623, 0.5452988147735596, -0.5678694248199463, 0.013036764226853848, -0.5730569362640381, 1.3753708600997925, ...
javascript/reference/global_objects/promise/any/index.md
JavaScript - Global Objects - Promise - any - Description: The `Promise.any()` method is one of the promise concurrency methods. This method is useful for returning the first promise that fulfills. It short-circuits after a promise fulfills, so it does not wait for the other promises to complete once it finds one. Un...
[ -1.3679122924804688, 0.5152079463005066, -0.6819234490394592, -0.2585451304912567, -0.4393557608127594, -1.1438239812850952, 0.3889625072479248, 0.6041490435600281, -0.7684102654457092, 0.37888798117637634, -1.0147994756698608, 0.009253459982573986, -0.36004191637039185, 0.5260943174362183...
javascript/reference/global_objects/promise/any/index.md
JavaScript - Global Objects - Promise - any - Examples - Using Promise.any(): `Promise.any()` fulfills with the first promise to fulfill, even if a promise rejects first. This is in contrast to `Promise.race()`, which fulfills or rejects with the first promise to settle. Example: const pErr = new Promise((resolve, r...
[ -0.6694725751876831, 0.6538683176040649, -0.04302922636270523, -0.4795820116996765, -0.9579785466194153, -1.1036250591278076, 0.3416076898574829, 0.2927634119987488, 0.09760864824056625, 0.16306555271148682, -0.8769139051437378, 0.06004619598388672, -0.39269527792930603, 0.4694189429283142...
javascript/reference/global_objects/promise/any/index.md
JavaScript - Global Objects - Promise - any - Examples - Rejections with AggregateError: `Promise.any()` rejects with an `AggregateError` if no promise fulfills. Example: const failure = new Promise((resolve, reject) => { reject(new Error("Always fails")); }); Promise.any([failure]).catch((err) => { console.log...
[ -1.1156435012817383, 0.3285009562969208, -0.12353203445672989, -0.9855377674102783, -0.7128605246543884, -1.4693152904510498, 0.3804751932621002, 0.03736778348684311, -1.023012399673462, -0.013257337734103203, -0.20005743205547333, -0.5409080982208252, -0.3385106921195984, 0.90595275163650...
javascript/reference/global_objects/promise/any/index.md
JavaScript - Global Objects - Promise - any - Examples - Displaying the first image loaded: In this example, we have a function that fetches an image and returns a blob. We use `Promise.any()` to fetch a couple of images and display the first one available (i.e., whose promise has resolved). Example: async function ...
[ -0.4880795180797577, 0.6578704714775085, -0.2489369958639145, -0.22972695529460907, -0.22278225421905518, -0.9527289271354675, -0.028261698782444, 1.1047194004058838, -0.44143572449684143, -0.027738520875573158, -0.3815782070159912, -0.7590832710266113, -0.7060416340827942, 0.9758042097091...
javascript/reference/global_objects/promise/all/index.md
JavaScript - Global Objects - Promise - all: The `Promise.all()` 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 fulfill (including when an empty iterable is passed), with an array of the fulfillment values. It rejects...
[ -0.949767529964447, 0.2052958756685257, -0.5656878352165222, -0.3537202477455139, -0.005804998800158501, -1.6732293367385864, 0.7180991768836975, 0.17746911942958832, -1.165127158164978, 0.5760070085525513, -0.8828049302101135, 0.3425416052341461, 0.6273404359817505, 0.6831632256507874, ...
javascript/reference/global_objects/promise/all/index.md
JavaScript - Global Objects - Promise - all - Syntax: Example: Promise.all(iterable)
[ 0.013573216274380684, 0.5828412771224976, -0.32975253462791443, -0.6348943114280701, -0.9532345533370972, -1.542677879333496, 0.35612866282463074, 1.215773344039917, -0.5683302283287048, -0.416752427816391, -0.3409784138202667, 0.35495808720588684, -0.19875170290470123, 0.7064571380615234,...
javascript/reference/global_objects/promise/all/index.md
JavaScript - Global Objects - Promise - all - Syntax - Parameters: - `iterable`: An iterable (such as an `Array`) of promises.
[ 0.41523534059524536, 0.5449778437614441, -0.4130585193634033, -0.22540487349033356, -0.5577440857887268, -1.112532615661621, 0.2861216366291046, 1.3310350179672241, -0.6788811087608337, -0.305009126663208, -0.7663825154304504, 0.42794516682624817, -0.4160999357700348, 0.9417135119438171, ...
javascript/reference/global_objects/promise/all/index.md
JavaScript - Global Objects - Promise - all - Syntax - Return value: A `Promise` that is: - Already fulfilled, if the `iterable` passed is empty. - Asynchronously fulfilled, when all the promises in the given `iterable` fulfill. The fulfillment value is an array of fulfillment values, in the order of the promises pas...
[ -0.5897946357727051, 0.6639937162399292, 0.06394646316766739, -0.25712254643440247, -0.47676053643226624, -1.3701508045196533, 1.0150632858276367, 0.34098026156425476, -0.7649327516555786, 0.5754277110099792, -0.49707359075546265, 0.3158963620662689, -0.4675455391407013, 1.466357946395874,...
javascript/reference/global_objects/promise/all/index.md
JavaScript - Global Objects - Promise - all - Description: The `Promise.all()` method is one of the promise concurrency methods. It can be useful for aggregating the results of multiple promises. It is typically used when there are multiple related asynchronous tasks that the overall code relies on to work successfull...
[ -0.8094881772994995, 0.8068969249725342, -1.2118905782699585, -0.2841421067714691, -0.40991416573524475, -1.3252358436584473, 0.4984185993671417, 0.3619857132434845, -0.4302845895290375, 0.3317267894744873, -1.405069351196289, 0.6172378063201904, 0.10176163911819458, 0.6897158622741699, ...
javascript/reference/global_objects/promise/all/index.md
JavaScript - Global Objects - Promise - all - Examples - Using Promise.all(): `Promise.all` waits for all fulfillments (or the first rejection). Example: const p1 = Promise.resolve(3); const p2 = 1337; const p3 = new Promise((resolve, reject) => { setTimeout(() => { resolve("foo"); }, 100); }); Promise.all(...
[ 0.5305425524711609, 0.4113255441188812, 0.20906805992126465, -0.06910301744937897, 0.23773439228534698, -0.26410582661628723, 0.1766652911901474, 0.02105659246444702, -0.6672987341880798, 0.15944483876228333, -0.7306894659996033, -0.400269478559494, 0.08870822936296463, 0.2845311760902405,...