file stringlengths 16 94 | text stringlengths 32 24.4k | vector list |
|---|---|---|
javascript/reference/global_objects/iterator/toarray/index.md | JavaScript - Global Objects - Iterator - toArray - Syntax:
Example:
toArray() | [
-0.042317945510149,
0.6537641882896423,
-0.5041220188140869,
0.06651005893945694,
-0.5906015634536743,
-1.5697345733642578,
-0.35654786229133606,
1.3653122186660767,
-0.4925156235694885,
-0.28447237610816956,
0.04525921493768692,
0.11421462148427963,
-0.687111496925354,
0.07605285197496414... |
javascript/reference/global_objects/iterator/toarray/index.md | JavaScript - Global Objects - Iterator - toArray - Syntax - Parameters:
None. | [
-0.17523320019245148,
0.5057726502418518,
-0.6471914649009705,
-0.3647277057170868,
-0.42772990465164185,
-1.3596019744873047,
0.2210955023765564,
1.2910715341567993,
-0.725858747959137,
-0.3549276888370514,
-0.5094919800758362,
-0.4256271719932556,
-0.39566299319267273,
0.2380429804325103... |
javascript/reference/global_objects/iterator/toarray/index.md | JavaScript - Global Objects - Iterator - toArray - Syntax - Return value:
A new `Array` instance containing the elements from the iterator in the order they were produced. | [
0.5061573386192322,
-0.22301965951919556,
-0.4968542754650116,
0.34327030181884766,
-0.44388189911842346,
-0.9625844359397888,
-0.5553069710731506,
1.425247073173523,
-0.41812410950660706,
0.4061735272407532,
-0.17808248102664948,
0.3910598158836365,
-0.5837037563323975,
1.2994270324707031... |
javascript/reference/global_objects/iterator/toarray/index.md | JavaScript - Global Objects - Iterator - toArray - Examples - Using toArray():
`iterator.toArray()` is equivalent to `Array.from(iterator)` and `[...iterator]`, except that it's easier to chain when multiple iterator helper methods are involved. The following example creates an iterator that yields terms in the Fibona... | [
-0.35162153840065,
0.19546380639076233,
-1.0660121440887451,
0.7099848985671997,
0.3054542541503906,
-1.465700387954712,
-0.2752455770969391,
0.9831193089485168,
-0.5328453183174133,
0.5772574543952942,
-0.363906592130661,
0.4171384572982788,
-0.45089074969291687,
0.5604456067085266,
-0.... |
javascript/reference/global_objects/iterator/symbol.dispose/index.md | JavaScript - Global Objects - Iterator - Symbol.dispose:
The `[Symbol.dispose]()` method of `Iterator` instances implements the disposable protocol and allows it to be disposed when used with `using`. It calls the `return()` method of `this`, if it exists. | [
-0.028577705845236778,
-0.19423983991146088,
-0.4305950999259949,
0.6910054683685303,
-0.3165684640407562,
-1.7132450342178345,
0.6229405999183655,
1.184159517288208,
-0.536424458026886,
0.5785769820213318,
-0.5762690901756287,
0.6620836853981018,
-0.042099643498659134,
0.7241395115852356,... |
javascript/reference/global_objects/iterator/symbol.dispose/index.md | JavaScript - Global Objects - Iterator - Symbol.dispose - Syntax:
Example:
iterator[Symbol.dispose]() | [
0.1440054178237915,
-0.03288809582591057,
-0.535548210144043,
-0.1713227778673172,
-0.8548615574836731,
-1.5737015008926392,
0.2251543402671814,
1.4756003618240356,
0.11385478079319,
-0.27639642357826233,
0.049148354679346085,
0.3799336850643158,
-0.40923309326171875,
0.35253971815109253,
... |
javascript/reference/global_objects/iterator/symbol.dispose/index.md | JavaScript - Global Objects - Iterator - Symbol.dispose - Syntax - Parameters:
None. | [
0.006606424693018198,
0.022464046254754066,
-0.9128557443618774,
-0.5557233691215515,
-0.8205993175506592,
-1.273577094078064,
0.7534482479095459,
1.3126927614212036,
-0.3154202103614807,
-0.4406246840953827,
-0.6732960939407349,
-0.09523367881774902,
-0.11832835525274277,
0.60345435142517... |
javascript/reference/global_objects/iterator/symbol.dispose/index.md | JavaScript - Global Objects - Iterator - Symbol.dispose - Syntax - Return value:
None (`undefined`). | [
-0.3214872479438782,
0.1064915582537651,
-0.6957374811172485,
-0.6755328178405762,
-0.8898648619651794,
-1.161996603012085,
0.6999770402908325,
1.1983673572540283,
-0.6601192951202393,
0.14096218347549438,
-0.02992178313434124,
0.36985069513320923,
-0.12534527480602264,
0.5736500024795532,... |
javascript/reference/global_objects/iterator/symbol.dispose/index.md | JavaScript - Global Objects - Iterator - Symbol.dispose - Examples - Declaring an iterator with `using`:
The `Symbol.dispose` method is intended to be automatically called in a `using` declaration. This is useful if you have an iterator that you manually iterate over by calling its `next()` method; if you iterate it w... | [
-0.23350147902965546,
-0.35375040769577026,
-0.9714763164520264,
0.42530134320259094,
-0.1621745526790619,
-1.5338753461837769,
0.06396237015724182,
1.1733863353729248,
-0.4128912389278412,
0.6219715476036072,
-0.07223866879940033,
0.5666427612304688,
-0.4139668941497803,
0.524239778518676... |
javascript/reference/global_objects/iterator/concat/index.md | JavaScript - Global Objects - Iterator - concat:
The `Iterator.concat()` static method creates a new `Iterator` object from a list of iterable objects. The new iterator yields the values from each of the input iterables in sequence. | [
-0.8034048676490784,
-0.4028455317020416,
-1.074446439743042,
0.42083293199539185,
0.2565027177333832,
-0.8784022331237793,
-0.6020427346229553,
0.6223772764205933,
-0.42612573504447937,
0.2127787470817566,
-0.7581086158752441,
0.29722872376441956,
-0.543540894985199,
0.23989057540893555,
... |
javascript/reference/global_objects/iterator/concat/index.md | JavaScript - Global Objects - Iterator - concat - Syntax:
Example:
Iterator.concat(it)
Iterator.concat(it1, it2)
Iterator.concat(it1, it2, /* …, */ itN) | [
-0.3838483989238739,
0.784574568271637,
-0.33818143606185913,
-0.005202945787459612,
-0.6126135587692261,
-1.1127634048461914,
-0.7728453278541565,
0.6857785582542419,
-0.9164583683013916,
-0.1967841237783432,
-0.24788543581962585,
0.24855008721351624,
-0.9439721703529358,
-0.1299323439598... |
javascript/reference/global_objects/iterator/concat/index.md | JavaScript - Global Objects - Iterator - concat - Syntax - Parameters:
- `it1`, `it2`, …, `itN`: An object that implements the iterable protocol. Iterators which are not also iterable cannot be passed directly to this method; they must first be wrapped using `Iterator.from()`. | [
-0.27901333570480347,
0.4878685176372528,
-0.3617677390575409,
0.34085753560066223,
-0.09551659226417542,
-1.2275346517562866,
-0.8773799538612366,
0.10042263567447662,
-0.9136365652084351,
0.20717667043209076,
-1.1344715356826782,
0.33246877789497375,
-0.7509082555770874,
0.15275619924068... |
javascript/reference/global_objects/iterator/concat/index.md | JavaScript - Global Objects - Iterator - concat - Syntax - Return value:
A new `Iterator` object that yields the values from each of the input iterables in sequence. | [
-0.3568965196609497,
-0.12563060224056244,
-1.0541538000106812,
0.05681362748146057,
-0.5566486120223999,
-0.5579699277877808,
-0.8046061396598816,
0.9455650448799133,
-0.26616746187210083,
-0.09601808339357376,
-0.4901869595050812,
0.6936827301979065,
-0.48224925994873047,
1.2205871343612... |
javascript/reference/global_objects/iterator/concat/index.md | JavaScript - Global Objects - Iterator - concat - Description:
The `Iterator.concat()` method is conceptually similar to `Array`'s `concat()` method, but it operates on any kind of iterable, and returns an iterator instead of an array. This means that the iterables can be lazily iterated, avoiding unnecessary allocati... | [
-0.6135711669921875,
0.3282545506954193,
-0.08436338603496552,
0.6509615778923035,
0.47958484292030334,
-0.47999176383018494,
0.43852025270462036,
0.8651982545852661,
-0.11676120012998581,
0.26171034574508667,
-0.6212230324745178,
0.007618866860866547,
-0.22806356847286224,
0.2887017428874... |
javascript/reference/global_objects/iterator/concat/index.md | JavaScript - Global Objects - Iterator - concat - Examples - Combining maps:
In this example, we create a new `Map` that's the union of three other maps. The `Map()` constructor accepts an iterable of key-value pairs, while the Map iterator yields key-value pairs from the map, so just using `Iterator.concat()` on the ... | [
-0.11506424844264984,
-0.008290397934615612,
-1.22108793258667,
0.15059901773929596,
-0.007978982292115688,
-0.8349908590316772,
-0.3109840452671051,
0.3940337300300598,
-0.36657649278640747,
0.3528169095516205,
-0.30616873502731323,
0.4674515426158905,
-0.0018861565040424466,
0.4416853189... |
javascript/reference/global_objects/iterator/concat/index.md | JavaScript - Global Objects - Iterator - concat - Examples - Concatenating infinite iterables:
When any of the input iterables is infinite, the resulting iterator will also be infinite. This isn't immediately a problem because iterators can be consumed lazily and closed at any time, but it does mean that iterables aft... | [
-0.17491185665130615,
0.8628433346748352,
-0.7087004780769348,
-0.012902867048978806,
-0.4079788029193878,
-0.8129968047142029,
-0.4837128818035126,
0.5940117239952087,
-0.7478449940681458,
0.11424161493778229,
-0.0706552192568779,
0.09543302655220032,
-0.5719600915908813,
-0.1912026852369... |
javascript/reference/global_objects/iterator/concat/index.md | JavaScript - Global Objects - Iterator - concat - Examples - Concatenating iterables of different types:
You can concatenate iterables of different types.
Example:
const array = [1, 2, 3];
const set = new Set([4, 5, 6]);
function* gen() {
yield 7;
yield 8;
yield 9;
}
const it = Iterator.concat(array, set, gen... | [
0.18194621801376343,
0.032635338604450226,
-1.3028583526611328,
0.3584388196468353,
-0.17996348440647125,
-0.8817188143730164,
-0.6698509454727173,
1.3369940519332886,
-0.7070009112358093,
0.07377070188522339,
-0.26896268129348755,
0.3721840977668762,
-0.8419774770736694,
-0.02088432572782... |
javascript/reference/global_objects/iterator/concat/index.md | JavaScript - Global Objects - Iterator - concat - Examples - Concatenating non-iterable objects:
Non-iterable objects throw a `TypeError` when passed to `Iterator.concat()` because they don't have the `[Symbol.iterator]()` method.
Example:
const nonIterable = {
next() {
return { done: true };
},
};
const it... | [
-0.31756463646888733,
-0.10672082751989365,
-1.0556361675262451,
0.6460875272750854,
0.4749533236026764,
-0.5365636348724365,
-0.666432797908783,
1.133545160293579,
-0.7465606927871704,
0.5246738791465759,
0.029736477881669998,
0.3182510733604431,
-0.34969812631607056,
0.2165190875530243,
... |
javascript/reference/global_objects/iterator/foreach/index.md | JavaScript - Global Objects - Iterator - forEach:
The `forEach()` method of `Iterator` instances is similar to `Array.prototype.forEach()`: it executes a provided function once for each element produced by the iterator. | [
0.2825358510017395,
-0.7011861205101013,
-0.7233162522315979,
0.20616158843040466,
-0.0742146223783493,
-1.4603804349899292,
0.787446141242981,
1.0484614372253418,
-1.4387401342391968,
0.5158836841583252,
-0.6187266707420349,
-0.15531542897224426,
-0.20401638746261597,
0.6777997612953186,
... |
javascript/reference/global_objects/iterator/foreach/index.md | JavaScript - Global Objects - Iterator - forEach - Syntax:
Example:
forEach(callbackFn) | [
-0.5062392354011536,
0.2111692726612091,
-0.4763415455818176,
-0.7516753673553467,
-0.6059618592262268,
-2.0350427627563477,
0.7195323705673218,
0.6044631004333496,
-1.1653990745544434,
0.20247210562229156,
-0.6461502909660339,
0.706028938293457,
-0.8773221969604492,
0.952613353729248,
0... |
javascript/reference/global_objects/iterator/foreach/index.md | JavaScript - Global Objects - Iterator - forEach - Syntax - Parameters:
- `callbackFn`: A function to execute for each element produced by the iterator. Its return value is discarded. The function is called with the following arguments:
- `element`: The current element being processed.
- `index`: The index of the ... | [
-0.5335836410522461,
-0.14992672204971313,
-0.858226478099823,
-0.08050155639648438,
-0.03217189386487007,
-1.6907227039337158,
0.28107813000679016,
0.17366822063922882,
-0.8438869118690491,
0.5544782280921936,
-1.0777466297149658,
0.5501108169555664,
-1.3188109397888184,
1.883124709129333... |
javascript/reference/global_objects/iterator/foreach/index.md | JavaScript - Global Objects - Iterator - forEach - Syntax - Return value:
`undefined`. | [
-0.601673424243927,
0.41157448291778564,
-0.40485239028930664,
-1.222511649131775,
-0.42242908477783203,
-1.343072533607483,
1.0572866201400757,
1.1355513334274292,
-1.1423486471176147,
0.12811407446861267,
-0.04994592070579529,
0.4293951392173767,
-0.145511656999588,
0.2158299684524536,
... |
javascript/reference/global_objects/iterator/foreach/index.md | JavaScript - Global Objects - Iterator - forEach - Description:
`forEach()` iterates the iterator and invokes the `callbackFn` function once for each element. Unlike most other iterator helper methods, it does not work with infinite iterators, because it is not lazy. | [
-0.7753202319145203,
-0.31663981080055237,
-0.6443202495574951,
-0.3570869565010071,
-0.421648770570755,
-1.6890850067138672,
1.1887239217758179,
-0.16083981096744537,
-1.7201176881790161,
0.43852999806404114,
-0.8830485343933105,
0.5467137694358826,
-0.5242379903793335,
0.9903406500816345... |
javascript/reference/global_objects/iterator/foreach/index.md | JavaScript - Global Objects - Iterator - forEach - Examples - Using forEach():
Example:
new Set([1, 2, 3]).values().forEach((v) => console.log(v));
// Logs:
// 1
// 2
// 3
This is equivalent to:
Example:
for (const v of new Set([1, 2, 3]).values()) {
console.log(v);
} | [
-0.19965100288391113,
-0.6442636847496033,
-1.2181941270828247,
0.2965547740459442,
0.09340425580739975,
-1.8544420003890991,
-0.19161204993724823,
1.228305459022522,
-0.5048065781593323,
-0.697134792804718,
0.08547542989253998,
0.6258736252784729,
0.24433009326457977,
0.2281518131494522,
... |
javascript/reference/global_objects/referenceerror/index.md | JavaScript - Global Objects - ReferenceError:
The `ReferenceError` object represents an error when a variable that doesn't exist (or hasn't yet been initialized) in the current scope is referenced.
`ReferenceError` is a `serializable object`, so it can be cloned with `structuredClone()` or copied between Workers usin... | [
-1.191787600517273,
0.4589334726333618,
-0.904612123966217,
0.8315375447273254,
-0.2440750002861023,
-0.3871600925922394,
0.3889782428741455,
0.5913476943969727,
-0.3232586085796356,
-0.8897067904472351,
-0.42903876304626465,
-0.19863882660865784,
0.1712472289800644,
0.6048687100410461,
... |
javascript/reference/global_objects/referenceerror/index.md | JavaScript - Global Objects - ReferenceError - Constructor:
- `ReferenceError()`: Creates a new `ReferenceError` object. | [
-0.8394497632980347,
0.07782145589590073,
-0.8603639602661133,
0.3524622917175293,
-0.295261412858963,
-1.0660496950149536,
0.24726448953151703,
0.7806464433670044,
-0.674344539642334,
-0.6630009412765503,
-0.7544685006141663,
-0.32507431507110596,
0.028862059116363525,
0.4020823836326599,... |
javascript/reference/global_objects/referenceerror/index.md | JavaScript - Global Objects - ReferenceError - Instance properties:
Also inherits instance properties from its parent `Error`.
These properties are defined on `ReferenceError.prototype` and shared by all `ReferenceError` instances.
- `ReferenceError.prototype.constructor`: The constructor function that created the i... | [
-0.2196824848651886,
0.029354892671108246,
-0.8050385117530823,
0.7237550616264343,
-0.26874202489852905,
-1.0504862070083618,
0.5147989392280579,
1.0503027439117432,
0.16812768578529358,
-0.43809035420417786,
-0.9940351247787476,
0.21169796586036682,
-0.9606300592422485,
0.633775055408477... |
javascript/reference/global_objects/referenceerror/index.md | JavaScript - Global Objects - ReferenceError - Instance methods:
Inherits instance methods from its parent `Error`. | [
-0.2827471196651459,
-0.29946887493133545,
-0.8669458031654358,
-0.10024388879537582,
-0.521290123462677,
-1.7611536979675293,
0.9486498832702637,
0.8117247223854065,
-0.7981621623039246,
-1.264491081237793,
-0.649290144443512,
-0.08849442005157471,
-0.5541688203811646,
0.699023962020874,
... |
javascript/reference/global_objects/referenceerror/index.md | JavaScript - Global Objects - ReferenceError - Examples - Catching a ReferenceError:
Example:
try {
let a = undefinedVariable;
} catch (e) {
console.log(e instanceof ReferenceError); // true
console.log(e.message); // "undefinedVariable is not defined"
console.log(e.name); // "ReferenceError"
console.log(e.... | [
-0.43854930996894836,
0.35181179642677307,
-1.2382736206054688,
0.9515208601951599,
-0.5065480470657349,
-1.107953667640686,
1.2903836965560913,
0.65688157081604,
-0.9372742176055908,
-0.5684935450553894,
0.22880186140537262,
-0.4601128399372101,
0.1341610699892044,
0.10837383568286896,
... |
javascript/reference/global_objects/referenceerror/index.md | JavaScript - Global Objects - ReferenceError - Examples - Creating a ReferenceError:
Example:
try {
throw new ReferenceError("Hello");
} catch (e) {
console.log(e instanceof ReferenceError); // true
console.log(e.message); // "Hello"
console.log(e.name); // "ReferenceError"
console.log(e.stack); // Stack of... | [
-0.3088493049144745,
-0.09966776520013809,
-1.007046103477478,
1.2183305025100708,
-0.02563312090933323,
-0.9125648140907288,
0.3223845064640045,
0.21891885995864868,
-0.3367910087108612,
-0.5371526479721069,
-0.26782217621803284,
0.09061684459447861,
0.44317033886909485,
0.239960566163063... |
javascript/reference/global_objects/referenceerror/referenceerror/index.md | JavaScript - Global Objects - ReferenceError:
The `ReferenceError()` constructor creates `ReferenceError` objects. | [
-0.5314146280288696,
0.3146389424800873,
-0.8983314037322998,
0.5858752131462097,
-0.4416336417198181,
-1.1699864864349365,
0.10107439011335373,
0.6264654397964478,
-0.8288698792457581,
-0.5092930793762207,
-0.6395888924598694,
-0.22832238674163818,
-0.2761063873767853,
0.13096946477890015... |
javascript/reference/global_objects/referenceerror/referenceerror/index.md | JavaScript - Global Objects - ReferenceError - Syntax:
Example:
new ReferenceError()
new ReferenceError(message)
new ReferenceError(message, options)
new ReferenceError(message, fileName)
new ReferenceError(message, fileName, lineNumber)
ReferenceError()
ReferenceError(message)
ReferenceError(message, options)
Refer... | [
-0.7847766280174255,
-0.2427932471036911,
-0.829184889793396,
-0.07459688931703568,
-0.26312610507011414,
-1.184150218963623,
0.2706248462200165,
0.8416409492492676,
-0.16756394505500793,
-0.7100366950035095,
-0.20367278158664703,
-0.11623406410217285,
0.5131118297576904,
0.771222651004791... |
javascript/reference/global_objects/referenceerror/referenceerror/index.md | JavaScript - Global Objects - ReferenceError - Syntax - Parameters:
- `message` (optional): Human-readable description of the error.
- `options` (optional): An object that has the following properties:
- `cause` (optional): A property indicating the specific cause of the error. When catching and re-throwing an error... | [
-0.5031318068504333,
-0.5994829535484314,
-0.987299919128418,
-0.27980899810791016,
0.08703683316707611,
-1.6541138887405396,
0.7416812181472778,
0.4421156048774719,
-0.041784923523664474,
-0.5023511648178101,
-1.1189194917678833,
0.16286052763462067,
-0.0022349031642079353,
0.926916658878... |
javascript/reference/global_objects/referenceerror/referenceerror/index.md | JavaScript - Global Objects - ReferenceError - Examples - Catching a ReferenceError:
Example:
try {
let a = undefinedVariable;
} catch (e) {
console.log(e instanceof ReferenceError); // true
console.log(e.message); // "undefinedVariable is not defined"
console.log(e.name); // "ReferenceError"
console.log(e.... | [
-0.43854930996894836,
0.35181179642677307,
-1.2382736206054688,
0.9515208601951599,
-0.5065480470657349,
-1.107953667640686,
1.2903836965560913,
0.65688157081604,
-0.9372742176055908,
-0.5684935450553894,
0.22880186140537262,
-0.4601128399372101,
0.1341610699892044,
0.10837383568286896,
... |
javascript/reference/global_objects/referenceerror/referenceerror/index.md | JavaScript - Global Objects - ReferenceError - Examples - Creating a ReferenceError:
Example:
try {
throw new ReferenceError("Hello");
} catch (e) {
console.log(e instanceof ReferenceError); // true
console.log(e.message); // "Hello"
console.log(e.name); // "ReferenceError"
console.log(e.stack); // Stack of... | [
-0.3088493049144745,
-0.09966776520013809,
-1.007046103477478,
1.2183305025100708,
-0.02563312090933323,
-0.9125648140907288,
0.3223845064640045,
0.21891885995864868,
-0.3367910087108612,
-0.5371526479721069,
-0.26782217621803284,
0.09061684459447861,
0.44317033886909485,
0.239960566163063... |
javascript/reference/global_objects/generator/index.md | JavaScript - Global Objects - Generator:
The `Generator` object is returned by a `generator function` and it conforms to both the iterable protocol and the iterator protocol.
`Generator` is a subclass of the `Iterator` class. | [
-0.7325214743614197,
-0.4057687222957611,
-1.0016276836395264,
-0.12380190938711166,
-0.36931052803993225,
-1.7114089727401733,
-0.5344991087913513,
0.4631114900112152,
-0.7777063846588135,
0.08532872051000595,
-1.0104726552963257,
0.12409334629774094,
-0.06324984133243561,
0.5387371778488... |
javascript/reference/global_objects/generator/index.md | JavaScript - Global Objects - Generator - Constructor:
There's no JavaScript entity that corresponds to the `Generator` constructor. Instances of `Generator` must be returned from generator functions:
Example:
function* generator() {
yield 1;
yield 2;
yield 3;
}
const gen = generator(); // "Generator { }"
co... | [
-0.2011292278766632,
-0.7547634840011597,
-0.9726758599281311,
0.015450620092451572,
-0.3836933672428131,
-1.6910674571990967,
-0.6188866496086121,
0.7065412402153015,
-0.64699387550354,
0.005157668609172106,
-0.11436548084020615,
-0.12122537195682526,
-0.5285720229148865,
0.12758193910121... |
javascript/reference/global_objects/generator/index.md | JavaScript - Global Objects - Generator - Instance properties:
These properties are defined on `Generator.prototype` and shared by all `Generator` instances.
- `Generator.prototype.constructor`: The constructor function that created the instance object. For `Generator` instances, the initial value is `GeneratorFuncti... | [
-0.3724307417869568,
-0.6504368185997009,
-0.7593590021133423,
0.5046802163124084,
-0.10649755597114563,
-2.269556999206543,
-0.08199717104434967,
1.197022795677185,
0.14821432530879974,
-0.2398766577243805,
-0.8659862875938416,
0.2870044708251953,
-0.3393648564815521,
0.057880062609910965... |
javascript/reference/global_objects/generator/index.md | JavaScript - Global Objects - Generator - Instance methods:
Also inherits instance methods from its parent `Iterator`.
- `Generator.prototype.next()`: Returns a value yielded by the `yield` expression.
- `Generator.prototype.return()`: Acts as if a `return` statement is inserted in the generator's body at the current... | [
-0.40154337882995605,
-0.3976012170314789,
-0.6180330514907837,
0.2866518497467041,
-0.33550915122032166,
-1.8057132959365845,
0.15814223885536194,
1.2736095190048218,
-0.19040361046791077,
0.047709979116916656,
-0.6470392942428589,
0.20944929122924805,
-0.38967782258987427,
0.584028184413... |
javascript/reference/global_objects/generator/index.md | JavaScript - Global Objects - Generator - Examples - An infinite iterator:
With a generator function, values are not evaluated until they are needed. Therefore a generator allows us to define a potentially infinite data structure.
Example:
function* infinite() {
let index = 0;
while (true) {
yield index++;
... | [
-1.000234842300415,
-0.06996943801641464,
-0.6807025074958801,
0.6534274816513062,
-0.3344051241874695,
-1.8680306673049927,
-0.7947028875350952,
0.8016363978385925,
-0.11728670448064804,
0.27677494287490845,
0.27769356966018677,
-0.19770202040672302,
-0.3220559060573578,
-0.00704996287822... |
javascript/reference/global_objects/generator/throw/index.md | JavaScript - Global Objects - Generator - throw:
The `throw()` method of `Generator` instances acts as if a `throw` statement is inserted in the generator's body at the current suspended position, which informs the generator of an error condition and allows it to handle the error, or perform cleanup and close itself. | [
0.35985511541366577,
-0.4108448624610901,
-0.8836150765419006,
0.7425065636634827,
-0.24350157380104065,
-2.1335508823394775,
0.11279898136854172,
1.3669764995574951,
-0.27660101652145386,
0.273233026266098,
-0.5974087715148926,
0.03891626372933388,
0.07028369605541229,
0.16794244945049286... |
javascript/reference/global_objects/generator/throw/index.md | JavaScript - Global Objects - Generator - throw - Syntax:
Example:
generatorInstance.throw(exception) | [
0.2078602910041809,
-0.025388091802597046,
-0.6604092717170715,
0.22778716683387756,
-0.7140541672706604,
-2.1389882564544678,
-0.5135976672172546,
1.3222965002059937,
-0.4314306378364563,
-0.8387005925178528,
-0.3087391257286072,
0.4947971701622009,
-0.12109051644802094,
-0.00294878636486... |
javascript/reference/global_objects/generator/throw/index.md | JavaScript - Global Objects - Generator - throw - Syntax - Parameters:
- `exception`: The exception to throw. For debugging purposes, it is useful to make it an `instanceof` `Error`. | [
0.34132447838783264,
-0.4143941104412079,
-0.8927581906318665,
0.36392834782600403,
-0.3669319152832031,
-2.0907437801361084,
-0.2508505880832672,
1.2872997522354126,
0.2622053623199463,
-0.7210134863853455,
-1.0022037029266357,
0.615386962890625,
-0.18873903155326843,
0.5933770537376404,
... |
javascript/reference/global_objects/generator/throw/index.md | JavaScript - Global Objects - Generator - throw - Syntax - Return value:
If the thrown exception is caught by a `try...catch` and the generator resumes to yield more values, it will return an `Object` with two properties:
- `done`: A boolean value:
- `true` if the generator function's control flow has reached the e... | [
-0.0031641977839171886,
-0.2827523946762085,
-0.7606616020202637,
0.5938705801963806,
-0.5943845510482788,
-1.6133712530136108,
-0.1888231784105301,
1.3772542476654053,
-0.5765054225921631,
-0.1656169295310974,
-0.6167720556259155,
0.5146991014480591,
-0.101143479347229,
0.7185224294662476... |
javascript/reference/global_objects/generator/throw/index.md | JavaScript - Global Objects - Generator - throw - Syntax - Exceptions:
- `TypeError`: Thrown if the generator is already running.
If the `exception` is not caught by a `try...catch` within the generator function, it is also thrown to the caller of `throw()`. | [
-0.24588339030742645,
0.27059251070022583,
-0.6200442910194397,
0.5450810790061951,
-0.7110204100608826,
-1.63221275806427,
-0.46286436915397644,
1.1532793045043945,
-0.6481502056121826,
-0.22299997508525848,
-0.20589400827884674,
-0.31454452872276306,
0.22329866886138916,
-0.0113860694691... |
javascript/reference/global_objects/generator/throw/index.md | JavaScript - Global Objects - Generator - throw - Description:
The `throw()` method, when called, can be seen as if a `throw exception;` statement is inserted in the generator's body at the current suspended position, where `exception` is the exception passed to the `throw()` method. Therefore, in a typical flow, call... | [
-0.42195209860801697,
0.08016632497310638,
-1.4430485963821411,
0.3769364655017853,
-0.3311935365200043,
-1.8774033784866333,
-0.501319408416748,
1.6620686054229736,
-0.2426406741142273,
0.49709320068359375,
-0.33241134881973267,
0.22493892908096313,
0.07656027376651764,
0.2468452453613281... |
javascript/reference/global_objects/generator/throw/index.md | JavaScript - Global Objects - Generator - throw - Examples - Using throw():
The following example shows a generator and an error that is thrown using the `throw` method. An error can be caught by a `try...catch` block as usual.
Example:
function* gen() {
while (true) {
try {
yield 42;
} catch (e) {
... | [
0.31972765922546387,
-0.18683117628097534,
-1.0704364776611328,
0.30388036370277405,
-0.36812394857406616,
-1.4844505786895752,
-0.16461697220802307,
1.0793238878250122,
-0.7140227556228638,
-0.16128946840763092,
-0.26046022772789,
0.17997989058494568,
0.04465246945619583,
0.22767515480518... |
javascript/reference/global_objects/generator/return/index.md | JavaScript - Global Objects - Generator - return:
The `return()` method of `Generator` instances acts as if a `return` statement is inserted in the generator's body at the current suspended position, which finishes the generator and allows the generator to perform any cleanup tasks when combined with a `try...finally`... | [
0.16278313100337982,
0.08365461975336075,
-0.8898462057113647,
0.6812121868133545,
-0.690209686756134,
-1.770981788635254,
0.18155691027641296,
0.7645413279533386,
-0.713496744632721,
1.0681729316711426,
-0.5440670251846313,
0.3852163851261139,
0.0012858340051025152,
0.7006397247314453,
... |
javascript/reference/global_objects/generator/return/index.md | JavaScript - Global Objects - Generator - return - Syntax:
Example:
generatorInstance.return()
generatorInstance.return(value) | [
0.0703640878200531,
0.3093944191932678,
-0.5560896992683411,
0.16781051456928253,
-1.040004014968872,
-1.882423996925354,
-0.0897563025355339,
1.2792237997055054,
-0.8490119576454163,
-0.2424432635307312,
-0.32490241527557373,
0.6388362050056458,
0.0993838757276535,
0.1330174058675766,
-... |
javascript/reference/global_objects/generator/return/index.md | JavaScript - Global Objects - Generator - return - Syntax - Parameters:
- `value` (optional): The value to return. | [
0.19425012171268463,
0.28574296832084656,
-0.7970544695854187,
-0.0062008933164179325,
-1.0193232297897339,
-2.075273275375366,
0.4316158890724182,
0.824449360370636,
-0.3352886438369751,
-0.05235471948981285,
-0.7544628977775574,
1.039669394493103,
0.24268928170204163,
0.7728859782218933,... |
javascript/reference/global_objects/generator/return/index.md | JavaScript - Global Objects - Generator - return - Syntax - Return value:
An `Object` with two properties:
- `done`: A boolean value:
- `true` if the generator function's control flow has reached the end.
- `false` if the generator function's control flow hasn't reached the end and can produce more values. This c... | [
-0.24068565666675568,
0.3320573568344116,
-0.43265917897224426,
0.22879920899868011,
-0.7759552597999573,
-1.4869238138198853,
0.26098474860191345,
1.3194308280944824,
-0.2822742462158203,
0.43874186277389526,
-0.6809180974960327,
0.5384830832481384,
-0.1348915696144104,
0.6296914219856262... |
javascript/reference/global_objects/generator/return/index.md | JavaScript - Global Objects - Generator - return - Syntax - Exceptions:
- `TypeError`: Thrown if the generator is already running. | [
-0.26897528767585754,
0.30792033672332764,
-0.6951479315757751,
0.4986879229545593,
-1.0230430364608765,
-2.008765935897827,
-0.08487340062856674,
1.2039811611175537,
-0.7921109795570374,
0.19317297637462616,
-0.5577204823493958,
-0.23345623910427094,
0.19838884472846985,
0.018606022000312... |
javascript/reference/global_objects/generator/return/index.md | JavaScript - Global Objects - Generator - return - Description:
The `return()` method, when called, can be seen as if a `return value;` statement is inserted in the generator's body at the current suspended position, where `value` is the value passed to the `return()` method. Therefore, in a typical flow, calling `ret... | [
-0.22847898304462433,
0.5348536968231201,
-1.1154594421386719,
0.33173510432243347,
-0.6526421904563904,
-1.4240124225616455,
0.09402269124984741,
1.3807271718978882,
-0.7189446687698364,
0.8702435493469238,
-0.3391002118587494,
0.30212491750717163,
0.04795065522193909,
1.049756646156311,
... |
javascript/reference/global_objects/generator/return/index.md | JavaScript - Global Objects - Generator - return - Examples - Using return():
The following example shows a generator and the `return` method.
Example:
function* gen() {
yield 1;
yield 2;
yield 3;
}
const g = gen();
g.next(); // { value: 1, done: false }
g.return("foo"); // { value: "foo", done: true }
g.nex... | [
-0.6623876094818115,
-0.047550980001688004,
-0.5948057770729065,
0.5112762451171875,
-0.006488461513072252,
-0.6829530000686646,
-0.02636447548866272,
0.8165996670722961,
-0.8470713496208191,
0.0648219883441925,
-0.7383958697319031,
0.5034359097480774,
-0.08174006640911102,
0.1658913195133... |
javascript/reference/global_objects/generator/return/index.md | JavaScript - Global Objects - Generator - return - Examples - Using return() with try...finally:
The fact that the `return` method has been called can only be made known to the generator itself if the `yield` expression is wrapped in a `try...finally` block.
When the `return` method is called on a generator that is s... | [
-0.3005254566669464,
0.18271759152412415,
-0.20475924015045166,
0.13510003685951233,
-0.19020475447177887,
-0.6742615699768066,
-0.4131961464881897,
0.8933748602867126,
-0.7723071575164795,
0.338645875453949,
-0.44491076469421387,
0.19049838185310364,
-0.28238505125045776,
0.47825175523757... |
javascript/reference/global_objects/generator/next/index.md | JavaScript - Global Objects - Generator - next:
The `next()` method of `Generator` instances returns an object with two properties `done` and `value`. You can also provide a parameter to the `next` method to send a value to the generator. | [
-0.004017220810055733,
-0.297748863697052,
-0.6487507224082947,
0.6072502136230469,
-0.6285643577575684,
-1.4768059253692627,
-0.03989822790026665,
0.4777717590332031,
-0.6234764456748962,
-0.23640760779380798,
-0.6112110018730164,
0.4121686816215515,
0.4955175220966339,
0.0463844947516918... |
javascript/reference/global_objects/generator/next/index.md | JavaScript - Global Objects - Generator - next - Syntax:
Example:
next()
next(value) | [
0.22564706206321716,
-0.045153774321079254,
-0.8889093995094299,
0.09583362936973572,
-1.0068278312683105,
-1.6600085496902466,
-0.05961735174059868,
0.9924651980400085,
-0.20706473290920258,
-0.7612854838371277,
-0.04930456355214119,
0.5066852569580078,
0.09952221810817719,
-0.08673916012... |
javascript/reference/global_objects/generator/next/index.md | JavaScript - Global Objects - Generator - next - Syntax - Parameters:
- `value` (optional): The value to send to the generator. The value will be assigned as a result of a `yield` expression. For example, in `variable = yield expression`, the value passed to the `.next()` function will be assigned to `variable`. | [
-0.499196857213974,
0.1593039631843567,
-0.8027844429016113,
0.4756172299385071,
-0.7375851273536682,
-1.966914415359497,
0.5394052863121033,
0.7846706509590149,
0.31550779938697815,
-0.5983254909515381,
-0.39188888669013977,
0.2634509801864624,
0.2576967477798462,
0.9416622519493103,
0.... |
javascript/reference/global_objects/generator/next/index.md | JavaScript - Global Objects - Generator - next - Syntax - Return value:
An `Object` with two properties:
- `done`: A boolean value:
- `true` if the generator is past the end of its control flow. In this case `value` specifies the return value of the generator (which may be undefined).
- `false` if the generator i... | [
-0.23450249433517456,
-0.09157869219779968,
-0.38511496782302856,
0.5041080713272095,
-0.7885345220565796,
-1.587445616722107,
0.4097708761692047,
1.080439567565918,
-0.32443690299987793,
-0.1724475771188736,
-0.6480135321617126,
0.7311916351318359,
0.06298831850290298,
0.09291113168001175... |
javascript/reference/global_objects/generator/next/index.md | JavaScript - Global Objects - Generator - next - Syntax - Exceptions:
- `TypeError`: Thrown if the generator is already running. | [
-0.1434454470872879,
0.47467419505119324,
-0.6903828978538513,
0.6313539743423462,
-0.9640503525733948,
-1.8865578174591064,
-0.1995304524898529,
1.2070471048355103,
-0.5198422074317932,
0.10159986466169357,
-0.44775328040122986,
-0.5819967985153198,
0.2713359594345093,
-0.3390070199966430... |
javascript/reference/global_objects/generator/next/index.md | JavaScript - Global Objects - Generator - next - Examples - Using next():
The following example shows a generator and the object that the `next` method returns:
Example:
function* gen() {
yield 1;
yield 2;
yield 3;
}
const g = gen(); // Generator { }
g.next(); // { value: 1, done: false }
g.next(); // { value... | [
-0.3853932023048401,
0.007626192644238472,
-1.2117494344711304,
-0.18351082503795624,
-0.5711898803710938,
-1.308485507965088,
-0.4106350243091583,
1.4899506568908691,
-0.5811505317687988,
-0.16813261806964874,
-0.6321039199829102,
0.3688948452472687,
0.21540819108486176,
-0.16740936040878... |
javascript/reference/global_objects/generator/next/index.md | JavaScript - Global Objects - Generator - next - Examples - Using next() with a list:
In this example, `getPage` takes a list and "paginates" it into chunks of size `pageSize`. Each call to `next` will yield one such chunk.
Example:
function* getPage(list, pageSize = 1) {
for (let index = 0; index < list.length; i... | [
-0.6013138294219971,
0.21351392567157745,
-1.0771934986114502,
-0.1556907445192337,
-0.4174855351448059,
-0.4281025230884552,
-0.03137798234820366,
0.2122635841369629,
-0.31726890802383423,
0.20239530503749847,
-0.6081467866897583,
0.7229807376861572,
-0.1556389331817627,
-0.24911083281040... |
javascript/reference/global_objects/generator/next/index.md | JavaScript - Global Objects - Generator - next - Examples - Sending values to the generator:
In this example, `next` is called with a value.
Note: The first call does not log anything, because the generator was not yielding anything initially.
Example:
function* gen() {
while (true) {
const value = yield;
... | [
-0.8539704084396362,
0.32101842761039734,
-1.0719374418258667,
0.007055171299725771,
-0.29887789487838745,
-1.4336069822311401,
-0.362505167722702,
0.26005619764328003,
-0.6398152709007263,
-0.5376745462417603,
0.1395961046218872,
-0.12316092103719711,
0.36154478788375854,
0.00539009273052... |
javascript/reference/global_objects/number/index.md | JavaScript - Global Objects - Number:
`Number` values represent floating-point numbers like `37` or `-9.25`.
The `Number` constructor contains constants and methods for working with numbers. Values of other types can be converted to numbers using the `Number()` function. | [
-0.6687589883804321,
-0.21779635548591614,
-1.04702627658844,
-0.449169784784317,
-0.4224390983581543,
-1.9097093343734741,
-0.017790185287594795,
0.7275639772415161,
0.09079699218273163,
-0.20820584893226624,
-1.057769536972046,
0.3770400285720825,
0.06082972139120102,
-0.0024222654756158... |
javascript/reference/global_objects/number/index.md | JavaScript - Global Objects - Number - Description:
Numbers are most commonly expressed in literal forms like `255` or `3.14159`. The lexical grammar contains a more detailed reference.
Example:
255; // two-hundred and fifty-five
255.0; // same number
255 === 255.0; // true
255 === 0xff; // true (hexadecimal notatio... | [
-1.6908283233642578,
-0.2724688649177551,
-0.6069992184638977,
-0.3584679961204529,
-0.018710048869252205,
-0.9849584102630615,
0.6007530093193054,
0.44289901852607727,
-0.433187872171402,
0.10616541653871536,
-0.9485032558441162,
0.41557422280311584,
-0.8302174806594849,
-0.30218732357025... |
javascript/reference/global_objects/number/index.md | JavaScript - Global Objects - Number - Description - Number encoding:
The JavaScript `Number` type is a double-precision 64-bit binary format IEEE 754 value, like `double` in Java or C#. This means it can represent fractional values, but there are some limits to the stored number's magnitude and precision. Very briefl... | [
-0.7359688878059387,
-0.5788316130638123,
-0.684464693069458,
0.45105689764022827,
-0.16215848922729492,
-1.6805229187011719,
0.41957008838653564,
0.905159592628479,
0.03765195608139038,
0.590208888053894,
-0.9235816597938538,
1.3314495086669922,
-0.7712507247924805,
0.5856479406356812,
... |
javascript/reference/global_objects/number/index.md | JavaScript - Global Objects - Number - Description - Number coercion:
Many built-in operations that expect numbers first coerce their arguments to numbers (which is largely why `Number` objects behave similarly to number primitives). The operation can be summarized as follows:
- Numbers are returned as-is.
- `undefin... | [
-0.2408178150653839,
-0.19743712246418,
-0.5294316411018372,
0.29044684767723083,
0.4758392572402954,
-0.35187220573425293,
0.2712647020816803,
0.625548243522644,
-0.2918842136859894,
0.020959822461009026,
-1.00082528591156,
-0.44294407963752747,
-0.7905868887901306,
0.3946015238761902,
... |
javascript/reference/global_objects/number/index.md | JavaScript - Global Objects - Number - Description - Number coercion - Integer conversion:
Some operations expect integers, most notably those that work with array/string indices, date/time components, and number radixes. After performing the number coercion steps above, the result is truncated to an integer (by disca... | [
-1.0177031755447388,
0.5910989046096802,
-0.44951775670051575,
0.4020133316516876,
-0.48977798223495483,
-1.132143259048462,
0.05519791692495346,
0.30385997891426086,
-0.2867503762245178,
0.7865657210350037,
-1.2163728475570679,
-0.5404641628265381,
-0.12429916113615036,
-0.345255732536315... |
javascript/reference/global_objects/number/index.md | JavaScript - Global Objects - Number - Description - Number coercion - Fixed-width number conversion:
JavaScript has some lower-level functions that deal with the binary encoding of integer numbers, most notably bitwise operators and `TypedArray` objects. Bitwise operators always convert the operands to 32-bit integer... | [
-1.0593280792236328,
0.043845996260643005,
-0.7135871052742004,
0.33028197288513184,
0.07431583106517792,
-0.6927381753921509,
0.2651229500770569,
0.454585462808609,
-0.4531822204589844,
1.0109293460845947,
-1.9348257780075073,
-0.1582370400428772,
-0.2170068472623825,
0.12925897538661957,... |
javascript/reference/global_objects/number/index.md | JavaScript - Global Objects - Number - Constructor:
- `Number()`: Creates `Number` objects. When called as a function, it returns primitive values of type Number. | [
-0.5914729833602905,
-0.11622001230716705,
-1.093227744102478,
-0.1543044149875641,
-0.35471147298812866,
-1.4252550601959229,
0.20509512722492218,
0.518409013748169,
-0.5191706418991089,
0.09642623364925385,
-1.2684319019317627,
0.12374695390462875,
-0.31773099303245544,
-0.09804359823465... |
javascript/reference/global_objects/number/index.md | JavaScript - Global Objects - Number - Static properties:
- `Number.EPSILON`: The smallest interval between two representable numbers.
- `Number.MAX_SAFE_INTEGER`: The maximum safe integer in JavaScript (253 - 1).
- `Number.MAX_VALUE`: The largest positive representable number.
- `Number.MIN_SAFE_INTEGER`: The minimum... | [
-1.200870156288147,
-0.5329368710517883,
-0.26579299569129944,
0.23951685428619385,
0.01674218662083149,
-1.9485911130905151,
0.6308553814888,
-0.48627907037734985,
0.03728858381509781,
0.7809827923774719,
-0.9337893128395081,
0.9000115394592285,
-0.6679167151451111,
-0.7862006425857544,
... |
javascript/reference/global_objects/number/index.md | JavaScript - Global Objects - Number - Static methods:
- `Number.isFinite()`: Determine whether the passed value is a finite number.
- `Number.isInteger()`: Determine whether the passed value is an integer.
- `Number.isNaN()`: Determine whether the passed value is `NaN`.
- `Number.isSafeInteger()`: Determine whether t... | [
-0.5904874205589294,
-0.3091375231742859,
-0.7738087773323059,
-0.2080271691083908,
-0.0327063649892807,
-1.61496102809906,
1.3037904500961304,
-0.23236055672168732,
-0.19192364811897278,
1.063005805015564,
-1.3697806596755981,
-0.3217194080352783,
0.09519720822572708,
0.21382828056812286,... |
javascript/reference/global_objects/number/index.md | JavaScript - Global Objects - Number - Instance properties:
These properties are defined on `Number.prototype` and shared by all `Number` instances.
- `Number.prototype.constructor`: The constructor function that created the instance object. For `Number` instances, the initial value is the `Number` constructor. | [
0.04225512221455574,
-0.45589014887809753,
-0.8202186822891235,
0.08019036799669266,
-0.19890354573726654,
-1.6057400703430176,
-0.2733862102031708,
0.5033860206604004,
0.5222712755203247,
-0.04470309615135193,
-1.3023449182510376,
-0.03419988229870796,
-0.5531103014945984,
0.4889026284217... |
javascript/reference/global_objects/number/index.md | JavaScript - Global Objects - Number - Instance methods:
- `Number.prototype.toExponential()`: Returns a string representing the number in exponential notation.
- `Number.prototype.toFixed()`: Returns a string representing the number in fixed-point notation.
- `Number.prototype.toLocaleString()`: Returns a string with... | [
-0.7517139315605164,
-0.4910948872566223,
-0.42657405138015747,
-0.7503844499588013,
-0.19168415665626526,
-2.532750129699707,
0.6509547829627991,
0.10260283946990967,
0.04400740563869476,
-0.1514984518289566,
-0.9873376488685608,
1.2431102991104126,
-0.35312485694885254,
-0.07696525007486... |
javascript/reference/global_objects/number/index.md | JavaScript - Global Objects - Number - Examples - Using the Number object to assign values to numeric variables:
The following example uses the `Number` object's properties to assign values to several numeric variables:
Example:
const biggestNum = Number.MAX_VALUE;
const smallestNum = Number.MIN_VALUE;
const infinit... | [
-0.6350318193435669,
0.07640618085861206,
-0.6978376507759094,
0.45920631289482117,
-0.7411624193191528,
-1.3514976501464844,
0.6567699313163757,
-0.2044065147638321,
0.19205588102340698,
-0.07432184368371964,
-0.7099961638450623,
0.3513002097606659,
-0.32381483912467957,
-0.45559188723564... |
javascript/reference/global_objects/number/index.md | JavaScript - Global Objects - Number - Examples - Integer range for Number:
The following example shows the minimum and maximum integer values that can be represented as `Number` object.
Example:
const biggestInt = Number.MAX_SAFE_INTEGER; // (2**53 - 1) => 9007199254740991
const smallestInt = Number.MIN_SAFE_INTEGE... | [
-1.0554382801055908,
0.16880841553211212,
-1.1484448909759521,
0.017747173085808754,
0.20361441373825073,
-1.6566271781921387,
-0.6648432612419128,
-0.05229349806904793,
-0.5157106518745422,
0.4966001808643341,
-0.27034932374954224,
1.1644492149353027,
-0.8792494535446167,
-0.7308768033981... |
javascript/reference/global_objects/number/index.md | JavaScript - Global Objects - Number - Examples - Using Number() to convert a Date object:
The following example converts the `Date` object to a numerical value using `Number` as a function:
Example:
const d = new Date("1995-12-17T03:24:00");
console.log(Number(d));
This logs `819199440000`. | [
-0.3942331075668335,
-0.07644196599721909,
-1.1722533702850342,
0.501977264881134,
-0.4384947717189789,
-1.2776824235916138,
-0.16160288453102112,
0.4059084951877594,
-0.22003348171710968,
-0.08587498217821121,
-0.30045849084854126,
0.12784269452095032,
0.3384568393230438,
-0.5078055858612... |
javascript/reference/global_objects/number/index.md | JavaScript - Global Objects - Number - Examples - Convert numeric strings and null to numbers:
Example:
Number("123"); // 123
Number("123") === 123; // true
Number("12.3"); // 12.3
Number("12.00"); // 12
Number("123e-1"); // 12.3
Number(""); // 0
Number(null); // 0
Number("0x11"); // 17
Number("0b11"); // 3
Number("0... | [
-0.5780687928199768,
-0.02611355483531952,
-0.2902912497520447,
-0.8478955626487732,
-0.5349941849708557,
-1.5224781036376953,
0.9873874187469482,
-0.28708451986312866,
-0.1502215564250946,
0.010485813021659851,
-1.0217095613479614,
0.2892792820930481,
-0.13338428735733032,
-0.564401447772... |
javascript/reference/global_objects/number/toexponential/index.md | JavaScript - Global Objects - Number - toExponential:
The `toExponential()` method of `Number` values returns a string representing this number in exponential notation.
Example:
function expo(x, f) {
return Number.parseFloat(x).toExponential(f);
}
console.log(expo(123456, 2));
// Expected output: "1.23e+5"
conso... | [
-1.5766876935958862,
-0.4398195445537567,
-0.9451295137405396,
-0.39279401302337646,
-0.20419591665267944,
-2.2644217014312744,
-0.20357222855091095,
0.4576416313648224,
-0.18229226768016815,
-0.32712557911872864,
-0.6038408279418945,
1.2110825777053833,
-0.4926055669784546,
0.006752769928... |
javascript/reference/global_objects/number/toexponential/index.md | JavaScript - Global Objects - Number - toExponential - Syntax:
Example:
toExponential()
toExponential(fractionDigits) | [
-0.9252035617828369,
0.20882442593574524,
-0.0019818295259028673,
-0.4341980218887329,
-1.205628514289856,
-2.626791000366211,
0.5682249665260315,
-0.14306913316249847,
-0.08944344520568848,
-1.0911118984222412,
-1.0395374298095703,
1.0714309215545654,
-1.1916635036468506,
0.06832323968410... |
javascript/reference/global_objects/number/toexponential/index.md | JavaScript - Global Objects - Number - toExponential - Syntax - Parameters:
- `fractionDigits` (optional): Optional. An integer specifying the number of digits after the decimal point. Defaults to as many digits as necessary to specify the number. | [
-0.7267908453941345,
-0.6728203892707825,
-0.46762600541114807,
0.022765763103961945,
-0.5509609580039978,
-1.7867794036865234,
1.298813819885254,
-0.2464703917503357,
-0.19461871683597565,
-0.6190835237503052,
-1.7060502767562866,
0.5713548064231873,
-1.2510738372802734,
0.526379823684692... |
javascript/reference/global_objects/number/toexponential/index.md | JavaScript - Global Objects - Number - toExponential - Syntax - Return value:
A string representing the given `Number` object in exponential notation with one digit before the decimal point, rounded to `fractionDigits` digits after the decimal point. | [
-0.8740088939666748,
-0.01608285680413246,
-0.18885253369808197,
-0.5338701605796814,
-0.48313918709754944,
-2.0704991817474365,
0.6970711946487427,
0.37397047877311707,
-0.4718625545501709,
-0.26572442054748535,
-0.9951322078704834,
1.3382951021194458,
-1.0225633382797241,
0.4255014359951... |
javascript/reference/global_objects/number/toexponential/index.md | JavaScript - Global Objects - Number - toExponential - Syntax - Exceptions:
- `RangeError`: Thrown if `fractionDigits` is not between `0` and `100` (inclusive).
- `TypeError`: Thrown if this method is invoked on an object that is not a `Number`. | [
-1.0671030282974243,
-0.37681159377098083,
-0.11177513003349304,
0.11325721442699432,
-0.3890426456928253,
-2.2998509407043457,
0.07579638808965683,
-0.07348639518022537,
-0.6521662473678589,
-0.4579647183418274,
-0.9177819490432739,
0.7284238338470459,
-1.014721393585205,
-0.5283326506614... |
javascript/reference/global_objects/number/toexponential/index.md | JavaScript - Global Objects - Number - toExponential - Description:
If the `fractionDigits` argument is omitted, the number of digits after the decimal point defaults to the number of digits necessary to represent the value uniquely.
If you use the `toExponential()` method for a numeric literal and the numeric litera... | [
-1.5423084497451782,
-0.43248969316482544,
0.1518305093050003,
-0.49471214413642883,
-0.447896808385849,
-2.3603646755218506,
0.9538470506668091,
-0.5605514049530029,
-0.32967230677604675,
-0.40586143732070923,
-0.9299460649490356,
1.0794683694839478,
-1.5137897729873657,
-0.24060899019241... |
javascript/reference/global_objects/number/toexponential/index.md | JavaScript - Global Objects - Number - toExponential - Examples - Using toExponential:
Example:
const numObj = 77.1234;
console.log(numObj.toExponential()); // 7.71234e+1
console.log(numObj.toExponential(4)); // 7.7123e+1
console.log(numObj.toExponential(2)); // 7.71e+1
console.log((77.1234).toExponential()); // 7.7... | [
-0.7117903828620911,
0.49036383628845215,
-0.6677877306938171,
-0.6465882658958435,
-0.6478118300437927,
-1.8215252161026,
-0.3308444917201996,
-0.15473681688308716,
0.3858569860458374,
-0.5167497396469116,
-0.34391212463378906,
1.1397278308868408,
-0.7796935439109802,
0.1476542353630066,
... |
javascript/reference/global_objects/number/tofixed/index.md | JavaScript - Global Objects - Number - toFixed:
The `toFixed()` method of `Number` values returns a string representing this number using fixed-point notation with the specified number of decimal places.
Example:
function financial(x) {
return Number.parseFloat(x).toFixed(2);
}
console.log(financial(123.456));
//... | [
-1.3383756875991821,
-0.3921606242656708,
-1.2936114072799683,
-0.868426501750946,
-0.20986272394657135,
-1.6535964012145996,
0.5925877690315247,
0.6121572852134705,
-0.2924967110157013,
0.22431500256061554,
-0.28726866841316223,
0.2619685232639313,
-0.4301450252532959,
0.1601526439189911,... |
javascript/reference/global_objects/number/tofixed/index.md | JavaScript - Global Objects - Number - toFixed - Syntax:
Example:
toFixed()
toFixed(digits) | [
-0.4236949384212494,
0.1393813043832779,
-0.6201606392860413,
-0.958677351474762,
-0.8660455942153931,
-1.9699400663375854,
0.7414465546607971,
0.712960958480835,
-0.6834542155265808,
-0.2776705026626587,
-1.0472280979156494,
0.40877336263656616,
-1.0099698305130005,
0.12258449196815491,
... |
javascript/reference/global_objects/number/tofixed/index.md | JavaScript - Global Objects - Number - toFixed - Syntax - Parameters:
- `digits` (optional): The number of digits to appear after the decimal point; should be a value between `0` and `100`, inclusive. If this argument is omitted, it is treated as `0`. | [
-0.4022071659564972,
-0.6340928673744202,
-0.6728304028511047,
-0.11673054844141006,
-0.21162857115268707,
-1.6674771308898926,
0.9173122048377991,
-0.1671668142080307,
-0.03912279009819031,
-0.19351589679718018,
-0.5690507888793945,
0.45623472332954407,
-0.45565861463546753,
0.04401601850... |
javascript/reference/global_objects/number/tofixed/index.md | JavaScript - Global Objects - Number - toFixed - Syntax - Return value:
A string representing the given number using fixed-point notation. Scientific notation is used if the number's magnitude (ignoring sign) is greater than or equal to 1021 (same return value as `Number.prototype.toString()`). | [
-1.0711486339569092,
0.08376411348581314,
-0.2587326467037201,
-0.635493814945221,
-0.5399585962295532,
-2.306220769882202,
0.7861828804016113,
-0.05393626540899277,
-0.4961104393005371,
0.3644024133682251,
-1.2989000082015991,
1.009516716003418,
-0.40909066796302795,
0.5264899134635925,
... |
javascript/reference/global_objects/number/tofixed/index.md | JavaScript - Global Objects - Number - toFixed - Syntax - Exceptions:
- `RangeError`: Thrown if `digits` is not between `0` and `100` (inclusive).
- `TypeError`: Thrown if this method is invoked on an object that is not a `Number`. | [
-0.7369709014892578,
-0.3856094181537628,
-0.36060836911201477,
0.15569047629833221,
-0.32322612404823303,
-1.846660852432251,
-0.11151281744241714,
0.40477222204208374,
-0.6394995450973511,
-0.050998251885175705,
-0.566216230392456,
0.5905769467353821,
-1.0126980543136597,
-0.527841031551... |
javascript/reference/global_objects/number/tofixed/index.md | JavaScript - Global Objects - Number - toFixed - Description:
The `toFixed()` method returns a string representation of a number without using exponential notation and with exactly `digits` digits after the decimal point. The number is rounded if necessary, and the fractional part is padded with zeros if necessary so ... | [
-0.3911639153957367,
0.05800291895866394,
-0.47238537669181824,
0.5021037459373474,
0.3592429459095001,
-0.7942293882369995,
0.8474944233894348,
0.7799712419509888,
-0.6718175411224365,
1.156653642654419,
-1.0517204999923706,
0.13369731605052948,
-0.835239827632904,
0.4418017268180847,
-... |
javascript/reference/global_objects/number/tofixed/index.md | JavaScript - Global Objects - Number - toFixed - Examples - Using toFixed():
Example:
const numObj = 12345.6789;
numObj.toFixed(); // '12346'; rounding, no fractional part
numObj.toFixed(1); // '12345.7'; it rounds up
numObj.toFixed(6); // '12345.678900'; additional zeros
(1.23e20).toFixed(2); // '123000000000000000... | [
0.0941409319639206,
0.12511630356311798,
-0.3271868824958801,
0.02825637347996235,
0.8240035176277161,
-1.0086976289749146,
0.44834664463996887,
0.6158642768859863,
-0.7206493616104126,
0.43268048763275146,
-1.3090630769729614,
-0.26637402176856995,
-0.968889057636261,
0.42418813705444336,... |
javascript/reference/global_objects/number/tofixed/index.md | JavaScript - Global Objects - Number - toFixed - Examples - Using toFixed() with negative numbers:
Because member access has higher precedence than unary minus, you need to group the negative number expression to get a string.
Example:
-2.34.toFixed(1); // -2.3; a number
(-2.34).toFixed(1); // '-2.3' | [
-0.6505449414253235,
0.48138394951820374,
-0.7757912874221802,
-0.18522915244102478,
-0.028576629236340523,
-2.1703600883483887,
1.1444134712219238,
0.08683021366596222,
-0.9955902099609375,
0.6856793761253357,
-1.4588704109191895,
-0.08374997228384018,
-0.9674187302589417,
-0.234174638986... |
javascript/reference/global_objects/number/isinteger/index.md | JavaScript - Global Objects - Number - isInteger:
The `Number.isInteger()` static method determines whether the passed value is an integer.
Example:
function fits(x, y) {
if (Number.isInteger(y / x)) {
return "Fits!";
}
return "Does NOT fit!";
}
console.log(fits(5, 10));
// Expected output: "Fits!"
conso... | [
-0.5288549661636353,
-1.018324613571167,
-1.1855559349060059,
0.3903198838233948,
-0.03793264925479889,
-1.722316026687622,
0.5358518362045288,
-0.025471461936831474,
-0.0026085451245307922,
0.6224759221076965,
-1.1782382726669312,
-0.624742865562439,
0.26615041494369507,
0.175887510180473... |
javascript/reference/global_objects/number/isinteger/index.md | JavaScript - Global Objects - Number - isInteger - Syntax:
Example:
Number.isInteger(value) | [
0.10038363188505173,
0.03443114086985588,
-0.5836343765258789,
-0.26196837425231934,
-0.8859561681747437,
-1.8995121717453003,
0.6812896728515625,
0.794407844543457,
-0.2727322280406952,
-0.6410030722618103,
-1.0947110652923584,
-0.08612562716007233,
-0.05760724097490311,
-0.30135580897331... |
javascript/reference/global_objects/number/isinteger/index.md | JavaScript - Global Objects - Number - isInteger - Syntax - Parameters:
- `value`: The value to be tested for being an integer. | [
0.2779008150100708,
-0.013724124990403652,
-0.5894611477851868,
-0.15477518737316132,
-0.46379855275154114,
-1.7481130361557007,
0.6488908529281616,
0.6149135828018188,
0.22776134312152863,
-0.4663136303424835,
-1.187323808670044,
0.032788053154945374,
-0.13790813088417053,
0.1635581701993... |
javascript/reference/global_objects/number/isinteger/index.md | JavaScript - Global Objects - Number - isInteger - Syntax - Return value:
The boolean value `true` if the given value is an integer. Otherwise `false`. | [
-0.6155059337615967,
0.09118334203958511,
-0.5875326991081238,
0.12451612204313278,
-0.6469652652740479,
-2.118588924407959,
0.8080977201461792,
0.7817995548248291,
-0.45044639706611633,
-0.5488507151603699,
-1.415407657623291,
-0.09715314954519272,
0.5274321436882019,
-0.21042127907276154... |
javascript/reference/global_objects/number/isinteger/index.md | JavaScript - Global Objects - Number - isInteger - Description:
If the target value is an integer, return `true`, otherwise return `false`. If the value is `NaN` or `Infinity`, return `false`. The method will also return `true` for floating point numbers that can be represented as integer. It will always return `false... | [
-1.3435781002044678,
-0.5347899198532104,
-0.5345368385314941,
-0.1391383707523346,
-0.018588565289974213,
-1.4507088661193848,
0.5926084518432617,
0.10471833497285843,
0.04745640605688095,
0.5158883929252625,
-0.7215947508811951,
0.6236552000045776,
-0.010309829376637936,
-0.2551378011703... |
javascript/reference/global_objects/number/isinteger/index.md | JavaScript - Global Objects - Number - isInteger - Examples - Using isInteger:
Example:
Number.isInteger(0); // true
Number.isInteger(1); // true
Number.isInteger(-100000); // true
Number.isInteger(99999999999999999999999); // true
Number.isInteger(0.1); // false
Number.isInteger(Math.PI); // false
Number.isInteger... | [
-0.701428234577179,
-0.19692955911159515,
-0.7313076257705688,
-0.41632306575775146,
-0.325293630361557,
-2.098755121231079,
0.3610524535179138,
-0.07019445300102234,
-0.3447612524032593,
0.004863427486270666,
-1.533862829208374,
-0.3978535234928131,
-0.1258087009191513,
0.1405100226402282... |
javascript/reference/global_objects/number/tostring/index.md | JavaScript - Global Objects - Number - toString:
The `toString()` method of `Number` values returns a string representing this number value.
Example:
function hexColor(c) {
if (c < 256) {
return Math.abs(c).toString(16);
}
return 0;
}
console.log(hexColor(233));
// Expected output: "e9"
console.log(hexCo... | [
-1.3177738189697266,
-0.23061169683933258,
-0.7941964268684387,
-0.08637449890375137,
-0.0810217633843422,
-1.9876999855041504,
-0.4424656629562378,
0.26384514570236206,
-0.5787802338600159,
-0.3546063303947449,
-0.6541505455970764,
0.32634469866752625,
0.2626190781593323,
-0.2138392478227... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.