file stringlengths 16 94 | text stringlengths 32 24.4k | vector list |
|---|---|---|
javascript/reference/global_objects/map/get/index.md | JavaScript - Global Objects - Map - get - Syntax - Return value:
The value associated with the specified key in the `Map` object. If the key can't be found, `undefined` is returned. | [
-0.4142362177371979,
0.04265822097659111,
-1.0531586408615112,
-0.30851608514785767,
-0.8515132069587708,
-1.5599499940872192,
0.917283296585083,
0.6197516322135925,
-0.41360506415367126,
0.018451355397701263,
0.24226070940494537,
0.655561089515686,
-0.24295125901699066,
0.9859354496002197... |
javascript/reference/global_objects/map/get/index.md | JavaScript - Global Objects - Map - get - Examples - Using get():
Example:
const myMap = new Map();
myMap.set("bar", "foo");
console.log(myMap.get("bar")); // Returns "foo"
console.log(myMap.get("baz")); // Returns undefined | [
-0.20421530306339264,
-0.2652919590473175,
-1.3341002464294434,
0.137272447347641,
-0.4657837748527527,
-1.999860167503357,
-0.047544192522764206,
0.0951840877532959,
-0.2507557272911072,
0.17833200097084045,
-0.44261330366134644,
0.32937464118003845,
-0.11666379868984222,
-0.0102091785520... |
javascript/reference/global_objects/map/get/index.md | JavaScript - Global Objects - Map - get - Examples - Using get() to retrieve a reference to an object:
Example:
const arr = [];
const myMap = new Map();
myMap.set("bar", arr);
myMap.get("bar").push("foo");
console.log(arr); // ["foo"]
console.log(myMap.get("bar")); // ["foo"] | [
-0.2580071687698364,
-0.20469975471496582,
-1.223721981048584,
0.2900402545928955,
-0.5702695846557617,
-2.2762796878814697,
0.4533291757106781,
0.21378502249717712,
-0.35664620995521545,
0.14472827315330505,
-0.5474808812141418,
0.3395027816295624,
-0.527680516242981,
0.7241564393043518,
... |
javascript/reference/global_objects/map/values/index.md | JavaScript - Global Objects - Map - values:
The `values()` method of `Map` instances returns a new map iterator object that contains the values for each element in this map in insertion order.
Example:
const map = new Map();
map.set("0", "foo");
map.set(1, "bar");
const iterator = map.values();
console.log(iterat... | [
0.10822111368179321,
-0.9750451445579529,
-1.2526135444641113,
0.6676229238510132,
0.17743046581745148,
-1.5231359004974365,
0.3199784457683563,
0.508510410785675,
-0.3923061192035675,
0.3391706049442291,
-0.06940816342830658,
0.607044517993927,
0.8718647360801697,
0.4978898763656616,
0.... |
javascript/reference/global_objects/map/values/index.md | JavaScript - Global Objects - Map - values - Syntax:
Example:
values() | [
0.019857734441757202,
-0.30155959725379944,
-1.1294269561767578,
-0.0844174474477768,
-0.8670240044593811,
-2.120347023010254,
1.190685749053955,
0.9046820402145386,
-0.1495848298072815,
-0.8440526723861694,
0.015592053532600403,
0.7221892476081848,
0.5279321670532227,
-0.0904352068901062,... |
javascript/reference/global_objects/map/values/index.md | JavaScript - Global Objects - Map - values - Syntax - Parameters:
None. | [
-0.18571962416172028,
0.1967092603445053,
-1.3159571886062622,
-0.5922896265983582,
-0.6354140043258667,
-1.6659584045410156,
1.1696354150772095,
1.1119168996810913,
-0.372231662273407,
-0.7338579297065735,
-0.5375524759292603,
-0.5059042572975159,
0.3124989867210388,
0.021752864122390747,... |
javascript/reference/global_objects/map/values/index.md | JavaScript - Global Objects - Map - values - Syntax - Return value:
A new iterable iterator object. | [
-0.19142663478851318,
0.021281246095895767,
-0.8440465331077576,
-0.03904007375240326,
-0.5386602282524109,
-1.7678166627883911,
0.028203042224049568,
1.3383443355560303,
-0.28340670466423035,
0.11867658793926239,
-0.4392567276954651,
0.4120657742023468,
0.058163583278656006,
0.98039013147... |
javascript/reference/global_objects/map/values/index.md | JavaScript - Global Objects - Map - values - Examples - Using values():
Example:
const myMap = new Map();
myMap.set("0", "foo");
myMap.set(1, "bar");
myMap.set({}, "baz");
const mapIter = myMap.values();
console.log(mapIter.next().value); // "foo"
console.log(mapIter.next().value); // "bar"
console.log(mapIter.next... | [
-0.23126740753650665,
-0.4500172734260559,
-1.3557149171829224,
0.690765917301178,
-0.4507361650466919,
-2.139965772628784,
0.3152622878551483,
0.2886047065258026,
0.2985061705112457,
0.1356653869152069,
-0.5082288980484009,
0.10296642780303955,
0.4487801492214203,
-0.3514240086078644,
0... |
javascript/reference/global_objects/map/delete/index.md | JavaScript - Global Objects - Map - delete:
The `delete()` method of `Map` instances removes the entry specified by the key from this `Map`.
Example:
const map = new Map();
map.set("bar", "foo");
console.log(map.delete("bar"));
// Expected result: true
// True indicates successful removal
console.log(map.has("bar"... | [
0.16075295209884644,
-0.7080135345458984,
-1.0698859691619873,
0.3779856562614441,
-0.10090304911136627,
-2.509673833847046,
0.7319625616073608,
-0.10749570280313492,
-0.04032226279377937,
0.5956972241401672,
-0.43470287322998047,
-0.12275057286024094,
0.0878814309835434,
0.502444863319397... |
javascript/reference/global_objects/map/delete/index.md | JavaScript - Global Objects - Map - delete - Syntax:
Example:
mapInstance.delete(key) | [
-0.23480500280857086,
0.1616171896457672,
-0.5810138583183289,
-0.2612609565258026,
-0.535841166973114,
-2.092960834503174,
0.828031063079834,
0.5952492952346802,
0.17783012986183167,
-0.24433279037475586,
-0.07609971612691879,
0.3047700822353363,
0.1414775401353836,
0.6431955099105835,
... |
javascript/reference/global_objects/map/delete/index.md | JavaScript - Global Objects - Map - delete - Syntax - Parameters:
- `key`: The key of the entry to remove from the `Map` object. Object keys are compared by reference, not by value. | [
-0.14343634247779846,
-0.2720188796520233,
-1.2009366750717163,
-0.40155965089797974,
-0.09415971487760544,
-2.093500852584839,
0.9819450378417969,
0.620961606502533,
0.2915228605270386,
-0.3501018285751343,
-0.633102536201477,
0.08573751896619797,
-0.5106789469718933,
0.7959575057029724,
... |
javascript/reference/global_objects/map/delete/index.md | JavaScript - Global Objects - Map - delete - Syntax - Return value:
`true` if an entry in the `Map` object has been removed successfully. `false` if the key is not found in the `Map`. | [
-0.7295326590538025,
-0.1821444183588028,
-0.7027449607849121,
-0.12026524543762207,
-0.31213465332984924,
-2.2237389087677,
1.220009446144104,
0.3870045244693756,
-0.5038736462593079,
0.30944836139678955,
-0.31418395042419434,
-0.20245718955993652,
0.17765435576438904,
0.6996803283691406,... |
javascript/reference/global_objects/map/delete/index.md | JavaScript - Global Objects - Map - delete - Examples - Using delete():
Example:
const myMap = new Map();
myMap.set("bar", "foo");
console.log(myMap.delete("bar")); // Returns true. Successfully removed.
console.log(myMap.has("bar")); // Returns false. The "bar" element is no longer present. | [
-0.43271753191947937,
-0.11009741574525833,
-0.7129495143890381,
0.3901876211166382,
-0.3566196858882904,
-2.502107858657837,
0.4857200086116791,
0.1959313601255417,
0.2601271867752075,
0.5748804211616516,
-0.26666831970214844,
0.12392722070217133,
-0.04917207360267639,
0.32581406831741333... |
javascript/reference/global_objects/map/entries/index.md | JavaScript - Global Objects - Map - entries:
The `entries()` method of `Map` instances returns a new map iterator object that contains the `[key, value]` pairs for each element in this map in insertion order.
Example:
const map = new Map();
map.set("0", "foo");
map.set(1, "bar");
const iterator = map.entries();
c... | [
0.39682331681251526,
-0.9457595944404602,
-1.1994140148162842,
0.9305700063705444,
0.23103199899196625,
-1.6371169090270996,
0.40049007534980774,
0.1529245227575302,
-0.28544074296951294,
0.782600462436676,
-0.24055837094783783,
0.22805480659008026,
0.6820070743560791,
0.5049000978469849,
... |
javascript/reference/global_objects/map/entries/index.md | JavaScript - Global Objects - Map - entries - Syntax:
Example:
entries() | [
0.6911500096321106,
-0.5388948321342468,
-1.1878169775009155,
0.5107730627059937,
-0.8121500015258789,
-2.277411699295044,
0.8191085457801819,
0.684519350528717,
-0.13291458785533905,
-0.31414076685905457,
-0.13436777889728546,
0.2597730755805969,
0.2508173882961273,
0.11301463097333908,
... |
javascript/reference/global_objects/map/entries/index.md | JavaScript - Global Objects - Map - entries - Syntax - Parameters:
None. | [
0.23247824609279633,
0.07321622967720032,
-1.2261645793914795,
-0.38192614912986755,
-0.45898857712745667,
-1.5147600173950195,
0.9976920485496521,
0.9778341054916382,
-0.40875759720802307,
-0.5331935882568359,
-0.6011294722557068,
-0.7297552227973938,
0.2751237154006958,
0.379586309194564... |
javascript/reference/global_objects/map/entries/index.md | JavaScript - Global Objects - Map - entries - Syntax - Return value:
A new iterable iterator object. | [
0.016635090112686157,
-0.1997087448835373,
-0.894128680229187,
-0.025808485224843025,
-0.5031822323799133,
-1.7908480167388916,
0.10203531384468079,
1.1693066358566284,
-0.12208632379770279,
0.23581820726394653,
-0.5365621447563171,
0.17651619017124176,
-0.003187258029356599,
1.04778897762... |
javascript/reference/global_objects/map/entries/index.md | JavaScript - Global Objects - Map - entries - Examples - Using entries():
Example:
const myMap = new Map();
myMap.set("0", "foo");
myMap.set(1, "bar");
myMap.set({}, "baz");
const mapIter = myMap.entries();
console.log(mapIter.next().value); // ["0", "foo"]
console.log(mapIter.next().value); // [1, "bar"]
console.l... | [
0.5391721129417419,
-0.5189552903175354,
-1.2786226272583008,
0.9654864072799683,
-0.3328564167022705,
-2.3511438369750977,
0.07471173256635666,
-0.10117600113153458,
0.3897646963596344,
0.15833070874214172,
-0.775783121585846,
0.14372707903385162,
0.3613182306289673,
-0.17745745182037354,... |
javascript/reference/global_objects/map/foreach/index.md | JavaScript - Global Objects - Map - forEach:
The `forEach()` method of `Map` instances executes a provided function once per each key/value pair in this map, in insertion order.
Example:
function logMapElements(value, key, map) {
console.log(`m[${key}] = ${value}`);
}
new Map([
["foo", 3],
["bar", {}],
["ba... | [
0.40109822154045105,
-0.8753488659858704,
-1.3331891298294067,
-0.012531131505966187,
-0.042425911873579025,
-1.3356541395187378,
1.0188660621643066,
0.3454132378101349,
-1.1968199014663696,
0.008034936152398586,
-0.032063886523246765,
0.3595236837863922,
0.3913455009460449,
0.602160990238... |
javascript/reference/global_objects/map/foreach/index.md | JavaScript - Global Objects - Map - forEach - Syntax:
Example:
forEach(callbackFn)
forEach(callbackFn, thisArg) | [
0.035083625465631485,
0.25001612305641174,
-0.16020245850086212,
-0.709302544593811,
-0.9698088765144348,
-2.9450080394744873,
1.381678581237793,
0.6258934736251831,
-0.7627719640731812,
-0.21873044967651367,
-0.4971846342086792,
0.6483269929885864,
-0.4709950089454651,
0.7845127582550049,... |
javascript/reference/global_objects/map/foreach/index.md | JavaScript - Global Objects - Map - forEach - Syntax - Parameters:
- `callbackFn`: A function to execute for each entry in the map. The function is called with the following arguments:
- `value`: Value of each iteration.
- `key`: Key of each iteration.
- `map`: The map being iterated.
- `thisArg` (optional): A v... | [
-0.1946989893913269,
-0.08004689961671829,
-0.8689077496528625,
-0.21946948766708374,
-0.3866143226623535,
-2.1943466663360596,
1.5276163816452026,
-0.23689670860767365,
-0.7677653431892395,
0.278664767742157,
-0.6914358735084534,
0.4644519090652466,
-0.553106963634491,
1.3434566259384155,... |
javascript/reference/global_objects/map/foreach/index.md | JavaScript - Global Objects - Map - forEach - Syntax - Return value:
None (`undefined`). | [
-0.32682380080223083,
0.15045250952243805,
-0.822182297706604,
-1.1748040914535522,
-0.6677969694137573,
-1.7393226623535156,
1.5602489709854126,
0.9156897068023682,
-0.9171016812324524,
-0.0054506538435816765,
-0.054347746074199677,
0.4441946744918823,
0.0466076023876667,
0.14121627807617... |
javascript/reference/global_objects/map/foreach/index.md | JavaScript - Global Objects - Map - forEach - Description:
The `forEach` method executes the provided `callback` once for each key of the map which actually exist. It is not invoked for keys which have been deleted. However, it is executed for values which are present but have the value `undefined`.
`callback` is inv... | [
-0.5422540307044983,
-0.13420309126377106,
-0.9926570057868958,
-0.018999960273504257,
-0.19445326924324036,
-1.933876872062683,
1.8472809791564941,
0.24906860291957855,
-0.9591957926750183,
0.6249380707740784,
0.0665660873055458,
0.5298134684562683,
0.32965341210365295,
0.8172796368598938... |
javascript/reference/global_objects/map/foreach/index.md | JavaScript - Global Objects - Map - forEach - Examples - Printing the contents of a Map object:
The following code logs a line for each element in a `Map` object:
Example:
function logMapElements(value, key, map) {
console.log(`map.get('${key}') = ${value}`);
}
new Map([
["foo", 3],
["bar", {}],
["baz", unde... | [
-0.11894140392541885,
0.11901872605085373,
-0.9710026383399963,
0.1651667207479477,
0.34549590945243835,
-0.6760983467102051,
0.010740731842815876,
0.10223297029733658,
-0.7694480419158936,
0.05214594677090645,
-0.2489020824432373,
0.1646670401096344,
0.1711014360189438,
0.4993056058883667... |
javascript/reference/global_objects/iterator/filter/index.md | JavaScript - Global Objects - Iterator - filter:
The `filter()` method of `Iterator` instances returns a new iterator helper object that yields only those elements of the iterator for which the provided callback function returns `true`. | [
-0.7824289202690125,
-0.5044354796409607,
-1.3244768381118774,
0.44207948446273804,
-0.1893405318260193,
-1.5583281517028809,
0.2863422930240631,
0.8655991554260254,
-1.4610917568206787,
0.6485388875007629,
-0.7089744806289673,
-0.42521029710769653,
0.07987818866968155,
1.143996238708496,
... |
javascript/reference/global_objects/iterator/filter/index.md | JavaScript - Global Objects - Iterator - filter - Syntax:
Example:
filter(callbackFn) | [
-0.7498244643211365,
0.15828508138656616,
-0.8902668952941895,
-0.24118274450302124,
-0.6524064540863037,
-1.513576865196228,
0.4677768647670746,
0.6818650364875793,
-1.279438853263855,
0.619208812713623,
-0.42125460505485535,
0.32169172167778015,
-0.6912463903427124,
1.2111777067184448,
... |
javascript/reference/global_objects/iterator/filter/index.md | JavaScript - Global Objects - Iterator - filter - Syntax - Parameters:
- `callbackFn`: A function to execute for each element produced by the iterator. It should return a truthy value to make the element yielded by the iterator helper, and a falsy value otherwise. The function is called with the following arguments:
... | [
-0.7606275081634521,
-0.22433628141880035,
-0.9466015100479126,
-0.05757426097989082,
-0.2322978675365448,
-1.523711085319519,
0.20042498409748077,
-0.08119108527898788,
-0.90867680311203,
0.7366355657577515,
-0.9073030352592468,
0.3122975528240204,
-0.9600595831871033,
1.765557885169983,
... |
javascript/reference/global_objects/iterator/filter/index.md | JavaScript - Global Objects - Iterator - filter - Syntax - Return value:
A new iterator helper object. Each time the iterator helper's `next()` method is called, it returns the next element in the iterator for which the callback function returns `true`. When the underlying iterator is completed, the iterator helper ob... | [
-0.4050537049770355,
-0.11315228790044785,
-0.9113859534263611,
0.2539657950401306,
-0.36696070432662964,
-1.344659447669983,
0.34189489483833313,
1.0128942728042603,
-0.6056638956069946,
0.5146340727806091,
-0.19863329827785492,
0.057210102677345276,
-0.004021961707621813,
1.0001853704452... |
javascript/reference/global_objects/iterator/filter/index.md | JavaScript - Global Objects - Iterator - filter - Description:
The main advantage of iterator helpers over array methods is that they are lazy, meaning that they only produce the next value when requested. This avoids unnecessary computation and also allows them to be used with infinite iterators. | [
0.07510348409414291,
0.14598773419857025,
-1.2024115324020386,
0.474526584148407,
0.19113261997699738,
-1.5804486274719238,
0.029792819172143936,
0.6124392747879028,
-0.370602011680603,
0.5691066980361938,
-1.0145503282546997,
-0.7599809765815735,
-0.1412840038537979,
0.07267548143863678,
... |
javascript/reference/global_objects/iterator/filter/index.md | JavaScript - Global Objects - Iterator - filter - Examples - Using filter():
The following example creates an iterator that yields terms in the Fibonacci sequence, and then reads the first few terms that are even:
Example:
function* fibonacci() {
let current = 1;
let next = 1;
while (true) {
yield current;... | [
-1.3447998762130737,
0.14520755410194397,
-0.895099937915802,
0.37321531772613525,
0.28043684363365173,
-1.019658088684082,
-0.034643422812223434,
1.0882636308670044,
-0.3917705714702606,
0.2031513899564743,
-0.47161805629730225,
0.3021744191646576,
-0.5339751243591309,
0.5081348419189453,... |
javascript/reference/global_objects/iterator/filter/index.md | JavaScript - Global Objects - Iterator - filter - Examples - Using filter() with a for...of loop:
`filter()` is most convenient when you are not hand-rolling the iterator. Because iterators are also iterable, you can iterate the returned helper with a `for...of` loop:
Example:
for (const n of fibonacci().filter((x) ... | [
-0.9168809652328491,
-0.32407137751579285,
-0.44551196694374084,
0.9974533319473267,
0.1820763200521469,
-1.4843534231185913,
-0.08948114514350891,
0.06377840787172318,
-0.8131386041641235,
0.9476649165153503,
0.3744325637817383,
0.1630256474018097,
-0.08777596056461334,
0.6757818460464478... |
javascript/reference/global_objects/iterator/symbol.iterator/index.md | JavaScript - Global Objects - Iterator - Symbol.iterator:
The `[Symbol.iterator]()` method of `Iterator` instances implements the iterable protocol and allows built-in iterators to be consumed by most syntaxes expecting iterables, such as the spread syntax and `for...of` loops. It returns the value of `this`, which is... | [
-0.3765213191509247,
0.22799129784107208,
-0.4093402922153473,
0.6531385183334351,
-0.07627465575933456,
-1.7998285293579102,
-0.14653651416301727,
1.4501346349716187,
-0.4182210862636566,
0.2715896666049957,
-0.7605155110359192,
0.8562673330307007,
-0.27915826439857483,
0.6079425811767578... |
javascript/reference/global_objects/iterator/symbol.iterator/index.md | JavaScript - Global Objects - Iterator - Symbol.iterator - Syntax:
Example:
iterator[Symbol.iterator]() | [
-0.14913587272167206,
0.2784838378429413,
-0.4818302392959595,
-0.3396318554878235,
-0.4378601312637329,
-1.94127357006073,
-0.3274328112602234,
1.5760605335235596,
-0.25020238757133484,
-0.4162416458129883,
-0.22108636796474457,
0.6790456771850586,
-0.5287349820137024,
0.04648522287607193... |
javascript/reference/global_objects/iterator/symbol.iterator/index.md | JavaScript - Global Objects - Iterator - Symbol.iterator - Syntax - Parameters:
None. | [
-0.08311408758163452,
0.3763413429260254,
-0.7359476685523987,
-0.5520834922790527,
-0.4934186041355133,
-1.6353235244750977,
-0.065143883228302,
1.7116336822509766,
-0.5868775248527527,
-0.5435002446174622,
-0.6016245484352112,
0.09181574732065201,
-0.27068057656288147,
0.2461598664522171... |
javascript/reference/global_objects/iterator/symbol.iterator/index.md | JavaScript - Global Objects - Iterator - Symbol.iterator - Syntax - Return value:
The value of `this`, which is the iterator object itself. | [
0.03395456075668335,
0.2911809980869293,
-0.6444164514541626,
0.013010298833251,
-0.42956632375717163,
-1.7932519912719727,
-0.11380288004875183,
1.722249984741211,
-0.09989867359399796,
0.0765664204955101,
-0.5224661827087402,
1.2158336639404297,
-0.3961769938468933,
0.8285036087036133,
... |
javascript/reference/global_objects/iterator/symbol.iterator/index.md | JavaScript - Global Objects - Iterator - Symbol.iterator - Examples - Iteration using for...of loop:
Note that you seldom need to call this method directly. The existence of the `[Symbol.iterator]()` method makes built-in iterators iterable, and iterating syntaxes like the `for...of` loop automatically call this metho... | [
-0.18547292053699493,
0.3543255925178528,
-0.13685743510723114,
0.830459713935852,
0.1419261395931244,
-2.0259809494018555,
-0.6781921982765198,
0.7330765724182129,
-1.1159261465072632,
0.08909972757101059,
0.07125776261091232,
0.31311923265457153,
-0.526502788066864,
0.6828721761703491,
... |
javascript/reference/global_objects/iterator/take/index.md | JavaScript - Global Objects - Iterator - take:
The `take()` method of `Iterator` instances returns a new iterator helper object that yields the given number of elements in this iterator and then terminates. | [
-0.09704750776290894,
-0.4032779932022095,
-0.9304714202880859,
0.057279039174318314,
-0.30355116724967957,
-1.4355465173721313,
0.515582263469696,
0.8673166036605835,
-0.920660138130188,
0.6251245141029358,
-0.6742554903030396,
0.010207078419625759,
-0.8172913193702698,
1.190436840057373,... |
javascript/reference/global_objects/iterator/take/index.md | JavaScript - Global Objects - Iterator - take - Syntax:
Example:
take(limit) | [
-0.3281405568122864,
0.07378669828176498,
-0.8823118805885315,
-0.4504343867301941,
-0.8570157289505005,
-1.6794664859771729,
-0.04588840529322624,
1.1828278303146362,
-0.586852490901947,
0.0497293658554554,
-0.7656709551811218,
0.4199979603290558,
-0.8102256655693054,
0.4555111527442932,
... |
javascript/reference/global_objects/iterator/take/index.md | JavaScript - Global Objects - Iterator - take - Syntax - Parameters:
- `limit`: The number of elements to take from the start of the iteration. | [
0.04021736979484558,
-0.14978128671646118,
-0.9173325896263123,
-0.6099885106086731,
-0.6874201893806458,
-1.3112843036651611,
-0.2165510654449463,
0.9664133787155151,
-0.5649141073226929,
-0.09441237151622772,
-1.4428073167800903,
0.15728747844696045,
-1.0945509672164917,
0.72927087545394... |
javascript/reference/global_objects/iterator/take/index.md | JavaScript - Global Objects - Iterator - take - Syntax - Return value:
A new iterator helper object. The returned iterator helper yields the elements in the original iterator one-by-one, and then completes (the `next()` method produces `{ value: undefined, done: true }`) once `limit` elements have been yielded, or whe... | [
-0.21916188299655914,
0.05653688311576843,
-0.8656051158905029,
0.21477265655994415,
-0.4007677137851715,
-1.6215459108352661,
0.3584975004196167,
1.3289847373962402,
-0.5618013143539429,
0.43748369812965393,
-0.6517807245254517,
0.25092819333076477,
-1.1096000671386719,
1.252777338027954,... |
javascript/reference/global_objects/iterator/take/index.md | JavaScript - Global Objects - Iterator - take - Syntax - Exceptions:
- `RangeError`: Thrown if `limit` becomes `NaN` or negative when converted to an integer. | [
-0.9947449564933777,
0.18656684458255768,
-0.20359943807125092,
0.0826437845826149,
-0.603020429611206,
-1.9363549947738647,
-0.5743273496627808,
1.1286859512329102,
-1.1149379014968872,
0.14582479000091553,
-0.9064463376998901,
-0.23090769350528717,
-0.8898300528526306,
-0.272388339042663... |
javascript/reference/global_objects/iterator/take/index.md | JavaScript - Global Objects - Iterator - take - Examples - Using take():
The following example creates an iterator that yields terms in the Fibonacci sequence, and then logs the first three terms:
Example:
function* fibonacci() {
let current = 1;
let next = 1;
while (true) {
yield current;
[current, ne... | [
-1.2335869073867798,
0.14502102136611938,
-1.1663470268249512,
0.560585081577301,
0.11218979954719543,
-0.9000658988952637,
-0.09733115136623383,
1.33079993724823,
-0.6743191480636597,
0.1334974616765976,
-0.5832036137580872,
0.7846344709396362,
-0.7380243539810181,
0.3887559175491333,
0... |
javascript/reference/global_objects/iterator/take/index.md | JavaScript - Global Objects - Iterator - take - Examples - Using take() with a for...of loop:
`take()` is most convenient when you are not hand-rolling the iterator. Because iterators are also iterable, you can iterate the returned helper with a `for...of` loop:
Example:
for (const n of fibonacci().take(5)) {
cons... | [
-0.7757663726806641,
0.16284574568271637,
-0.5158767104148865,
1.2645972967147827,
-0.268104612827301,
-1.54240882396698,
0.32469865679740906,
0.32883644104003906,
-0.6221057176589966,
0.9632085561752319,
0.01096111536026001,
0.3131657540798187,
-0.42366257309913635,
0.45025935769081116,
... |
javascript/reference/global_objects/iterator/take/index.md | JavaScript - Global Objects - Iterator - take - Examples - Combining drop() with take():
You can combine `take()` with `Iterator.prototype.drop()` to get a slice of an iterator:
Example:
for (const n of fibonacci().drop(2).take(5)) {
// Drops the first two elements, then takes the next five
console.log(n);
}
// ... | [
-0.45851725339889526,
-0.527281641960144,
-0.7137004137039185,
0.6429382562637329,
0.09688379615545273,
-0.9046211838722229,
0.5134731531143188,
0.7994868159294128,
-1.2581214904785156,
0.8963779807090759,
-0.253456711769104,
0.45722338557243347,
-0.7515032887458801,
0.5391473770141602,
... |
javascript/reference/global_objects/iterator/take/index.md | JavaScript - Global Objects - Iterator - take - Examples - Lower and upper bounds of take count:
When the `limit` is negative or `NaN`, a `RangeError` is thrown:
Example:
fibonacci().take(-1); // RangeError: -1 must be positive
fibonacci().take(undefined); // RangeError: undefined must be positive
When the `limit` ... | [
-1.1417982578277588,
-0.36953064799308777,
-0.8764115571975708,
0.4919885993003845,
0.11546587198972702,
-1.744511365890503,
-0.20157736539840698,
0.9478892087936401,
-1.5217444896697998,
0.22608034312725067,
-1.1674292087554932,
0.1745130568742752,
-0.9109069108963013,
0.3286939561367035,... |
javascript/reference/global_objects/iterator/flatmap/index.md | JavaScript - Global Objects - Iterator - flatMap:
The `flatMap()` method of `Iterator` instances returns a new iterator helper object that takes each element in the original iterator, runs it through a mapping function, and yields elements returned by the mapping function (which are contained in another iterator or it... | [
-0.6206418871879578,
-0.42081138491630554,
-1.447089672088623,
0.4178721010684967,
0.20657503604888916,
-1.1994426250457764,
0.9262385368347168,
0.8794021010398865,
-1.0283641815185547,
0.2568759024143219,
-0.6076506972312927,
0.16130875051021576,
-0.5266891717910767,
1.1343061923980713,
... |
javascript/reference/global_objects/iterator/flatmap/index.md | JavaScript - Global Objects - Iterator - flatMap - Syntax:
Example:
flatMap(callbackFn) | [
-1.0021274089813232,
0.35238516330718994,
-0.9995194673538208,
-0.261410653591156,
-0.4464481770992279,
-1.6657992601394653,
1.290705680847168,
0.6801056265830994,
-1.2123610973358154,
0.33606502413749695,
-0.34012657403945923,
0.5950936675071716,
-0.8931862115859985,
1.0341144800186157,
... |
javascript/reference/global_objects/iterator/flatmap/index.md | JavaScript - Global Objects - Iterator - flatMap - Syntax - Parameters:
- `callbackFn`: A function to execute for each element produced by the iterator. It should return an iterator or iterable that yields elements to be yielded by `flatMap()`. Note that unlike `Array.prototype.flatMap()`, you cannot return single non... | [
-1.0274971723556519,
-0.30162885785102844,
-1.0598686933517456,
-0.003164695343002677,
-0.09054196625947952,
-1.3660821914672852,
0.640842616558075,
0.397238165140152,
-0.9276019930839539,
0.6639018654823303,
-0.5814016461372375,
0.5726569890975952,
-1.1028615236282349,
1.8739436864852905,... |
javascript/reference/global_objects/iterator/flatmap/index.md | JavaScript - Global Objects - Iterator - flatMap - Syntax - Return value:
A new iterator helper object. The first time the iterator helper's `next()` method is called, it calls `callbackFn` on the first element produced by the underlying iterator, and the return value, which should be an iterator or iterable, is yield... | [
-0.6623662114143372,
0.2224518209695816,
-1.0341523885726929,
0.23767352104187012,
-0.2688176929950714,
-1.207999348640442,
0.5882686376571655,
0.7863218188285828,
-0.8314716219902039,
0.6718971729278564,
-0.1284596025943756,
0.3986402750015259,
-1.0052357912063599,
1.4140827655792236,
-... |
javascript/reference/global_objects/iterator/flatmap/index.md | JavaScript - Global Objects - Iterator - flatMap - Syntax - Exceptions:
- `TypeError`: Thrown if `callbackFn` returns a non-iterator/iterable value or a string primitive. | [
-0.8961828351020813,
0.24077093601226807,
-0.7468839287757874,
-0.16763125360012054,
-0.4428849220275879,
-1.6262264251708984,
0.9249655604362488,
0.4145199656486511,
-0.9960630536079407,
0.4919893145561218,
-0.32954150438308716,
-0.001377027714625001,
-0.9442655444145203,
0.52906119823455... |
javascript/reference/global_objects/iterator/flatmap/index.md | JavaScript - Global Objects - Iterator - flatMap - Description:
`flatMap` accepts two kinds of return values from `callbackFn`: an iterator or iterable. They are handled in the same way as `Iterator.from()`: if the return value is iterable, the `[Symbol.iterator]()` method is called and the return value is used; other... | [
-1.3023015260696411,
-0.19696593284606934,
-0.8607020378112793,
0.12995967268943787,
0.038205526769161224,
-1.3330100774765015,
0.7644530534744263,
0.8363926410675049,
-1.0282137393951416,
0.8107985854148865,
-0.11626604199409485,
0.5991320610046387,
-0.1193200945854187,
0.7949443459510803... |
javascript/reference/global_objects/iterator/flatmap/index.md | JavaScript - Global Objects - Iterator - flatMap - Examples - Merging maps:
The following example merges two `Map` objects into one:
Example:
const map1 = new Map([
["a", 1],
["b", 2],
["c", 3],
]);
const map2 = new Map([
["d", 4],
["e", 5],
["f", 6],
]);
const merged = new Map([map1, map2].values().fla... | [
-0.23400157690048218,
0.029167097061872482,
-1.2019902467727661,
0.20959021151065826,
0.15560515224933624,
-0.9877399802207947,
0.1661366969347,
0.6613523960113525,
-0.3652293086051941,
0.5948635339736938,
0.0009337191586382687,
0.11047378182411194,
0.29041117429733276,
0.18491482734680176... |
javascript/reference/global_objects/iterator/flatmap/index.md | JavaScript - Global Objects - Iterator - flatMap - Examples - Returning strings:
Strings are iterable, but `flatMap()` specifically rejects string primitives returned from `callbackFn`, this is because the behavior of iterating by code points is often not what you want.
Example:
[1, 2, 3]
.values()
.flatMap((x) ... | [
-1.267149806022644,
0.2611673176288605,
-0.6610525250434875,
-0.3645789921283722,
0.38962307572364807,
-2.0728418827056885,
1.0101256370544434,
0.10788493603467941,
-1.162789225578308,
0.7650630474090576,
-0.7591702938079834,
0.06349685043096542,
-0.7622237801551819,
0.14963912963867188,
... |
javascript/reference/global_objects/iterator/map/index.md | JavaScript - Global Objects - Iterator - map:
The `map()` method of `Iterator` instances returns a new iterator helper object that yields elements of the iterator, each transformed by a mapping function. | [
-0.07204267382621765,
-0.4162808656692505,
-1.083804726600647,
0.33634132146835327,
-0.043190307915210724,
-1.5138527154922485,
0.3671758770942688,
0.7414389848709106,
-0.802401602268219,
0.5303668975830078,
-0.524989664554596,
-0.09319757670164108,
-0.11397142708301544,
0.8382652401924133... |
javascript/reference/global_objects/iterator/map/index.md | JavaScript - Global Objects - Iterator - map - Syntax:
Example:
map(callbackFn) | [
-0.7265104651451111,
0.47928017377853394,
-0.8123711943626404,
-0.2663709223270416,
-0.6182038187980652,
-1.7144497632980347,
0.7381007671356201,
0.46896740794181824,
-1.0640848875045776,
0.5639786124229431,
-0.2386167049407959,
0.7626577615737915,
-0.5256769061088562,
0.9675564765930176,
... |
javascript/reference/global_objects/iterator/map/index.md | JavaScript - Global Objects - Iterator - map - Syntax - Parameters:
- `callbackFn`: A function to execute for each element produced by the iterator. Its return value is yielded by the iterator helper. The function is called with the following arguments:
- `element`: The current element being processed.
- `index`: ... | [
-0.7421486377716064,
-0.04204510524868965,
-0.9949856400489807,
0.1628199815750122,
-0.21734099090099335,
-1.6109167337417603,
0.16695363819599152,
0.043880049139261246,
-0.6733371019363403,
0.6469056010246277,
-0.782450795173645,
0.6049969792366028,
-1.058801293373108,
1.8514478206634521,... |
javascript/reference/global_objects/iterator/map/index.md | JavaScript - Global Objects - Iterator - map - Syntax - Return value:
A new iterator helper object. Each time the iterator helper's `next()` method is called, it gets the next element from the underlying iterator, applies `callbackFn`, and yields the return value. When the underlying iterator is completed, the iterato... | [
-0.6167239546775818,
0.003324494929984212,
-0.8302807807922363,
0.06576432287693024,
-0.40007728338241577,
-1.4585353136062622,
0.26884016394615173,
0.5389879941940308,
-0.5231162905693054,
0.6360501050949097,
-0.2535472512245178,
0.36247920989990234,
-0.5540874600410461,
1.321154832839965... |
javascript/reference/global_objects/iterator/map/index.md | JavaScript - Global Objects - Iterator - map - Description:
The main advantage of iterator helpers over array methods is that they are lazy, meaning that they only produce the next value when requested. This avoids unnecessary computation and also allows them to be used with infinite iterators. The `map()` method allo... | [
0.07441451400518417,
0.07443085312843323,
-1.1138437986373901,
0.6297613382339478,
0.17634780704975128,
-1.966288447380066,
-0.01041781809180975,
0.5974027514457703,
-0.4274374842643738,
0.8550663590431213,
-0.8202401399612427,
-0.25940054655075073,
-0.17004823684692383,
-0.134994983673095... |
javascript/reference/global_objects/iterator/map/index.md | JavaScript - Global Objects - Iterator - map - Examples - Using map():
The following example creates an iterator that yields terms in the Fibonacci sequence, transforms it into a new sequence with each term squared, and then reads the first few terms:
Example:
function* fibonacci() {
let current = 1;
let next = ... | [
-0.9697831869125366,
0.6159780025482178,
-0.7670491933822632,
0.5653055906295776,
0.37189149856567383,
-1.2665766477584839,
0.11514502763748169,
0.677172064781189,
-0.1724943369626999,
0.15661504864692688,
-0.2751491665840149,
0.5298868417739868,
-0.5966482758522034,
0.35657477378845215,
... |
javascript/reference/global_objects/iterator/map/index.md | JavaScript - Global Objects - Iterator - map - Examples - Using map() with a for...of loop:
`map()` is most convenient when you are not hand-rolling the iterator. Because iterators are also iterable, you can iterate the returned helper with a `for...of` loop:
Example:
for (const n of fibonacci().map((x) => x ** 2)) ... | [
-0.7083856463432312,
-0.1007128581404686,
-0.42639607191085815,
0.9487002491950989,
0.03606947883963585,
-1.771324872970581,
0.20179642736911774,
0.07271310687065125,
-0.5772184133529663,
0.9870883822441101,
0.462115615606308,
0.6614298224449158,
-0.14469145238399506,
0.4917147755622864,
... |
javascript/reference/global_objects/iterator/drop/index.md | JavaScript - Global Objects - Iterator - drop:
The `drop()` method of `Iterator` instances returns a new iterator helper object that skips the given number of elements at the start of this iterator. | [
-0.0020427070558071136,
-0.4156075119972229,
-1.0262075662612915,
0.255756676197052,
-0.061416249722242355,
-1.687248706817627,
0.9318682551383972,
0.44920313358306885,
-1.5095900297164917,
0.23432521522045135,
-0.9077363610267639,
-0.5537324547767639,
-0.7141565084457397,
0.85260909795761... |
javascript/reference/global_objects/iterator/drop/index.md | JavaScript - Global Objects - Iterator - drop - Syntax:
Example:
drop(limit) | [
-0.2014555186033249,
-0.013271874748170376,
-0.8230869770050049,
-0.3534037470817566,
-0.8541226983070374,
-1.8599779605865479,
-0.12661907076835632,
0.7057628035545349,
-0.6523139476776123,
-0.4612668454647064,
-0.9259684681892395,
0.08200985938310623,
-0.7482733726501465,
0.5448865890502... |
javascript/reference/global_objects/iterator/drop/index.md | JavaScript - Global Objects - Iterator - drop - Syntax - Parameters:
- `limit`: The number of elements to drop from the start of the iteration. | [
-0.012935647740960121,
-0.31210872530937195,
-0.931679904460907,
-0.5225528478622437,
-0.5596538186073303,
-1.4265882968902588,
-0.3275498151779175,
0.7774490118026733,
-0.6479443311691284,
-0.3292529582977295,
-1.4799742698669434,
-0.18681354820728302,
-0.9824205040931702,
0.7638520598411... |
javascript/reference/global_objects/iterator/drop/index.md | JavaScript - Global Objects - Iterator - drop - Syntax - Return value:
A new iterator helper object. The first time the returned iterator helper's `next()` method is called, the current iterator is immediately advanced by `limit` elements, and then the next element (the `limit+1`-th element) is yielded. The iterator h... | [
-0.36585626006126404,
0.004897546488791704,
-0.6016768217086792,
0.1742691993713379,
-0.12975522875785828,
-1.3319156169891357,
0.41513770818710327,
0.7005807757377625,
-0.5608415007591248,
0.5075583457946777,
-0.652133584022522,
0.00804869458079338,
-0.9513641595840454,
1.2316806316375732... |
javascript/reference/global_objects/iterator/drop/index.md | JavaScript - Global Objects - Iterator - drop - Syntax - Exceptions:
- `RangeError`: Thrown if `limit` becomes `NaN` or negative when converted to an integer. | [
-0.8499366044998169,
0.11649584770202637,
-0.041874662041664124,
0.2943190634250641,
-0.5118948221206665,
-1.9020055532455444,
-0.4778963029384613,
0.7828091382980347,
-1.198463797569275,
0.032577913254499435,
-0.9099520444869995,
-0.3331165015697479,
-0.8555691242218018,
-0.28775176405906... |
javascript/reference/global_objects/iterator/drop/index.md | JavaScript - Global Objects - Iterator - drop - Examples - Using drop():
The following example creates an iterator that yields terms in the Fibonacci sequence, starting from the 3rd term by dropping the first two terms:
Example:
function* fibonacci() {
let current = 1;
let next = 1;
while (true) {
yield cu... | [
-1.0964746475219727,
-0.07600932568311691,
-0.7139893174171448,
0.7112641930580139,
0.01083632092922926,
-1.1112903356552124,
0.28365346789360046,
0.8962860107421875,
-0.8213266134262085,
0.010499167256057262,
-0.5516442656517029,
0.562599241733551,
-0.8115353584289551,
0.4459999203681946,... |
javascript/reference/global_objects/iterator/drop/index.md | JavaScript - Global Objects - Iterator - drop - Examples - Using drop() with a for...of loop:
`drop()` is most convenient when you are not hand-rolling the iterator. Because iterators are also iterable, you can iterate the returned helper with a `for...of` loop:
Example:
for (const n of fibonacci().drop(2)) {
cons... | [
-0.5811866521835327,
-0.07233250886201859,
-0.31026169657707214,
1.13241708278656,
-0.2613246738910675,
-1.5605944395065308,
0.2212662547826767,
-0.0818202868103981,
-0.8996562957763672,
0.615807294845581,
0.030070515349507332,
0.47842058539390564,
-0.39594176411628723,
0.4849059581756592,... |
javascript/reference/global_objects/iterator/drop/index.md | JavaScript - Global Objects - Iterator - drop - Examples - Combining drop() with take():
You can combine `drop()` with `Iterator.prototype.take()` to get a slice of an iterator:
Example:
for (const n of fibonacci().drop(2).take(5)) {
// Drops the first two elements, then takes the next five
console.log(n);
}
// ... | [
-0.4994993209838867,
-0.48335132002830505,
-0.648440420627594,
0.7321470975875854,
0.0862121507525444,
-0.8834571838378906,
0.4876577854156494,
0.7055703401565552,
-1.247812032699585,
0.833319365978241,
-0.24094459414482117,
0.4279614984989166,
-0.6683686971664429,
0.5408865809440613,
-0... |
javascript/reference/global_objects/iterator/drop/index.md | JavaScript - Global Objects - Iterator - drop - Examples - Lower and upper bounds of drop count:
When the `limit` is negative or `NaN`, a `RangeError` is thrown:
Example:
fibonacci().drop(-1); // RangeError: -1 must be positive
fibonacci().drop(undefined); // RangeError: undefined must be positive
When the `limit` ... | [
-1.0502444505691528,
-0.12058315426111221,
-0.6703672409057617,
0.40356796979904175,
0.11517700552940369,
-1.818580150604248,
0.14432308077812195,
0.23453398048877716,
-1.3304792642593384,
0.19099533557891846,
-0.8158740401268005,
0.20929056406021118,
-0.5812878608703613,
0.533660590648651... |
javascript/reference/global_objects/iterator/iterator/index.md | JavaScript - Global Objects - Iterator:
The `Iterator()` constructor is intended to be used as the superclass of other classes that create iterators. It throws an error when constructed by itself. | [
-0.500365674495697,
0.11157026141881943,
-0.8571637868881226,
0.4577181935310364,
0.34238526225090027,
-1.6414767503738403,
-0.5991839170455933,
0.6393375992774963,
-1.0738896131515503,
0.15445101261138916,
-0.8198343515396118,
-0.1265399158000946,
-0.594608724117279,
-0.28818848729133606,... |
javascript/reference/global_objects/iterator/iterator/index.md | JavaScript - Global Objects - Iterator - Syntax:
Example:
new Iterator()
Note: `Iterator()` can only be constructed with `new`. Attempting to call it without `new` throws a `TypeError`. In addition, `Iterator()` cannot actually be constructed itself — it's usually implicitly constructed through `super()` calls insid... | [
-0.8500434756278992,
0.18704812228679657,
-0.18206270039081573,
0.46031492948532104,
0.06268209218978882,
-1.3337666988372803,
-0.8291578888893127,
1.2981562614440918,
-0.7965015769004822,
0.1124190166592598,
-0.32246315479278564,
0.03600695729255676,
-0.10665227472782135,
-0.0638878643512... |
javascript/reference/global_objects/iterator/iterator/index.md | JavaScript - Global Objects - Iterator - Syntax - Parameters:
None. | [
-0.39032626152038574,
0.34735310077667236,
-0.8853752613067627,
-0.42098715901374817,
-0.3867883086204529,
-1.2915332317352295,
0.7027983069419861,
1.3381543159484863,
-0.6670215129852295,
-0.4253219962120056,
-0.7974323034286499,
-0.4939362108707428,
-0.21035264432430267,
0.50228989124298... |
javascript/reference/global_objects/iterator/iterator/index.md | JavaScript - Global Objects - Iterator - Syntax - Return value:
A new `Iterator` object. | [
-0.17728780210018158,
-0.2780514657497406,
-0.8377003073692322,
-0.3453402519226074,
-0.4651169776916504,
-1.4368305206298828,
-0.28125470876693726,
1.7707531452178955,
-0.18541261553764343,
0.012123645283281803,
-0.12254898995161057,
0.1446898877620697,
-0.3803279399871826,
1.007284879684... |
javascript/reference/global_objects/iterator/iterator/index.md | JavaScript - Global Objects - Iterator - Syntax - Exceptions:
- `TypeError`: When `new.target` is the `Iterator` function itself, i.e., when the `Iterator` constructor itself is constructed. | [
-0.7518637776374817,
0.179799884557724,
-0.42566049098968506,
0.13528640568256378,
-0.3395247161388397,
-1.3070787191390991,
-0.7163859009742737,
1.1841707229614258,
-0.8987717628479004,
0.2781614363193512,
-0.24272362887859344,
-0.83893883228302,
-0.3731235861778259,
-0.10125171393156052,... |
javascript/reference/global_objects/iterator/iterator/index.md | JavaScript - Global Objects - Iterator - Description:
`Iterator` represents an abstract class — a class that provides common utilities for its subclasses, but is not intended to be instantiated itself. It is the superclass of all other iterator classes, and is used to create subclasses that implement specific iteratio... | [
-0.8937790989875793,
-0.48575299978256226,
-0.9303863048553467,
0.2802620232105255,
0.274601012468338,
-1.380163311958313,
-0.18545910716056824,
0.7325809597969055,
-0.3672594726085663,
0.22191686928272247,
-0.5264284610748291,
-0.04042074829339981,
-0.4286292791366577,
0.4124159812927246,... |
javascript/reference/global_objects/iterator/iterator/index.md | JavaScript - Global Objects - Iterator - Examples - Subclassing Iterator:
The following example defines a custom data structure, `Range`, which allows iteration. To make an object iterable, we can provide a `[Symbol.iterator]()` method in the form of a generator function:
Example:
class Range {
#start;
#end;
#... | [
-0.4796779453754425,
0.1845417022705078,
-0.27151191234588623,
0.8245556354522705,
1.4298080205917358,
-1.143112063407898,
0.05127429962158203,
0.9498070478439331,
-0.7996215224266052,
0.26371124386787415,
0.07407563924789429,
0.48252472281455994,
-1.049968957901001,
0.5768550038337708,
... |
javascript/reference/global_objects/iterator/zip/index.md | JavaScript - Global Objects - Iterator - zip:
The `Iterator.zip()` static method creates a new `Iterator` object that aggregates elements from multiple iterable objects by yielding arrays containing elements at the same position. It essentially "zips" the input iterables together, allowing simultaneous iteration over ... | [
-0.9280318021774292,
-0.7148069739341736,
-0.479020357131958,
0.9216553568840027,
0.437854528427124,
-0.8479276299476624,
0.34958672523498535,
0.18970096111297607,
-1.3387057781219482,
0.7103159427642822,
-0.7051279544830322,
0.061157554388046265,
-0.8651684522628784,
0.5105460286140442,
... |
javascript/reference/global_objects/iterator/zip/index.md | JavaScript - Global Objects - Iterator - zip - Syntax:
Example:
Iterator.zip(iterables)
Iterator.zip(iterables, options) | [
-0.6372877955436707,
0.016221115365624428,
-0.060184821486473083,
0.40624427795410156,
-0.4779374301433563,
-1.0938360691070557,
0.3583737909793854,
0.39378589391708374,
-0.7696396112442017,
-0.2556893527507782,
-0.24725770950317383,
-0.13627076148986816,
-0.511813759803772,
0.161916285753... |
javascript/reference/global_objects/iterator/zip/index.md | JavaScript - Global Objects - Iterator - zip - Syntax - Parameters:
- `iterables`: An iterable of iterables whose elements are aggregated. It must be iterable and cannot be an iterator. It should be finite, although its elements can be infinite iterables. Each element must implement either the iterable protocol or, fa... | [
-0.08080551028251648,
0.19663217663764954,
-0.09087333083152771,
0.5197920799255371,
1.0703130960464478,
-0.15155595541000366,
0.07584238797426224,
-0.12194530665874481,
-0.9467852711677551,
0.32994693517684937,
-0.5983719229698181,
-0.42059126496315,
-0.49879002571105957,
0.57162410020828... |
javascript/reference/global_objects/iterator/zip/index.md | JavaScript - Global Objects - Iterator - zip - Syntax - Return value:
A new `Iterator` object. Each of its elements is an array with length equal to the number of input iterables, containing the elements from each input iterable at the corresponding position. If the `iterables` object is empty, the resulting iterator ... | [
-0.5531918406486511,
-0.504636824131012,
-0.3664124310016632,
0.6784971356391907,
-0.1648191213607788,
-0.7727149128913879,
0.7552924156188965,
0.6999169588088989,
-0.9486115574836731,
0.3450234532356262,
-0.3741849660873413,
0.4510655403137207,
-0.4986724257469177,
0.9565736055374146,
-... |
javascript/reference/global_objects/iterator/zip/index.md | JavaScript - Global Objects - Iterator - zip - Description:
The `Iterator.zip()` function behaves like a transpose operation, yielding arrays containing the elements at matching positions in each of the inputs. If we represent iterables as arrays, the input may looks like this:
Example:
[
[a1, a2, a3, a4], // Iter... | [
-0.7543655037879944,
-0.049836255609989166,
-0.23755082488059998,
0.6051954627037048,
0.9411501288414001,
0.1299060583114624,
0.6443449258804321,
0.5882878303527832,
-0.6545462608337402,
-0.06142755597829819,
-0.22949904203414917,
-0.02452496811747551,
-0.1866096705198288,
0.72784888744354... |
javascript/reference/global_objects/iterator/zip/index.md | JavaScript - Global Objects - Iterator - zip - Examples - Iteration over a map with indices:
Using `Iterator.zip()`, you can iterate over any iterable object (strings aren't supported by default) while also having access to an incrementing counter:
Example:
const ages = new Map([
["Caroline", 30],
["Danielle", 2... | [
-0.4252696633338928,
-0.1553543359041214,
-0.4482135772705078,
-0.04943516477942467,
0.7660189867019653,
-1.178354024887085,
0.788200855255127,
0.7987620830535889,
-0.8767125010490417,
0.656141996383667,
-0.5865518450737,
0.3932441771030426,
-0.9885525703430176,
0.1287975013256073,
-0.92... |
javascript/reference/global_objects/iterator/zip/index.md | JavaScript - Global Objects - Iterator - zip - Examples - Creating a Map from lists of keys and values:
Suppose you have two arrays: one with keys and another with values. You can use `Iterator.zip()` to combine them into a `Map`:
Example:
const days = ["Mon", "Tue", "Wed", "Thu", "Fri"];
const temperatures = [22, 2... | [
-0.6883552074432373,
-0.20391768217086792,
-0.8668603301048279,
0.7508324384689331,
-0.10123908519744873,
-1.7985295057296753,
-0.2549154758453369,
0.09527686983346939,
-0.8868999481201172,
0.219535693526268,
0.05237608775496483,
0.39297929406166077,
-0.2307526171207428,
0.0087684532627463... |
javascript/reference/global_objects/iterator/zip/index.md | JavaScript - Global Objects - Iterator - zip - Examples - Joint iteration over multiple data sources:
Suppose you have data coming from multiple sources, such as multiple microservices or databases. You know that each source provides related data in the same order, and you want to process them together. You can use `I... | [
-1.3377639055252075,
-0.5934261083602905,
-1.2215728759765625,
0.16713958978652954,
0.4131762385368347,
-0.7270954251289368,
-0.3049842417240143,
0.06680712103843689,
-0.7199769020080566,
0.7642173171043396,
-0.14502596855163574,
0.4840563237667084,
-1.4666155576705933,
-0.1976203024387359... |
javascript/reference/global_objects/iterator/zip/index.md | JavaScript - Global Objects - Iterator - zip - Examples - Providing padding for uneven iterables:
When zipping iterables of different lengths with `mode` set to `"longest"`, you can provide a `padding` iterable to specify the values used to fill in missing entries:
Example:
const letters = ["a", "b", "c", "d", "e"];... | [
-1.0316425561904907,
-0.769634485244751,
-0.7874788045883179,
0.32705774903297424,
0.0237667728215456,
-0.5554106831550598,
0.9658118486404419,
0.6017026901245117,
-1.2527488470077515,
0.505472719669342,
-0.9157562851905823,
0.05386780574917793,
-0.3019018769264221,
0.26159265637397766,
... |
javascript/reference/global_objects/iterator/zip/index.md | JavaScript - Global Objects - Iterator - zip - Examples - Zipping strings:
Strings are not accepted as input iterables to `Iterator.zip()`, because it is now considered a mistake to make strings implicitly iterable. To zip strings, convert them to iterators explicitly using `Iterator.from()`:
Example:
const str1 = "... | [
-1.3803141117095947,
0.20195189118385315,
0.07891516387462616,
0.061096955090761185,
0.6422008872032166,
-1.385677695274353,
-0.08072522282600403,
-0.4993842840194702,
-1.0875964164733887,
0.4584229290485382,
-0.3675145208835602,
-0.05975258722901344,
-0.5289795398712158,
-0.18728613853454... |
javascript/reference/global_objects/iterator/zipkeyed/index.md | JavaScript - Global Objects - Iterator - zipKeyed:
The `Iterator.zipKeyed()` static method creates a new `Iterator` object that aggregates elements from multiple iterable objects by yielding objects containing elements at the same position, with keys specified by the input. It essentially "zips" the input iterables to... | [
-0.6150988936424255,
-0.6341937780380249,
-0.6175820231437683,
0.7352167963981628,
0.2612803876399994,
-1.0622111558914185,
0.17119093239307404,
0.3050425350666046,
-1.3767914772033691,
0.6230747103691101,
-0.6565588116645813,
-0.09883399307727814,
-0.970937967300415,
0.5994200706481934,
... |
javascript/reference/global_objects/iterator/zipkeyed/index.md | JavaScript - Global Objects - Iterator - zipKeyed - Syntax:
Example:
Iterator.zipKeyed(iterables)
Iterator.zipKeyed(iterables, options) | [
-0.388412743806839,
0.2831210792064667,
-0.19414961338043213,
0.0622057244181633,
-0.5837181210517883,
-1.3810093402862549,
0.43251872062683105,
0.6979964375495911,
-1.1339426040649414,
-0.11116524785757065,
-0.1381331980228424,
-0.05688580870628357,
-0.7497708201408386,
0.1967148929834365... |
javascript/reference/global_objects/iterator/zipkeyed/index.md | JavaScript - Global Objects - Iterator - zipKeyed - Syntax - Parameters:
- `iterables`: An object. Each property's key is used as the key in the resulting objects. The property's value must implement either the iterable protocol or, failing that, the iterator protocol. These iterables may be infinite. Strings are reje... | [
-0.5522446036338806,
0.08176734298467636,
-0.5918159484863281,
0.48797208070755005,
0.029073039069771767,
-1.1289942264556885,
0.5265753269195557,
0.18156535923480988,
-1.1682921648025513,
0.42025306820869446,
-0.9291280508041382,
0.015117197297513485,
-0.4137464761734009,
0.74177545309066... |
javascript/reference/global_objects/iterator/zipkeyed/index.md | JavaScript - Global Objects - Iterator - zipKeyed - Syntax - Return value:
A new `Iterator` object. Each of its elements is an object with the same keys as the `iterables` argument, containing the elements from each input iterable at the corresponding position. | [
-0.21195107698440552,
-0.3693268597126007,
-0.48463666439056396,
0.3981626629829407,
-0.33387133479118347,
-0.9535958170890808,
0.6403592824935913,
0.6453691720962524,
-0.8665664792060852,
0.2802598774433136,
-0.23675601184368134,
0.41302990913391113,
-0.7371039390563965,
1.045212149620056... |
javascript/reference/global_objects/iterator/zipkeyed/index.md | JavaScript - Global Objects - Iterator - zipKeyed - Description:
The `Iterator.zipKeyed()` function behaves like `Iterator.zip()`; the only difference is that you can specify the keys used in the resulting objects, while `Iterator.zip()` always uses numeric indices (by yielding arrays).
If we represent iterables as a... | [
-0.6369287967681885,
0.03516106680035591,
-0.28727367520332336,
0.5521508455276489,
0.9452492594718933,
-0.7729142904281616,
0.3128499388694763,
0.23192644119262695,
-1.0189697742462158,
0.28009384870529175,
-0.14736412465572357,
0.006430276669561863,
-0.6210569739341736,
0.889170825481414... |
javascript/reference/global_objects/iterator/zipkeyed/index.md | JavaScript - Global Objects - Iterator - zipKeyed - Examples - Transposing tabular data:
There are two common ways to represent tabular data: as an object where each property is a column, or as an array of objects where each object is a row. This example shows how you can iterate the column-based representation by row... | [
-0.8465617299079895,
-0.2660660743713379,
-0.7483596205711365,
0.6607303619384766,
1.1179163455963135,
-1.0573949813842773,
0.8882808089256287,
0.7736992835998535,
-0.35407453775405884,
0.9492717981338501,
-0.18273162841796875,
0.792473554611206,
-0.9442501664161682,
0.5677223801612854,
... |
javascript/reference/global_objects/iterator/reduce/index.md | JavaScript - Global Objects - Iterator - reduce:
The `reduce()` method of `Iterator` instances is similar to `Array.prototype.reduce`: it executes a user-supplied "reducer" callback function on each element produced by the iterator, passing in the return value from the calculation on the preceding element. The final r... | [
-0.9222726821899414,
-0.2612338066101074,
-1.2293816804885864,
0.4784424304962158,
-0.2808710038661957,
-0.8414130210876465,
0.7085427045822144,
0.5538102984428406,
-0.85125333070755,
0.8143435120582581,
-1.1903983354568481,
-0.02216711826622486,
0.053523484617471695,
1.028493046760559,
... |
javascript/reference/global_objects/iterator/reduce/index.md | JavaScript - Global Objects - Iterator - reduce - Syntax:
Example:
reduce(callbackFn)
reduce(callbackFn, initialValue) | [
-0.616730272769928,
0.7580350637435913,
-0.1453772932291031,
0.008988072164356709,
-0.9277277588844299,
-1.6264276504516602,
1.0483263731002808,
0.7214418649673462,
-0.7024158239364624,
0.420655220746994,
-1.0481798648834229,
-0.37570369243621826,
-1.0994354486465454,
1.1353223323822021,
... |
javascript/reference/global_objects/iterator/reduce/index.md | JavaScript - Global Objects - Iterator - reduce - Syntax - Parameters:
- `callbackFn`: A function to execute for each element produced by the iterator. Its return value becomes the value of the `accumulator` parameter on the next invocation of `callbackFn`. For the last invocation, the return value becomes the return ... | [
-0.470355749130249,
0.31506624817848206,
-1.1195502281188965,
-0.16290055215358734,
-0.12797848880290985,
-1.4203909635543823,
0.711161732673645,
0.1765177845954895,
-0.5935011506080627,
0.7984766364097595,
-0.7348894476890564,
0.19051232933998108,
-1.2439115047454834,
1.3555777072906494,
... |
javascript/reference/global_objects/iterator/reduce/index.md | JavaScript - Global Objects - Iterator - reduce - Syntax - Return value:
The value that results from running the "reducer" callback function to completion over the entire iterator. | [
-0.7110460996627808,
0.2562620937824249,
-0.9988083839416504,
0.13860127329826355,
-0.5778235793113708,
-1.0791292190551758,
0.34653013944625854,
0.9981024265289307,
-0.2940373420715332,
0.34449562430381775,
-1.014046311378479,
0.3857318162918091,
-0.44365718960762024,
1.6958646774291992,
... |
javascript/reference/global_objects/iterator/reduce/index.md | JavaScript - Global Objects - Iterator - reduce - Syntax - Exceptions:
- `TypeError`: Thrown if the iterator contains no elements and `initialValue` is not provided. | [
-0.5167077779769897,
0.16852161288261414,
-0.33303719758987427,
0.11516916751861572,
-0.4051424264907837,
-1.19271981716156,
0.7536722421646118,
1.0885682106018066,
-1.2772382497787476,
0.13271751999855042,
-0.2830868065357208,
-0.7621875405311584,
-0.7845060229301453,
0.07634168863296509,... |
javascript/reference/global_objects/iterator/reduce/index.md | JavaScript - Global Objects - Iterator - reduce - Description:
See `Array.prototype.reduce()` for details about how `reduce()` works. Unlike most other iterator helper methods, it does not work well with infinite iterators, because it is not lazy. | [
-1.2011581659317017,
0.27811452746391296,
-0.5611770749092102,
0.08229470252990723,
-0.6077736616134644,
-1.1765753030776978,
0.46182605624198914,
0.40461620688438416,
-0.6297648549079895,
0.6222254037857056,
-1.24129319190979,
-0.2021096646785736,
-0.1285609006881714,
0.2956964671611786,
... |
javascript/reference/global_objects/iterator/reduce/index.md | JavaScript - Global Objects - Iterator - reduce - Examples - Using reduce():
The following example creates an iterator that yields terms in the Fibonacci sequence, and then sums the first ten terms:
Example:
function* fibonacci() {
let current = 1;
let next = 1;
while (true) {
yield current;
[current, ... | [
-1.3399040699005127,
0.38091251254081726,
-0.917492687702179,
0.7667940258979797,
-0.01870165951550007,
-1.221924066543579,
0.7944031357765198,
1.0749536752700806,
-0.4752151668071747,
0.277865469455719,
-1.0582059621810913,
0.4579370617866516,
-0.8062348961830139,
0.603380024433136,
0.5... |
javascript/reference/global_objects/iterator/toarray/index.md | JavaScript - Global Objects - Iterator - toArray:
The `toArray()` method of `Iterator` instances creates a new `Array` instance populated with the elements yielded from the iterator. | [
0.30530238151550293,
0.08809413760900497,
-0.8604747653007507,
0.7094049453735352,
0.10485795140266418,
-1.5129075050354004,
-0.37288355827331543,
1.293367862701416,
-0.6599766612052917,
0.309951514005661,
-0.5067964792251587,
-0.2235814481973648,
-1.1487401723861694,
0.791752278804779,
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.