file stringlengths 16 94 | text stringlengths 32 24.4k | vector list |
|---|---|---|
javascript/reference/global_objects/function/name/index.md | JavaScript - Global Objects - Function - name - Description - Default-exported function declaration:
An `export default` declaration exports the function as a declaration instead of an expression. If the declaration is anonymous, the name is `"default"`.
Example:
// -- someModule.js --
export default function () {}
... | [
-0.8130260109901428,
-0.22500887513160706,
-1.2129656076431274,
0.8676865100860596,
-0.8480441570281982,
-1.4101922512054443,
0.403161883354187,
0.7677944302558899,
-0.2672775089740753,
0.12965893745422363,
-0.8717499375343323,
0.30527263879776,
-0.5266546607017517,
0.24102281033992767,
... |
javascript/reference/global_objects/function/name/index.md | JavaScript - Global Objects - Function - name - Description - Function constructor:
Functions created with the `Function()` constructor have name "anonymous".
Example:
new Function().name; // "anonymous" | [
-1.113375186920166,
-0.19127975404262543,
-1.004073143005371,
0.1948608011007309,
-0.34796759486198425,
-1.8572568893432617,
0.29871848225593567,
0.5622470378875732,
-0.22604848444461823,
-0.27133142948150635,
-0.6990696787834167,
-0.3878236413002014,
-0.6492648720741272,
-0.22591839730739... |
javascript/reference/global_objects/function/name/index.md | JavaScript - Global Objects - Function - name - Description - Function expression:
If the function expression is named, that name is used as the `name` property.
Example:
const someFunction = function someFunctionName() {};
someFunction.name; // "someFunctionName"
Anonymous function expressions, created using eithe... | [
-0.28011268377304077,
0.2621821165084839,
-1.3042833805084229,
0.18156340718269348,
-0.2667110860347748,
-2.3274471759796143,
1.1600682735443115,
0.7040640115737915,
0.1599232703447342,
-0.30367493629455566,
-0.369899719953537,
-0.17803111672401428,
-0.6261346936225891,
-0.3257733881473541... |
javascript/reference/global_objects/function/name/index.md | JavaScript - Global Objects - Function - name - Description - Variable declaration and method:
Variables and methods can infer the name of an anonymous function from its syntactic position.
Example:
const f = function () {};
const object = {
someMethod: function () {},
};
console.log(f.name); // "f"
console.log(o... | [
-0.013920911587774754,
-0.5347588062286377,
-0.6676267385482788,
0.3873519003391266,
0.010764154605567455,
-1.9627386331558228,
0.6711665987968445,
0.4973132312297821,
0.22360381484031677,
-0.2739287316799164,
-0.47467222809791565,
-0.3136683404445648,
-0.40724775195121765,
-0.282099753618... |
javascript/reference/global_objects/function/name/index.md | JavaScript - Global Objects - Function - name - Description - Initializer and default value:
Functions in initializers (default values) of destructuring, default parameters, class fields, etc., will inherit the name of the bound identifier as their `name`.
Example:
const [f = () => {}] = [];
f.name; // "f"
const { ... | [
-0.03518394008278847,
-0.4436725974082947,
-1.8760188817977905,
-0.12203069031238556,
-0.6050173044204712,
-1.843072772026062,
0.3265950381755829,
1.072561264038086,
-0.22655092179775238,
-0.4121156334877014,
-1.3433722257614136,
-0.6634526252746582,
-0.5130505561828613,
-0.140346348285675... |
javascript/reference/global_objects/function/name/index.md | JavaScript - Global Objects - Function - name - Description - Shorthand method:
Example:
const o = {
foo() {},
};
o.foo.name; // "foo"; | [
-0.02745814435184002,
-0.30481311678886414,
-1.5825080871582031,
-0.15218515694141388,
-0.35990580916404724,
-2.166376829147339,
0.4136488437652588,
1.0719529390335083,
-0.522985577583313,
-0.03892102465033531,
-1.0538548231124878,
0.04936928302049637,
0.20936354994773865,
-0.0919168293476... |
javascript/reference/global_objects/function/name/index.md | JavaScript - Global Objects - Function - name - Description - Bound function:
`Function.prototype.bind()` produces a function whose name is "bound " plus the function name.
Example:
function foo() {}
foo.bind({}).name; // "bound foo" | [
-1.2369036674499512,
-0.09245912730693817,
-0.8541318774223328,
-0.2842308580875397,
-0.5435009598731995,
-1.3632770776748657,
0.17050069570541382,
1.029877781867981,
-0.7080695629119873,
-0.08143477886915207,
-1.3069288730621338,
0.014800677075982094,
-0.4159596562385559,
0.21232560276985... |
javascript/reference/global_objects/function/name/index.md | JavaScript - Global Objects - Function - name - Description - Getter and setter:
When using `get` and `set` accessor properties, "get" or "set" will appear in the function name.
Example:
const o = {
get foo() {
return 1;
},
set foo(x) {},
};
const descriptor = Object.getOwnPropertyDescriptor(o, "foo");
de... | [
-0.8868367075920105,
-0.15832267701625824,
-2.1298563480377197,
0.07752547413110733,
-0.6688063740730286,
-1.6043262481689453,
-0.276659220457077,
0.3402058482170105,
0.3039551377296448,
-0.19240820407867432,
-0.5639722943305969,
-0.17131008207798004,
-0.4403294324874878,
0.146882846951484... |
javascript/reference/global_objects/function/name/index.md | JavaScript - Global Objects - Function - name - Description - Class:
A class's name follows the same algorithm as function declarations and expressions.
Example:
class Foo {}
Foo.name; // "Foo"
Warning: JavaScript will set the function's `name` property only if a function does not have an own property called `name`... | [
-0.4017152488231659,
-0.9639703035354614,
-1.225389838218689,
0.7335854768753052,
-0.2195739597082138,
-2.197716474533081,
0.935059666633606,
0.6004796624183655,
-1.034103512763977,
-0.4977555274963379,
-0.5148270130157471,
-0.27516305446624756,
-0.44463789463043213,
-0.6497353911399841,
... |
javascript/reference/global_objects/function/name/index.md | JavaScript - Global Objects - Function - name - Description - Symbol as function name:
If a `Symbol` is used a function name and the symbol has a description, the method's name is the description in square brackets.
Example:
const sym1 = Symbol("foo");
const sym2 = Symbol();
const o = {
[sym1]() {},
[sym2]() {}... | [
-0.20973195135593414,
-0.5428982377052307,
-1.1049476861953735,
-0.45651865005493164,
-0.15568168461322784,
-2.602621555328369,
0.037947747856378555,
0.7139773368835449,
0.21659868955612183,
-0.20105284452438354,
-1.1070265769958496,
0.2976270616054535,
0.3665400445461273,
-0.4134516417980... |
javascript/reference/global_objects/function/name/index.md | JavaScript - Global Objects - Function - name - Description - Private fields and methods:
Private fields and private methods have the hash (`#`) as part of their names.
Example:
class Foo {
#field = () => {};
#method() {}
getNames() {
console.log(this.#field.name);
console.log(this.#method.name);
}
}... | [
-0.09155791252851486,
-0.9402863383293152,
-1.440324306488037,
-0.04880360886454582,
-0.4268258213996887,
-2.1973204612731934,
1.126232385635376,
0.20939642190933228,
-0.49458691477775574,
-0.3628048300743103,
-1.0298681259155273,
0.12863275408744812,
-0.4776555001735687,
-0.48302322626113... |
javascript/reference/global_objects/function/name/index.md | JavaScript - Global Objects - Function - name - Examples - Telling the constructor name of an object:
You can use `obj.constructor.name` to check the "class" of an object.
Example:
function Foo() {} // Or: class Foo {}
const fooInstance = new Foo();
console.log(fooInstance.constructor.name); // "Foo"
However, beca... | [
-0.4061882197856903,
-0.7200659513473511,
-1.4329196214675903,
0.13586299121379852,
0.21385537087917328,
-1.8576833009719849,
0.31048569083213806,
0.6078599095344543,
-0.7027344107627869,
0.3351500630378723,
0.08726824820041656,
-0.007548260968178511,
-0.24516712129116058,
-0.5561878085136... |
javascript/reference/global_objects/function/name/index.md | JavaScript - Global Objects - Function - name - Examples - JavaScript compressors and minifiers:
Warning: Be careful when using the `name` property with source-code transformations, such as those carried out by JavaScript compressors (minifiers) or obfuscators. These tools are often used as part of a JavaScript build ... | [
0.9703842401504517,
-0.33823487162590027,
-1.191568374633789,
0.8335439562797546,
0.9823529720306396,
-1.7654227018356323,
0.6239530444145203,
0.8074495196342468,
-1.1466609239578247,
-0.18072208762168884,
-0.45458829402923584,
-0.45539116859436035,
0.26894962787628174,
-0.2062596082687378... |
javascript/reference/global_objects/function/tostring/index.md | JavaScript - Global Objects - Function - toString:
The `toString()` method of `Function` instances returns a string representing the source code of this function.
Example:
function sum(a, b) {
return a + b;
}
console.log(sum.toString());
// Expected output: "function sum(a, b) {
// return a + ... | [
-0.7373213171958923,
0.054534051567316055,
-1.1463643312454224,
-0.0787116214632988,
0.14288242161273956,
-1.7589821815490723,
-0.02484406903386116,
0.48593470454216003,
-0.4570721983909607,
-0.4146592915058136,
-0.07833658903837204,
0.8775858879089355,
0.36094674468040466,
-0.166273117065... |
javascript/reference/global_objects/function/tostring/index.md | JavaScript - Global Objects - Function - toString - Syntax:
Example:
toString() | [
-1.16876220703125,
0.4314570426940918,
-0.48652997612953186,
-0.19344793260097504,
-0.5061665773391724,
-2.4165544509887695,
0.08726240694522858,
0.4371051788330078,
-0.30375832319259644,
-0.872037410736084,
-0.2719663679599762,
0.2718169391155243,
-0.11884960532188416,
-0.3644612431526184... |
javascript/reference/global_objects/function/tostring/index.md | JavaScript - Global Objects - Function - toString - Syntax - Parameters:
None. | [
-1.0091402530670166,
0.3522551357746124,
-0.6435326337814331,
-0.584303617477417,
-0.47587114572525024,
-1.959502100944519,
0.44556787610054016,
0.4547124207019806,
-0.4385165572166443,
-0.9769733548164368,
-0.9449664354324341,
-0.6382237672805786,
0.05232568457722664,
-0.16386838257312775... |
javascript/reference/global_objects/function/tostring/index.md | JavaScript - Global Objects - Function - toString - Syntax - Return value:
A string representing the source code of the function. | [
-0.8389007449150085,
-0.042406365275382996,
-0.681738018989563,
-0.38130614161491394,
-0.3752160966396332,
-2.2973134517669678,
-0.041645485907793045,
0.666754424571991,
-0.08312317728996277,
-0.6106951832771301,
-0.5163431763648987,
0.6203807592391968,
-0.3526184558868408,
0.4881825745105... |
javascript/reference/global_objects/function/tostring/index.md | JavaScript - Global Objects - Function - toString - Description:
The `Function` object overrides the `toString()` method inherited from `Object`; it does not inherit `Object.prototype.toString`. For user-defined `Function` objects, the `toString` method returns a string containing the source text segment which was use... | [
-0.06847090274095535,
-0.05467071756720543,
-0.4608108699321747,
0.5668487548828125,
1.185056209564209,
-1.519219160079956,
0.45394444465637207,
0.8570870757102966,
-0.9817875027656555,
0.11635611951351166,
-0.24904440343379974,
0.3623042106628418,
0.055606551468372345,
0.42300179600715637... |
javascript/reference/global_objects/function/tostring/index.md | JavaScript - Global Objects - Function - toString - Examples - Comparing actual source code and toString results:
Example:
function test(fn) {
console.log(fn.toString());
}
function f() {}
class A {
a() {}
}
function* g() {}
test(f); // "function f() {}"
test(A); // "class A { a() {} }"
test(g); // "function* g... | [
-0.26311561465263367,
0.056276317685842514,
-0.10608918964862823,
0.061318133026361465,
1.0092886686325073,
-1.5061520338058472,
-0.19656124711036682,
0.2464234083890915,
-0.8033698797225952,
0.03549988940358162,
-0.4042162001132965,
0.4372170567512512,
-0.9197057485580444,
0.3348936438560... |
javascript/reference/global_objects/function/tostring/index.md | JavaScript - Global Objects - Function - toString - Examples - Getting source text of a function:
It is possible to get the source text of a function by coercing it to a string — for example, by wrapping it in a template literal:
Example:
function foo() {
return "bar";
}
console.log(`${foo}`);
// function foo() {
... | [
-0.5284784436225891,
-0.16581478714942932,
-0.00040125951636582613,
0.29586079716682434,
0.8429325222969055,
-1.5676648616790771,
0.6701374650001526,
0.2878934442996979,
-0.7660175561904907,
-0.37219303846359253,
-0.2268998622894287,
-0.37767112255096436,
-0.0746409073472023,
-0.0830065011... |
javascript/reference/global_objects/function/call/index.md | JavaScript - Global Objects - Function - call:
The `call()` method of `Function` instances calls this function with a given `this` value and arguments provided individually.
Example:
function Product(name, price) {
this.name = name;
this.price = price;
}
function Food(name, price) {
Product.call(this, name, p... | [
-0.433795690536499,
-0.2591469883918762,
-0.9951245784759521,
0.981770932674408,
-0.002791857346892357,
-0.9471599459648132,
0.18697187304496765,
0.5383148789405823,
-1.087990403175354,
-0.13525742292404175,
-0.41608500480651855,
-0.1823491007089615,
-0.2006836235523224,
0.2482035458087921... |
javascript/reference/global_objects/function/call/index.md | JavaScript - Global Objects - Function - call - Syntax:
Example:
call(thisArg)
call(thisArg, arg1)
call(thisArg, arg1, arg2)
call(thisArg, arg1, arg2, /* …, */ argN) | [
-0.4683630168437958,
0.9433026909828186,
-0.2817659080028534,
0.14316459000110626,
-0.6266980767250061,
-1.9324347972869873,
-0.0679803341627121,
0.8727149367332458,
-0.5884499549865723,
-0.4278046488761902,
-0.8746475577354431,
-0.06987351924180984,
-0.38016727566719055,
0.065976619720458... |
javascript/reference/global_objects/function/call/index.md | JavaScript - Global Objects - Function - call - Syntax - Parameters:
- `thisArg`: The value to use as `this` when calling `func`. If the function is not in strict mode, `null` and `undefined` will be replaced with the global object, and primitive values will be converted to objects.
- `arg1`, …, `argN` (optional): Arg... | [
-0.3793147802352905,
0.5389693379402161,
-0.5411868095397949,
0.4122145175933838,
-0.5782381296157837,
-2.5481607913970947,
0.6170975565910339,
0.46405237913131714,
0.024294665083289146,
0.035999905318021774,
-1.1083755493164062,
-0.18592184782028198,
-0.15681862831115723,
0.51980251073837... |
javascript/reference/global_objects/function/call/index.md | JavaScript - Global Objects - Function - call - Syntax - Return value:
The result of calling the function with the specified `this` value and arguments. | [
0.061464838683605194,
0.20308548212051392,
-1.0120245218276978,
0.00992698222398758,
-0.7464269995689392,
-1.4253145456314087,
0.18807655572891235,
0.7461026310920715,
-0.12026365846395493,
-0.16587142646312714,
-0.7493048906326294,
1.1391353607177734,
-0.03948616981506348,
0.9209833741188... |
javascript/reference/global_objects/function/call/index.md | JavaScript - Global Objects - Function - call - Description:
Note: This function is almost identical to `apply()`, except that the function arguments are passed to `call()` individually as a list, while for `apply()` they are combined in one object, typically an array — for example, `func.call(this, "eat", "bananas")`... | [
-0.8063222765922546,
0.19923514127731323,
-1.1959182024002075,
0.9550337195396423,
-0.2161535918712616,
-1.2801120281219482,
0.30244144797325134,
0.27703365683555603,
-0.6075336933135986,
0.007931872271001339,
-0.6904105544090271,
0.40493452548980713,
0.5006953477859497,
0.2106885761022567... |
javascript/reference/global_objects/function/call/index.md | JavaScript - Global Objects - Function - call - Examples - Using call() to invoke a function and specifying the this value:
In the example below, when we call `greet`, the value of `this` will be bound to object `obj`, even when `greet` is not a method of `obj`.
Example:
function greet() {
console.log(this.animal,... | [
-1.2109109163284302,
0.2885156571865082,
-1.3853856325149536,
0.16291870176792145,
-0.849055290222168,
-2.0934557914733887,
-0.4474279582500458,
-0.4122241139411926,
-0.6017454266548157,
-0.20794357359409332,
-0.1280696988105774,
0.7553844451904297,
0.24164830148220062,
-0.4465054571628570... |
javascript/reference/global_objects/function/call/index.md | JavaScript - Global Objects - Function - call - Examples - Using call() to invoke a function without specifying the first argument:
If the first `thisArg` parameter is omitted, it defaults to `undefined`. In non-strict mode, the `this` value is then substituted with `globalThis` (which is akin to the global object).
... | [
-0.9097952842712402,
0.5912581086158752,
-0.49449071288108826,
0.5129372477531433,
-0.6185003519058228,
-1.8278710842132568,
0.4725038409233093,
0.3134280741214752,
-0.2596021592617035,
-0.4184340834617615,
-0.4425170123577118,
-0.8191892504692078,
0.36767786741256714,
-0.40654677152633667... |
javascript/reference/global_objects/function/call/index.md | JavaScript - Global Objects - Function - call - Examples - Transforming methods to utility functions:
`call()` is almost equivalent to a normal function call, except that `this` is passed as a normal parameter instead of as the value that the function was accessed on. This is similar to how general-purpose utility fun... | [
-1.0000413656234741,
0.15619423985481262,
-1.1676464080810547,
0.9898515939712524,
0.25457707047462463,
-1.1994143724441528,
0.409061998128891,
-0.03376039117574692,
-0.04929870739579201,
0.6310960650444031,
-0.3763010501861572,
0.5587805509567261,
0.687775194644928,
-0.21199311316013336,
... |
javascript/reference/global_objects/function/function/index.md | JavaScript - Global Objects - Function:
Warning: The arguments passed to this constructor are dynamically parsed and executed as JavaScript. APIs like this are known as injection sinks, and are potentially a vector for cross-site-scripting (XSS) attacks. You can mitigate this risk by always passing `TrustedScript` obj... | [
-0.9184898734092712,
-0.38418349623680115,
-0.8454868793487549,
0.7334542870521545,
0.19983892142772675,
-1.7767164707183838,
-0.49384117126464844,
-0.3523433208465576,
-0.7670943737030029,
0.49832668900489807,
-0.6740168333053589,
0.778880774974823,
-0.05137117952108383,
-0.43383195996284... |
javascript/reference/global_objects/function/function/index.md | JavaScript - Global Objects - Function - Syntax:
Example:
new Function(functionBody)
new Function(arg1, functionBody)
new Function(arg1, arg2, functionBody)
new Function(arg1, arg2, /* …, */ argN, functionBody)
Function(functionBody)
Function(arg1, functionBody)
Function(arg1, arg2, functionBody)
Function(arg1, arg2... | [
-0.5555096864700317,
-0.006045838817954063,
-0.6956074833869934,
0.0871991440653801,
-0.163887619972229,
-2.504132032394409,
-0.7454572916030884,
0.6066005229949951,
-0.24968113005161285,
-0.7835658192634583,
-0.6598871946334839,
-0.4400986135005951,
-0.5648291707038879,
0.5457800030708313... |
javascript/reference/global_objects/function/function/index.md | JavaScript - Global Objects - Function - Syntax - Parameters:
- `arg1`, …, `argN` (optional): `TrustedScript` instances or strings specifying names to be used by the function as formal argument names. The value must correspond to a valid JavaScript parameter (any of plain identifier, rest parameter, or destructured pa... | [
-0.29801955819129944,
-0.09870593249797821,
-0.969237744808197,
0.090069979429245,
0.2470710426568985,
-2.503908157348633,
0.621133029460907,
-1.0627450942993164,
-0.8121230006217957,
-0.07162733376026154,
-0.4156864285469055,
-0.5256386399269104,
-1.2213332653045654,
0.4339527189731598,
... |
javascript/reference/global_objects/function/function/index.md | JavaScript - Global Objects - Function - Syntax - Exceptions:
- `SyntaxError`: Function parameter arguments can't be parsed as a valid parameter list, or the `functionBody` can't be parsed as valid JavaScript statements.
- `TypeError`: Any parameter is a string when Trusted Types are enforced by a CSP and no default p... | [
-0.6201125979423523,
-0.22039690613746643,
-0.8431495428085327,
0.784257709980011,
-0.5094302296638489,
-2.551389694213867,
0.04643075913190842,
0.14206212759017944,
-0.40101805329322815,
-0.1525888592004776,
-0.2863036096096039,
-0.3380894064903259,
-0.11561574786901474,
-0.06928123533725... |
javascript/reference/global_objects/function/function/index.md | JavaScript - Global Objects - Function - Description:
`Function` objects created with the `Function` constructor are parsed when the function is created. This is less efficient than creating a function with a function expression or function declaration and calling it within your code, because such functions are parsed... | [
0.3078124225139618,
0.30909690260887146,
-0.4206574857234955,
0.8045357465744019,
0.7482315301895142,
-1.1824843883514404,
-0.2626095414161682,
0.2442641705274582,
-0.7238588333129883,
0.28250420093536377,
-0.6001908779144287,
-0.3630366027355194,
-0.47579678893089294,
0.7031620740890503,
... |
javascript/reference/global_objects/function/function/index.md | JavaScript - Global Objects - Function - Description - Security considerations:
The method can be used to execute arbitrary input passed to any parameter. If the input is a potentially unsafe string provided by a user, this is a possible vector for Cross-site-scripting (XSS) attacks. For example, the following example... | [
-0.397244930267334,
0.337422251701355,
-0.5325795412063599,
0.7998064756393433,
0.517620325088501,
-0.06949013471603394,
0.23859484493732452,
0.04651886969804764,
-0.11018439382314682,
0.13545094430446625,
0.10249562561511993,
-0.19735023379325867,
-0.4316014051437378,
-0.3700747489929199,... |
javascript/reference/global_objects/function/function/index.md | JavaScript - Global Objects - Function - Examples:
Note that these examples omit the use of trusted types for brevity. For code showing the recommended approach, see Using `TrustedScript` in `eval()`. | [
-1.3975263833999634,
0.40103501081466675,
-0.893622100353241,
0.16608655452728271,
-0.37604111433029175,
-1.0817089080810547,
1.3971045017242432,
-0.09940115362405777,
-0.9245296716690063,
0.36588582396507263,
-0.1681923121213913,
0.40568801760673523,
-0.02344268001616001,
-0.3159283995628... |
javascript/reference/global_objects/function/function/index.md | JavaScript - Global Objects - Function - Examples - Specifying arguments with the Function constructor:
The following code creates a `Function` object that takes two arguments.
Example:
// Example can be run directly in your JavaScript console
// Create a function that takes two arguments, and returns the sum of th... | [
-0.2684696316719055,
-0.41734278202056885,
-1.0799376964569092,
1.3776601552963257,
-0.5534157752990723,
-1.530193567276001,
-0.236589252948761,
-0.07635180652141571,
-0.608658492565155,
-0.42208635807037354,
-0.26238083839416504,
0.15280212461948395,
-0.021341970190405846,
-0.125957742333... |
javascript/reference/global_objects/function/function/index.md | JavaScript - Global Objects - Function - Examples - Creating a function object from a function declaration or function expression:
Example:
// The function constructor can take in multiple statements separated by a semicolon. Function expressions require a return statement with the function's name
// Observe that ne... | [
0.39621981978416443,
0.25956618785858154,
-0.5931783318519592,
0.4868133068084717,
0.8859896063804626,
-0.36538559198379517,
-0.7602750062942505,
0.2248808592557907,
-0.4669873118400574,
-0.19016693532466888,
-0.4921794831752777,
0.20621155202388763,
-0.16540896892547607,
0.451565712690353... |
javascript/reference/global_objects/function/prototype/index.md | JavaScript - Global Objects - Function - prototype:
The `prototype` data property of a `Function` instance is used when the function is used as a constructor with the `new` operator. It will become the new object's prototype.
Note: Not all `Function` objects have the `prototype` property — see description. | [
-0.5156177878379822,
-0.40766969323158264,
-1.156002163887024,
0.7869952321052551,
-0.009406683035194874,
-1.4987276792526245,
-0.10122174769639969,
1.2872986793518066,
0.8425210118293762,
0.14456228911876678,
-1.0034098625183105,
-0.45710524916648865,
-0.29618704319000244,
0.0416947305202... |
javascript/reference/global_objects/function/prototype/index.md | JavaScript - Global Objects - Function - prototype - Value:
An object.
Note: Classes are a type of function, so most of the description here applies to the `prototype` property of classes too. The only salient difference is that the `prototype` property of a class is not writable. | [
-0.2178456336259842,
-0.5929774045944214,
-0.0673307403922081,
-0.2574518322944641,
-0.0039106192998588085,
-1.6350387334823608,
-0.042078230530023575,
1.388650894165039,
0.32151174545288086,
-0.5368393063545227,
-0.6287180781364441,
0.11544118076562881,
-0.5875125527381897,
-0.50273936986... |
javascript/reference/global_objects/function/prototype/index.md | JavaScript - Global Objects - Function - prototype - Description:
When a function is called with `new`, the constructor's `prototype` property will become the resulting object's prototype.
Example:
function Ctor() {}
const inst = new Ctor();
console.log(Object.getPrototypeOf(inst) === Ctor.prototype); // true
You c... | [
0.6594040393829346,
0.14906665682792664,
0.12491176277399063,
1.0210613012313843,
0.9662821888923645,
-1.2055686712265015,
0.27526843547821045,
1.2806357145309448,
-0.6084914803504944,
-0.1573657989501953,
-0.7300986051559448,
0.6120204925537109,
-0.21824978291988373,
0.0601905882358551,
... |
javascript/reference/global_objects/function/prototype/index.md | JavaScript - Global Objects - Function - prototype - Examples - Changing the prototype of all instances by mutating the prototype property:
Example:
function Ctor() {}
const p1 = new Ctor();
const p2 = new Ctor();
Ctor.prototype.prop = 1;
console.log(p1.prop); // 1
console.log(p2.prop); // 1 | [
-0.24638500809669495,
-0.12110308557748795,
-0.3049994111061096,
0.6976155042648315,
-0.5904459953308105,
-1.5899235010147095,
-0.458030104637146,
0.3191443383693695,
0.18323346972465515,
0.23919767141342163,
-0.6619154810905457,
-0.08776139467954636,
-0.6025193929672241,
-0.15482665598392... |
javascript/reference/global_objects/function/prototype/index.md | JavaScript - Global Objects - Function - prototype - Examples - Adding a non-method property to a class's prototype property:
Class fields add properties to each instance. Class methods declare function properties on the prototype. However, there's no way to add a non-function property to the prototype. In case you wa... | [
-0.8311846852302551,
-1.1442034244537354,
-0.9042451977729797,
0.790399968624115,
-0.28627726435661316,
-1.0761868953704834,
0.8002025485038757,
0.7269667387008667,
-0.1701681762933731,
-0.3599691390991211,
-0.404911607503891,
-0.13722725212574005,
-0.04061559960246086,
-0.2921957373619079... |
javascript/reference/global_objects/function/length/index.md | JavaScript - Global Objects - Function - length:
The `length` data property of a `Function` instance indicates the number of parameters expected by the function.
Example:
function func1() {}
function func2(a, b) {}
console.log(func1.length);
// Expected output: 0
console.log(func2.length);
// Expected output: 2 | [
-1.211724042892456,
-0.6879417300224304,
-1.7187515497207642,
0.5859155654907227,
-0.4910086393356323,
-1.6078729629516602,
-0.8057715892791748,
0.20696277916431427,
-0.29893261194229126,
-0.7291905283927917,
-0.7762895822525024,
0.4066731631755829,
0.1454673856496811,
0.40120944380760193,... |
javascript/reference/global_objects/function/length/index.md | JavaScript - Global Objects - Function - length - Value:
A number. | [
-0.3288193643093109,
-0.670433521270752,
-1.4824161529541016,
-0.8516407608985901,
-0.834484338760376,
-1.482072353363037,
0.2567303478717804,
0.2603817880153656,
-0.3292340040206909,
-0.7088109850883484,
-0.9971762299537659,
0.07677841186523438,
-0.41260647773742676,
0.14929735660552979,
... |
javascript/reference/global_objects/function/length/index.md | JavaScript - Global Objects - Function - length - Description:
A `Function` object's `length` property indicates how many arguments the function expects, i.e., the number of formal parameters:
- Only parameters before the first one with a default value are counted.
- A destructuring pattern counts as a single paramet... | [
-1.1145986318588257,
-0.743574857711792,
-1.2266066074371338,
0.5067267417907715,
-0.22170664370059967,
-2.0468556880950928,
-0.41606438159942627,
-0.37518808245658875,
-0.40295010805130005,
-0.46061116456985474,
-1.2756177186965942,
0.01071610115468502,
-0.12679889798164368,
0.35135266184... |
javascript/reference/global_objects/function/length/index.md | JavaScript - Global Objects - Function - length - Examples - Using function length:
Example:
console.log(Function.length); // 1
console.log((() => {}).length); // 0
console.log(((a) => {}).length); // 1
console.log(((a, b) => {}).length); // 2 etc.
console.log(((...args) => {}).length);
// 0, rest parameter is not ... | [
-0.22883062064647675,
-0.24944202601909637,
-1.9455420970916748,
0.11431048810482025,
-0.5575689673423767,
-2.030005693435669,
-0.10459796339273453,
-0.2451438009738922,
-0.5904265642166138,
-0.34749045968055725,
0.07663161307573318,
-0.08968976140022278,
0.14912517368793488,
-0.1870366483... |
javascript/reference/global_objects/function/displayname/index.md | JavaScript - Global Objects - Function - displayName:
Non-standard: This feature is not standardized.
The optional `displayName` property of a `Function` instance specifies the display name of the function. | [
-0.8294044137001038,
0.08524870127439499,
-1.3797669410705566,
-0.38091909885406494,
-1.1333917379379272,
-1.1372809410095215,
-0.07696422189474106,
0.6407211422920227,
-0.5192416310310364,
-0.0976942703127861,
-0.4808571934700012,
-0.16811920702457428,
-0.12486958503723145,
0.313885837793... |
javascript/reference/global_objects/function/displayname/index.md | JavaScript - Global Objects - Function - displayName - Value:
The `displayName` property is not initially present on any function — it's added by the code authors. For the purpose of display, it should be a string. | [
-1.1219158172607422,
-0.2771513760089874,
-1.2533327341079712,
-0.227897509932518,
-0.9259325861930847,
-1.0818418264389038,
0.6915410161018372,
0.2882588803768158,
-0.3138158917427063,
-0.44205325841903687,
-0.14505864679813385,
-0.29316312074661255,
-0.7938843965530396,
-0.21440498530864... |
javascript/reference/global_objects/function/displayname/index.md | JavaScript - Global Objects - Function - displayName - Description:
The `displayName` property, if present, may be preferred by consoles and profilers over the `name` property to be displayed as the name of a function.
Among browsers, only the Firefox console utilizes this property. React devtools also use the `displ... | [
-0.18168173730373383,
-0.3533017933368683,
-0.7722630500793457,
0.890597403049469,
0.046068232506513596,
-0.19487924873828888,
0.6238590478897095,
0.3673568069934845,
0.0988326445221901,
0.35340577363967896,
-0.3076234459877014,
-0.05268457904458046,
-0.5644180774688721,
0.1653857678174972... |
javascript/reference/global_objects/function/displayname/index.md | JavaScript - Global Objects - Function - displayName - Examples - Setting a displayName:
By entering the following in a Firefox console, it should display as something like `function MyFunction()`:
Example:
function a() {}
a.displayName = "MyFunction";
a; // function MyFunction() | [
-0.6373909115791321,
-0.05999818444252014,
-1.0545034408569336,
0.355055570602417,
-0.7654131054878235,
-0.4016241729259491,
0.28609079122543335,
0.5421011447906494,
-0.12863221764564514,
0.1499858796596527,
0.05344667285680771,
-0.23365509510040283,
-0.8111732006072998,
-0.224076405167579... |
javascript/reference/global_objects/function/displayname/index.md | JavaScript - Global Objects - Function - displayName - Examples - Changing displayName dynamically:
You can dynamically change the `displayName` of a function:
Example:
const object = {
// anonymous
someMethod: function someMethod(value) {
someMethod.displayName = `someMethod (${value})`;
},
};
console.lo... | [
-0.498842716217041,
-0.4505392909049988,
-0.6687148809432983,
-0.38210365176200867,
-0.6937310099601746,
-1.6174633502960205,
0.1499093770980835,
0.00708202738314867,
-0.07913524657487869,
-0.4940831959247589,
0.05176442861557007,
-0.35411134362220764,
-0.4983578026294708,
-0.4382433295249... |
javascript/reference/global_objects/function/displayname/index.md | JavaScript - Global Objects - Function - displayName - Examples - Cleaning of displayName:
Firefox devtools would clean up a few common patterns in the `displayName` property before displaying it.
Example:
function foo() {}
function testName(name) {
foo.displayName = name;
console.log(foo);
}
testName("$foo$")... | [
-0.7716633081436157,
-0.25596708059310913,
-1.205357313156128,
-0.00509642343968153,
-0.5781456828117371,
-1.1016443967819214,
0.6458577513694763,
0.2745518386363983,
-1.1160916090011597,
0.4763895273208618,
-0.001618557726033032,
-0.058463361114263535,
-1.083019733428955,
-0.4845109581947... |
javascript/reference/global_objects/function/symbol.hasinstance/index.md | JavaScript - Global Objects - Function - Symbol.hasInstance:
The `[Symbol.hasInstance]()` method of `Function` instances specifies the default procedure for determining if a constructor function recognizes an object as one of the constructor's instances. It is called by the `instanceof` operator. | [
-0.338539183139801,
-0.8127395510673523,
-0.7863155007362366,
0.9657328724861145,
0.1336113065481186,
-1.5647319555282593,
-0.07041838765144348,
0.45935049653053284,
0.41008254885673523,
0.33390986919403076,
-0.9406929612159729,
-0.5026554465293884,
0.8442150950431824,
0.8172565698623657,
... |
javascript/reference/global_objects/function/symbol.hasinstance/index.md | JavaScript - Global Objects - Function - Symbol.hasInstance - Syntax:
Example:
func[Symbol.hasInstance](value) | [
-0.028818095102906227,
-0.046437181532382965,
-0.723588764667511,
-0.037989430129528046,
-0.6789100766181946,
-1.5165221691131592,
0.2213694304227829,
1.6597484350204468,
0.3344285786151886,
-0.45616140961647034,
-0.27270960807800293,
0.33056899905204773,
0.5113347172737122,
0.225546196103... |
javascript/reference/global_objects/function/symbol.hasinstance/index.md | JavaScript - Global Objects - Function - Symbol.hasInstance - Syntax - Parameters:
- `value`: The object to test. Primitive values always return `false`. | [
-0.4545956552028656,
-0.12249304354190826,
-0.8041297197341919,
-0.49535712599754333,
-0.17091257870197296,
-1.7358661890029907,
0.8326135873794556,
0.9255927205085754,
-0.07916723191738129,
0.0777679830789566,
-1.7906101942062378,
0.04847220703959465,
0.3286503553390503,
0.470567256212234... |
javascript/reference/global_objects/function/symbol.hasinstance/index.md | JavaScript - Global Objects - Function - Symbol.hasInstance - Syntax - Return value:
`true` if `func.prototype` is in the prototype chain of `value`; otherwise, `false`. Always returns `false` if `value` is not an object or `this` is not a function. If `this` is a bound function, returns the result of an `instanceof` ... | [
-0.9758360981941223,
-0.22170382738113403,
-0.2168644517660141,
0.056267380714416504,
-0.44040822982788086,
-1.2980791330337524,
0.3582873046398163,
0.9722051024436951,
-0.5549989342689514,
0.09296184778213501,
-0.7765886187553406,
0.5906175971031189,
0.9220982193946838,
0.2149976193904876... |
javascript/reference/global_objects/function/symbol.hasinstance/index.md | JavaScript - Global Objects - Function - Symbol.hasInstance - Syntax - Exceptions:
- `TypeError`: Thrown if `this` is not a bound function and `this.prototype` is not an object. | [
-0.7573288083076477,
-0.316704660654068,
-0.19977819919586182,
0.12777093052864075,
-0.7023223042488098,
-1.442161202430725,
-0.36378544569015503,
1.443091630935669,
-0.1279781311750412,
-0.5069500207901001,
-1.0650311708450317,
-0.015430432744324207,
0.18877501785755157,
-0.38927316665649... |
javascript/reference/global_objects/function/symbol.hasinstance/index.md | JavaScript - Global Objects - Function - Symbol.hasInstance - Description:
The `instanceof` operator calls the `[Symbol.hasInstance]()` method of the right-hand side whenever such a method exists. Because all functions inherit from `Function.prototype` by default, they would all have the `[Symbol.hasInstance]()` metho... | [
-0.6972317695617676,
-0.3269321620464325,
-0.7819337844848633,
0.17312704026699066,
-0.2015600949525833,
-0.5313081741333008,
0.30759620666503906,
1.3671188354492188,
0.49122539162635803,
-0.23305250704288483,
-1.3529298305511475,
-0.12842155992984772,
0.6000762581825256,
0.32322958111763,... |
javascript/reference/global_objects/function/symbol.hasinstance/index.md | JavaScript - Global Objects - Function - Symbol.hasInstance - Examples - Reverting to default instanceof behavior:
You would rarely need to call this method directly. Instead, this method is called by the `instanceof` operator. You should expect the two results to usually be equivalent.
Example:
class Foo {}
const f... | [
-0.1364315152168274,
-0.4870426058769226,
-0.5479658842086792,
0.5329692959785461,
-0.3762354850769043,
-1.419318675994873,
0.08375126123428345,
0.45657411217689514,
-0.47861212491989136,
0.14750410616397858,
-0.7654150128364563,
-0.22744862735271454,
0.47197863459587097,
0.628006458282470... |
javascript/reference/global_objects/function/apply/index.md | JavaScript - Global Objects - Function - apply:
The `apply()` method of `Function` instances calls this function with a given `this` value, and `arguments` provided as an array (or an array-like object).
Example:
const numbers = [5, 6, 2, 3, 7];
const max = Math.max.apply(null, numbers);
console.log(max);
// Expec... | [
-0.026561452075839043,
-0.32818305492401123,
-1.117443561553955,
0.9949592351913452,
-0.25657328963279724,
-0.9845446348190308,
-0.21003179252147675,
0.23703952133655548,
-0.08220982551574707,
-0.18585731089115143,
-0.9285070896148682,
0.49243080615997314,
0.10216553509235382,
0.3795585632... |
javascript/reference/global_objects/function/apply/index.md | JavaScript - Global Objects - Function - apply - Syntax:
Example:
apply(thisArg)
apply(thisArg, argsArray) | [
-0.4021923243999481,
0.5509300231933594,
-0.5344461798667908,
0.2198532223701477,
-0.8709743022918701,
-2.046635150909424,
0.4037085175514221,
0.8344417810440063,
0.043280769139528275,
-0.6846883893013,
-0.9290651082992554,
-0.0048721483908593655,
-0.1275143176317215,
0.30827996134757996,
... |
javascript/reference/global_objects/function/apply/index.md | JavaScript - Global Objects - Function - apply - Syntax - Parameters:
- `thisArg`: The value of `this` provided for the call to `func`. If the function is not in strict mode, `null` and `undefined` will be replaced with the global object, and primitive values will be converted to objects.
- `argsArray` (optional): An ... | [
-0.662662923336029,
-0.014073794707655907,
-0.5614777207374573,
0.43863099813461304,
-0.7161462903022766,
-2.2360317707061768,
0.6224190592765808,
0.37655341625213623,
0.29660531878471375,
-0.16348592936992645,
-1.0889866352081299,
-0.20668530464172363,
-0.0589725524187088,
0.7053474783897... |
javascript/reference/global_objects/function/apply/index.md | JavaScript - Global Objects - Function - apply - Syntax - Return value:
The result of calling the function with the specified `this` value and arguments. | [
-0.007438132539391518,
0.047105949372053146,
-0.9634327292442322,
0.09520812332630157,
-0.852425217628479,
-1.6480774879455566,
0.22128693759441376,
0.5813896059989929,
0.1855834722518921,
-0.36104828119277954,
-0.9346014857292175,
1.0083779096603394,
0.03956648334860802,
1.027457714080810... |
javascript/reference/global_objects/function/apply/index.md | JavaScript - Global Objects - Function - apply - Description:
Note: This function is almost identical to `call()`, except that the function arguments are passed to `call()` individually as a list, while for `apply()` they are combined in one object, typically an array — for example, `func.call(this, "eat", "bananas")`... | [
-0.19647552073001862,
0.19534848630428314,
-0.6458989977836609,
0.8011312484741211,
0.39401304721832275,
-0.8459896445274353,
-0.1354341357946396,
0.5346387624740601,
-0.5893927812576294,
-0.34024757146835327,
-0.6701024174690247,
0.38544195890426636,
-0.05865742638707161,
0.41316771507263... |
javascript/reference/global_objects/function/apply/index.md | JavaScript - Global Objects - Function - apply - Examples - Using apply() to append an array to another:
You can use `Array.prototype.push()` to append an element to an array. Because `push()` accepts a variable number of arguments, you can also push multiple elements at once. But if you pass an array to `push()`, it ... | [
-0.0748862475156784,
0.6631461381912231,
-0.8636756539344788,
0.8133717775344849,
0.10333533585071564,
-0.6407089233398438,
0.03642212972044945,
0.1933431327342987,
-0.17444324493408203,
-0.16451703011989594,
-0.6042913198471069,
0.5126992464065552,
0.011879045516252518,
0.7038314938545227... |
javascript/reference/global_objects/function/apply/index.md | JavaScript - Global Objects - Function - apply - Examples - Using apply() and built-in functions:
Clever usage of `apply()` allows you to use built-in functions for some tasks that would probably otherwise require manually looping over a collection (or using the spread syntax).
For example, we can use `Math.max()` an... | [
0.525506317615509,
0.47075343132019043,
-1.2032794952392578,
0.8714327216148376,
0.5173822045326233,
-0.8841383457183838,
-0.3350938558578491,
0.6468459963798523,
-0.5824596285820007,
-0.2700430452823639,
-0.5440371632575989,
0.7302066683769226,
-0.20035338401794434,
0.4068520963191986,
... |
javascript/reference/global_objects/int32array/index.md | JavaScript - Global Objects - Int32Array:
The `Int32Array` typed array represents an array of 32-bit signed integers in the platform byte order. If control over byte order is needed, use `DataView` instead. The contents are initialized to `0` unless initialization data is explicitly provided. Once established, you can... | [
-0.4603320062160492,
-0.19290019571781158,
-0.5648031830787659,
0.9708170294761658,
0.8468165397644043,
-1.331140398979187,
0.4583515226840973,
1.4096336364746094,
-0.048540305346250534,
0.9576136469841003,
-0.4032873213291168,
-0.09963077306747437,
0.08958741277456284,
-0.0416451171040535... |
javascript/reference/global_objects/int32array/index.md | JavaScript - Global Objects - Int32Array - Constructor:
- `Int32Array()`: Creates a new `Int32Array` object. | [
-0.7560251951217651,
0.23413945734500885,
-0.7710283398628235,
1.0620250701904297,
-0.003907603677362204,
-1.1613497734069824,
-0.8971709609031677,
0.7906200885772705,
0.1487053632736206,
0.14232487976551056,
-0.3315845727920532,
-0.4422093331813812,
-0.07021916657686234,
-0.10771784186363... |
javascript/reference/global_objects/int32array/index.md | JavaScript - Global Objects - Int32Array - Static properties:
Also inherits static properties from its parent `TypedArray`.
- `Int32Array.BYTES_PER_ELEMENT`: Returns a number value of the element size. `4` in the case of `Int32Array`. | [
-0.7008875608444214,
0.7602314352989197,
-0.7794286012649536,
0.5630837678909302,
0.015322703868150711,
-1.5178056955337524,
0.42012709379196167,
0.8155704140663147,
-0.12341935187578201,
-0.004902796354144812,
-0.4479120671749115,
0.567142128944397,
-0.41250455379486084,
-0.20605885982513... |
javascript/reference/global_objects/int32array/index.md | JavaScript - Global Objects - Int32Array - Static methods:
Inherits static methods from its parent `TypedArray`. | [
-0.4488857090473175,
0.2924627363681793,
-0.918134331703186,
0.23824284970760345,
0.07869851589202881,
-1.354947805404663,
0.45430895686149597,
1.6914223432540894,
-0.3825049102306366,
0.11552663147449493,
-0.6761018633842468,
-0.5588106513023376,
-0.4886765480041504,
-0.10593996196985245,... |
javascript/reference/global_objects/int32array/index.md | JavaScript - Global Objects - Int32Array - Instance properties:
Also inherits instance properties from its parent `TypedArray`.
These properties are defined on `Int32Array.prototype` and shared by all `Int32Array` instances.
- `Int32Array.prototype.BYTES_PER_ELEMENT`: Returns a number value of the element size. `4` ... | [
-0.13722312450408936,
0.23072472214698792,
-0.6531899571418762,
0.6676655411720276,
0.1384812444448471,
-1.3895666599273682,
-0.17019125819206238,
0.7056480646133423,
0.3616948127746582,
0.1777501255273819,
-0.5272291898727417,
0.38665351271629333,
-0.7676681280136108,
0.40474119782447815,... |
javascript/reference/global_objects/int32array/index.md | JavaScript - Global Objects - Int32Array - Instance methods:
Inherits instance methods from its parent `TypedArray`. | [
0.024808255955576897,
0.05773413926362991,
-0.5395192503929138,
0.45101767778396606,
-0.24277929961681366,
-1.2058075666427612,
0.4523770213127136,
1.0989983081817627,
-0.4217030704021454,
-0.3773634135723114,
-0.5002089142799377,
-0.2994547486305237,
-0.40112245082855225,
0.32769712805747... |
javascript/reference/global_objects/int32array/index.md | JavaScript - Global Objects - Int32Array - Examples - Different ways to create an Int32Array:
Example:
// From a length
const int32 = new Int32Array(2);
int32[0] = 42;
console.log(int32[0]); // 42
console.log(int32.length); // 2
console.log(int32.BYTES_PER_ELEMENT); // 4
// From an array
const x = new Int32Array([21... | [
0.02612212486565113,
0.3668154180049896,
-0.5380898118019104,
0.9492650032043457,
0.5036393404006958,
-0.8245670199394226,
-1.3854402303695679,
0.20665408670902252,
0.31525588035583496,
0.19145993888378143,
0.46161362528800964,
0.13246706128120422,
-0.3742145895957947,
-0.12468534708023071... |
javascript/reference/global_objects/int32array/int32array/index.md | JavaScript - Global Objects - Int32Array:
The `Int32Array()` constructor creates `Int32Array` objects. The contents are initialized to `0` unless initialization data is explicitly provided. | [
-0.2841176390647888,
0.31212806701660156,
-0.47823411226272583,
1.378330945968628,
-0.18190622329711914,
-1.3578007221221924,
-0.343705415725708,
0.6582949161529541,
-0.14230482280254364,
0.334403932094574,
-0.43651634454727173,
-0.6226006746292114,
-0.3749069571495056,
-0.3781940340995788... |
javascript/reference/global_objects/int32array/int32array/index.md | JavaScript - Global Objects - Int32Array - Syntax:
Example:
new Int32Array()
new Int32Array(length)
new Int32Array(typedArray)
new Int32Array(object)
new Int32Array(buffer)
new Int32Array(buffer, byteOffset)
new Int32Array(buffer, byteOffset, length)
Note: `Int32Array()` can only be constructed with `new`. Attempti... | [
-0.46218109130859375,
0.3284951150417328,
-0.7230614423751831,
0.4369373619556427,
0.16994263231754303,
-1.4417343139648438,
-1.1518409252166748,
0.9189853072166443,
0.4148291051387787,
0.021971261128783226,
0.12189266830682755,
0.057011742144823074,
0.15645115077495575,
0.3181679248809814... |
javascript/reference/global_objects/int32array/int32array/index.md | JavaScript - Global Objects - Int32Array - Syntax - Parameters:
See `TypedArray`. | [
0.22185596823692322,
0.24722100794315338,
-0.6624634861946106,
0.3725825548171997,
-0.13363038003444672,
-0.9665365219116211,
0.01605900004506111,
0.9860342144966125,
0.04913504421710968,
0.2367592751979828,
-0.28266018629074097,
-0.0843764916062355,
0.3502070903778076,
0.27420562505722046... |
javascript/reference/global_objects/int32array/int32array/index.md | JavaScript - Global Objects - Int32Array - Syntax - Exceptions:
See `TypedArray`. | [
-0.1958235800266266,
-0.09342452883720398,
-0.39805492758750916,
0.6344412565231323,
-0.2835802435874939,
-1.421104907989502,
-0.3663500249385834,
1.0922547578811646,
-0.1684785932302475,
0.08808577805757523,
-0.0012186291860416532,
-0.40903180837631226,
0.03532866761088371,
0.258170366287... |
javascript/reference/global_objects/int32array/int32array/index.md | JavaScript - Global Objects - Int32Array - Examples - Different ways to create an Int32Array:
Example:
// From a length
const int32 = new Int32Array(2);
int32[0] = 42;
console.log(int32[0]); // 42
console.log(int32.length); // 2
console.log(int32.BYTES_PER_ELEMENT); // 4
// From an array
const x = new Int32Array([21... | [
0.02612212486565113,
0.3668154180049896,
-0.5380898118019104,
0.9492650032043457,
0.5036393404006958,
-0.8245670199394226,
-1.3854402303695679,
0.20665408670902252,
0.31525588035583496,
0.19145993888378143,
0.46161362528800964,
0.13246706128120422,
-0.3742145895957947,
-0.12468534708023071... |
javascript/reference/global_objects/symbol/tostringtag/index.md | JavaScript - Global Objects - Symbol - toStringTag:
The `Symbol.toStringTag` static data property represents the well-known symbol `Symbol.toStringTag`. `Object.prototype.toString()` looks up this symbol on the `this` value for the property containing a string that represents the type of the object.
Example:
class V... | [
-1.8124196529388428,
-0.5071773529052734,
-0.32813557982444763,
-0.4077067971229553,
0.09709125757217407,
-2.8058888912200928,
-0.21669915318489075,
0.9292017817497253,
0.03474418446421623,
-0.34679174423217773,
-0.7952263951301575,
0.5443778038024902,
-0.09176609665155411,
-0.079142004251... |
javascript/reference/global_objects/symbol/tostringtag/index.md | JavaScript - Global Objects - Symbol - toStringTag - Value:
The well-known symbol `Symbol.toStringTag`. | [
-0.8590453863143921,
0.29282400012016296,
-0.5057997703552246,
-0.5056355595588684,
-0.4544517993927002,
-2.940927743911743,
0.3561062216758728,
0.6385267972946167,
-0.22765089571475983,
-0.8895777463912964,
-0.6610994338989258,
-0.21706387400627136,
-0.105365090072155,
0.2822658121585846,... |
javascript/reference/global_objects/symbol/tostringtag/index.md | JavaScript - Global Objects - Symbol - toStringTag - Examples - Default tags:
Some values do not have `Symbol.toStringTag`, but have special `toString()` representations. For a complete list, see `Object.prototype.toString()`.
Example:
Object.prototype.toString.call("foo"); // "[object String]"
Object.prototype.toSt... | [
-1.7357361316680908,
0.07135053724050522,
-0.6610432863235474,
-0.3531944453716278,
-0.1442941129207611,
-2.694880247116089,
-0.2807808518409729,
-0.052683472633361816,
-0.5603480935096741,
-0.3171257972717285,
-0.26885485649108887,
0.1640404313802719,
0.11935058981180191,
-0.3394210636615... |
javascript/reference/global_objects/symbol/tostringtag/index.md | JavaScript - Global Objects - Symbol - toStringTag - Examples - Built-in toStringTag symbols:
Most built-in objects provide their own `[Symbol.toStringTag]` property. Almost all built-in objects' `[Symbol.toStringTag]` property is not writable, not enumerable, and configurable; the exception is `Iterator`, which is wr... | [
-0.2551438510417938,
0.07214841991662979,
-0.22382156550884247,
0.5869119763374329,
0.40941429138183594,
-1.806514859199524,
0.41136446595191956,
1.2975879907608032,
-0.5624508857727051,
0.451249897480011,
-0.910020649433136,
0.4315769672393799,
-0.0365818589925766,
-0.21522147953510284,
... |
javascript/reference/global_objects/symbol/tostringtag/index.md | JavaScript - Global Objects - Symbol - toStringTag - Examples - Custom tag with toStringTag:
When creating your own class, JavaScript defaults to the "Object" tag:
Example:
class ValidatorClass {}
Object.prototype.toString.call(new ValidatorClass()); // "[object Object]"
Now, with the help of `toStringTag`, you ar... | [
-1.1155259609222412,
-0.5408241748809814,
-0.4361843466758728,
0.00856081023812294,
0.36055922508239746,
-2.6609532833099365,
-0.4924801290035248,
-0.3279149532318115,
-0.7548091411590576,
-0.5966721177101135,
-0.44079041481018066,
0.15332892537117004,
-0.4090815782546997,
-0.0763963535428... |
javascript/reference/global_objects/symbol/tostringtag/index.md | JavaScript - Global Objects - Symbol - toStringTag - Examples - toStringTag available on all DOM prototype objects:
Due to a WebIDL spec change in mid-2020, browsers are adding a `Symbol.toStringTag` property to all DOM prototype objects. For example, to access the `Symbol.toStringTag` property on `HTMLButtonElement`:... | [
-1.6451994180679321,
0.2692683935165405,
0.19986556470394135,
-0.4786057770252228,
-0.25075480341911316,
-2.408933162689209,
-0.10292818397283554,
0.6356634497642517,
-0.22092881798744202,
-0.5615487098693848,
-0.2701018452644348,
0.3811861276626587,
-0.14809344708919525,
-0.31155261397361... |
javascript/reference/global_objects/symbol/symbol.toprimitive/index.md | JavaScript - Global Objects - Symbol - Symbol.toPrimitive:
The `[Symbol.toPrimitive]()` method of `Symbol` values returns this symbol value. | [
-0.8016941547393799,
0.5763103365898132,
-0.11850428581237793,
-0.6233688592910767,
-0.9041415452957153,
-2.3282675743103027,
1.2604479789733887,
1.4904996156692505,
-0.4825027883052826,
-0.25620394945144653,
-1.0768887996673584,
-0.14200206100940704,
0.22196924686431885,
0.404094398021698... |
javascript/reference/global_objects/symbol/symbol.toprimitive/index.md | JavaScript - Global Objects - Symbol - Symbol.toPrimitive - Syntax:
Example:
symbolValue[Symbol.toPrimitive](hint) | [
-0.8592004776000977,
0.5089581608772278,
0.38892805576324463,
-0.3297484815120697,
-0.7974219918251038,
-2.6484525203704834,
0.7572284936904907,
1.1598892211914062,
-0.28317809104919434,
-0.29100239276885986,
-0.8884191513061523,
-0.13823534548282623,
-0.4745815396308899,
0.033212695270776... |
javascript/reference/global_objects/symbol/symbol.toprimitive/index.md | JavaScript - Global Objects - Symbol - Symbol.toPrimitive - Syntax - Parameters:
- `hint`: A string value indicating the primitive value to return. The value is ignored. | [
-0.9532967805862427,
0.07196154445409775,
-0.47950035333633423,
0.22494392096996307,
-0.38338643312454224,
-3.1375436782836914,
1.755737066268921,
1.0446966886520386,
-0.8200434446334839,
-0.0324949212372303,
-1.7243314981460571,
0.21764874458312988,
-0.9509940147399902,
0.5490807890892029... |
javascript/reference/global_objects/symbol/symbol.toprimitive/index.md | JavaScript - Global Objects - Symbol - Symbol.toPrimitive - Syntax - Return value:
The primitive value of the specified `Symbol` object. | [
-0.3158875107765198,
0.43231654167175293,
-0.4515111744403839,
-0.612226665019989,
-0.9191337823867798,
-1.980514645576477,
1.4409958124160767,
1.446519136428833,
-0.021541371941566467,
0.05990925803780556,
-0.9650600552558899,
0.5868867635726929,
-0.821103036403656,
0.8020807504653931,
... |
javascript/reference/global_objects/symbol/symbol.toprimitive/index.md | JavaScript - Global Objects - Symbol - Symbol.toPrimitive - Description:
The `[Symbol.toPrimitive]()` method of `Symbol` returns the primitive value of a Symbol object as a Symbol data type. The `hint` argument is not used.
JavaScript calls the `[Symbol.toPrimitive]()` method to convert an object to a primitive value... | [
-0.9268787503242493,
0.04416918754577637,
-0.40788543224334717,
0.08588054031133652,
-0.44230300188064575,
-2.5239601135253906,
1.8222044706344604,
0.7915661334991455,
-0.4741382300853729,
-0.1630377173423767,
-1.127428412437439,
0.3864475190639496,
-0.519664466381073,
0.11929989606142044,... |
javascript/reference/global_objects/symbol/symbol.toprimitive/index.md | JavaScript - Global Objects - Symbol - Symbol.toPrimitive - Examples - Using `[Symbol.toPrimitive]()`:
Example:
const sym = Symbol("example");
sym === sym[Symbol.toPrimitive](); // true | [
-0.524088978767395,
-0.04915258288383484,
0.1852022260427475,
-0.1539992392063141,
-0.6826311945915222,
-2.387976884841919,
0.6586850881576538,
0.8673651218414307,
-0.09392829239368439,
-0.01673259027302265,
-0.8912148475646973,
0.2062792032957077,
-0.44543999433517456,
-0.2185897827148437... |
javascript/reference/global_objects/symbol/matchall/index.md | JavaScript - Global Objects - Symbol - matchAll:
The `Symbol.matchAll` static data property represents the well-known symbol `Symbol.matchAll`. The `String.prototype.matchAll()` method looks up this symbol on its first argument for the method that returns an iterator, that yields matches of the current object against ... | [
-1.0904872417449951,
-0.11617238074541092,
-0.8975302577018738,
-0.2954336702823639,
0.6603145003318787,
-1.8374452590942383,
0.26245471835136414,
1.3591457605361938,
0.3460100591182709,
0.22325436770915985,
-1.0985873937606812,
0.6759521961212158,
0.4268375039100647,
0.46915820240974426,
... |
javascript/reference/global_objects/symbol/matchall/index.md | JavaScript - Global Objects - Symbol - matchAll - Value:
The well-known symbol `Symbol.matchAll`. | [
0.593021810054779,
0.1462697684764862,
-1.314491868019104,
-0.44952675700187683,
-0.4821690022945404,
-2.0905308723449707,
1.2243314981460571,
1.0496206283569336,
-0.272377610206604,
-0.5243016481399536,
-1.201709270477295,
-0.03438309580087662,
0.25726231932640076,
0.8576470017433167,
0... |
javascript/reference/global_objects/symbol/matchall/index.md | JavaScript - Global Objects - Symbol - matchAll - Examples - Using Symbol.matchAll:
Example:
const str = "2016-01-02|2019-03-07";
const numbers = {
*[Symbol.matchAll](str) {
for (const n of str.matchAll(/\d+/g)) yield n[0];
},
};
console.log(Array.from(str.matchAll(numbers)));
// ["2016", "01", "02", "2019"... | [
-0.5550068616867065,
0.19769147038459778,
-0.9056140184402466,
-0.4122542142868042,
0.2443089485168457,
-1.8685442209243774,
-0.1992078423500061,
0.5184012055397034,
0.06219739839434624,
0.24389377236366272,
-0.034390807151794434,
0.6639364957809448,
-0.039983540773391724,
0.47801312804222... |
javascript/reference/global_objects/symbol/toprimitive/index.md | JavaScript - Global Objects - Symbol - toPrimitive:
The `Symbol.toPrimitive` static data property represents the well-known symbol `Symbol.toPrimitive`. All type coercion algorithms look up this symbol on objects for the method that accepts a preferred type and returns a primitive representation of the object, before ... | [
-0.9392611384391785,
-0.5698460340499878,
-0.2889476418495178,
-0.47371092438697815,
-0.09015090018510818,
-2.2705068588256836,
0.683481752872467,
1.1541320085525513,
-0.04520493373274803,
0.2846241891384125,
-1.6449635028839111,
-0.34961485862731934,
-0.3830448091030121,
-0.15114560723304... |
javascript/reference/global_objects/symbol/toprimitive/index.md | JavaScript - Global Objects - Symbol - toPrimitive - Value:
The well-known symbol `Symbol.toPrimitive`. | [
-0.4899095296859741,
0.40746426582336426,
-0.2580636739730835,
-0.5540168285369873,
-0.7246431112289429,
-2.4021565914154053,
1.054762363433838,
0.937401533126831,
-0.2908175587654114,
-0.32269009947776794,
-1.2085304260253906,
-0.6557392477989197,
-0.5642477869987488,
0.35890886187553406,... |
javascript/reference/global_objects/symbol/toprimitive/index.md | JavaScript - Global Objects - Symbol - toPrimitive - Description:
With the help of the `Symbol.toPrimitive` property (used as a function value), an object can be converted to a primitive value. The function is called with a string argument `hint`, which specifies the preferred type of the result primitive value. The `... | [
-0.6722264289855957,
0.12080898135900497,
-0.5340803265571594,
-0.3168468475341797,
0.17524658143520355,
-2.461588144302368,
0.8120607733726501,
0.2755988538265228,
0.013757633045315742,
0.44524624943733215,
-1.358871340751648,
-0.10052715241909027,
-0.8914720416069031,
-0.1020829305052757... |
javascript/reference/global_objects/symbol/toprimitive/index.md | JavaScript - Global Objects - Symbol - toPrimitive - Examples - Modifying primitive values converted from an object:
Following example describes how `Symbol.toPrimitive` property can modify the primitive value converted from an object.
Example:
// An object without Symbol.toPrimitive property.
const obj1 = {};
conso... | [
-0.6442159414291382,
0.20298783481121063,
-0.24714885652065277,
0.08128277212381363,
-0.5361705422401428,
-2.828348159790039,
0.6741752624511719,
0.5686593651771545,
-0.09843836724758148,
-0.2280808836221695,
-1.1956068277359009,
-0.5028116703033447,
-1.2227205038070679,
-0.380224615335464... |
javascript/reference/global_objects/symbol/replace/index.md | JavaScript - Global Objects - Symbol - replace:
The `Symbol.replace` static data property represents the well-known symbol `Symbol.replace`. The `String.prototype.replace()` and `String.prototype.replaceAll()` methods look up this symbol on their first argument for the method that replaces substrings matched by the cu... | [
-0.5545068979263306,
-0.16849136352539062,
-0.79628986120224,
-0.0780627503991127,
-0.01853799819946289,
-2.6928229331970215,
0.3041246235370636,
1.4336731433868408,
0.7215626835823059,
-0.5356324315071106,
-0.7142236828804016,
-0.14154799282550812,
-0.18001781404018402,
0.2799166440963745... |
javascript/reference/global_objects/symbol/replace/index.md | JavaScript - Global Objects - Symbol - replace - Value:
The well-known symbol `Symbol.replace`. | [
0.37235695123672485,
0.4493209719657898,
-0.6929963827133179,
-0.49378523230552673,
-0.7228063344955444,
-2.609619379043579,
0.42069101333618164,
1.3949031829833984,
0.3159070611000061,
-1.2345845699310303,
-0.3875774145126343,
-0.018275978043675423,
-0.4953776001930237,
0.7517184019088745... |
javascript/reference/global_objects/symbol/replace/index.md | JavaScript - Global Objects - Symbol - replace - Examples - Using Symbol.replace:
Example:
class CustomReplacer {
constructor(value) {
this.value = value;
}
[Symbol.replace](string) {
return string.replace(this.value, "#!@?");
}
}
console.log("football".replace(new CustomReplacer("foo"))); // "#!@?tb... | [
-0.03575846180319786,
-0.05403883755207062,
-0.5443630218505859,
0.31521672010421753,
-0.13493981957435608,
-2.6023571491241455,
0.35816463828086853,
1.264454960823059,
-0.13060127198696136,
-0.6299801468849182,
0.44498103857040405,
0.19591191411018372,
-0.38490140438079834,
-0.34948229789... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.