file stringlengths 16 94 | text stringlengths 32 24.4k | vector list |
|---|---|---|
javascript/reference/global_objects/promise/all/index.md | JavaScript - Global Objects - Promise - all - Examples - Destructuring the result:
You will find destructuring very useful if you are batching together a known number of tasks.
Example:
// With then()
Promise.all([p1, p2, p3]).then(([a, b, c]) => {
console.log(a, b, c); // 3 1337 "foo"
});
// With await
const [a,... | [
-0.16924549639225006,
0.20952799916267395,
-0.8921476602554321,
0.18317662179470062,
-0.8619793653488159,
-1.795884132385254,
1.1680636405944824,
-0.4602823853492737,
-0.42898300290107727,
0.2559952735900879,
-1.2712570428848267,
0.007122116629034281,
-0.5624960064888,
-0.03095866739749908... |
javascript/reference/global_objects/promise/all/index.md | JavaScript - Global Objects - Promise - all - Examples - Asynchronicity or synchronicity of Promise.all:
This following example demonstrates the asynchronicity of `Promise.all` when a non-empty `iterable` is passed:
Example:
// Passing an array of promises that are already resolved,
// to trigger Promise.all as soon... | [
0.1839400976896286,
0.2825448513031006,
-0.2103808969259262,
-0.4374622702598572,
0.40158766508102417,
0.03956082463264465,
0.3085966110229492,
0.6197041273117065,
-0.453779399394989,
0.2623679041862488,
-0.05637303367257118,
-0.32882794737815857,
-0.10393372178077698,
0.6542627215385437,
... |
javascript/reference/global_objects/promise/all/index.md | JavaScript - Global Objects - Promise - all - Examples - Using Promise.all() with async functions:
Within async functions, it's very common to "over-await" your code. For example, given the following functions:
Example:
function promptForDishChoice() {
return new Promise((resolve, reject) => {
const dialog = d... | [
-0.4318391680717468,
0.28683388233184814,
-0.851466953754425,
0.37475234270095825,
-0.3362797200679779,
-1.0706686973571777,
0.6323451995849609,
0.5786287188529968,
-0.4528058171272278,
0.04306095466017723,
-0.371994286775589,
0.24394799768924713,
-0.7956886887550354,
1.1618454456329346,
... |
javascript/reference/global_objects/promise/all/index.md | JavaScript - Global Objects - Promise - all - Examples - Promise.all fail-fast behavior:
`Promise.all` is rejected if any of the elements are rejected. For example, if you pass in four promises that resolve after a timeout and one promise that rejects immediately, then `Promise.all` will reject immediately.
Example:
... | [
-0.9039626121520996,
0.7179245352745056,
-0.429855614900589,
-0.21662715077400208,
-0.325568825006485,
-0.7375481128692627,
0.24119926989078522,
0.638843834400177,
-0.7508864998817444,
0.5783594846725464,
-1.020673394203186,
-0.20817764103412628,
-0.475136935710907,
0.7680915594100952,
1... |
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... |
javascript/reference/global_objects/arraybuffer/transfertofixedlength/index.md | JavaScript - Global Objects - ArrayBuffer - transferToFixedLength - Syntax - Exceptions:
- `TypeError`: Thrown if this `ArrayBuffer` is already detached, or if it can only be detached by designated operations. Currently, only certain web APIs are capable of creating `ArrayBuffer` objects with designated detaching meth... | [
-0.2031569480895996,
-0.13436046242713928,
-1.1630527973175049,
1.1347264051437378,
-0.5771174430847168,
-2.160836696624756,
-0.11763257533311844,
1.1992170810699463,
-0.1813475787639618,
0.26106661558151245,
-0.8047438263893127,
0.1197628527879715,
0.13522671163082123,
0.3661128580570221,... |
javascript/reference/global_objects/arraybuffer/transfertofixedlength/index.md | JavaScript - Global Objects - ArrayBuffer - transferToFixedLength - Description:
Unlike `transfer()`, `transferToFixedLength()` always creates a non-resizable `ArrayBuffer`. This means `newByteLength` can be larger than the `maxByteLength`, even if this `ArrayBuffer` is resizable. See transferring ArrayBuffers for mor... | [
-0.8277596831321716,
-0.37417319416999817,
-1.484879493713379,
1.4563950300216675,
-0.2282762974500656,
-1.3701139688491821,
-0.23056510090827942,
0.7347081899642944,
-0.17144715785980225,
-0.097585029900074,
-0.9708415269851685,
0.047859810292720795,
-0.7076816558837891,
0.725826144218444... |
javascript/reference/global_objects/arraybuffer/transfertofixedlength/index.md | JavaScript - Global Objects - ArrayBuffer - transferToFixedLength - Examples - Transferring a resizable ArrayBuffer to fixed-length:
Example:
const buffer = new ArrayBuffer(8, { maxByteLength: 16 });
const view = new Uint8Array(buffer);
view[1] = 2;
view[7] = 4;
const buffer2 = buffer.transferToFixedLength();
consol... | [
0.316979318857193,
0.06372855603694916,
-0.6477140784263611,
0.6637674570083618,
0.2711726129055023,
-0.7594266533851624,
0.34852203726768494,
0.21293649077415466,
-0.034179702401161194,
-0.23473896086215973,
-0.3695286214351654,
0.2535083591938019,
-0.5633313059806824,
0.37445539236068726... |
javascript/reference/global_objects/arraybuffer/symbol.species/index.md | JavaScript - Global Objects - ArrayBuffer - Symbol.species:
The `ArrayBuffer[Symbol.species]` static accessor property returns the constructor used to construct return values from array buffer methods.
Warning: The existence of `[Symbol.species]` allows execution of arbitrary code and may create security vulnerabilit... | [
-1.125251293182373,
-0.7585452198982239,
-1.5775384902954102,
0.8387690186500549,
-0.9276396036148071,
-2.033339262008667,
1.1938931941986084,
1.1729309558868408,
-0.04837609827518463,
0.3539610207080841,
-0.9760116934776306,
0.4555901288986206,
-0.1266467571258545,
0.3694716691970825,
0... |
javascript/reference/global_objects/arraybuffer/symbol.species/index.md | JavaScript - Global Objects - ArrayBuffer - Symbol.species - Syntax:
Example:
ArrayBuffer[Symbol.species] | [
-0.15928734838962555,
-0.11163379997015,
-1.5169672966003418,
-0.1093742698431015,
-1.2854288816452026,
-2.3517043590545654,
0.15708395838737488,
1.4407271146774292,
0.40882882475852966,
-0.5436610579490662,
-0.5476687550544739,
0.5658193230628967,
-0.1441563218832016,
0.423683762550354,
... |
javascript/reference/global_objects/arraybuffer/symbol.species/index.md | JavaScript - Global Objects - ArrayBuffer - 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 array buffer methods that create new array buffers. | [
-0.7803013920783997,
0.004951810464262962,
-1.273610234260559,
0.5846596956253052,
-0.8202638626098633,
-2.0939462184906006,
0.43090274930000305,
1.4519329071044922,
0.05984838306903839,
0.13403581082820892,
-0.8647848963737488,
1.0055036544799805,
-0.219492107629776,
1.0479553937911987,
... |
javascript/reference/global_objects/arraybuffer/symbol.species/index.md | JavaScript - Global Objects - ArrayBuffer - Symbol.species - Description:
The `[Symbol.species]` accessor property returns the default constructor for `ArrayBuffer` objects. Subclass constructors may override it to change the constructor assignment. The default implementation is basically:
Example:
// Hypothetical u... | [
-0.7463738918304443,
-0.8940186500549316,
-1.7429440021514893,
0.6500590443611145,
-0.5752060413360596,
-1.5832836627960205,
0.8061502575874329,
0.8843517899513245,
0.3743726909160614,
0.03837136551737785,
-0.7181894779205322,
0.3886871337890625,
-0.3667854070663452,
0.5196014642715454,
... |
javascript/reference/global_objects/arraybuffer/symbol.species/index.md | JavaScript - Global Objects - ArrayBuffer - Symbol.species - Examples - Species in ordinary objects:
The `[Symbol.species]` property returns the default constructor function, which is the `ArrayBuffer` constructor for `ArrayBuffer`.
Example:
ArrayBuffer[Symbol.species]; // function ArrayBuffer() | [
-0.6330621242523193,
-0.008170167915523052,
-1.9585458040237427,
0.47243914008140564,
-0.7762950658798218,
-2.0823867321014404,
0.07179594039916992,
1.0419375896453857,
-0.19069939851760864,
-0.2102666050195694,
-0.5968004465103149,
0.5147579908370972,
-0.18043199181556702,
0.2253684401512... |
javascript/reference/global_objects/arraybuffer/symbol.species/index.md | JavaScript - Global Objects - ArrayBuffer - Symbol.species - Examples - Species in derived objects:
In an instance of a custom `ArrayBuffer` subclass, such as `MyArrayBuffer`, the `MyArrayBuffer` species is the `MyArrayBuffer` constructor. However, you might want to overwrite this, in order to return parent `ArrayBuff... | [
-0.7157895565032959,
-0.5731102824211121,
-1.431132435798645,
1.030170202255249,
-0.46935614943504333,
-1.9484684467315674,
0.22100499272346497,
0.6946861147880554,
0.05803202837705612,
-0.000147677244967781,
-0.959304690361023,
0.6534109115600586,
-1.1472126245498657,
0.3918013274669647,
... |
javascript/reference/global_objects/arraybuffer/resize/index.md | JavaScript - Global Objects - ArrayBuffer - resize:
The `resize()` method of `ArrayBuffer` instances resizes the `ArrayBuffer` to the specified size, in bytes.
Example:
const buffer = new ArrayBuffer(8, { maxByteLength: 16 });
console.log(buffer.byteLength);
// Expected output: 8
buffer.resize(12);
console.log(bu... | [
0.08562478423118591,
-0.48872968554496765,
-1.4620776176452637,
0.14007501304149628,
-0.6741212606430054,
-1.497024655342102,
0.32051533460617065,
0.32422399520874023,
0.33880528807640076,
-0.06465961784124374,
-1.0319557189941406,
0.3772326707839966,
-0.5303437113761902,
0.456190526485443... |
javascript/reference/global_objects/arraybuffer/resize/index.md | JavaScript - Global Objects - ArrayBuffer - resize - Syntax:
Example:
resize(newLength) | [
-0.41530826687812805,
0.0878419280052185,
-1.13224196434021,
-0.1962203085422516,
-1.0132883787155151,
-1.7041537761688232,
0.6786609292030334,
0.8143996000289917,
-0.0022623878903687,
-0.4279094636440277,
-1.0467500686645508,
0.19160744547843933,
-0.42485833168029785,
0.4724871814250946,
... |
javascript/reference/global_objects/arraybuffer/resize/index.md | JavaScript - Global Objects - ArrayBuffer - resize - Syntax - Parameters:
- `newLength`: The new length, in bytes, to resize the `ArrayBuffer` to. | [
0.008269616402685642,
0.10692767798900604,
-1.4746297597885132,
-0.11977902799844742,
-0.6505259275436401,
-1.856641411781311,
0.2841411232948303,
0.45199522376060486,
0.39029237627983093,
-0.5044565200805664,
-1.5656651258468628,
0.0632418543100357,
-0.1723206490278244,
0.5253316760063171... |
javascript/reference/global_objects/arraybuffer/resize/index.md | JavaScript - Global Objects - ArrayBuffer - resize - Syntax - Return value:
None (`undefined`). | [
-0.5509272813796997,
0.4490484595298767,
-1.1832971572875977,
-0.4762209355831146,
-0.9939622282981873,
-1.1449284553527832,
1.219022512435913,
1.0672636032104492,
-0.406800240278244,
0.28135329484939575,
-0.6550501585006714,
0.03967669978737831,
-0.2760021388530731,
0.5630320906639099,
... |
javascript/reference/global_objects/arraybuffer/resize/index.md | JavaScript - Global Objects - ArrayBuffer - resize - Syntax - Exceptions:
- `TypeError`: Thrown if the `ArrayBuffer` is detached or is not resizable.
- `RangeError`: Thrown if `newLength` is larger than the `maxByteLength` of the `ArrayBuffer`. | [
-0.04060870781540871,
-0.008712115697562695,
-1.0020869970321655,
0.8814043402671814,
-0.5195400714874268,
-1.7966804504394531,
0.11795030534267426,
1.1061240434646606,
-0.22177556157112122,
0.17397060990333557,
-0.9171209931373596,
-0.2933137118816376,
-0.6095530390739441,
0.2332303375005... |
javascript/reference/global_objects/arraybuffer/resize/index.md | JavaScript - Global Objects - ArrayBuffer - resize - Description:
The `resize()` method resizes an `ArrayBuffer` to the size specified by the `newLength` parameter, provided that the `ArrayBuffer` is resizable and the new size is less than or equal to the `maxByteLength` of the `ArrayBuffer`. New bytes are initialized... | [
-0.5007840394973755,
0.19871722161769867,
-1.549237608909607,
0.549592912197113,
-0.2818526029586792,
-1.4897068738937378,
1.0693784952163696,
0.3074885308742523,
0.030652696266770363,
0.16959542036056519,
-1.353698968887329,
-0.05442305654287338,
-0.4471808969974518,
0.26932916045188904,
... |
javascript/reference/global_objects/arraybuffer/resize/index.md | JavaScript - Global Objects - ArrayBuffer - resize - Examples - Using resize():
In this example, we create a 8-byte buffer that is resizable to a max length of 16 bytes, then check its `resizable` property, resizing it if `resizable` returns `true`:
Example:
const buffer = new ArrayBuffer(8, { maxByteLength: 16 });
... | [
-0.40965887904167175,
0.323067843914032,
-0.9252423048019409,
0.19601374864578247,
-0.7672231793403625,
-1.3052148818969727,
0.6625453233718872,
0.4282783269882202,
0.2548443078994751,
-0.1170281171798706,
-0.9486589431762695,
0.6854130625724792,
-0.3717523217201233,
0.2051624059677124,
... |
javascript/reference/global_objects/arraybuffer/resizable/index.md | JavaScript - Global Objects - ArrayBuffer - resizable:
The `resizable` accessor property of `ArrayBuffer` instances returns whether this array buffer can be resized or not.
Example:
const buffer1 = new ArrayBuffer(8, { maxByteLength: 16 });
const buffer2 = new ArrayBuffer(8);
console.log(buffer1.resizable);
// Expe... | [
-0.22453084588050842,
-0.26146623492240906,
-1.0787672996520996,
0.8500567674636841,
-0.6426777839660645,
-1.5721895694732666,
0.014566459693014622,
0.7015567421913147,
0.7312637567520142,
0.048659224063158035,
-1.271063208580017,
0.15900391340255737,
-0.25684407353401184,
0.85429376363754... |
javascript/reference/global_objects/arraybuffer/resizable/index.md | JavaScript - Global Objects - ArrayBuffer - resizable - Description:
The `resizable` property is an accessor property whose set accessor function is `undefined`, meaning that you can only read this property. The value is established when the array is constructed. If the `maxByteLength` option was set in the constructo... | [
-0.8042471408843994,
0.47733327746391296,
-0.6923770308494568,
1.0364359617233276,
-0.10513990372419357,
-1.239917278289795,
0.748955249786377,
0.8751991391181946,
0.30156710743904114,
0.46603113412857056,
-0.8098520040512085,
-0.006087772082537413,
-0.17770396173000336,
0.7075483202934265... |
javascript/reference/global_objects/arraybuffer/resizable/index.md | JavaScript - Global Objects - ArrayBuffer - resizable - Examples - Using resizable:
In this example, we create a 8-byte buffer that is resizable to a max length of 16 bytes, then check its `resizable` property, resizing it if `resizable` returns `true`:
Example:
const buffer = new ArrayBuffer(8, { maxByteLength: 16 ... | [
-0.36477741599082947,
0.21004006266593933,
-0.9365087151527405,
0.3443681001663208,
-0.7234680652618408,
-1.3040916919708252,
0.6943979263305664,
0.3359530568122864,
0.3336801528930664,
-0.06362203508615494,
-1.0073860883712769,
0.6505582332611084,
-0.30592551827430725,
0.3378153145313263,... |
javascript/reference/global_objects/arraybuffer/bytelength/index.md | JavaScript - Global Objects - ArrayBuffer - byteLength:
The `byteLength` accessor property of `ArrayBuffer` instances returns the length (in bytes) of this array buffer.
Example:
// Create an ArrayBuffer with a size in bytes
const buffer = new ArrayBuffer(8);
// Use byteLength to check the size
const bytes = buffer... | [
-0.1886417269706726,
-0.6984252333641052,
-1.4708166122436523,
0.6065448522567749,
-0.25578081607818604,
-1.5655473470687866,
-0.25139105319976807,
0.1361914426088333,
0.48327505588531494,
-0.22161610424518585,
-1.2335777282714844,
0.20095694065093994,
-0.20985622704029083,
0.2967322766780... |
javascript/reference/global_objects/arraybuffer/bytelength/index.md | JavaScript - Global Objects - ArrayBuffer - byteLength - Description:
The `byteLength` property is an accessor property whose set accessor function is `undefined`, meaning that you can only read this property. The value is established when the array is constructed and cannot be changed. This property returns 0 if this... | [
-0.7311875820159912,
-0.1679607778787613,
-1.1309243440628052,
0.7635627388954163,
0.19338224828243256,
-1.921204924583435,
0.2606111764907837,
1.091658592224121,
0.29465195536613464,
-0.3062342703342438,
-0.5535871982574463,
-0.07627949863672256,
-0.3317170739173889,
-0.05302509292960167,... |
javascript/reference/global_objects/arraybuffer/bytelength/index.md | JavaScript - Global Objects - ArrayBuffer - byteLength - Examples - Using byteLength:
Example:
const buffer = new ArrayBuffer(8);
buffer.byteLength; // 8 | [
-0.14479753375053406,
-0.4656340181827545,
-1.4040031433105469,
0.30713561177253723,
-0.6495959758758545,
-1.6314820051193237,
-0.1268114298582077,
0.5124292373657227,
0.2603665590286255,
-0.4537845551967621,
-1.1487090587615967,
0.06136792525649071,
-0.2365557998418808,
-0.044238027185201... |
javascript/reference/global_objects/arraybuffer/arraybuffer/index.md | JavaScript - Global Objects - ArrayBuffer:
The `ArrayBuffer()` constructor creates `ArrayBuffer` objects.
Example:
// Create an ArrayBuffer with a size in bytes
const buffer = new ArrayBuffer(8);
console.log(buffer.byteLength);
// Expected output: 8 | [
0.0944976955652237,
-0.23127883672714233,
-1.6050893068313599,
0.6815981268882751,
-0.4048616886138916,
-1.5805752277374268,
-0.6263437271118164,
0.7459540367126465,
0.5450512170791626,
-0.1557970941066742,
-0.9343500137329102,
-0.00863497331738472,
-0.43131089210510254,
-0.110725082457065... |
javascript/reference/global_objects/arraybuffer/arraybuffer/index.md | JavaScript - Global Objects - ArrayBuffer - Syntax:
Example:
new ArrayBuffer(length)
new ArrayBuffer(length, options)
Note: `ArrayBuffer()` can only be constructed with `new`. Attempting to call it without `new` throws a `TypeError`. | [
-0.26641175150871277,
0.18402604758739471,
-0.9337138533592224,
0.7072774171829224,
-0.7930548191070557,
-2.1010348796844482,
-0.12818817794322968,
1.2754288911819458,
0.12927284836769104,
-0.30270734429359436,
-0.3974365293979645,
-0.0951504334807396,
0.3977489769458771,
0.014070932753384... |
javascript/reference/global_objects/arraybuffer/arraybuffer/index.md | JavaScript - Global Objects - ArrayBuffer - Syntax - Parameters:
- `length`: The size, in bytes, of the array buffer to create.
- `options` (optional): An object, which can contain the following properties:
- `maxByteLength` (optional): The maximum size, in bytes, that the array buffer can be resized to. | [
-0.08535389602184296,
-0.1374283879995346,
-1.0747346878051758,
0.5859808325767517,
-0.6526564955711365,
-1.9624696969985962,
0.3788115978240967,
0.2645792067050934,
0.4059833586215973,
-0.1615303009748459,
-1.4490694999694824,
0.3597664535045624,
-0.26480478048324585,
0.36049380898475647,... |
javascript/reference/global_objects/arraybuffer/arraybuffer/index.md | JavaScript - Global Objects - ArrayBuffer - Syntax - Return value:
A new `ArrayBuffer` object of the specified size, with its `maxByteLength` property set to the specified `maxByteLength` if one was specified. Its contents are initialized to 0. | [
-0.011821978725492954,
-0.17099528014659882,
-1.1643736362457275,
0.8329122066497803,
-0.6463196873664856,
-1.419913649559021,
0.6804217100143433,
0.9728678464889526,
0.2554580271244049,
0.1859627068042755,
-0.8878318667411804,
0.37913239002227783,
-0.12744519114494324,
0.8648551106452942,... |
javascript/reference/global_objects/arraybuffer/arraybuffer/index.md | JavaScript - Global Objects - ArrayBuffer - Syntax - Exceptions:
- `RangeError`: Thrown in one of the following cases:
- `length` or `maxByteLength` is larger than `Number.MAX_SAFE_INTEGER` (≥ 253) or negative.
- `length` is larger than `maxByteLength`. | [
-0.6278427243232727,
-0.4413728713989258,
-1.000220537185669,
0.2874816954135895,
-0.369185209274292,
-1.797696828842163,
-0.2533339560031891,
0.5718679428100586,
-0.5478339791297913,
-0.06468147039413452,
-0.9150696396827698,
-0.07165354490280151,
-0.7449056506156921,
-0.2178104817867279,... |
javascript/reference/global_objects/arraybuffer/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/arraybuffer/index.md | JavaScript - Global Objects - ArrayBuffer - Examples - Creating a resizable ArrayBuffer:
In this example, we create a 8-byte buffer that is resizable to a max length of 16 bytes, then `resize()` it to 12 bytes:
Example:
const buffer = new ArrayBuffer(8, { maxByteLength: 16 });
buffer.resize(12);
Note: It is recomm... | [
-0.11811098456382751,
0.1076866090297699,
-1.1039423942565918,
0.43770527839660645,
-0.5482285618782043,
-1.2121742963790894,
0.4757574498653412,
0.5152985453605652,
0.4299386739730835,
-0.2808678150177002,
-0.891416609287262,
0.627112865447998,
-0.4597465395927429,
0.007925603538751602,
... |
javascript/reference/global_objects/arraybuffer/isview/index.md | JavaScript - Global Objects - ArrayBuffer - isView:
The `ArrayBuffer.isView()` static method determines whether the passed value is one of the `ArrayBuffer` views, such as typed array objects or a `DataView`.
Example:
// Create an ArrayBuffer with a size in bytes
const buffer = new ArrayBuffer(16);
console.log(Arra... | [
-0.1855228990316391,
-0.7638856768608093,
-1.0363901853561401,
0.7896708846092224,
-0.5529670119285583,
-1.2210571765899658,
0.49820011854171753,
0.5017669796943665,
0.6390111446380615,
0.28010645508766174,
-1.011800765991211,
-0.705392599105835,
0.9927312135696411,
0.5271100401878357,
-... |
javascript/reference/global_objects/arraybuffer/isview/index.md | JavaScript - Global Objects - ArrayBuffer - isView - Syntax:
Example:
ArrayBuffer.isView(value) | [
-0.0670820102095604,
0.05708988755941391,
-0.801702082157135,
0.006051891949027777,
-1.2151445150375366,
-1.6425164937973022,
0.654258131980896,
0.9085239171981812,
0.4035264551639557,
-0.33669808506965637,
-0.8824568390846252,
-0.25433099269866943,
0.5740389823913574,
0.5497278571128845,
... |
javascript/reference/global_objects/arraybuffer/isview/index.md | JavaScript - Global Objects - ArrayBuffer - isView - Syntax - Parameters:
- `value`: The value to be checked. | [
0.2633337676525116,
0.14830957353115082,
-1.068083643913269,
-0.420830637216568,
-0.661268949508667,
-1.6389023065567017,
1.0270285606384277,
0.8991800546646118,
0.2210746854543686,
-0.1185297742486,
-0.9535844922065735,
-0.14347349107265472,
0.39475712180137634,
0.9872633814811707,
0.32... |
javascript/reference/global_objects/arraybuffer/isview/index.md | JavaScript - Global Objects - ArrayBuffer - isView - Syntax - Return value:
`true` if the given argument is one of the `ArrayBuffer` views; otherwise, `false`. | [
-0.2664315700531006,
-0.3099784851074219,
-0.6714732646942139,
0.29661262035369873,
-1.09639310836792,
-2.0460736751556396,
0.9584346413612366,
0.870760977268219,
0.09785541892051697,
0.21860982477664948,
-1.12977933883667,
-0.9819898009300232,
0.8814268112182617,
0.7811187505722046,
0.0... |
javascript/reference/global_objects/arraybuffer/isview/index.md | JavaScript - Global Objects - ArrayBuffer - isView - Examples - Using isView:
Example:
ArrayBuffer.isView(); // false
ArrayBuffer.isView([]); // false
ArrayBuffer.isView({}); // false
ArrayBuffer.isView(null); // false
ArrayBuffer.isView(undefined); // false
ArrayBuffer.isView(new ArrayBuffer(10)); // false
ArrayBuf... | [
-0.5290407538414001,
-0.2507476806640625,
-0.7379127144813538,
-0.07171948999166489,
-0.7927243709564209,
-1.2134021520614624,
0.6795002222061157,
0.4730786681175232,
0.557623565196991,
0.3437165915966034,
-1.008203387260437,
-0.5929054617881775,
0.8098320960998535,
0.651081383228302,
-0... |
javascript/reference/global_objects/arraybuffer/transfer/index.md | JavaScript - Global Objects - ArrayBuffer - transfer:
The `transfer()` method of `ArrayBuffer` instances creates a new `ArrayBuffer` with the same byte content as this buffer, then detaches this buffer. | [
0.462825208902359,
-0.2642890214920044,
-1.2670834064483643,
1.4395520687103271,
-0.2044389247894287,
-1.2994886636734009,
0.5980689525604248,
1.061018705368042,
0.31207969784736633,
-0.16447433829307556,
-0.9934518337249756,
-0.047368694096803665,
-0.5190477967262268,
0.9398102760314941,
... |
javascript/reference/global_objects/arraybuffer/transfer/index.md | JavaScript - Global Objects - ArrayBuffer - transfer - Syntax:
Example:
transfer()
transfer(newByteLength) | [
-0.4114701449871063,
0.10369864106178284,
-1.2786668539047241,
0.6426932215690613,
-0.681016206741333,
-1.4585480690002441,
0.0022259934339672327,
0.8978551626205444,
0.23873282968997955,
-0.8358618021011353,
-0.7519922256469727,
0.5225851535797119,
-0.011293825693428516,
0.626516699790954... |
javascript/reference/global_objects/arraybuffer/transfer/index.md | JavaScript - Global Objects - ArrayBuffer - transfer - Syntax - Parameters:
- `newByteLength` (optional): 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.4623006284236908,
-0.40429919958114624,
-1.7720710039138794,
0.8435085415840149,
-0.1806413233280182,
-2.1284449100494385,
0.5230197310447693,
0.5937213897705078,
0.39780348539352417,
-0.34706637263298035,
-1.2120150327682495,
0.12868686020374298,
0.0253883246332407,
0.7695293426513672,... |
javascript/reference/global_objects/arraybuffer/transfer/index.md | JavaScript - Global Objects - ArrayBuffer - transfer - 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 resizable if and only if this `ArrayBuffer` is resizable, in which case ... | [
-0.024505427107214928,
-0.13850149512290955,
-1.0908489227294922,
1.25149667263031,
-0.43189680576324463,
-1.1927497386932373,
0.878365159034729,
1.1305924654006958,
0.43453171849250793,
0.42349720001220703,
-1.065401554107666,
0.15167632699012756,
-0.4165009558200836,
1.3623366355895996,
... |
javascript/reference/global_objects/arraybuffer/transfer/index.md | JavaScript - Global Objects - ArrayBuffer - transfer - Syntax - Exceptions:
- `RangeError`: Thrown if this `ArrayBuffer` is resizable and `newByteLength` is greater than the `maxByteLength` of this `ArrayBuffer`.
- `TypeError`: Thrown if this `ArrayBuffer` is already detached, or if it can only be detached by designat... | [
0.06820578873157501,
0.019196253269910812,
-0.42927899956703186,
1.4519556760787964,
0.07042183727025986,
-1.006919503211975,
0.20346930623054504,
1.3991608619689941,
-0.28800806403160095,
0.3672138750553131,
-0.8715099692344666,
0.30497148633003235,
-0.06088554114103317,
0.532716929912567... |
javascript/reference/global_objects/arraybuffer/transfer/index.md | JavaScript - Global Objects - ArrayBuffer - transfer - Description:
The `transfer()` method performs the same operation as the structured clone algorithm. It copies the bytes of this `ArrayBuffer` into a new `ArrayBuffer` object, then detaches this `ArrayBuffer` object. See transferring ArrayBuffers for more informati... | [
-0.22350986301898956,
0.28620395064353943,
-1.328047513961792,
1.6421781778335571,
0.47974416613578796,
-0.662056565284729,
0.618273138999939,
1.1147414445877075,
-0.1669856458902359,
0.6373762488365173,
-0.8530033230781555,
0.3080659806728363,
0.37059441208839417,
1.138012170791626,
-0.... |
javascript/reference/global_objects/arraybuffer/transfer/index.md | JavaScript - Global Objects - ArrayBuffer - transfer - Examples - Transferring an ArrayBuffer:
Example:
// Create an ArrayBuffer and write a few bytes
const buffer = new ArrayBuffer(8);
const view = new Uint8Array(buffer);
view[1] = 2;
view[7] = 4;
// Copy the buffer to the same size
const buffer2 = buffer.transfer(... | [
0.12835834920406342,
0.2248133420944214,
-1.322712779045105,
0.8098247051239014,
-0.18230928480625153,
-1.2452658414840698,
-0.19553199410438538,
0.6874802708625793,
0.4585650563240051,
-0.1001836508512497,
-0.3884147107601166,
0.1433083415031433,
0.08521740883588791,
0.8955200910568237,
... |
javascript/reference/global_objects/arraybuffer/transfer/index.md | JavaScript - Global Objects - ArrayBuffer - transfer - Examples - Transferring a resizable ArrayBuffer:
Example:
const buffer = new ArrayBuffer(8, { maxByteLength: 16 });
const view = new Uint8Array(buffer);
view[1] = 2;
view[7] = 4;
// Copy the buffer to a smaller size
const buffer2 = buffer.transfer(4);
console.lo... | [
-0.14108234643936157,
0.13010390102863312,
-1.1884809732437134,
0.6898225545883179,
-0.47330206632614136,
-0.8652568459510803,
-0.3972040116786957,
0.23070630431175232,
0.3795371651649475,
-0.09684189409017563,
-0.44703978300094604,
0.6844960451126099,
0.10524094104766846,
0.97915434837341... |
javascript/reference/global_objects/arraybuffer/slice/index.md | JavaScript - Global Objects - ArrayBuffer - slice:
The `slice()` method of `ArrayBuffer` instances returns a new `ArrayBuffer` whose contents are a copy of this `ArrayBuffer`'s bytes from `start`, inclusive, up to `end`, exclusive. If either `start` or `end` is negative, it refers to an index from the end of the array... | [
-0.7657424807548523,
-0.36811158061027527,
-0.981519341468811,
0.6364699602127075,
0.3883597254753113,
-0.5291693210601807,
-0.09098907560110092,
0.150907963514328,
0.16216135025024414,
0.6270559430122375,
-0.3840242326259613,
0.5000612735748291,
-0.010968690738081932,
0.6182413697242737,
... |
javascript/reference/global_objects/arraybuffer/slice/index.md | JavaScript - Global Objects - ArrayBuffer - slice - Syntax:
Example:
slice()
slice(start)
slice(start, end) | [
-0.41197022795677185,
0.5508705973625183,
-0.806542158126831,
-0.12865445017814636,
-0.6930887699127197,
-0.669214129447937,
0.3218349814414978,
0.8345474600791931,
-0.10353585332632065,
-0.06231536343693733,
-0.004134666174650192,
0.19509251415729523,
-0.4004342555999756,
0.41964983940124... |
javascript/reference/global_objects/arraybuffer/slice/index.md | JavaScript - Global Objects - ArrayBuffer - slice - Syntax - Parameters:
- `start` (optional): Zero-based index at which to start extraction, converted to an integer.
- Negative index counts back from the end of the buffer — if `-buffer.length <= start < 0`, `start + buffer.length` is used.
- If `start < -buffer.l... | [
-0.6690972447395325,
0.252557635307312,
-1.097537636756897,
0.6279142498970032,
0.09782391786575317,
-1.285636067390442,
0.7452073097229004,
0.3247077763080597,
0.13563960790634155,
0.6407795548439026,
-1.1452194452285767,
0.12940673530101776,
-0.07616373896598816,
0.7846935391426086,
1.... |
javascript/reference/global_objects/arraybuffer/slice/index.md | JavaScript - Global Objects - ArrayBuffer - slice - Syntax - Return value:
A new `ArrayBuffer` containing the extracted elements. It is not resizable, even if the original was. | [
-0.2475574016571045,
0.36975613236427307,
-1.4082380533218384,
0.46629950404167175,
-0.4140515923500061,
-1.4389643669128418,
0.5512797832489014,
1.2264463901519775,
-0.11996850371360779,
0.6246060132980347,
-0.7495390176773071,
-0.018817581236362457,
-0.5115006566047668,
1.142849802970886... |
javascript/reference/global_objects/arraybuffer/slice/index.md | JavaScript - Global Objects - ArrayBuffer - slice - Examples - Copying an ArrayBuffer:
Example:
const buf1 = new ArrayBuffer(8);
const buf2 = buf1.slice(0); | [
-0.9631382822990417,
0.334368497133255,
-0.8002213835716248,
0.5883662700653076,
-0.1655620038509369,
-1.2000725269317627,
0.15849050879478455,
0.43061789870262146,
0.30498993396759033,
-0.017093678936362267,
-0.9837887287139893,
-0.1608106642961502,
-0.2522277235984802,
0.3239047527313232... |
javascript/reference/global_objects/arraybuffer/maxbytelength/index.md | JavaScript - Global Objects - ArrayBuffer - maxByteLength:
The `maxByteLength` accessor property of `ArrayBuffer` instances returns the maximum length (in bytes) that this array buffer can be resized to.
Example:
const buffer = new ArrayBuffer(8, { maxByteLength: 16 });
console.log(buffer.byteLength);
// Expected o... | [
-0.18939536809921265,
-0.8030007481575012,
-1.478362798690796,
0.7166653871536255,
-0.5908358097076416,
-1.5314571857452393,
-0.450412780046463,
0.22173064947128296,
0.8699314594268799,
-0.10452782362699509,
-1.160127878189087,
0.46129727363586426,
-0.5570599436759949,
0.5789836645126343,
... |
javascript/reference/global_objects/arraybuffer/maxbytelength/index.md | JavaScript - Global Objects - ArrayBuffer - maxByteLength - Description:
The `maxByteLength` property is an accessor property whose set accessor function is `undefined`, meaning that you can only read this property. The value is established when the array is constructed, set via the `maxByteLength` option of the `Arra... | [
-0.7971346974372864,
-0.4460861086845398,
-1.2017520666122437,
0.9234227538108826,
0.015835704281926155,
-1.3175562620162964,
0.3015749454498291,
0.6516678333282471,
0.5884687900543213,
-0.13840311765670776,
-0.6377978324890137,
0.11677096784114838,
-0.6849759817123413,
0.1699102371931076,... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.