{"index":"<h1>JavaScript</h1> <p>This part of the JavaScript section on MDN serves as a repository of facts about the JavaScript language. Read more <a href=\"about\">about this reference</a>.</p> <h2 id=\"Global_objects\">Global objects</h2> <p>This chapter documents all the <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects\">JavaScript standard built-in objects</a>, along with their methods and properties.</p> <h3 id=\"Value_properties\">Value properties</h3> <p>These global properties return a simple value; they have no properties or methods.</p> <ul> <li><a href=\"global_objects/infinity\"><code>Infinity</code></a></li> <li><a href=\"global_objects/nan\"><code>NaN</code></a></li> <li><a href=\"global_objects/undefined\"><code>undefined</code></a></li> <li>\n<a href=\"global_objects/null\"><code>null</code></a> literal</li> </ul> <h3 id=\"Function_properties\">Function properties</h3> <p>These global functions—functions which are called globally rather than on an object—directly return their results to the caller.</p> <ul> <li><a href=\"global_objects/eval\"><code>eval()</code></a></li> <li>\n<a href=\"global_objects/uneval\"><code>uneval()</code></a> \n</li> <li><a href=\"global_objects/isfinite\"><code>isFinite()</code></a></li> <li><a href=\"global_objects/isnan\"><code>isNaN()</code></a></li> <li><a href=\"global_objects/parsefloat\"><code>parseFloat()</code></a></li> <li><a href=\"global_objects/parseint\"><code>parseInt()</code></a></li> <li><a href=\"global_objects/decodeuri\"><code>decodeURI()</code></a></li> <li><a href=\"global_objects/decodeuricomponent\"><code>decodeURIComponent()</code></a></li> <li><a href=\"global_objects/encodeuri\"><code>encodeURI()</code></a></li> <li><a href=\"global_objects/encodeuricomponent\"><code>encodeURIComponent()</code></a></li> <li>\n<a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/escape\"><code>escape()</code></a> \n</li> <li>\n<a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/unescape\"><code>unescape()</code></a> \n</li> </ul> <h3 id=\"Fundamental_objects\">Fundamental objects</h3> <p>These are the fundamental, basic objects upon which all other objects are based. This includes objects that represent general objects, functions, and errors.</p> <ul> <li><a href=\"global_objects/object\"><code>Object</code></a></li> <li><a href=\"global_objects/function\"><code>Function</code></a></li> <li><a href=\"global_objects/boolean\"><code>Boolean</code></a></li> <li><a href=\"global_objects/symbol\"><code>Symbol</code></a></li> <li><a href=\"global_objects/error\"><code>Error</code></a></li> <li><a href=\"global_objects/evalerror\"><code>EvalError</code></a></li> <li><a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/InternalError\"><code>InternalError</code></a></li> <li><a href=\"global_objects/rangeerror\"><code>RangeError</code></a></li> <li><a href=\"global_objects/referenceerror\"><code>ReferenceError</code></a></li> <li><a href=\"global_objects/syntaxerror\"><code>SyntaxError</code></a></li> <li><a href=\"global_objects/typeerror\"><code>TypeError</code></a></li> <li><a href=\"global_objects/urierror\"><code>URIError</code></a></li> </ul> <h3 id=\"Numbers_and_dates\">Numbers and dates</h3> <p>These are the base objects representing numbers, dates, and mathematical calculations.</p> <ul> <li><a href=\"global_objects/number\"><code>Number</code></a></li> <li><a href=\"global_objects/math\"><code>Math</code></a></li> <li><a href=\"global_objects/date\"><code>Date</code></a></li> </ul> <h3 id=\"Text_processing\">Text processing</h3> <p>These objects represent strings and support manipulating them.</p> <ul> <li><a href=\"global_objects/string\"><code>String</code></a></li> <li><a href=\"global_objects/regexp\"><code>RegExp</code></a></li> </ul> <h3 id=\"Indexed_collections\">Indexed collections</h3> <p>These objects represent collections of data which are ordered by an index value. This includes (typed) arrays and array-like constructs.</p> <ul> <li><a href=\"global_objects/array\"><code>Array</code></a></li> <li><a href=\"global_objects/int8array\"><code>Int8Array</code></a></li> <li><a href=\"global_objects/uint8array\"><code>Uint8Array</code></a></li> <li><a href=\"global_objects/uint8clampedarray\"><code>Uint8ClampedArray</code></a></li> <li><a href=\"global_objects/int16array\"><code>Int16Array</code></a></li> <li><a href=\"global_objects/uint16array\"><code>Uint16Array</code></a></li> <li><a href=\"global_objects/int32array\"><code>Int32Array</code></a></li> <li><a href=\"global_objects/uint32array\"><code>Uint32Array</code></a></li> <li><a href=\"global_objects/float32array\"><code>Float32Array</code></a></li> <li><a href=\"global_objects/float64array\"><code>Float64Array</code></a></li> </ul> <h3 id=\"Keyed_collections\">Keyed collections</h3> <p>These objects represent collections which use keys; these contain elements which are iterable in the order of insertion.</p> <ul> <li><a href=\"global_objects/map\"><code>Map</code></a></li> <li><a href=\"global_objects/set\"><code>Set</code></a></li> <li><a href=\"global_objects/weakmap\"><code>WeakMap</code></a></li> <li><a href=\"global_objects/weakset\"><code>WeakSet</code></a></li> </ul> <h3 id=\"Structured_data\">Structured data</h3> <p>These objects represent and interact with structured data buffers and data coded using JavaScript Object Notation (JSON).</p> <ul> <li><a href=\"global_objects/arraybuffer\"><code>ArrayBuffer</code></a></li> <li>\n<a href=\"global_objects/sharedarraybuffer\"><code>SharedArrayBuffer</code></a> \n</li> <li>\n<a href=\"global_objects/atomics\"><code>Atomics</code></a> \n</li> <li><a href=\"global_objects/dataview\"><code>DataView</code></a></li> <li><a href=\"global_objects/json\"><code>JSON</code></a></li> </ul> <h3 id=\"Control_abstraction_objects\">Control abstraction objects</h3> <ul> <li><a href=\"global_objects/promise\"><code>Promise</code></a></li> <li><a href=\"global_objects/generator\"><code>Generator</code></a></li> <li><a href=\"global_objects/generatorfunction\"><code>GeneratorFunction</code></a></li> <li>\n <a href=\"global_objects/asyncfunction\"><code>AsyncFunction</code></a>\n</li> </ul> <h3 id=\"Reflection\">Reflection</h3> <ul> <li><a href=\"global_objects/reflect\"><code>Reflect</code></a></li> <li><a href=\"global_objects/proxy\"><code>Proxy</code></a></li> </ul> <h3 id=\"Internationalization\">Internationalization</h3> <p>Additions to the ECMAScript core for language-sensitive functionalities.</p> <ul> <li><a href=\"global_objects/intl\"><code>Intl</code></a></li> <li><a href=\"global_objects/collator\"><code>Intl.Collator</code></a></li> <li><a href=\"global_objects/datetimeformat\"><code>Intl.DateTimeFormat</code></a></li> <li><a href=\"global_objects/numberformat\"><code>Intl.NumberFormat</code></a></li> </ul> <h3 id=\"WebAssembly\">WebAssembly</h3> <ul> <li><a href=\"global_objects/webassembly\"><code>WebAssembly</code></a></li> <li><a href=\"global_objects/webassembly/module\"><code>WebAssembly.Module</code></a></li> <li><a href=\"global_objects/webassembly/instance\"><code>WebAssembly.Instance</code></a></li> <li><a href=\"global_objects/webassembly/memory\"><code>WebAssembly.Memory</code></a></li> <li><a href=\"global_objects/webassembly/table\"><code>WebAssembly.Table</code></a></li> <li><a href=\"global_objects/webassembly/compileerror\"><code>WebAssembly.CompileError</code></a></li> <li><a href=\"global_objects/webassembly/linkerror\"><code>WebAssembly.LinkError</code></a></li> <li><a href=\"global_objects/webassembly/runtimeerror\"><code>WebAssembly.RuntimeError</code></a></li> </ul> <h3 id=\"Other\">Other</h3> <ul> <li><code><a href=\"functions/arguments\">arguments</a></code></li> </ul> <h2 id=\"Statements\">Statements</h2> <p>This chapter documents all the <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements\">JavaScript statements and declarations</a>.</p> <p>For an alphabetical listing see the sidebar on the left.</p> <h3 id=\"Control_flow\">Control flow</h3> <dl> <dt><a href=\"statements/block\"><code>Block</code></a></dt> <dd>A block statement is used to group zero or more statements. The block is delimited by a pair of curly brackets.</dd> <dt><a href=\"statements/break\"><code>break</code></a></dt> <dd>Terminates the current loop, switch, or label statement and transfers program control to the statement following the terminated statement.</dd> <dt><a href=\"statements/continue\"><code>continue</code></a></dt> <dd>Terminates execution of the statements in the current iteration of the current or labeled loop, and continues execution of the loop with the next iteration.</dd> <dt><a href=\"statements/empty\"><code>Empty</code></a></dt> <dd>An empty statement is used to provide no statement, although the JavaScript syntax would expect one.</dd> <dt><a href=\"statements/if...else\"><code>if...else</code></a></dt> <dd>Executes a statement if a specified condition is true. If the condition is false, another statement can be executed.</dd> <dt><a href=\"statements/switch\"><code>switch</code></a></dt> <dd>Evaluates an expression, matching the expression's value to a case clause, and executes statements associated with that case.</dd> <dt><a href=\"statements/throw\"><code>throw</code></a></dt> <dd>Throws a user-defined exception.</dd> <dt><a href=\"statements/try...catch\"><code>try...catch</code></a></dt> <dd>Marks a block of statements to try, and specifies a response, should an exception be thrown.</dd> </dl> <h3 id=\"Declarations\">Declarations</h3> <dl> <dt><a href=\"statements/var\"><code>var</code></a></dt> <dd>Declares a variable, optionally initializing it to a value.</dd> <dt><a href=\"statements/let\"><code>let</code></a></dt> <dd>Declares a block scope local variable, optionally initializing it to a value.</dd> <dt><a href=\"statements/const\"><code>const</code></a></dt> <dd>Declares a read-only named constant.</dd> </dl> <h3 id=\"Functions_and_classes\">Functions and classes</h3> <dl> <dt><a href=\"statements/function\"><code>function</code></a></dt> <dd>Declares a function with the specified parameters.</dd> <dt><a href=\"statements/function*\"><code>function*</code></a></dt> <dd>Generator Functions enable writing <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/The_Iterator_protocol\">iterators</a> more easily.</dd> <dt><a href=\"statements/async_function\"><code>async function</code></a></dt> <dd>Declares an async function with the specified parameters.</dd> <dt><a href=\"statements/return\"><code>return</code></a></dt> <dd>Specifies the value to be returned by a function.</dd> <dt><a href=\"statements/class\"><code>class</code></a></dt> <dd>Declares a class.</dd> </dl> <h3 id=\"Iterations\">Iterations</h3> <dl> <dt><a href=\"statements/do...while\"><code>do...while</code></a></dt> <dd>Creates a loop that executes a specified statement until the test condition evaluates to false. The condition is evaluated after executing the statement, resulting in the specified statement executing at least once.</dd> <dt><a href=\"statements/for\"><code>for</code></a></dt> <dd>Creates a loop that consists of three optional expressions, enclosed in parentheses and separated by semicolons, followed by a statement executed in the loop.</dd> <dt>\n  <a href=\"statements/for_each...in\"><code>for each...in</code></a>\n</dt> <dd>Iterates a specified variable over all values of object's properties. For each distinct property, a specified statement is executed.</dd> <dt><a href=\"statements/for...in\"><code>for...in</code></a></dt> <dd>Iterates over the enumerable properties of an object, in arbitrary order. For each distinct property, statements can be executed.</dd> <dt><a href=\"statements/for...of\"><code>for...of</code></a></dt> <dd>Iterates over iterable objects (including <a href=\"global_objects/array\">arrays</a>, array-like objects, <a href=\"https://developer.mozilla.org/en-US/docs/JavaScript/Guide/Iterators_and_Generators\">iterators and generators</a>), invoking a custom iteration hook with statements to be executed for the value of each distinct property.</dd> <dt><a href=\"statements/for-await...of\"><code>for await...of</code></a></dt> <dd>Iterates over async iterable objects, array-like objects, <a href=\"https://developer.mozilla.org/en-US/docs/JavaScript/Guide/Iterators_and_Generators\">iterators and generators</a>, invoking a custom iteration hook with statements to be executed for the value of each distinct property.</dd> <dt><a href=\"statements/while\"><code>while</code></a></dt> <dd>Creates a loop that executes a specified statement as long as the test condition evaluates to true. The condition is evaluated before executing the statement.</dd> </dl> <h3 id=\"Others\">Others</h3> <dl> <dt><a href=\"statements/debugger\"><code>debugger</code></a></dt> <dd>Invokes any available debugging functionality. If no debugging functionality is available, this statement has no effect.</dd> <dt><a href=\"statements/export\"><code>export</code></a></dt> <dd>Used to export functions to make them available for imports in external modules, and other scripts.</dd> <dt><a href=\"statements/import\"><code>import</code></a></dt> <dd>Used to import functions exported from an external module, another script.</dd> <dt><code><a href=\"statements/import.meta\">import.meta</a></code></dt> <dd>A meta-property exposing context-specific metadata to a JavaScript module.</dd> <dt><a href=\"statements/label\"><code>label</code></a></dt> <dd>Provides a statement with an identifier that you can refer to using a <code>break</code> or <code>continue</code> statement.</dd> </dl> <dl> <dt>\n <a href=\"statements/with\"><code>with</code></a>\n</dt> <dd>Extends the scope chain for a statement.</dd> </dl> <h2 id=\"Expressions_and_operators\">Expressions and operators</h2> <p>This chapter documents all the <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators\">JavaScript expressions and operators</a>. </p> <p>For an alphabetical listing see the sidebar on the left.</p> <h3 id=\"Primary_expressions\">Primary expressions</h3> <p>Basic keywords and general expressions in JavaScript.</p> <dl> <dt><a href=\"operators/this\"><code>this</code></a></dt> <dd>The <code>this</code> keyword refers to a special property of an execution context.</dd> <dt><a href=\"operators/function\"><code>function</code></a></dt> <dd>The <code>function</code> keyword defines a function expression.</dd> <dt><a href=\"operators/class\"><code>class</code></a></dt> <dd>The <code>class</code> keyword defines a class expression.</dd> <dt><a href=\"operators/function*\"><code>function*</code></a></dt> <dd>The <code>function*</code> keyword defines a generator function expression.</dd> <dt><a href=\"operators/yield\"><code>yield</code></a></dt> <dd>Pause and resume a generator function.</dd> <dt><a href=\"operators/yield*\"><code>yield*</code></a></dt> <dd>Delegate to another generator function or iterable object.</dd> <dt><a href=\"operators/async_function\"><code>async function</code></a></dt> <dd>The <code>async function</code> defines an async function expression.</dd> <dt><a href=\"operators/await\"><code>await</code></a></dt> <dd>Pause and resume an async function and wait for the promise's resolution/rejection.</dd> <dt><a href=\"global_objects/array\"><code>[]</code></a></dt> <dd>Array initializer/literal syntax.</dd> <dt><a href=\"operators/object_initializer\"><code>{}</code></a></dt> <dd>Object initializer/literal syntax.</dd> <dt><a href=\"global_objects/regexp\"><code>/ab+c/i</code></a></dt> <dd>Regular expression literal syntax.</dd> <dt><a href=\"operators/grouping\"><code>( )</code></a></dt> <dd>Grouping operator.</dd> </dl> <h3 id=\"Left-hand-side_expressions\">Left-hand-side expressions</h3> <p>Left values are the destination of an assignment.</p> <dl> <dt><a href=\"operators/property_accessors\">Property accessors</a></dt> <dd>Member operators provide access to a property or method of an object<br> (<code>object.property</code> and <code>object[\"property\"]</code>).</dd> <dt><a href=\"operators/new\"><code>new</code></a></dt> <dd>The <code>new</code> operator creates an instance of a constructor.</dd> <dt><a href=\"operators/new.target\">new.target</a></dt> <dd>In constructors, <code>new.target</code> refers to the constructor that was invoked by <a href=\"operators/new\"><code>new</code></a>.</dd> <dt><a href=\"operators/super\"><code>super</code></a></dt> <dd>The <code>super</code> keyword calls the parent constructor.</dd> <dt><a href=\"operators/spread_syntax\"><code>...obj</code></a></dt> <dd>Spread syntax allows an expression to be expanded in places where multiple arguments (for function calls) or multiple elements (for array literals) are expected.</dd> </dl> <h3 id=\"Increment_and_decrement\">Increment and decrement</h3> <p>Postfix/prefix increment and postfix/prefix decrement operators.</p> <dl> <dt><a href=\"operators/arithmetic_operators#Increment\"><code>A++</code></a></dt> <dd>Postfix increment operator.</dd> <dt><a href=\"operators/arithmetic_operators#Decrement\"><code>A--</code></a></dt> <dd>Postfix decrement operator.</dd> <dt><a href=\"operators/arithmetic_operators#Increment\"><code>++A</code></a></dt> <dd>Prefix increment operator.</dd> <dt><a href=\"operators/arithmetic_operators#Decrement\"><code>--A</code></a></dt> <dd>Prefix decrement operator.</dd> </dl> <h3 id=\"Unary_operators\">Unary operators</h3> <p>A unary operation is operation with only one operand.</p> <dl> <dt><a href=\"operators/delete\"><code>delete</code></a></dt> <dd>The <code>delete</code> operator deletes a property from an object.</dd> <dt><a href=\"operators/void\"><code>void</code></a></dt> <dd>The <code>void</code> operator discards an expression's return value.</dd> <dt><a href=\"operators/typeof\"><code>typeof</code></a></dt> <dd>The <code>typeof</code> operator determines the type of a given object.</dd> <dt><a href=\"operators/arithmetic_operators#Unary_plus\"><code>+</code></a></dt> <dd>The unary plus operator converts its operand to Number type.</dd> <dt><a href=\"operators/arithmetic_operators#Unary_negation\"><code>-</code></a></dt> <dd>The unary negation operator converts its operand to Number type and then negates it.</dd> <dt><a href=\"operators/bitwise_operators#Bitwise_NOT\"><code>~</code></a></dt> <dd>Bitwise NOT operator.</dd> <dt><a href=\"operators/logical_operators#Logical_NOT\"><code>!</code></a></dt> <dd>Logical NOT operator.</dd> </dl> <h3 id=\"Arithmetic_operators\">Arithmetic operators</h3> <p>Arithmetic operators take numerical values (either literals or variables) as their operands and return a single numerical value.</p> <dl> <dt><a href=\"operators/arithmetic_operators#Addition\"><code>+</code></a></dt> <dd>Addition operator.</dd> <dt><a href=\"operators/arithmetic_operators#Subtraction\"><code>-</code></a></dt> <dd>Subtraction operator.</dd> <dt><a href=\"operators/arithmetic_operators#Division\"><code>/</code></a></dt> <dd>Division operator.</dd> <dt><a href=\"operators/arithmetic_operators#Multiplication\"><code>*</code></a></dt> <dd>Multiplication operator.</dd> <dt><a href=\"operators/arithmetic_operators#Remainder\"><code>%</code></a></dt> <dd>Remainder operator.</dd> </dl> <dl> <dt><a href=\"operators/arithmetic_operators#Exponentiation\"><code>**</code></a></dt> <dd>Exponentiation operator.</dd> </dl> <h3 id=\"Relational_operators\">Relational operators</h3> <p>A comparison operator compares its operands and returns a <code>Boolean</code> value based on whether the comparison is true.</p> <dl> <dt><a href=\"operators/in\"><code>in</code></a></dt> <dd>The <code>in</code> operator determines whether an object has a given property.</dd> <dt><a href=\"operators/instanceof\"><code>instanceof</code></a></dt> <dd>The <code>instanceof</code> operator determines whether an object is an instance of another object.</dd> <dt><a href=\"operators/comparison_operators#Less_than_operator\"><code>&lt;</code></a></dt> <dd>Less than operator.</dd> <dt><a href=\"operators/comparison_operators#Greater_than_operator\"><code>&gt;</code></a></dt> <dd>Greater than operator.</dd> <dt><a href=\"operators/comparison_operators#Less_than_or_equal_operator\"><code>&lt;=</code></a></dt> <dd>Less than or equal operator.</dd> <dt><a href=\"operators/comparison_operators#Greater_than_or_equal_operator\"><code>&gt;=</code></a></dt> <dd>Greater than or equal operator.</dd> </dl> <div class=\"note\"> <p><strong>Note: =&gt;</strong> is not an operator, but the notation for <a href=\"functions/arrow_functions\">Arrow functions</a>.</p> </div> <h3 id=\"Equality_operators\">Equality operators</h3> <p>The result of evaluating an equality operator is always of type <code>Boolean</code> based on whether the comparison is true.</p> <dl> <dt><a href=\"operators/comparison_operators#Equality\"><code>==</code></a></dt> <dd>Equality operator.</dd> <dt><a href=\"operators/comparison_operators#Inequality\"><code>!=</code></a></dt> <dd>Inequality operator.</dd> <dt><a href=\"operators/comparison_operators#Identity\"><code>===</code></a></dt> <dd>Identity operator.</dd> <dt><a href=\"operators/comparison_operators#Nonidentity\"><code>!==</code></a></dt> <dd>Nonidentity operator.</dd> </dl> <h3 id=\"Bitwise_shift_operators\">Bitwise shift operators</h3> <p>Operations to shift all bits of the operand.</p> <dl> <dt><a href=\"operators/bitwise_operators#Left_shift\"><code>&lt;&lt;</code></a></dt> <dd>Bitwise left shift operator.</dd> <dt><a href=\"operators/bitwise_operators#Right_shift\"><code>&gt;&gt;</code></a></dt> <dd>Bitwise right shift operator.</dd> <dt><a href=\"operators/bitwise_operators#Unsigned_right_shift\"><code>&gt;&gt;&gt;</code></a></dt> <dd>Bitwise unsigned right shift operator.</dd> </dl> <h3 id=\"Binary_bitwise_operators\">Binary bitwise operators</h3> <p>Bitwise operators treat their operands as a set of 32 bits (zeros and ones) and return standard JavaScript numerical values.</p> <dl> <dt><a href=\"operators/bitwise_operators#Bitwise_AND\"><code>&amp;</code></a></dt> <dd>Bitwise AND.</dd> <dt><a href=\"operators/bitwise_operators#Bitwise_OR\"><code>|</code></a></dt> <dd>Bitwise OR.</dd> <dt><a href=\"operators/bitwise_operators#Bitwise_XOR\"><code>^</code></a></dt> <dd>Bitwise XOR.</dd> </dl> <h3 id=\"Binary_logical_operators\">Binary logical operators</h3> <p>Logical operators are typically used with boolean (logical) values, and when they are, they return a boolean value.</p> <dl> <dt><a href=\"operators/logical_operators#Logical_AND\"><code>&amp;&amp;</code></a></dt> <dd>Logical AND.</dd> <dt><a href=\"operators/logical_operators#Logical_OR\"><code>||</code></a></dt> <dd>Logical OR.</dd> </dl> <h3 id=\"Conditional_(ternary)_operator\">Conditional (ternary) operator</h3> <dl> <dt><a href=\"operators/conditional_operator\"><code>(condition ? ifTrue : ifFalse)</code></a></dt> <dd> <p>The conditional operator returns one of two values based on the logical value of the condition.</p> </dd> </dl> <h3 id=\"Assignment_operators\">Assignment operators</h3> <p>An assignment operator assigns a value to its left operand based on the value of its right operand.</p> <dl> <dt><a href=\"operators/assignment_operators#Assignment\"><code>=</code></a></dt> <dd>Assignment operator.</dd> <dt><a href=\"operators/assignment_operators#Multiplication_assignment\"><code>*=</code></a></dt> <dd>Multiplication assignment.</dd> <dt><a href=\"operators/assignment_operators#Division_assignment\"><code>/=</code></a></dt> <dd>Division assignment.</dd> <dt><a href=\"operators/assignment_operators#Remainder_assignment\"><code>%=</code></a></dt> <dd>Remainder assignment.</dd> <dt><a href=\"operators/assignment_operators#Addition_assignment\"><code>+=</code></a></dt> <dd>Addition assignment.</dd> <dt><a href=\"operators/assignment_operators#Subtraction_assignment\"><code>-=</code></a></dt> <dd>Subtraction assignment</dd> <dt><a href=\"operators/assignment_operators#Left_shift_assignment\"><code>&lt;&lt;=</code></a></dt> <dd>Left shift assignment.</dd> <dt><a href=\"operators/assignment_operators#Right_shift_assignment\"><code>&gt;&gt;=</code></a></dt> <dd>Right shift assignment.</dd> <dt><a href=\"operators/assignment_operators#Unsigned_right_shift_assignment\"><code>&gt;&gt;&gt;=</code></a></dt> <dd>Unsigned right shift assignment.</dd> <dt><a href=\"operators/assignment_operators#Bitwise_AND_assignment\"><code>&amp;=</code></a></dt> <dd>Bitwise AND assignment.</dd> <dt><a href=\"operators/assignment_operators#Bitwise_XOR_assignment\"><code>^=</code></a></dt> <dd>Bitwise XOR assignment.</dd> <dt><a href=\"operators/assignment_operators#Bitwise_OR_assignment\"><code>|=</code></a></dt> <dd>Bitwise OR assignment.</dd> <dt>\n<a href=\"operators/destructuring_assignment\"><code>[a, b] = [1, 2]</code></a><br> <a href=\"operators/destructuring_assignment\"><code>{a, b} = {a:1, b:2}</code></a>\n</dt> <dd> <p>Destructuring assignment allows you to assign the properties of an array or object to variables using syntax that looks similar to array or object literals.</p> </dd> </dl> <h3 id=\"Comma_operator\">Comma operator</h3> <dl> <dt><a href=\"operators/comma_operator\"><code>,</code></a></dt> <dd>The comma operator allows multiple expressions to be evaluated in a single statement and returns the result of the last expression.</dd> </dl> <h3 name=\"Non-standard_features\" id=\"Non-standard_features\">Non-standard features \n</h3> <dl> <dt>\n<a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Expression_closures\">Expression closures</a> <span class=\"inlineIndicator obsolete obsoleteInline\">Obsolete since Gecko 60</span>\n</dt> <dd>The expression closure syntax is a shorthand for writing simple function.</dd> <dt>\n<a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Legacy_generator_function\">Legacy generator function</a> <span class=\"inlineIndicator obsolete obsoleteInline\">Obsolete since Gecko 58</span>\n</dt> <dd>The <code>function</code> keyword can be used to define a legacy generator function inside an expression. To make the function a legacy generator, the function body should contains at least one <a href=\"operators/yield\"><code>yield</code></a> expression.</dd> <dt>\n<a href=\"operators/array_comprehensions\"><code>[for (x of y) x]</code></a> <span class=\"inlineIndicator obsolete obsoleteInline\">Obsolete since Gecko 58</span>\n</dt> <dd>Array comprehensions.</dd> <dt>\n<a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Generator_comprehensions\"><code>(for (x of y) y)</code></a> <span class=\"inlineIndicator obsolete obsoleteInline\">Obsolete since Gecko 58</span>\n</dt> <dd>Generator comprehensions.</dd> </dl> <h2 id=\"Functions\">Functions</h2> <p>This chapter documents how to work with <a href=\"functions\">JavaScript functions</a> to develop your applications.</p> <ul> <li><a href=\"functions/arguments\"><code>arguments</code></a></li> <li><a href=\"functions/arrow_functions\">Arrow functions</a></li> <li><a href=\"functions/default_parameters\">Default parameters</a></li> <li><a href=\"functions/rest_parameters\">Rest parameters</a></li> </ul> <h2 id=\"Additional_reference_pages\">Additional reference pages</h2> <ul> <li><a href=\"lexical_grammar\">Lexical grammar</a></li> <li><a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures\">Data types and data structures</a></li> <li><a href=\"strict_mode\">Strict mode</a></li> <li><a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Deprecated_and_obsolete_features\">Deprecated features</a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference</a>\n  </p>\n</div>\n","strict_mode":"<h1>Strict mode</h1> <div class=\"callout-box\">Sometimes you'll see the default, non-strict mode referred to as <strong>\"<a href=\"https://developer.mozilla.org/docs/Glossary/Sloppy_mode\" id=\"sloppyModeId333\">sloppy mode</a>\"</strong>. This isn't an official term, but be aware of it, just in case.</div> <p>JavaScript's strict mode, introduced in ECMAScript 5, is a way to <em>opt in</em> to a restricted variant of JavaScript, thereby implicitly opting-out of \"<a href=\"https://developer.mozilla.org/docs/Glossary/Sloppy_mode\">sloppy mode</a>\". Strict mode isn't just a subset: it <em>intentionally</em> has different semantics from normal code. Browsers not supporting strict mode will run strict mode code with different behavior from browsers that do, so don't rely on strict mode without feature-testing for support for the relevant aspects of strict mode. Strict mode code and non-strict mode code can coexist, so scripts can opt into strict mode incrementally.</p> <p>Strict mode makes several changes to normal JavaScript semantics:</p> <ol> <li>Eliminates some JavaScript silent errors by changing them to throw errors.</li> <li>Fixes mistakes that make it difficult for JavaScript engines to perform optimizations: strict mode code can sometimes be made to run faster than identical code that's not strict mode.</li> <li>Prohibits some syntax likely to be defined in future versions of ECMAScript.</li> </ol> <p>See <a href=\"strict_mode/transitioning_to_strict_mode\">transitioning to strict mode</a>, if you want to change your code to work in the restricted variant of JavaScript.</p> <h2 id=\"Invoking_strict_mode\">Invoking strict mode</h2> <p>Strict mode applies to <em>entire scripts</em> or to <em>individual functions</em>. It doesn't apply to block statements enclosed in <code>{}</code> braces; attempting to apply it to such contexts does nothing. <code>eval</code> code, <code>Function</code> code, event handler attributes, strings passed to <a href=\"https://developer.mozilla.org/en-US/docs/Web/API/WindowTimers/setTimeout\"><code>WindowTimers.setTimeout()</code></a>, and related functions are entire scripts, and invoking strict mode in them works as expected.</p> <h3 id=\"Strict_mode_for_scripts\">Strict mode for scripts</h3> <p>To invoke strict mode for an entire script, put the <em>exact</em> statement <code>\"use strict\";</code> (or <code>'use strict';</code>) before any other statements.</p> <pre data-language=\"js\">// Whole-script strict mode syntax\n'use strict';\nvar v = \"Hi! I'm a strict mode script!\";\n</pre> <p>This syntax has a trap that has <a href=\"https://bugzilla.mozilla.org/show_bug.cgi?id=579119\" class=\"link-https\">already bitten</a> <a href=\"https://bugzilla.mozilla.org/show_bug.cgi?id=627531\" class=\"link-https\">a major site</a>: it isn't possible to blindly concatenate conflicting scripts. Consider concatenating a strict mode script with a non-strict mode script: the entire concatenation looks strict! The inverse is also true: non-strict plus strict looks non-strict. Obviously, concatentation of scripts is never ideal, but if you must, consider enabling strict on a function-by-function basis.</p> <p>You can also take the approach of wrapping the entire contents of a script in a function and having that outer function use strict mode. This eliminates the concatenation problem and it means that you have to explicitly export any shared variables out of the function scope.</p> <h3 id=\"Strict_mode_for_functions\">Strict mode for functions</h3> <p>Likewise, to invoke strict mode for a function, put the <em>exact</em> statement <code>\"use strict\";</code> (or <code>'use strict';</code>) in the function's body before any other statements.</p> <pre data-language=\"js\">function strict() {\n  // Function-level strict mode syntax\n  'use strict';\n  function nested() { return 'And so am I!'; }\n  return \"Hi!  I'm a strict mode function!  \" + nested();\n}\nfunction notStrict() { return \"I'm not strict.\"; }\n</pre> <h3 id=\"Strict_mode_for_modules\">Strict mode for modules</h3> <p>ECMAScript 2015 introduced <a href=\"statements/export\">JavaScript modules</a> and therefore a 3rd way to enter strict mode. The entire contents of JavaScript modules are automatically in strict mode, with no statement needed to initiate it.</p> <pre data-language=\"js\">function strict() {\n    // because this is a module, I'm strict by default\n}\nexport default strict;\n</pre> <h2 id=\"Changes_in_strict_mode\">Changes in strict mode</h2> <p>Strict mode changes both syntax and runtime behavior. Changes generally fall into these categories: changes converting mistakes into errors (as syntax errors or at runtime), changes simplifying how the particular variable for a given use of a name is computed, changes simplifying <code>eval</code> and <code>arguments</code>, changes making it easier to write \"secure\" JavaScript, and changes anticipating future ECMAScript evolution.</p> <h3 id=\"Converting_mistakes_into_errors\">Converting mistakes into errors</h3> <p>Strict mode changes some previously-accepted mistakes into errors. JavaScript was designed to be easy for novice developers, and sometimes it gives operations which should be errors non-error semantics. Sometimes this fixes the immediate problem, but sometimes this creates worse problems in the future. Strict mode treats these mistakes as errors so that they're discovered and promptly fixed.</p> <p>First, strict mode makes it impossible to accidentally create global variables. In normal JavaScript mistyping a variable in an assignment creates a new property on the global object and continues to \"work\" (although future failure is possible: likely, in modern JavaScript). Assignments, which would accidentally create global variables, instead throw an error in strict mode:</p> <pre data-language=\"js\">'use strict';\n                       // Assuming a global variable mistypedVariable exists\nmistypeVariable = 17;  // this line throws a ReferenceError due to the \n                       // misspelling of variable\n</pre> <p>Second, strict mode makes assignments which would otherwise silently fail to throw an exception. For example, <code>NaN</code> is a non-writable global variable. In normal code assigning to <code>NaN</code> does nothing; the developer receives no failure feedback. In strict mode assigning to <code>NaN</code> throws an exception. Any assignment that silently fails in normal code (assignment to a non-writable global or property, assignment to a getter-only property, assignment to a new property on a <a href=\"https://developer.mozilla.org/en-US/Web/JavaScript/Reference/Global_Objects/Object/preventExtensions\">non-extensible</a> object) will throw in strict mode:</p> <pre data-language=\"js\">'use strict';\n\n// Assignment to a non-writable global\nvar undefined = 5; // throws a TypeError\nvar Infinity = 5; // throws a TypeError\n\n// Assignment to a non-writable property\nvar obj1 = {};\nObject.defineProperty(obj1, 'x', { value: 42, writable: false });\nobj1.x = 9; // throws a TypeError\n\n// Assignment to a getter-only property\nvar obj2 = { get x() { return 17; } };\nobj2.x = 5; // throws a TypeError\n\n// Assignment to a new property on a non-extensible object\nvar fixed = {};\nObject.preventExtensions(fixed);\nfixed.newProp = 'ohai'; // throws a TypeError\n</pre> <p>Third, strict mode makes attempts to delete undeletable properties throw (where before the attempt would simply have no effect):</p> <pre data-language=\"js\">'use strict';\ndelete Object.prototype; // throws a TypeError\n</pre> <p>Fourth, strict mode prior to Gecko 34 requires that all properties named in an object literal be unique. The normal code may duplicate property names, with the last one determining the property's value. But since only the last one does anything, the duplication is simply a vector for bugs, if the code is modified to change the property value other than by changing the last instance. Duplicate property names are a syntax error in strict mode:</p> <div class=\"note\"> <p>This is no longer the case in ECMAScript 2015 (<a href=\"https://bugzilla.mozilla.org/show_bug.cgi?id=1041128\">bug 1041128</a>).</p> </div> <pre data-language=\"js\">'use strict';\nvar o = { p: 1, p: 2 }; // !!! syntax error\n</pre> <p>Fifth, strict mode requires that function parameter names be unique. In normal code the last duplicated argument hides previous identically-named arguments. Those previous arguments remain available through <code>arguments[i]</code>, so they're not completely inaccessible. Still, this hiding makes little sense and is probably undesirable (it might hide a typo, for example), so in strict mode duplicate argument names are a syntax error:</p> <pre data-language=\"js\">function sum(a, a, c) { // !!! syntax error\n  'use strict';\n  return a + a + c; // wrong if this code ran\n}\n</pre> <p>Sixth, a strict mode in ECMAScript 5 forbids octal syntax. The octal syntax isn't part of ECMAScript 5, but it's supported in all browsers by prefixing the octal number with a zero: <code>0644 === 420</code> and <code>\"\\045\" === \"%\"</code>. In ECMAScript 2015 Octal number is supported by prefixing a number with \"<code>0o</code>\". i.e. </p> <pre data-language=\"js\">var a = 0o10; // ES2015: Octal</pre> <p>Novice developers sometimes believe a leading zero prefix has no semantic meaning, so they use it as an alignment device — but this changes the number's meaning! A leading zero syntax for the octals is rarely useful and can be mistakenly used, so strict mode makes it a syntax error:</p> <pre data-language=\"js\">'use strict';\nvar sum = 015 + // !!! syntax error\n          197 +\n          142;\n\nvar sumWithOctal = 0o10 + 8;\nconsole.log(sumWithOctal); // 16\n</pre> <p>Seventh, strict mode in ECMAScript 2015 forbids setting properties on <a href=\"https://developer.mozilla.org/en-US/docs/Glossary/primitive\">primitive</a> values. Without strict mode, setting properties is simply ignored (no-op), with strict mode, however, a <a href=\"global_objects/typeerror\"><code>TypeError</code></a> is thrown.</p> <pre data-language=\"js\">(function() {\n'use strict';\n\nfalse.true = '';         // TypeError\n(14).sailing = 'home';   // TypeError\n'with'.you = 'far away'; // TypeError\n\n})();</pre> <h3 id=\"Simplifying_variable_uses\">Simplifying variable uses</h3> <p>Strict mode simplifies how variable names map to particular variable definitions in the code. Many compiler optimizations rely on the ability to say that variable <em>X</em> is stored in <em>that</em> location: this is critical to fully optimizing JavaScript code. JavaScript sometimes makes this basic mapping of name to variable definition in the code impossible to perform until runtime. Strict mode removes most cases where this happens, so the compiler can better optimize strict mode code.</p> <p>First, strict mode prohibits <code>with</code>. The problem with <code>with</code> is that any name inside the block might map either to a property of the object passed to it, or to a variable in surrounding (or even global) scope, at runtime: it's impossible to know which beforehand. Strict mode makes <code>with</code> a syntax error, so there's no chance for a name in a <code>with</code> to refer to an unknown location at runtime:</p> <pre data-language=\"js\">'use strict';\nvar x = 17;\nwith (obj) { // !!! syntax error\n  // If this weren't strict mode, would this be var x, or\n  // would it instead be obj.x?  It's impossible in general\n  // to say without running the code, so the name can't be\n  // optimized.\n  x;\n}\n</pre> <p>The simple alternative of assigning the object to a short name variable, then accessing the corresponding property on that variable, stands ready to replace <code>with</code>.</p> <p>Second, <a href=\"http://whereswalden.com/2011/01/10/new-es5-strict-mode-support-new-vars-created-by-strict-mode-eval-code-are-local-to-that-code-only/\"><code>eval</code> of strict mode code does not introduce new variables into the surrounding scope</a>. In normal code <code>eval(\"var x;\")</code> introduces a variable <code>x</code> into the surrounding function or the global scope. This means that, in general, in a function containing a call to <code>eval</code> every name not referring to an argument or local variable must be mapped to a particular definition at runtime (because that <code>eval</code> might have introduced a new variable that would hide the outer variable). In strict mode <code>eval</code> creates variables only for the code being evaluated, so <code>eval</code> can't affect whether a name refers to an outer variable or some local variable:</p> <pre data-language=\"js\">var x = 17;\nvar evalX = eval(\"'use strict'; var x = 42; x;\");\nconsole.assert(x === 17);\nconsole.assert(evalX === 42);\n</pre> <p>If the function <code>eval</code> is invoked by an expression of the form <code>eval(...)</code> in strict mode code, the code will be evaluated as strict mode code. The code may explicitly invoke strict mode, but it's unnecessary to do so.</p> <pre data-language=\"js\">function strict1(str) {\n  'use strict';\n  return eval(str); // str will be treated as strict mode code\n}\nfunction strict2(f, str) {\n  'use strict';\n  return f(str); // not eval(...): str is strict if and only\n                 // if it invokes strict mode\n}\nfunction nonstrict(str) {\n  return eval(str); // str is strict if and only \n                    // if it invokes strict mode\n}\n\nstrict1(\"'Strict mode code!'\");\nstrict1(\"'use strict'; 'Strict mode code!'\");\nstrict2(eval, \"'Non-strict code.'\");\nstrict2(eval, \"'use strict'; 'Strict mode code!'\");\nnonstrict(\"'Non-strict code.'\");\nnonstrict(\"'use strict'; 'Strict mode code!'\");\n</pre> <p>Thus names in strict mode <code>eval</code> code behave identically to names in strict mode code not being evaluated as the result of <code>eval</code>.</p> <p>Third, strict mode forbids deleting plain names. <code>delete name</code> in strict mode is a syntax error:</p> <pre data-language=\"js\">'use strict';\n\nvar x;\ndelete x; // !!! syntax error\n\neval('var y; delete y;'); // !!! syntax error</pre> <h3 id=\"Making_eval_and_arguments_simpler\">Making <code>eval</code> and <code>arguments</code> simpler</h3> <p>Strict mode makes <code>arguments</code> and <code>eval</code> less bizarrely magical. Both involve a considerable amount of magical behavior in normal code: <code>eval</code> to add or remove bindings and to change binding values, and <code>arguments</code> by its indexed properties aliasing named arguments. Strict mode makes great strides toward treating <code>eval</code> and <code>arguments</code> as keywords, although full fixes will not come until a future edition of ECMAScript.</p> <p>First, the names <code>eval</code> and <code>arguments</code> can't be bound or assigned in language syntax. All these attempts to do so are syntax errors:</p> <pre data-language=\"js\">'use strict';\neval = 17;\narguments++;\n++eval;\nvar obj = { set p(arguments) { } };\nvar eval;\ntry { } catch (arguments) { }\nfunction x(eval) { }\nfunction arguments() { }\nvar y = function eval() { };\nvar f = new Function('arguments', \"'use strict'; return 17;\");\n</pre> <p>Second, strict mode code doesn't alias properties of <code>arguments</code> objects created within it. In normal code within a function whose first argument is <code>arg</code>, setting <code>arg</code> also sets <code>arguments[0]</code>, and vice versa (unless no arguments were provided or <code>arguments[0]</code> is deleted). <code>arguments</code> objects for strict mode functions store the original arguments when the function was invoked. <code>arguments[i]</code> does not track the value of the corresponding named argument, nor does a named argument track the value in the corresponding <code>arguments[i]</code>.</p> <pre data-language=\"js\">function f(a) {\n  'use strict';\n  a = 42;\n  return [a, arguments[0]];\n}\nvar pair = f(17);\nconsole.assert(pair[0] === 42);\nconsole.assert(pair[1] === 17);\n</pre> <p>Third, <code>arguments.callee</code> is no longer supported. In normal code <code>arguments.callee</code> refers to the enclosing function. This use case is weak: simply name the enclosing function! Moreover, <code>arguments.callee</code> substantially hinders optimizations like inlining functions, because it must be made possible to provide a reference to the un-inlined function if <code>arguments.callee</code> is accessed. <code>arguments.callee</code> for strict mode functions is a non-deletable property which throws an error when set or retrieved:</p> <pre data-language=\"js\">'use strict';\nvar f = function() { return arguments.callee; };\nf(); // throws a TypeError\n</pre> <h3 id=\"Securing_JavaScript\">\"Securing\" JavaScript</h3> <p>Strict mode makes it easier to write \"secure\" JavaScript. Some websites now provide ways for users to write JavaScript which will be run by the website <em>on behalf of other users</em>. JavaScript in browsers can access the user's private information, so such JavaScript must be partially transformed before it is run, to censor access to forbidden functionality. JavaScript's flexibility makes it effectively impossible to do this without many runtime checks. Certain language functions are so pervasive that performing runtime checks has a considerable performance cost. A few strict mode tweaks, plus requiring that user-submitted JavaScript be strict mode code and that it be invoked in a certain manner, substantially reduce the need for those runtime checks.</p> <p>First, the value passed as <code>this</code> to a function in strict mode is not forced into being an object (a.k.a. \"boxed\"). For a normal function, <code>this</code> is always an object: either the provided object if called with an object-valued <code>this</code>; the value, boxed, if called with a Boolean, string, or number <code>this</code>; or the global object if called with an <code>undefined</code> or <code>null</code> <code>this</code>. (Use <a href=\"https://developer.mozilla.org/en-US/Web/JavaScript/Reference/Global_Objects/Function/call\"><code>call</code></a>, <a href=\"https://developer.mozilla.org/en-US/Web/JavaScript/Reference/Global_Objects/Function/apply\"><code>apply</code></a>, or <a href=\"https://developer.mozilla.org/en-US/Web/JavaScript/Reference/Global_Objects/Function/bind\"><code>bind</code></a> to specify a particular <code>this</code>.) Not only is automatic boxing a performance cost, but exposing the global object in browsers is a security hazard because the global object provides access to functionality that \"secure\" JavaScript environments must restrict. Thus for a strict mode function, the specified <code>this</code> is not boxed into an object, and if unspecified, <code>this</code> will be <code>undefined</code>:</p> <pre data-language=\"js\">'use strict';\nfunction fun() { return this; }\nconsole.assert(fun() === undefined);\nconsole.assert(fun.call(2) === 2);\nconsole.assert(fun.apply(null) === null);\nconsole.assert(fun.call(undefined) === undefined);\nconsole.assert(fun.bind(true)() === true);\n</pre> <p>That means, among other things, that in browsers it's no longer possible to reference the <code>window</code> object through <code>this</code> inside a strict mode function.</p> <p>Second, in strict mode it's no longer possible to \"walk\" the JavaScript stack via commonly-implemented extensions to ECMAScript. In normal code with these extensions, when a function <code>fun</code> is in the middle of being called, <code>fun.caller</code> is the function that most recently called <code>fun</code>, and <code>fun.arguments</code> is the <code>arguments</code> for that invocation of <code>fun</code>. Both extensions are problematic for \"secure\" JavaScript because they allow \"secured\" code to access \"privileged\" functions and their (potentially unsecured) arguments. If <code>fun</code> is in strict mode, both <code>fun.caller</code> and <code>fun.arguments</code> are non-deletable properties which throw when set or retrieved:</p> <pre data-language=\"js\">function restricted() {\n  'use strict';\n  restricted.caller;    // throws a TypeError\n  restricted.arguments; // throws a TypeError\n}\nfunction privilegedInvoker() {\n  return restricted();\n}\nprivilegedInvoker();\n</pre> <p>Third, <code>arguments</code> for strict mode functions no longer provide access to the corresponding function call's variables. In some old ECMAScript implementations <code>arguments.caller</code> was an object whose properties aliased variables in that function. This is a <a href=\"http://stuff.mit.edu/iap/2008/facebook/\">security hazard</a> because it breaks the ability to hide privileged values via function abstraction; it also precludes most optimizations. For these reasons no recent browsers implement it. Yet because of its historical functionality, <code>arguments.caller</code> for a strict mode function is also a non-deletable property which throws when set or retrieved:</p> <pre data-language=\"js\">'use strict';\nfunction fun(a, b) {\n  'use strict';\n  var v = 12;\n  return arguments.caller; // throws a TypeError\n}\nfun(1, 2); // doesn't expose v (or a or b)\n</pre> <h3 id=\"Paving_the_way_for_future_ECMAScript_versions\">Paving the way for future ECMAScript versions</h3> <p>Future ECMAScript versions will likely introduce new syntax, and strict mode in ECMAScript 5 applies some restrictions to ease the transition. It will be easier to make some changes if the foundations of those changes are prohibited in strict mode.</p> <p>First, in strict mode, a short list of identifiers become reserved keywords. These words are <code>implements</code>, <code>interface</code>, <code>let</code>, <code>package</code>, <code>private</code>, <code>protected</code>, <code>public</code>, <code>static</code>, and <code>yield</code>. In strict mode, then, you can't name or use variables or arguments with these names.</p> <pre data-language=\"js\">function package(protected) { // !!!\n  'use strict';\n  var implements; // !!!\n\n  interface: // !!!\n  while (true) {\n    break interface; // !!!\n  }\n\n  function private() { } // !!!\n}\nfunction fun(static) { 'use strict'; } // !!!\n\n</pre> <p>Two Mozilla-specific caveats: First, if your code is JavaScript 1.7 or greater (for example in chrome code or when using the right <code>&lt;script type=\"\"&gt;</code>) and is strict mode code, <code>let</code> and <code>yield</code> have the functionality they've had since those keywords were first introduced. But strict mode code on the web, loaded with <code>&lt;script src=\"\"&gt;</code> or <code>&lt;script&gt;...&lt;/script&gt;</code>, won't be able to use <code>let</code>/<code>yield</code> as identifiers. Second, while ES5 unconditionally reserves the words <code>class</code>, <code>enum</code>, <code>export</code>, <code>extends</code>, <code>import</code>, and <code>super</code>, before Firefox 5 Mozilla reserved them only in strict mode.</p> <p>Second, <a href=\"http://whereswalden.com/2011/01/24/new-es5-strict-mode-requirement-function-statements-not-at-top-level-of-a-program-or-function-are-prohibited/\">strict mode prohibits function statements, not at the top level of a script or function</a>. In normal mode in browsers, function statements are permitted \"everywhere\". <em>This is not part of ES5 (or even ES3)!</em> It's an extension with incompatible semantics in different browsers. Note that function statements outside top level are permitted in ES2015.</p> <pre data-language=\"js\">'use strict';\nif (true) {\n  function f() { } // !!! syntax error\n  f();\n}\n\nfor (var i = 0; i &lt; 5; i++) {\n  function f2() { } // !!! syntax error\n  f2();\n}\n\nfunction baz() { // kosher\n  function eit() { } // also kosher\n}\n</pre> <p>This prohibition isn't strict mode proper because such function statements are an extension of basic ES5. But it is the recommendation of the ECMAScript committee, and browsers will implement it.</p> <h2 id=\"Strict_mode_in_browsers\">Strict mode in browsers</h2> <p>The major browsers now implement strict mode. However, don't blindly depend on it since there still are numerous <a rel=\"external\" href=\"http://caniuse.com/use-strict\">Browser versions used in the wild that only have partial support for strict mode</a> or do not support it at all (e.g. Internet Explorer below version 10!). <em>Strict mode changes semantics.</em> Relying on those changes will cause mistakes and errors in browsers which don't implement strict mode. Exercise caution in using strict mode, and back up reliance on strict mode with feature tests that check whether relevant parts of strict mode are implemented. Finally, make sure to <em>test your code in browsers that do and don't support strict mode</em>. If you test only in browsers that don't support strict mode, you're very likely to have problems in browsers that do, and vice versa.</p> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/5.1/#sec-10.1.1\" hreflang=\"en\">ECMAScript 5.1 (ECMA-262)<br><small>The definition of 'Strict Mode Code' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition. See also: <a href=\"http://www.ecma-international.org/ecma-262/5.1/#sec-C\">Strict mode restriction and exceptions</a>\n</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-strict-mode-code\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Strict Mode Code' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td><a href=\"http://www.ecma-international.org/ecma-262/6.0/#sec-strict-mode-of-ecmascript\">Strict mode restriction and exceptions</a></td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-strict-mode-code\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Strict Mode Code' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td><a href=\"https://tc39.github.io/ecma262/#sec-strict-mode-of-ecmascript\">Strict mode restriction and exceptions</a></td> </tr> </tbody> </table></div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"http://whereswalden.com/2010/09/08/new-es5-strict-mode-support-now-with-poison-pills/\">Where's Walden? » New ES5 strict mode support: now with poison pills!</a></li> <li><a href=\"http://whereswalden.com/2011/01/24/new-es5-strict-mode-requirement-function-statements-not-at-top-level-of-a-program-or-function-are-prohibited/\">Where's Walden? » New ES5 strict mode requirement: function statements not at top level of a program or function are prohibited</a></li> <li><a href=\"http://whereswalden.com/2011/01/10/new-es5-strict-mode-support-new-vars-created-by-strict-mode-eval-code-are-local-to-that-code-only/\">Where's Walden? » New ES5 strict mode support: new vars created by strict mode eval code are local to that code only</a></li> <li><a href=\"http://qnimate.com/javascript-strict-mode-in-nutshell/\">JavaScript \"use strict\" tutorial for beginners.</a></li> <li><a href=\"http://ejohn.org/blog/ecmascript-5-strict-mode-json-and-more/\">John Resig - ECMAScript 5 Strict Mode, JSON, and More</a></li> <li><a href=\"http://dmitrysoshnikov.com/ecmascript/es5-chapter-2-strict-mode/\">ECMA-262-5 in detail. Chapter 2. Strict Mode.</a></li> <li><a href=\"http://kangax.github.io/compat-table/es5/#Strict_mode\">Strict mode compatibility table</a></li> <li><a href=\"strict_mode/transitioning_to_strict_mode\">Transitioning to strict mode</a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Strict_mode$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Strict_mode\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Strict_mode</a>\n  </p>\n</div>\n","global_objects/evalerror":"<h1>EvalError</h1> <p>The <code>EvalError</code> object indicates an error regarding the global <a href=\"eval\"><code>eval()</code></a> function. This exception is not thrown by JavaScript anymore, however the <code>EvalError</code> object remains for compatibility.</p> <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\">new EvalError([<var>message</var>[, <var>fileName</var>[, <var>lineNumber</var>]]])</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><code>message</code></dt> <dd>Optional. Human-readable description of the error</dd> <dt>\n<code>fileName</code> \n</dt> <dd>Optional. The name of the file containing the code that caused the exception</dd> <dt>\n<code>lineNumber</code> \n</dt> <dd>Optional. The line number of the code that caused the exception</dd> </dl> <h2 id=\"Properties\">Properties</h2> <dl> <dt><a href=\"evalerror/prototype\"><code>EvalError.prototype</code></a></dt> <dd>Allows the addition of properties to an <code>EvalError</code> object.</dd> </dl> <h2 id=\"Methods\">Methods</h2> <p>The global <code>EvalError</code> contains no methods of its own, however, it does inherit some methods through the prototype chain.</p> <h2 id=\"EvalError_instances\">EvalError instances</h2> <h3 id=\"Properties_2\">Properties</h3> <dl> <dt><code>EvalError.prototype.constructor</code></dt> <dd>Specifies the function that created an instance's prototype.</dd> <dt><a href=\"error/message\"><code>EvalError.prototype.message</code></a></dt> <dd>Error message. Although ECMA-262 specifies that <a href=\"evalerror\"><code>EvalError</code></a> should provide its own <code>message</code> property, in <a href=\"https://developer.mozilla.org/en-US/docs/Mozilla/Projects/SpiderMonkey\">SpiderMonkey</a>, it inherits <a href=\"error/message\"><code>Error.prototype.message</code></a>.</dd> <dt><a href=\"error/name\"><code>EvalError.prototype.name</code></a></dt> <dd>Error name. Inherited from <a href=\"error\"><code>Error</code></a>.</dd> <dt><a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/fileName\"><code>EvalError.prototype.fileName</code></a></dt> <dd>Path to file that raised this error. Inherited from <a href=\"error\"><code>Error</code></a>.</dd> <dt><a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/lineNumber\"><code>EvalError.prototype.lineNumber</code></a></dt> <dd>Line number in file that raised this error. Inherited from <a href=\"error\"><code>Error</code></a>.</dd> <dt><a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/columnNumber\"><code>EvalError.prototype.columnNumber</code></a></dt> <dd>Column number in line that raised this error. Inherited from <a href=\"error\"><code>Error</code></a>.</dd> <dt><a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/stack\"><code>EvalError.prototype.stack</code></a></dt> <dd>Stack trace. Inherited from <a href=\"error\"><code>Error</code></a>.</dd> </dl> <h3 id=\"Methods_2\">Methods</h3> <p>Although the <a href=\"evalerror\"><code>EvalError</code></a> prototype object does not contain any methods of its own, <a href=\"evalerror\"><code>EvalError</code></a> instances do inherit some methods through the prototype chain.</p> <h2 id=\"Examples\">Examples</h2> <p><code>EvalError</code> is not used in the current ECMAScript specification and will thus not be thrown by the runtime. However, the object itself remains for backwards compatibility with earlier versions of the specification.</p> <h3 id=\"Creating_an_EvalError\">Creating an EvalError</h3> <pre data-language=\"js\">try {\n  throw new EvalError('Hello', 'someFile.js', 10);\n} catch (e) {\n  console.log(e instanceof EvalError); // true\n  console.log(e.message);              // \"Hello\"\n  console.log(e.name);                 // \"EvalError\"\n  console.log(e.fileName);             // \"someFile.js\"\n  console.log(e.lineNumber);           // 10\n  console.log(e.columnNumber);         // 0\n  console.log(e.stack);                // \"@Scratchpad/2:2:9\\n\"\n}\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/publications/files/ECMA-ST-ARCH/ECMA-262,%203rd%20edition,%20December%201999.pdf\" hreflang=\"en\">ECMAScript 3rd Edition (ECMA-262)</a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/5.1/#sec-15.11.6.1\" hreflang=\"en\">ECMAScript 5.1 (ECMA-262)<br><small>The definition of 'EvalError' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Not used in this specification. Present for backward compatibility.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-native-error-types-used-in-this-standard-evalerror\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'EvalError' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Not used in this specification. Present for backward compatibility.</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-native-error-types-used-in-this-standard-evalerror\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'EvalError' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>    <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div>   <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"error\"><code>Error</code></a></li> <li><a href=\"evalerror/prototype\"><code>EvalError.prototype</code></a></li> <li><a href=\"eval\"><code>eval()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/EvalError$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/EvalError\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/EvalError</a>\n  </p>\n</div>\n","global_objects/generatorfunction":"<h1>GeneratorFunction</h1> <p>The <code>GeneratorFunction</code> creates a new <a href=\"../statements/function*\"><code>generator function</code></a> object. In JavaScript every generator function is actually a <code>GeneratorFunction</code> object.</p> <p>Note that <code>GeneratorFunction</code> is not a global object. It could be obtained by evaluating the following code.</p> <pre data-language=\"js\">Object.getPrototypeOf(function*(){}).constructor\n</pre> <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\">new GeneratorFunction ([<var>arg1</var>[, <var>arg2</var>[, ...<var>argN</var>]],] <var>functionBody</var>)</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><code>arg1, arg2, ... arg<em>N</em></code></dt> <dd>Names to be used by the function as formal argument names. Each must be a string that corresponds to a valid JavaScript identifier or a list of such strings separated with a comma; for example \"<code>x</code>\", \"<code>theValue</code>\", or \"<code>a,b</code>\".</dd> <dt><code>functionBody</code></dt> <dd>A string containing the JavaScript statements comprising the function definition.</dd> </dl> <h2 id=\"Description\">Description</h2> <p><a href=\"../statements/function*\"><code>generator function</code></a> objects created with the <code>GeneratorFunction</code> constructor are parsed when the function is created. This is less efficient than declaring a generator function with a <a href=\"../statements/function*\"><code>function* expression</code></a> and calling it within your code, because such functions are parsed with the rest of the code.</p> <p>All arguments passed to the function are treated as the names of the identifiers of the parameters in the function to be created, in the order in which they are passed.</p> <div class=\"note\"> <p><strong>Note:</strong> <a href=\"../statements/function*\"><code>generator function</code></a> created with the <code>GeneratorFunction</code> constructor do not create closures to their creation contexts; they always are created in the global scope. When running them, they will only be able to access their own local variables and global ones, not the ones from the scope in which the <code>GeneratorFunction</code> constructor was called. This is different from using <a href=\"eval\"><code>eval</code></a> with code for a generator function expression.</p> </div> <p>Invoking the <code>GeneratorFunction</code> constructor as a function (without using the <code>new</code> operator) has the same effect as invoking it as a constructor.</p> <h2 id=\"Properties\">Properties</h2> <dl> <dt><code><strong>GeneratorFunction.length</strong></code></dt> <dd>The <code>GeneratorFunction</code> constructor's length property whose value is 1.</dd> <dt><a href=\"generatorfunction/prototype\"><code>GeneratorFunction.prototype</code></a></dt> <dd>Allows the addition of properties to all generator function objects.</dd> </dl> <h2 id=\"GeneratorFunction_prototype_object\">\n<code>GeneratorFunction</code> prototype object</h2> <h3 id=\"Properties_2\">Properties</h3> <dl> <dt><code><strong>GeneratorFunction.constructor</strong></code></dt> <dd>The initial value is <a href=\"generatorfunction\"><code>GeneratorFunction</code></a>.</dd> <dt><code><strong>GeneratorFunction.prototype.prototype</strong></code></dt> <dd>The value is <code>%GeneratorPrototype%</code>.</dd> </dl> <h2 id=\"GeneratorFunction_instances\">\n<code>GeneratorFunction</code> instances</h2> <p><code>GeneratorFunction</code> instances inherit methods and properties from <a href=\"generatorfunction/prototype\"><code>GeneratorFunction.prototype</code></a>. As with all constructors, you can change the constructor's prototype object to make changes to all <code>GeneratorFunction</code> instances.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Creating_a_generator_function_from_a_GeneratorFunction_constructor\">Creating a generator function from a <code>GeneratorFunction</code> constructor</h3> <pre data-language=\"js\">var GeneratorFunction = Object.getPrototypeOf(function*(){}).constructor\nvar g = new GeneratorFunction('a', 'yield a * 2');\nvar iterator = g(10);\nconsole.log(iterator.next().value); // 20\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-generatorfunction-objects\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'GeneratorFunction' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-generatorfunction-objects\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'GeneratorFunction' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>   <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 26</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td> ? </td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/GeneratorFunction/prototype\"><code>prototype</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 26</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td> ? </td>\n</tr>\n</tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 26</td>\n<td> ? </td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/GeneratorFunction/prototype\"><code>prototype</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 26</td>\n<td> ? </td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n</tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td> ? </td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/GeneratorFunction/prototype\"><code>prototype</code></a></th>\n<td> ? </td>\n</tr>\n</tbody>\n</table>\n</div>  <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"../statements/function*\"><code>function* function</code></a></li> <li><a href=\"../operators/function*\"><code>function* expression</code></a></li> <li><a href=\"function\"><code>Function</code></a></li> <li><a href=\"../statements/function\"><code>function statement</code></a></li> <li><a href=\"../operators/function\"><code>function expression</code></a></li> <li><a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions\">Functions and function scope</a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/GeneratorFunction$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/GeneratorFunction\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/GeneratorFunction</a>\n  </p>\n</div>\n","global_objects/asyncfunction":"<h1>AsyncFunction</h1> <p>The <code><strong>Async</strong></code><code>Function</code> creates a new <a href=\"../statements/async_function\"><code>async function</code></a> object. In JavaScript every asynchronous function is actually an <code>AsyncFunction</code> object.</p> <p>Note that <code>AsyncFunction</code> is not a global object. It could be obtained by evaluating the following code.</p> <pre data-language=\"js\">Object.getPrototypeOf(async function(){}).constructor\n</pre> <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\">new AsyncFunction([<var>arg1</var>[, <var>arg2</var>[, ...<var>argN</var>]],] <var>functionBody</var>)</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><code>arg1, arg2, ... arg<em>N</em></code></dt> <dd>Names to be used by the function as formal argument names. Each must be a string that corresponds to a valid JavaScript identifier or a list of such strings separated with a comma; for example \"<code>x</code>\", \"<code>theValue</code>\", or \"<code>a,b</code>\".</dd> <dt><code>functionBody</code></dt> <dd>A string containing the JavaScript statements comprising the function definition.</dd> </dl> <h2 id=\"Description\">Description</h2> <p><a href=\"../statements/async_function\"><code>async function</code></a> objects created with the <code>AsyncFunction</code> constructor are parsed when the function is created. This is less efficient than declaring an async function with an <a href=\"../statements/async_function\"><code>async function expression</code></a> and calling it within your code, because such functions are parsed with the rest of the code.</p> <p>All arguments passed to the function are treated as the names of the identifiers of the parameters in the function to be created, in the order in which they are passed.</p> <div class=\"note\"> <p><strong>Note:</strong> <a href=\"../statements/async_function\"><code>async functions</code></a> created with the <code>AsyncFunction</code> constructor do not create closures to their creation contexts; they are always created in the global scope. When running them, they will only be able to access their own local variables and global ones, not the ones from the scope in which the <code>AsyncFunction</code> constructor was called. This is different from using <a href=\"eval\"><code>eval</code></a> with code for an async function expression.</p> </div> <p>Invoking the <code>AsyncFunction</code> constructor as a function (without using the <code>new</code> operator) has the same effect as invoking it as a constructor.</p> <h2 id=\"Properties\">Properties</h2> <dl> <dt><code><strong>AsyncFunction.length</strong></code></dt> <dd>The <code>AsyncFunction</code> constructor's length property whose value is 1.</dd> <dt><a href=\"asyncfunction/prototype\"><code>AsyncFunction.prototype</code></a></dt> <dd>Allows the addition of properties to all async function objects.</dd> </dl> <h2 id=\"AsyncFunction_prototype_object\">\n<code>AsyncFunction</code> prototype object</h2> <h3 id=\"Properties_2\">Properties</h3> <dl> <dt><code><strong>AsyncFunction.constructor</strong></code></dt> <dd>The initial value is <a href=\"asyncfunction\"><code>AsyncFunction</code></a>.</dd> <dt><code><strong>AsyncFunction.prototype[@@toStringTag]</strong></code></dt> <dd>Returns \"AsyncFunction\".</dd> </dl> <h2 id=\"AsyncFunction_instances\">\n<code>AsyncFunction</code> instances</h2> <p><code>AsyncFunction</code> instances inherit methods and properties from <a href=\"asyncfunction/prototype\"><code>AsyncFunction.prototype</code></a>. As with all constructors, you can change the constructor's prototype object to make changes to all <code>AsyncFunction</code> instances.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Creating_an_async_function_from_an_AsyncFunction_constructor\">Creating an async function from an <code>AsyncFunction</code> constructor</h3> <pre data-language=\"js\">function resolveAfter2Seconds(x) {\n  return new Promise(resolve =&gt; {\n    setTimeout(() =&gt; {\n      resolve(x);\n    }, 2000);\n  });\n}\n\nvar AsyncFunction = Object.getPrototypeOf(async function(){}).constructor\n\nvar a = new AsyncFunction('a', \n                          'b', \n                          'return await resolveAfter2Seconds(a) + await resolveAfter2Seconds(b);');\n\na(10, 20).then(v =&gt; {\n  console.log(v); // prints 30 after 4 seconds\n});\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <thead> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> </thead> <tbody> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-async-function-objects\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'AsyncFunction object' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td>Initial definition in ES2017.</td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>   <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 55</td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 52</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 42</td>\n<td> ? </td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/AsyncFunction/prototype\"><code>prototype</code></a></th>\n<td class=\"bc-supports-yes\"> 55</td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 52</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 42</td>\n<td> ? </td>\n</tr>\n</tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 55</td>\n<td class=\"bc-supports-yes\"> 55</td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 52</td>\n<td class=\"bc-supports-yes\"> 42</td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 6.0</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/AsyncFunction/prototype\"><code>prototype</code></a></th>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 55</td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 52</td>\n<td class=\"bc-supports-yes\"> 42</td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 6.0</td>\n</tr>\n</tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes bc-has-history\"> 7.6.0\n<section class=\"bc-history\" id=\"sect1\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 7.6.0\n</dt>\n\n<dt class=\"bc-supports-yes bc-supports\"> 7.0.0<div class=\"bc-icons\">Disabled </div>\n</dt>\n<dd>Disabled From version 7.0.0: this feature is behind the <code>--harmony</code> runtime flag.</dd>\n</dl></section>\n</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/AsyncFunction/prototype\"><code>prototype</code></a></th>\n<td class=\"bc-supports-yes bc-has-history\"> 7.6.0\n<section class=\"bc-history\" id=\"sect2\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 7.6.0\n</dt>\n\n<dt class=\"bc-supports-yes bc-supports\"> 7.0.0<div class=\"bc-icons\">Disabled </div>\n</dt>\n<dd>Disabled From version 7.0.0: this feature is behind the <code>--harmony</code> runtime flag.</dd>\n</dl></section>\n</td>\n</tr>\n</tbody>\n</table>\n</div>  <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"../statements/async_function\"><code>async function function</code></a></li> <li><a href=\"../operators/async_function\"><code>async function expression</code></a></li> <li><a href=\"function\"><code>Function</code></a></li> <li><a href=\"../statements/function\"><code>function statement</code></a></li> <li><a href=\"../operators/function\"><code>function expression</code></a></li> <li><a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions\">Functions and function scope</a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/AsyncFunction$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/AsyncFunction\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/AsyncFunction</a>\n  </p>\n</div>\n","global_objects/numberformat":"<h1>Intl.NumberFormat</h1> <p>The <code>Intl.NumberFormat</code> object is a constructor for objects that enable language sensitive number formatting.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/intl-numberformat.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\">new Intl.NumberFormat([<var>locales</var>[, <var>options</var>]])\nIntl.NumberFormat.call(<var>this</var>[, <var>locales</var>[, <var>options</var>]])\n</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><code>locales</code></dt> <dd> <p>Optional. A string with a BCP 47 language tag, or an array of such strings. For the general form and interpretation of the <code>locales</code> argument, see the <a href=\"intl#Locale_identification_and_negotiation\">Intl page</a>. The following Unicode extension key is allowed:</p> <dl> <dt><code>nu</code></dt> <dd>The numbering system to be used. Possible values include: <code>\"arab\"</code>, <code>\"arabext\"</code>, <code>\"bali\"</code>, <code>\"beng\"</code>, <code>\"deva\"</code>, <code>\"fullwide\"</code>, <code>\"gujr\"</code>, <code>\"guru\"</code>, <code>\"hanidec\"</code>, <code>\"khmr\"</code>, <code>\"knda\"</code>, <code>\"laoo\"</code>, <code>\"latn\"</code>, <code>\"limb\"</code>, <code>\"mlym\"</code>, <code>\"mong\"</code>, <code>\"mymr\"</code>, <code>\"orya\"</code>, <code>\"tamldec\"</code>, <code>\"telu\"</code>, <code>\"thai\"</code>, <code>\"tibt\"</code>.</dd> </dl> </dd> <dt><code>options</code></dt> <dd> <p>Optional. An object with some or all of the following properties:</p> <dl> <dt><code>localeMatcher</code></dt> <dd>The locale matching algorithm to use. Possible values are <code>\"lookup\"</code> and <code>\"best fit\"</code>; the default is <code>\"best fit\"</code>. For information about this option, see the <a href=\"intl#Locale_negotiation\">Intl page</a>.</dd> <dt><code>style</code></dt> <dd>The formatting style to use. Possible values are <code>\"decimal\"</code> for plain number formatting, <code>\"currency\"</code> for currency formatting, and <code>\"percent\"</code> for percent formatting; the default is <code>\"decimal\"</code>.</dd> <dt><code>currency</code></dt> <dd>The currency to use in currency formatting. Possible values are the ISO 4217 currency codes, such as <code>\"USD\"</code> for the US dollar, <code>\"EUR\"</code> for the euro, or <code>\"CNY\"</code> for the Chinese RMB — see the <a href=\"http://www.currency-iso.org/en/home/tables/table-a1.html\">Current currency &amp; funds code list</a>. There is no default value; if the <code>style</code> is <code>\"currency\"</code>, the <code>currency</code> property must be provided.</dd> <dt><code>currencyDisplay</code></dt> <dd>How to display the currency in currency formatting. Possible values are <code>\"symbol\"</code> to use a localized currency symbol such as €, <code>\"code\"</code> to use the ISO currency code, <code>\"name\"</code> to use a localized currency name such as <code>\"dollar\"</code>; the default is <code>\"symbol\"</code>.</dd> <dt><code>useGrouping</code></dt> <dd>Whether to use grouping separators, such as thousands separators or thousand/lakh/crore separators. Possible values are <code>true</code> and <code>false</code>; the default is <code>true</code>.</dd> </dl> <p>The following properties fall into two groups: <code>minimumIntegerDigits</code>, <code>minimumFractionDigits</code>, and <code>maximumFractionDigits</code> in one group, <code>minimumSignificantDigits</code> and <code>maximumSignificantDigits</code> in the other. If at least one property from the second group is defined, then the first group is ignored.</p> <dl> <dt><code>minimumIntegerDigits</code></dt> <dd>The minimum number of integer digits to use. Possible values are from 1 to 21; the default is 1.</dd> <dt><code>minimumFractionDigits</code></dt> <dd>The minimum number of fraction digits to use. Possible values are from 0 to 20; the default for plain number and percent formatting is 0; the default for currency formatting is the number of minor unit digits provided by the <a href=\"http://www.currency-iso.org/en/home/tables/table-a1.html\">ISO 4217 currency code list</a> (2 if the list doesn't provide that information).</dd> <dt><code>maximumFractionDigits</code></dt> <dd>The maximum number of fraction digits to use. Possible values are from 0 to 20; the default for plain number formatting is the larger of <code>minimumFractionDigits</code> and 3; the default for currency formatting is the larger of <code>minimumFractionDigits</code> and the number of minor unit digits provided by the <a href=\"http://www.currency-iso.org/en/home/tables/table-a1.html\">ISO 4217 currency code list</a> (2 if the list doesn't provide that information); the default for percent formatting is the larger of <code>minimumFractionDigits</code> and 0.</dd> <dt><code>minimumSignificantDigits</code></dt> <dd>The minimum number of significant digits to use. Possible values are from 1 to 21; the default is 1.</dd> <dt><code>maximumSignificantDigits</code></dt> <dd>The maximum number of significant digits to use. Possible values are from 1 to 21; the default is 21.</dd> </dl> </dd> </dl> <h2 id=\"Description\">Description</h2> <h3 id=\"Properties\">Properties</h3> <dl> <dt><a href=\"numberformat/prototype\"><code>Intl.NumberFormat.prototype</code></a></dt> <dd>Allows the addition of properties to all objects.</dd> </dl> <h3 id=\"Methods\">Methods</h3> <dl> <dt><a href=\"numberformat/supportedlocalesof\"><code>Intl.NumberFormat.supportedLocalesOf()</code></a></dt> <dd>Returns an array containing those of the provided locales that are supported without having to fall back to the runtime's default locale.</dd> </dl> <h2 id=\"NumberFormat_instances\">\n<code>NumberFormat</code> instances</h2> <h3 id=\"Properties_2\">Properties</h3> <p><code>NumberFormat</code> instances inherit the following properties from their prototype:</p> <dl> <dt><code>Intl.NumberFormat.prototype.constructor</code></dt> <dd>A reference to <code>Intl.NumberFormat</code>.</dd> <dt><a href=\"numberformat/format\"><code>Intl.NumberFormat.prototype.format</code></a></dt> <dd>Getter; returns a function that formats a number according to the locale and formatting options of this <a href=\"numberformat\"><code>NumberFormat</code></a> object.</dd> </dl> <h3 id=\"Methods_2\">Methods</h3> <p><code>NumberFormat</code> instances inherit the following methods from their prototype:</p> <dl> <dt><a href=\"numberformat/formattoparts\"><code>Intl.NumberFormat.prototype.formatToParts()</code></a></dt> <dd>Returns an <a href=\"array\"><code>Array</code></a> of objects representing the number string in parts that can be used for custom locale-aware formatting.</dd> <dt><a href=\"numberformat/resolvedoptions\"><code>Intl.NumberFormat.prototype.resolvedOptions()</code></a></dt> <dd>Returns a new object with properties reflecting the locale and collation options computed during initialization of the object.</dd> </dl> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Basic_usage\">Basic usage</h3> <p>In basic use without specifying a locale, a formatted string in the default locale and with default options is returned.</p> <pre data-language=\"js\">var number = 3500;\n\nconsole.log(new Intl.NumberFormat().format(number));\n// → '3,500' if in US English locale\n</pre> <h3 id=\"Using_locales\">Using <code>locales</code>\n</h3> <p>This example shows some of the variations in localized number formats. In order to get the format of the language used in the user interface of your application, make sure to specify that language (and possibly some fallback languages) using the <code>locales</code> argument:</p> <pre data-language=\"js\">var number = 123456.789;\n\n// German uses comma as decimal separator and period for thousands\nconsole.log(new Intl.NumberFormat('de-DE').format(number));\n// → 123.456,789\n\n// Arabic in most Arabic speaking countries uses real Arabic digits\nconsole.log(new Intl.NumberFormat('ar-EG').format(number));\n// → ١٢٣٤٥٦٫٧٨٩\n\n// India uses thousands/lakh/crore separators\nconsole.log(new Intl.NumberFormat('en-IN').format(number));\n// → 1,23,456.789\n\n// the nu extension key requests a numbering system, e.g. Chinese decimal\nconsole.log(new Intl.NumberFormat('zh-Hans-CN-u-nu-hanidec').format(number));\n// → 一二三,四五六.七八九\n\n// when requesting a language that may not be supported, such as\n// Balinese, include a fallback language, in this case Indonesian\nconsole.log(new Intl.NumberFormat(['ban', 'id']).format(number));\n// → 123.456,789\n</pre> <h3 id=\"Using_options\">Using <code>options</code>\n</h3> <p>The results can be customized using the <code>options</code> argument:</p> <pre data-language=\"js\">var number = 123456.789;\n\n// request a currency format\nconsole.log(new Intl.NumberFormat('de-DE', { style: 'currency', currency: 'EUR' }).format(number));\n// → 123.456,79 €\n\n// the Japanese yen doesn't use a minor unit\nconsole.log(new Intl.NumberFormat('ja-JP', { style: 'currency', currency: 'JPY' }).format(number));\n// → ￥123,457\n\n// limit to three significant digits\nconsole.log(new Intl.NumberFormat('en-IN', { maximumSignificantDigits: 3 }).format(number));\n// → 1,23,000\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-402/1.0/#sec-11.1\" hreflang=\"en\">ECMAScript Internationalization API 1.0 (ECMA-402)<br><small>The definition of 'Intl.NumberFormat' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-402/2.0/#sec-11.1\" hreflang=\"en\">ECMAScript Internationalization API 2.0 (ECMA-402)<br><small>The definition of 'Intl.NumberFormat' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma402/#numberformat-objects\" hreflang=\"en\">ECMAScript Internationalization API 4.0 (ECMA-402)<br><small>The definition of 'Intl.NumberFormat' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>   <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 24</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 29</td>\n<td class=\"bc-supports-yes\"> 11</td>\n<td class=\"bc-supports-yes\"> 15</td>\n<td class=\"bc-supports-yes\"> 10</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/NumberFormat/prototype\"><code>prototype</code></a></th>\n<td class=\"bc-supports-yes\"> 24</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 29</td>\n<td class=\"bc-supports-yes\"> 11</td>\n<td class=\"bc-supports-yes\"> 15</td>\n<td class=\"bc-supports-yes\"> 10</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/NumberFormat/format\"><code>format</code></a></th>\n<td class=\"bc-supports-yes\"> 24</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 29</td>\n<td class=\"bc-supports-yes\"> 11</td>\n<td class=\"bc-supports-yes\"> 15</td>\n<td class=\"bc-supports-yes\"> 10</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/NumberFormat/formatToParts\"><code>formatToParts</code></a> \n</th>\n<td class=\"bc-supports-yes bc-has-history\"> 63<div class=\"bc-icons\"> Disabled </div>\n<section class=\"bc-history\" id=\"sect1\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 63<div class=\"bc-icons\"> Disabled </div>\n</dt>\n<dd> Need to set the flag on the commandline via --js-flags</dd>\n<dd>Disabled From version 63: this feature is behind the <code>harmony-number-format-to-parts</code> runtime flag.</dd>\n</dl></section>\n</td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 58</td>\n<td> ? </td>\n<td> ? </td>\n<td> ? </td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/NumberFormat/resolvedOptions\"><code>resolvedOptions</code></a></th>\n<td class=\"bc-supports-yes\"> 24</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 29</td>\n<td class=\"bc-supports-yes\"> 11</td>\n<td class=\"bc-supports-yes\"> 15</td>\n<td class=\"bc-supports-yes\"> 10</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/NumberFormat/supportedLocalesOf\"><code>supportedLocalesOf</code></a></th>\n<td class=\"bc-supports-yes\"> 24</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 29</td>\n<td class=\"bc-supports-yes\"> 11</td>\n<td class=\"bc-supports-yes\"> 15</td>\n<td class=\"bc-supports-yes\"> 10</td>\n</tr>\n</tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 4.4</td>\n<td class=\"bc-supports-yes\"> 26</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 56</td>\n<td class=\"bc-supports-yes\"> 37</td>\n<td class=\"bc-supports-yes\"> 10</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/NumberFormat/prototype\"><code>prototype</code></a></th>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 26</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 56</td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 10</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/NumberFormat/format\"><code>format</code></a></th>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 26</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 56</td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 10</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/NumberFormat/formatToParts\"><code>formatToParts</code></a> \n</th>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes bc-has-history\"> 63<div class=\"bc-icons\"> Disabled </div>\n<section class=\"bc-history\" id=\"sect2\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 63<div class=\"bc-icons\"> Disabled </div>\n</dt>\n<dd> Need to set the flag on the commandline via --js-flags</dd>\n<dd>Disabled From version 63: this feature is behind the <code>harmony-number-format-to-parts</code> runtime flag.</dd>\n</dl></section>\n</td>\n<td> ? </td>\n<td> ? </td>\n<td> ? </td>\n<td> ? </td>\n<td class=\"bc-supports-no\"> No</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/NumberFormat/resolvedOptions\"><code>resolvedOptions</code></a></th>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 26</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 56</td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 10</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/NumberFormat/supportedLocalesOf\"><code>supportedLocalesOf</code></a></th>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 26</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 56</td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 10</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n</tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td> ? </td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/NumberFormat/prototype\"><code>prototype</code></a></th>\n<td> ? </td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/NumberFormat/format\"><code>format</code></a></th>\n<td> ? </td>\n</tr>\n<tr>\n<th scope=\"row\">\n<a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/NumberFormat/formatToParts\"><code>formatToParts</code></a> \n</th>\n<td> ? </td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/NumberFormat/resolvedOptions\"><code>resolvedOptions</code></a></th>\n<td> ? </td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/NumberFormat/supportedLocalesOf\"><code>supportedLocalesOf</code></a></th>\n<td> ? </td>\n</tr>\n</tbody>\n</table>\n</div>  <h2 id=\"See_also\">See also</h2> <ul> <li>Introduction: <a href=\"http://norbertlindenberg.com/2012/12/ecmascript-internationalization-api/index.html\">The ECMAScript Internationalization API</a>\n</li> <li>Constructors <ul> <li><a href=\"collator\"><code>Intl.Collator</code></a></li> <li><a href=\"datetimeformat\"><code>Intl.DateTimeFormat</code></a></li> <li><a href=\"numberformat\"><code>Intl.NumberFormat</code></a></li> </ul> </li> <li>Methods <ul> <li><a href=\"string/localecompare\"><code>String.prototype.localeCompare()</code></a></li> <li><a href=\"number/tolocalestring\"><code>Number.prototype.toLocaleString()</code></a></li> <li><a href=\"date/tolocalestring\"><code>Date.prototype.toLocaleString()</code></a></li> <li><a href=\"date/tolocaledatestring\"><code>Date.prototype.toLocaleDateString()</code></a></li> <li><a href=\"date/tolocaletimestring\"><code>Date.prototype.toLocaleTimeString()</code></a></li> </ul> </li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/NumberFormat$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/NumberFormat\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/NumberFormat</a>\n  </p>\n</div>\n","global_objects/json":"<h1>JSON</h1> <p>The <code>JSON</code> object contains methods for parsing <a href=\"https://json.org/\">JavaScript Object Notation</a> (<a href=\"https://developer.mozilla.org/en-US/docs/Glossary/JSON\">JSON</a>) and converting values to JSON. It can't be called or constructed, and aside from its two method properties, it has no interesting functionality of its own.</p> <h2 id=\"JavaScript_and_JSON_differences\">JavaScript and JSON differences</h2> <p>JSON is a syntax for serializing objects, arrays, numbers, strings, booleans, and <a href=\"null\"><code>null</code></a>. It is based upon JavaScript syntax but is distinct from it: some JavaScript is not JSON.</p> <p><strong>Objects and Arrays</strong>: Property names must be double-quoted strings; trailing commas are forbidden.</p> <p><strong>Numbers</strong>: Leading zeros are prohibited (in <a href=\"json/stringify\"><code>JSON.stringify</code></a> zeros will be ignored, but in <a href=\"json/parse\"><code>JSON.parse</code></a> it will throw SyntaxError); a decimal point must be followed by at least one digit.</p> <p><strong>Any JSON text is a valid JavaScript expression</strong> – but only in JavaScript engines that have implemented the <a href=\"https://github.com/tc39/proposal-json-superset\">proposal to make all JSON text valid ECMA-262</a>. In engines that haven't implemented the proposal, U+2028 LINE SEPARATOR and U+2029 PARAGRAPH SEPARATOR are allowed in string literals and property keys in JSON; but their use in these features in JavaScript literals is a <a href=\"syntaxerror\"><code>SyntaxError</code></a>.</p> <p>Consider this example where <a href=\"json/parse\"><code>JSON.parse()</code></a> parses the string as JSON and <code><a href=\"eval\">eval</a></code> executes the string as JavaScript:</p> <pre data-language=\"js\">var code = '\"\\u2028\\u2029\"';\nJSON.parse(code); // evaluates to \"\\u2028\\u2029\" in all engines\neval(code); // throws a SyntaxError in old engines\n</pre> <h2 id=\"Full_JSON_syntax\">Full JSON syntax</h2> <p>The full JSON syntax is as follows:</p> <pre><var>JSON</var> = <strong>null</strong>\n    <em>or</em> <strong>true</strong> <em>or</em> <strong>false</strong>\n    <em>or</em> <var>JSONNumber</var>\n    <em>or</em> <var>JSONString</var>\n    <em>or</em> <var>JSONObject</var>\n    <em>or</em> <var>JSONArray</var>\n\n<var>JSONNumber</var> = <strong>-</strong> <var>PositiveNumber</var>\n          <em>or</em> <var>PositiveNumber</var>\n<var>PositiveNumber</var> = DecimalNumber\n              <em>or</em> <var>DecimalNumber</var> <strong>.</strong> <var>Digits</var>\n              <em>or</em> <var>DecimalNumber</var> <strong>.</strong> <var>Digits</var> <var>ExponentPart</var>\n              <em>or</em> <var>DecimalNumber</var> <var>ExponentPart</var>\n<var>DecimalNumber</var> = <strong>0</strong>\n             <em>or</em> <var>OneToNine</var> <var>Digits</var>\n<var>ExponentPart</var> = <strong>e</strong> <var>Exponent</var>\n            <em>or</em> <strong>E</strong> <var>Exponent</var>\n<var>Exponent</var> = <var>Digits</var>\n        <em>or</em> <strong>+</strong> <var>Digits</var>\n        <em>or</em> <strong>-</strong> <var>Digits</var>\n<var>Digits</var> = <var>Digit</var>\n      <em>or</em> <var>Digits</var> <var>Digit</var>\n<var>Digit</var> = <strong>0</strong> through <strong>9</strong>\n<var>OneToNine</var> = <strong>1</strong> through <strong>9</strong>\n\n<var>JSONString</var> = <strong>\"\"</strong>\n          <em>or</em> <strong>\"</strong> <var>StringCharacters</var> <strong>\"</strong>\n<var>StringCharacters</var> = <var>StringCharacter</var>\n                <em>or</em> <var>StringCharacters</var> <var>StringCharacter</var>\n<var>StringCharacter</var> = any character\n                  <em>except</em> <strong>\"</strong> <em>or</em> <strong>\\</strong> <em>or</em> U+0000 through U+001F\n               <em>or</em> <var>EscapeSequence</var>\n<var>EscapeSequence</var> = <strong>\\\"</strong> <em>or</em> <strong>\\/</strong> <em>or</em> <strong>\\\\</strong> <em>or</em> <strong>\\b</strong> <em>or</em> <strong>\\f</strong> <em>or</em> <strong>\\n</strong> <em>or</em> <strong>\\r</strong> <em>or</em> <strong>\\t</strong>\n              <em>or</em> <strong>\\u</strong> <var>HexDigit</var> <var>HexDigit</var> <var>HexDigit</var> <var>HexDigit</var>\n<var>HexDigit</var> = <strong>0</strong> through <strong>9</strong>\n        <em>or</em> <strong>A</strong> through <strong>F</strong>\n        <em>or</em> <strong>a</strong> through <strong>f</strong>\n\n<var>JSONObject</var> = <strong>{</strong> <strong>}</strong>\n          <em>or</em> <strong>{</strong> <var>Members</var> <strong>}</strong>\n<var>Members</var> = <var>JSONString</var> <strong>:</strong> <var>JSON</var>\n       <em>or</em> <var>Members</var> <strong>,</strong> <var>JSONString</var> <strong>:</strong> <var>JSON</var>\n\n<var>JSONArray</var> = <strong>[</strong> <strong>]</strong>\n         <em>or</em> <strong>[</strong> <var>ArrayElements</var> <strong>]</strong>\n<var>ArrayElements</var> = <var>JSON</var>\n             <em>or</em> <var>ArrayElements</var> <strong>,</strong> <var>JSON</var>\n</pre> <p>Insignificant whitespace may be present anywhere except within a <code><var>JSONNumber</var></code> (numbers must contain no whitespace) or <code><var>JSONString</var></code> (where it is interpreted as the corresponding character in the string, or would cause an error). The tab character (<a href=\"http://unicode-table.com/en/0009/\">U+0009</a>), carriage return (<a href=\"http://unicode-table.com/en/000D/\">U+000D</a>), line feed (<a href=\"http://unicode-table.com/en/000A/\">U+000A</a>), and space (<a href=\"http://unicode-table.com/en/0020/\">U+0020</a>) characters are the only valid whitespace characters.</p> <h2 id=\"Methods\">Methods</h2> <dl> <dt><a href=\"json/parse\"><code>JSON.parse()</code></a></dt> <dd>Parse a string as JSON, optionally transform the produced value and its properties, and return the value.</dd> <dt><a href=\"json/stringify\"><code>JSON.stringify()</code></a></dt> <dd>Return a JSON string corresponding to the specified value, optionally including only certain properties or replacing property values in a user-defined manner.</dd> </dl> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/5.1/#sec-15.12\" hreflang=\"en\">ECMAScript 5.1 (ECMA-262)<br><small>The definition of 'JSON' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-json-object\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'JSON' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-json-object\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'JSON' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>    <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 3.5</td>\n<td class=\"bc-supports-yes\"> 8</td>\n<td class=\"bc-supports-yes\"> 10.5</td>\n<td class=\"bc-supports-yes\"> 4</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse\"><code>parse</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 3.5</td>\n<td class=\"bc-supports-yes\"> 8</td>\n<td class=\"bc-supports-yes\"> 10.5</td>\n<td class=\"bc-supports-yes\"> 4</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify\"><code>stringify</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 3.5</td>\n<td class=\"bc-supports-yes\"> 8</td>\n<td class=\"bc-supports-yes\"> 10.5</td>\n<td class=\"bc-supports-yes\"> 4</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/JSON#JavaScript_and_JSON_differences\">JavaScript is a superset of JSON</a></th>\n<td class=\"bc-supports-yes\"> 66</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 62</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 53</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n</tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse\"><code>parse</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify\"><code>stringify</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/JSON#JavaScript_and_JSON_differences\">JavaScript is a superset of JSON</a></th>\n<td class=\"bc-supports-yes\"> 66</td>\n<td class=\"bc-supports-yes\"> 66</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 62</td>\n<td class=\"bc-supports-yes\"> 53</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-no\"> No</td>\n</tr>\n</tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse\"><code>parse</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify\"><code>stringify</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/JSON#JavaScript_and_JSON_differences\">JavaScript is a superset of JSON</a></th>\n<td class=\"bc-supports-yes\"> 10.0.0</td>\n</tr>\n</tbody>\n</table>\n</div>   <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"date/tojson\"><code>Date.prototype.toJSON()</code></a></li> </ul>  <h2 id=\"Tools\">Tools</h2> <ul> <li>\n<a href=\"http://jsoncompare.org/\">JSON Diff</a> checker. </li> <li>\n<a href=\"http://jsonbeautifier.org/\">JSON Beautifier/editor</a>.</li> <li><a href=\"http://jsonparser.org/\">JSON Parser</a></li> <li>\n<a href=\"https://tools.learningcontainer.com/json-validator/\">JSON Validator</a>.</li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON</a>\n  </p>\n</div>\n","global_objects/generator":"<h1>Generator</h1> <p>The <code><strong>Generator</strong></code> object is returned by a <a href=\"../statements/function*\">generator function</a> and it conforms to both the <a href=\"../iteration_protocols#The_iterable_protocol\">iterable protocol</a> and the <a href=\"../iteration_protocols#The_iterator_protocol\">iterator protocol</a>.</p> <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\">function* gen() { \n  yield 1;\n  yield 2;\n  yield 3;\n}\n\nvar g = gen(); // \"Generator { }\"</pre> <h2 id=\"Methods\">Methods</h2> <dl> <dt><a href=\"generator/next\"><code>Generator.prototype.next()</code></a></dt> <dd>Returns a value yielded by the <a href=\"../operators/yield\"><code>yield</code></a> expression.</dd> <dt><a href=\"generator/return\"><code>Generator.prototype.return()</code></a></dt> <dd>Returns the given value and finishes the generator.</dd> <dt><a href=\"generator/throw\"><code>Generator.prototype.throw()</code></a></dt> <dd>Throws an error to a generator (also finishes the generator, unless caught from within that generator).</dd> </dl> <h2 id=\"Example\">Example</h2> <h3 id=\"An_infinite_iterator\">An infinite iterator</h3> <pre data-language=\"js\">function* idMaker() {\n    var index = 0;\n    while(true)\n        yield index++;\n}\n\nvar gen = idMaker(); // \"Generator { }\"\n\nconsole.log(gen.next().value); // 0\nconsole.log(gen.next().value); // 1\nconsole.log(gen.next().value); // 2\n// ...</pre> <h2 id=\"Legacy_generator_objects\">Legacy generator objects</h2> <p>Firefox (SpiderMonkey) also implemented an earlier version of generators in <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/New_in_JavaScript/1.7\">JavaScript 1.7</a>, where the star (*) in the function declaration was not necessary (you just use the <code>yield</code> keyword in the function body). However, legacy generators support has been removed since Firefox 58 (released on January 23, 2018) (<a href=\"https://bugzilla.mozilla.org/show_bug.cgi?id=1083482\">bug 1083482</a>).</p> <h3 id=\"Legacy_generator_methods\">Legacy generator methods</h3> <dl> <dt>\n<code>Generator.prototype.next() </code>\n</dt> <dd>Returns a value yielded by the <a href=\"../operators/yield\"><code>yield</code></a> expression. This corresponds to <code>next()</code> in the ES2015 generator object.</dd> <dt>\n<code>Generator.prototype.close()</code> \n</dt> <dd>Closes the generator, so that when calling <code>next()</code> an <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/StopIteration\"><code>StopIteration</code></a> error will be thrown. This corresponds to the <code>return()</code> method in the ES2015 generator object.</dd> <dt>\n<code>Generator.prototype.send()</code> \n</dt> <dd>Used to send a value to a generator. The value is returned from the <a href=\"../operators/yield\"><code>yield</code></a> expression, and returns a value yielded by the next <a href=\"../operators/yield\"><code>yield</code></a> expression. <code>send(x)</code> corresponds to <code>next(x)</code> in the ES2015 generator object.</dd> <dt>\n<code>Generator.</code><code>prototype.</code><code>throw()</code> \n</dt> <dd>Throws an error to a generator. This corresponds to the <code>throw()</code> method in the ES2015 generator object.</dd> </dl> <h3 id=\"Legacy_generator_example\">Legacy generator example</h3> <pre data-language=\"js\">function fibonacci() {\n  var a = yield 1;\n  yield a * 2;\n}\n\nvar it = fibonacci();\nconsole.log(it);          // \"Generator {  }\"\nconsole.log(it.next());   // 1\nconsole.log(it.send(10)); // 20\nconsole.log(it.close());  // undefined\nconsole.log(it.next());   // throws StopIteration (as the generator is now closed)\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-generator-objects\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Generator objects' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-generator-objects\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Generator objects' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 39</td>\n<td class=\"bc-supports-yes\"> 13</td>\n<td class=\"bc-supports-yes\"> 26</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 10</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Generator/next\"><code>next</code></a></th>\n<td class=\"bc-supports-yes\"> 39</td>\n<td class=\"bc-supports-yes\"> 13</td>\n<td class=\"bc-supports-yes\"> 26</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 10</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Generator/return\"><code>return</code></a></th>\n<td class=\"bc-supports-yes\"> 50</td>\n<td class=\"bc-supports-yes\"> 13</td>\n<td class=\"bc-supports-yes\"> 38</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 37</td>\n<td class=\"bc-supports-yes\"> 10</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Generator/throw\"><code>throw</code></a></th>\n<td class=\"bc-supports-yes\"> 39</td>\n<td class=\"bc-supports-yes\"> 13</td>\n<td class=\"bc-supports-yes\"> 26</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 10</td>\n</tr>\n</tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 13</td>\n<td class=\"bc-supports-yes\"> 26</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 10</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Generator/next\"><code>next</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 13</td>\n<td class=\"bc-supports-yes\"> 26</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 10</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Generator/return\"><code>return</code></a></th>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 50</td>\n<td class=\"bc-supports-yes\"> 13</td>\n<td class=\"bc-supports-yes\"> 38</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 10</td>\n<td class=\"bc-supports-yes\"> 5.0</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Generator/throw\"><code>throw</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 13</td>\n<td class=\"bc-supports-yes\"> 26</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 10</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n</tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes bc-has-history\"> 4.0.0\n<section class=\"bc-history\" id=\"sect1\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 4.0.0\n</dt>\n\n<dt class=\"bc-supports-yes bc-supports\"> 0.12<div class=\"bc-icons\">Disabled </div>\n</dt>\n<dd>Disabled From version 0.12: this feature is behind the <code>--harmony</code> runtime flag.</dd>\n</dl></section>\n</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Generator/next\"><code>next</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Generator/return\"><code>return</code></a></th>\n<td class=\"bc-supports-yes\"> 6.0.0</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Generator/throw\"><code>throw</code></a></th>\n<td class=\"bc-supports-yes bc-has-history\"> 4.0.0\n<section class=\"bc-history\" id=\"sect2\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 4.0.0\n</dt>\n\n<dt class=\"bc-supports-yes bc-supports\"> 0.12<div class=\"bc-icons\">Disabled </div>\n</dt>\n<dd>Disabled From version 0.12: this feature is behind the <code>--harmony</code> runtime flag.</dd>\n</dl></section>\n</td>\n</tr>\n</tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <h3 id=\"Legacy_generators\">Legacy generators</h3> <ul> <li><a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/Legacy_generator_function\">The legacy generator function</a></li> <li><a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Legacy_generator_function\">The legacy generator function expression</a></li> <li><a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/StopIteration\"><code>StopIteration</code></a></li> <li><a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Deprecated_and_obsolete_features/The_legacy_Iterator_protocol\">The legacy Iterator protocol</a></li> </ul> <h3 id=\"ES2015_generators\">ES2015 generators</h3> <ul> <li><a href=\"../functions\">Functions</a></li> <li><a href=\"../statements/function\"><code>function</code></a></li> <li><a href=\"../operators/function\"><code>function expression</code></a></li> <li><a href=\"function\"><code>Function</code></a></li> <li><a href=\"../statements/function*\"><code>function*</code></a></li> <li><a href=\"../operators/function*\"><code>function* expression</code></a></li> <li><a href=\"generatorfunction\"><code>GeneratorFunction</code></a></li> <li><a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/The_Iterator_protocol\">The Iterator protocol</a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Generator$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Generator\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Generator</a>\n  </p>\n</div>\n","global_objects/boolean":"<h1>Boolean</h1> <p>The <code>Boolean</code> object is an object wrapper for a boolean value.</p> <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\">new Boolean([<var>value</var>])</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><code>value</code></dt> <dd>Optional. The initial value of the <code>Boolean</code> object.</dd> </dl> <h2 id=\"Description\">Description</h2> <p>The value passed as the first parameter is converted to a boolean value, if necessary. If the value is omitted or is <code>0</code>, <code>-0</code>, <a href=\"null\"><code>null</code></a>, <code>false</code>, <a href=\"nan\"><code>NaN</code></a>, <a href=\"undefined\"><code>undefined</code></a>, or the empty string (<code>\"\"</code>), the object has an initial value of <code>false</code>. All other values, including any object or the string <code>\"false\"</code>, create an object with an initial value of <code>true</code>.</p> <p>Do not confuse the primitive <code>Boolean</code> values <code>true</code> and <code>false</code> with the <code>true</code> and <code>false</code> values of the <code>Boolean</code> object.</p> <p>Any object of which the value is not <a href=\"undefined\"><code>undefined</code></a> or <a href=\"null\"><code>null</code></a>, including a <code>Boolean</code> object whose value is <code>false</code>, evaluates to <code>true</code> when passed to a conditional statement. For example, the condition in the following <a href=\"../statements/if...else\"><code>if</code></a> statement evaluates to <code>true</code>:</p> <pre data-language=\"js\">var x = new Boolean(false);\nif (x) {\n  // this code is executed\n}\n</pre> <p>This behavior does not apply to <code>Boolean</code> primitives. For example, the condition in the following <a href=\"../statements/if...else\"><code>if</code></a> statement evaluates to <code>false</code>:</p> <pre data-language=\"js\">var x = false;\nif (x) {\n  // this code is not executed\n}\n</pre> <p>Do not use a <code>Boolean</code> object to convert a non-boolean value to a boolean value. Instead, use <code>Boolean</code> as a function to perform this task:</p> <pre data-language=\"js\">var x = Boolean(expression);     // preferred\nvar x = new Boolean(expression); // don't use\n</pre> <p>If you specify any object, including a <code>Boolean</code> object whose value is <code>false</code>, as the initial value of a <code>Boolean</code> object, the new <code>Boolean</code> object has a value of <code>true</code>.</p> <pre data-language=\"js\">var myFalse = new Boolean(false);   // initial value of false\nvar g = Boolean(myFalse);       // initial value of true\nvar myString = new String('Hello'); // string object\nvar s = Boolean(myString);      // initial value of true\n</pre> <p>Do not use a <code>Boolean</code> object in place of a <code>Boolean</code> primitive.</p> <div class=\"note\"> <p><strong>Note:</strong> When the non-standard property <code><a href=\"https://developer.mozilla.org/en-US/docs/Web/API/Document#Properties\">document.all</a></code> is used as an argument for this constructor, the result is a <code>Boolean</code> object with the value <code>false</code>. This property is legacy and non-standard and should not be used.</p> </div> <h2 id=\"Properties\">Properties</h2> <dl> <dt><code>Boolean.length</code></dt> <dd>Length property whose value is 1.</dd> <dt><a href=\"boolean/prototype\"><code>Boolean.prototype</code></a></dt> <dd>Represents the prototype for the <code>Boolean</code> constructor.</dd> </dl> <h2 id=\"Methods\">Methods</h2> <p>While the global <code>Boolean</code> object contains no methods of its own, it does inherit some methods through the prototype chain:</p> <h2 id=\"Boolean_instances\">\n<code>Boolean</code> instances</h2> <p>All <code>Boolean</code> instances inherit from <a href=\"boolean/prototype\"><code>Boolean.prototype</code></a>. As with all constructors, the prototype object dictates instances' inherited properties and methods.</p> <h3 id=\"Properties_2\">Properties</h3> <dl> <dt><code>Boolean.prototype.constructor</code></dt> <dd>Returns the function that created an instance's prototype. This is the <a href=\"boolean\"><code>Boolean</code></a> function by default.</dd> </dl> <h3 id=\"Methods_2\">Methods</h3> <dl> <dt>\n<a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean/toSource\"><code>Boolean.prototype.toSource()</code></a> \n</dt> <dd>Returns a string containing the source of the <a href=\"boolean\"><code>Boolean</code></a> object; you can use this string to create an equivalent object. Overrides the <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/toSource\"><code>Object.prototype.toSource()</code></a> method.</dd> <dt><a href=\"boolean/tostring\"><code>Boolean.prototype.toString()</code></a></dt> <dd>Returns a string of either <code>\"true\"</code> or <code>\"false\"</code> depending upon the value of the object. Overrides the <a href=\"object/tostring\"><code>Object.prototype.toString()</code></a> method.</dd> <dt><a href=\"boolean/valueof\"><code>Boolean.prototype.valueOf()</code></a></dt> <dd>Returns the primitive value of the <a href=\"boolean\"><code>Boolean</code></a> object. Overrides the <a href=\"object/valueof\"><code>Object.prototype.valueOf()</code></a> method.</dd> </dl> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Creating_Boolean_objects_with_an_initial_value_of_false\">Creating <code>Boolean</code> objects with an initial value of <code>false</code>\n</h3> <pre data-language=\"js\">var bNoParam = new Boolean();\nvar bZero = new Boolean(0);\nvar bNull = new Boolean(null);\nvar bEmptyString = new Boolean('');\nvar bfalse = new Boolean(false);\n</pre> <h3 id=\"Creating_Boolean_objects_with_an_initial_value_of_true\">Creating <code>Boolean</code> objects with an initial value of <code>true</code>\n</h3> <pre data-language=\"js\">var btrue = new Boolean(true);\nvar btrueString = new Boolean('true');\nvar bfalseString = new Boolean('false');\nvar bSuLin = new Boolean('Su Lin');\nvar bArrayProto = new Boolean([]);\nvar bObjProto = new Boolean({});\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/publications/files/ECMA-ST-ARCH/ECMA-262,%201st%20edition,%20June%201997.pdf\" hreflang=\"en\">ECMAScript 1st Edition (ECMA-262)</a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition. Implemented in JavaScript 1.0.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/5.1/#sec-15.6\" hreflang=\"en\">ECMAScript 5.1 (ECMA-262)<br><small>The definition of 'Boolean' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-boolean-objects\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Boolean' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-boolean-objects\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Boolean' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>   <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean/prototype\"><code>prototype</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean/toSource\"><code>toSource</code></a> \n</th>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean/toString\"><code>toString</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean/valueOf\"><code>valueOf</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n</tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean/prototype\"><code>prototype</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean/toSource\"><code>toSource</code></a> \n</th>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean/toString\"><code>toString</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean/valueOf\"><code>valueOf</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n</tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean/prototype\"><code>prototype</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean/toSource\"><code>toSource</code></a> \n</th>\n<td class=\"bc-supports-no\"> No</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean/toString\"><code>toString</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean/valueOf\"><code>valueOf</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n</tbody>\n</table>\n</div>  <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"boolean/prototype\"><code>Boolean.prototype</code></a></li> <li><a href=\"https://developer.mozilla.org/en-US/docs/Glossary/Boolean\">Boolean</a></li> <li><a href=\"http://en.wikipedia.org/wiki/Boolean_data_type\">Boolean data type (Wikipedia)</a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean</a>\n  </p>\n</div>\n","global_objects/intl":"<h1>Intl</h1> <p>The <code>Intl</code> object is the namespace for the ECMAScript Internationalization API, which provides language sensitive string comparison, number formatting, and date and time formatting. The constructors for <a href=\"collator\"><code>Collator</code></a>, <a href=\"numberformat\"><code>NumberFormat</code></a>, and <a href=\"datetimeformat\"><code>DateTimeFormat</code></a> objects are properties of the <code>Intl</code> object. This page documents these properties as well as functionality common to the internationalization constructors and other language sensitive functions.</p> <h2 id=\"Properties\">Properties</h2> <dl> <dt><a href=\"collator\"><code>Intl.Collator</code></a></dt> <dd>Constructor for collators, objects that enable language sensitive string comparison.</dd> <dt><a href=\"datetimeformat\"><code>Intl.DateTimeFormat</code></a></dt> <dd>Constructor for objects that enable language sensitive date and time formatting.</dd> <dt><a href=\"numberformat\"><code>Intl.NumberFormat</code></a></dt> <dd>Constructor for objects that enable language sensitive number formatting.</dd> <dt><a href=\"pluralrules\"><code>Intl.PluralRules</code></a></dt> <dd>Constructor for objects that enable plural sensitive formatting and plural language langue rules.</dd> </dl> <h2 id=\"Methods\">Methods</h2> <dl> <dt><a href=\"intl/getcanonicallocales\"><code>Intl.getCanonicalLocales()</code></a></dt> <dd>A method returning the canonical locale names.</dd> </dl> <h2 id=\"Locale_identification_and_negotiation\">Locale identification and negotiation</h2> <p>The internationalization constructors as well as several language sensitive methods of other constructors (listed under <a href=\"#See_also\">See also</a>) use a common pattern for identifying locales and determing the one they will actually use: they all accept <code>locales</code> and <code>options</code> arguments, and negotiate the requested locale(s) against the locales they support using an algorithm specified in the <code>options.localeMatcher</code> property.</p> <h3 id=\"locales_argument\">\n<code>locales</code> argument</h3> <p>The <code>locales</code> argument must be either a string holding a <a href=\"http://tools.ietf.org/html/rfc5646\">BCP 47 language tag</a>, or an array of such language tags. If the <code>locales</code> argument is not provided or is undefined, the runtime's default locale is used.</p> <p>A BCP 47 language tag defines a language and minimally contains a primary language code. In its most common form it can contain, in order: a language code, a script code, and a country or region code, all separated by hyphens. While the tag is not case sensitive, it is recommended to use title case for script code, upper case for country and region codes and lower case for everything else.</p> <p>Examples:</p> <ul> <li>\n<code>\"hi\"</code>: Hindi (primary language).</li> <li>\n<code>\"de-AT\"</code>: German as used in Austria (primary language with country code).</li> <li>\n<code>\"zh-Hans-CN\"</code>: Chinese written in simplified characters as used in China (primary language with script and country codes).</li> </ul> <p>The subtags identifying languages, scripts, countries (regions), and (rarely used) variants in BCP 47 language tags can be found in the <a href=\"http://www.iana.org/assignments/language-subtag-registry\">IANA Language Subtag Registry</a>.</p> <p>BCP 47 also allows for extensions. JavaScript internationalization functions use the <code>\"u\"</code> (Unicode) extension, which can be used to request additional customization of <a href=\"collator\"><code>Collator</code></a>, <a href=\"numberformat\"><code>NumberFormat</code></a>, or <a href=\"datetimeformat\"><code>DateTimeFormat</code></a> objects. Examples:</p> <ul> <li>\n<code>\"de-DE-u-co-phonebk\"</code>: Use the phonebook variant of the German sort order, which expands umlauted vowels to character pairs: ä → ae, ö → oe, ü → ue.</li> <li>\n<code>\"th-TH-u-nu-thai\"</code>: Use Thai digits (๐, ๑, ๒, ๓, ๔, ๕, ๖, ๗, ๘, ๙) in number formatting.</li> <li>\n<code>\"ja-JP-u-ca-japanese\"</code>: Use the Japanese calendar in date and time formatting, so that 2013 is expressed as the year 25 of the Heisei period, or 平成25.</li> <li>\n<code>\"en-GB-u-ca-islamic\"</code>: use British English with the Islamic (Hijri) calendar, where the Gregorian date 14 October, 2017 is the Hijri date 24 Muharram, 1439.</li> </ul> <h3 id=\"Locale_negotiation\">Locale negotiation</h3> <p>The <code>locales</code> argument, after stripping off all Unicode extensions, is interpreted as a prioritized request from the application. The runtime compares it against the locales it has available and picks the best one available. Two matching algorithms exist: the <code>\"lookup\"</code> matcher follows the Lookup algorithm specified in <a href=\"http://tools.ietf.org/html/rfc4647#section-3.4\">BCP 47</a>; the <code>\"best fit\"</code> matcher lets the runtime provide a locale that's at least, but possibly more, suited for the request than the result of the Lookup algorithm. If the application doesn't provide a <code>locales</code> argument, or the runtime doesn't have a locale that matches the request, then the runtime's default locale is used. The matcher can be selected using a property of the <code>options</code> argument (see below).</p> <p>If the selected language tag had a Unicode extension substring, that extension is now used to customize the constructed object or the behavior of the function. Each constructor or function supports only a subset of the keys defined for the Unicode extension, and the supported values often depend on the language tag. For example, the <code>\"co\"</code> key (collation) is only supported by <a href=\"collator\"><code>Collator</code></a>, and its <code>\"phonebk\"</code> value is only supported for German.</p> <h3 id=\"options_argument\">\n<code>options</code> argument</h3> <p>The <code>options</code> argument must be an object with properties that vary between constructors and functions. If the <code>options</code> argument is not provided or is undefined, default values are used for all properties.</p> <p>One property is supported by all language sensitive constructors and functions: The <code>localeMatcher</code> property, whose value must be a string <code>\"lookup\"</code> or <code>\"best fit\"</code> and which selects one of the locale matching algorithms described above.</p> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-402/1.0/#sec-8\" hreflang=\"en\">ECMAScript Internationalization API 1.0 (ECMA-402)<br><small>The definition of 'Intl' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-402/2.0/#sec-8\" hreflang=\"en\">ECMAScript Internationalization API 2.0 (ECMA-402)<br><small>The definition of 'Intl' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma402/#intl-object\" hreflang=\"en\">ECMAScript Internationalization API 4.0 (ECMA-402)<br><small>The definition of 'Intl' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td>Added Intl.getCanonicalLocales in the 4th edition.</td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>   <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 24</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 29</td>\n<td class=\"bc-supports-yes\"> 11</td>\n<td class=\"bc-supports-yes\"> 15</td>\n<td class=\"bc-supports-yes\"> 10</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Intl/getCanonicalLocales\"><code>getCanonicalLocales</code></a></th>\n<td class=\"bc-supports-yes\"> 54</td>\n<td class=\"bc-supports-yes\"> 16</td>\n<td class=\"bc-supports-yes\"> 48</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 11</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Collator\"><code>Collator</code></a></th>\n<td class=\"bc-supports-yes\"> 24</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 29</td>\n<td class=\"bc-supports-yes\"> 11</td>\n<td class=\"bc-supports-yes\"> 15</td>\n<td class=\"bc-supports-yes\"> 10</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/DateTimeFormat\"><code>DateTimeFormat</code></a></th>\n<td class=\"bc-supports-yes\"> 24</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 29</td>\n<td class=\"bc-supports-yes\"> 11</td>\n<td class=\"bc-supports-yes\"> 15</td>\n<td class=\"bc-supports-yes\"> 10</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/NumberFormat\"><code>NumberFormat</code></a></th>\n<td class=\"bc-supports-yes\"> 24</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 29</td>\n<td class=\"bc-supports-yes\"> 11</td>\n<td class=\"bc-supports-yes\"> 15</td>\n<td class=\"bc-supports-yes\"> 10</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/PluralRules\"><code>PluralRules</code></a></th>\n<td class=\"bc-supports-yes\"> 63</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 58</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 50</td>\n<td class=\"bc-supports-no\"> No</td>\n</tr>\n</tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 26</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 56</td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 10</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Intl/getCanonicalLocales\"><code>getCanonicalLocales</code></a></th>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 56</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 11</td>\n<td class=\"bc-supports-no\"> No</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Collator\"><code>Collator</code></a></th>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 26</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 56</td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 10</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/DateTimeFormat\"><code>DateTimeFormat</code></a></th>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 26</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 56</td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 10</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/NumberFormat\"><code>NumberFormat</code></a></th>\n<td class=\"bc-supports-yes\"> 4.4</td>\n<td class=\"bc-supports-yes\"> 26</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 56</td>\n<td class=\"bc-supports-yes\"> 37</td>\n<td class=\"bc-supports-yes\"> 10</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/PluralRules\"><code>PluralRules</code></a></th>\n<td class=\"bc-supports-yes\"> 63</td>\n<td class=\"bc-supports-yes\"> 63</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 58</td>\n<td class=\"bc-supports-yes\"> 50</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n</tr>\n</tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td> ? </td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Intl/getCanonicalLocales\"><code>getCanonicalLocales</code></a></th>\n<td class=\"bc-supports-no\"> No</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Collator\"><code>Collator</code></a></th>\n<td> ? </td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/DateTimeFormat\"><code>DateTimeFormat</code></a></th>\n<td> ? </td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/NumberFormat\"><code>NumberFormat</code></a></th>\n<td> ? </td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/PluralRules\"><code>PluralRules</code></a></th>\n<td class=\"bc-supports-no\"> No</td>\n</tr>\n</tbody>\n</table>\n</div>  <h2 id=\"See_also\">See also</h2> <ul> <li>Introduction: <a href=\"http://norbertlindenberg.com/2012/12/ecmascript-internationalization-api/index.html\">The ECMAScript Internationalization API</a>\n</li> <li>Constructors <ul> <li><a href=\"collator\"><code>Intl.Collator</code></a></li> <li><a href=\"datetimeformat\"><code>Intl.DateTimeFormat</code></a></li> <li><a href=\"numberformat\"><code>Intl.NumberFormat</code></a></li> </ul> </li> <li>Methods <ul> <li><a href=\"string/localecompare\"><code>String.prototype.localeCompare()</code></a></li> <li><a href=\"number/tolocalestring\"><code>Number.prototype.toLocaleString()</code></a></li> <li><a href=\"date/tolocalestring\"><code>Date.prototype.toLocaleString()</code></a></li> <li><a href=\"date/tolocaledatestring\"><code>Date.prototype.toLocaleDateString()</code></a></li> <li><a href=\"date/tolocaletimestring\"><code>Date.prototype.toLocaleTimeString()</code></a></li> </ul> </li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl</a>\n  </p>\n</div>\n","global_objects/float32array":"<h1>Float32Array</h1> <p>The <code>Float32Array</code> typed array represents an array of 32-bit floating point numbers (corresponding to the C <code>float</code> data type) in the platform byte order. If control over byte order is needed, use <a href=\"dataview\"><code>DataView</code></a> instead. The contents are initialized to <code>0</code>. Once established, you can reference elements in the array using the object's methods, or using standard array index syntax (that is, using bracket notation).</p> <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\">new Float32Array(); // new in ES2017\nnew Float32Array(length);\nnew Float32Array(typedArray);\nnew Float32Array(object);\nnew Float32Array(buffer [, byteOffset [, length]]);</pre> <p>For more information about the constructor syntax and the parameters, see <em><a href=\"typedarray#Syntax\">TypedArray</a></em>.</p> <h2 id=\"Properties\">Properties</h2> <dl> <dt><a href=\"typedarray/bytes_per_element\"><code>Float32Array.BYTES_PER_ELEMENT</code></a></dt> <dd>Returns a number value of the element size. <code>4</code> in the case of an <code>Float32Array</code>.</dd> <dt>Float32Array.length</dt> <dd>Static length property whose value is 0. For the actual length (number of elements), see <a href=\"typedarray/length\"><code>Float32Array.prototype.length</code></a>.</dd> <dt><a href=\"typedarray/name\"><code>Float32Array.name</code></a></dt> <dd>Returns the string value of the constructor name. In the case of the <code>Float32Array</code> type: \"Float32Array\".</dd> <dt><a href=\"typedarray/prototype\"><code>Float32Array.prototype</code></a></dt> <dd>Prototype for the <em>TypedArray</em> objects.</dd> </dl> <h2 id=\"Methods\">Methods</h2> <dl> <dt><a href=\"typedarray/from\"><code>Float32Array.from()</code></a></dt> <dd>Creates a new <code>Float32Array</code> from an array-like or iterable object. See also <a href=\"array/from\"><code>Array.from()</code></a>.</dd> <dt><a href=\"typedarray/of\"><code>Float32Array.of()</code></a></dt> <dd>Creates a new <code>Float32Array</code> with a variable number of arguments. See also <a href=\"array/of\"><code>Array.of()</code></a>.</dd> </dl> <h2 id=\"Float32Array_prototype\">\n<code>Float32Array</code> prototype</h2> <p>All <code>Float32Array</code> objects inherit from <a href=\"typedarray/prototype\"><code>%TypedArray%.prototype</code></a>.</p> <h3 id=\"Properties_2\">Properties</h3> <dl> <dt><code>Float32Array.prototype.constructor</code></dt> <dd>Returns the function that created an instance's prototype. This is the <code>Float32Array</code> constructor by default.</dd> <dt>\n<a href=\"typedarray/buffer\"><code>Float32Array.prototype.buffer</code></a> <span class=\"inlineIndicator readOnly readOnlyInline\">Read only </span>\n</dt> <dd>Returns the <a href=\"arraybuffer\"><code>ArrayBuffer</code></a> referenced by the <code>Float32Array</code> Fixed at construction time and thus <strong>read only</strong>.</dd> <dt>\n<a href=\"typedarray/bytelength\"><code>Float32Array.prototype.byteLength</code></a> <span class=\"inlineIndicator readOnly readOnlyInline\">Read only </span>\n</dt> <dd>Returns the length (in bytes) of the <code>Float32Array</code> from the start of its <a href=\"arraybuffer\"><code>ArrayBuffer</code></a>. Fixed at construction time and thus <strong>read only.</strong>\n</dd> <dt>\n<a href=\"typedarray/byteoffset\"><code>Float32Array.prototype.byteOffset</code></a> <span class=\"inlineIndicator readOnly readOnlyInline\">Read only </span>\n</dt> <dd>Returns the offset (in bytes) of the <code>Float32Array</code> from the start of its <a href=\"arraybuffer\"><code>ArrayBuffer</code></a>. Fixed at construction time and thus <strong>read only.</strong>\n</dd> <dt>\n<a href=\"typedarray/length\"><code>Float32Array.prototype.length</code></a> <span class=\"inlineIndicator readOnly readOnlyInline\">Read only </span>\n</dt> <dd>Returns the number of elements hold in the <code>Float32Array</code>. Fixed at construction time and thus <strong>read only.</strong>\n</dd> </dl> <h3 id=\"Methods_2\">Methods</h3> <dl> <dt><a href=\"typedarray/copywithin\"><code>Float32Array.prototype.copyWithin()</code></a></dt> <dd>Copies a sequence of array elements within the array. See also <a href=\"array/copywithin\"><code>Array.prototype.copyWithin()</code></a>.</dd> <dt><a href=\"typedarray/entries\"><code>Float32Array.prototype.entries()</code></a></dt> <dd>Returns a new <code>Array Iterator</code> object that contains the key/value pairs for each index in the array. See also <a href=\"array/entries\"><code>Array.prototype.entries()</code></a>.</dd> <dt><a href=\"typedarray/every\"><code>Float32Array.prototype.every()</code></a></dt> <dd>Tests whether all elements in the array pass the test provided by a function. See also <a href=\"array/every\"><code>Array.prototype.every()</code></a>.</dd> <dt><a href=\"typedarray/fill\"><code>Float32Array.prototype.fill()</code></a></dt> <dd>Fills all the elements of an array from a start index to an end index with a static value. See also <a href=\"array/fill\"><code>Array.prototype.fill()</code></a>.</dd> <dt><a href=\"typedarray/filter\"><code>Float32Array.prototype.filter()</code></a></dt> <dd>Creates a new array with all of the elements of this array for which the provided filtering function returns true. See also <a href=\"array/filter\"><code>Array.prototype.filter()</code></a>.</dd> <dt><a href=\"typedarray/find\"><code>Float32Array.prototype.find()</code></a></dt> <dd>Returns the found value in the array, if an element in the array satisfies the provided testing function or <code>undefined</code> if not found. See also <a href=\"array/find\"><code>Array.prototype.find()</code></a>.</dd> <dt><a href=\"typedarray/findindex\"><code>Float32Array.prototype.findIndex()</code></a></dt> <dd>Returns the found index in the array, if an element in the array satisfies the provided testing function or -1 if not found. See also <a href=\"array/findindex\"><code>Array.prototype.findIndex()</code></a>.</dd> <dt><a href=\"typedarray/foreach\"><code>Float32Array.prototype.forEach()</code></a></dt> <dd>Calls a function for each element in the array. See also <a href=\"array/foreach\"><code>Array.prototype.forEach()</code></a>.</dd> <dt>\n<a href=\"typedarray/includes\"><code>Float32Array.prototype.includes()</code></a> \n</dt> <dd>Determines whether a typed array includes a certain element, returning <code>true</code> or <code>false</code> as appropriate. See also <a href=\"array/includes\"><code>Array.prototype.includes()</code></a>.</dd> <dt><a href=\"typedarray/indexof\"><code>Float32Array.prototype.indexOf()</code></a></dt> <dd>Returns the first (least) index of an element within the array equal to the specified value, or -1 if none is found. See also <a href=\"array/indexof\"><code>Array.prototype.indexOf()</code></a>.</dd> <dt><a href=\"typedarray/join\"><code>Float32Array.prototype.join()</code></a></dt> <dd>Joins all elements of an array into a string. See also <a href=\"array/join\"><code>Array.prototype.join()</code></a>.</dd> <dt><a href=\"typedarray/keys\"><code>Float32Array.prototype.keys()</code></a></dt> <dd>Returns a new <code>Array Iterator</code> that contains the keys for each index in the array. See also <a href=\"array/keys\"><code>Array.prototype.keys()</code></a>.</dd> <dt><a href=\"typedarray/lastindexof\"><code>Float32Array.prototype.lastIndexOf()</code></a></dt> <dd>Returns the last (greatest) index of an element within the array equal to the specified value, or -1 if none is found. See also <a href=\"array/lastindexof\"><code>Array.prototype.lastIndexOf()</code></a>.</dd> <dt><a href=\"typedarray/map\"><code>Float32Array.prototype.map()</code></a></dt> <dd>Creates a new array with the results of calling a provided function on every element in this array. See also <a href=\"array/map\"><code>Array.prototype.map()</code></a>.</dd> <dt>\n<a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/move\"><code>Float32Array.prototype.move()</code></a>  <span class=\"inlineIndicator unimplemented unimplementedInline\">Unimplemented</span>\n</dt> <dd>Former non-standard version of <a href=\"typedarray/copywithin\"><code>Float32Array.prototype.copyWithin()</code></a>.</dd> <dt><a href=\"typedarray/reduce\"><code>Float32Array.prototype.reduce()</code></a></dt> <dd>Apply a function against an accumulator and each value of the array (from left-to-right) as to reduce it to a single value. See also <a href=\"array/reduce\"><code>Array.prototype.reduce()</code></a>.</dd> <dt><a href=\"typedarray/reduceright\"><code>Float32Array.prototype.reduceRight()</code></a></dt> <dd>Apply a function against an accumulator and each value of the array (from right-to-left) as to reduce it to a single value. See also <a href=\"array/reduceright\"><code>Array.prototype.reduceRight()</code></a>.</dd> <dt><a href=\"typedarray/reverse\"><code>Float32Array.prototype.reverse()</code></a></dt> <dd>Reverses the order of the elements of an array — the first becomes the last, and the last becomes the first. See also <a href=\"array/reverse\"><code>Array.prototype.reverse()</code></a>.</dd> <dt><a href=\"typedarray/set\"><code>Float32Array.prototype.set()</code></a></dt> <dd>Stores multiple values in the typed array, reading input values from a specified array.</dd> <dt><a href=\"typedarray/slice\"><code>Float32Array.prototype.slice()</code></a></dt> <dd>Extracts a section of an array and returns a new array. See also <a href=\"array/slice\"><code>Array.prototype.slice()</code></a>.</dd> <dt><a href=\"typedarray/some\"><code>Float32Array.prototype.some()</code></a></dt> <dd>Returns true if at least one element in this array satisfies the provided testing function. See also <a href=\"array/some\"><code>Array.prototype.some()</code></a>.</dd> <dt><a href=\"typedarray/sort\"><code>Float32Array.prototype.sort()</code></a></dt> <dd>Sorts the elements of an array in place and returns the array. See also <a href=\"array/sort\"><code>Array.prototype.sort()</code></a>.</dd> <dt><a href=\"typedarray/subarray\"><code>Float32Array.prototype.subarray()</code></a></dt> <dd>Returns a new <code>Float32Array</code> from the given start and end element index.</dd> <dt><a href=\"typedarray/values\"><code>Float32Array.prototype.values()</code></a></dt> <dd>Returns a new <code>Array Iterator</code> object that contains the values for each index in the array. See also <a href=\"array/values\"><code>Array.prototype.values()</code></a>.</dd> <dt><a href=\"typedarray/tolocalestring\"><code>Float32Array.prototype.toLocaleString()</code></a></dt> <dd>Returns a localized string representing the array and its elements. See also <a href=\"array/tolocalestring\"><code>Array.prototype.toLocaleString()</code></a>.</dd> <dt><a href=\"typedarray/tostring\"><code>Float32Array.prototype.toString()</code></a></dt> <dd>Returns a string representing the array and its elements. See also <a href=\"array/tostring\"><code>Array.prototype.toString()</code></a>.</dd> <dt><a href=\"typedarray/@@iterator\"><code>Float32Array.prototype[@@iterator]()</code></a></dt> <dd>Returns a new <code>Array Iterator</code> object that contains the values for each index in the array.</dd> </dl> <h2 id=\"Examples\">Examples</h2> <p>Different ways to create a <code>Float32Array</code>:</p> <pre data-language=\"js\">// From a length\nvar float32 = new Float32Array(2);\nfloat32[0] = 42;\nconsole.log(float32[0]); // 42\nconsole.log(float32.length); // 2\nconsole.log(float32.BYTES_PER_ELEMENT); // 4\n\n// From an array\nvar arr = new Float32Array([21,31]);\nconsole.log(arr[1]); // 31\n\n// From another TypedArray\nvar x = new Float32Array([21, 31]);\nvar y = new Float32Array(x);\nconsole.log(y[0]); // 21\n\n// From an ArrayBuffer\nvar buffer = new ArrayBuffer(16);\nvar z = new Float32Array(buffer, 0, 4);\n\n// From an iterable \nvar iterable = function*(){ yield* [1,2,3]; }(); \nvar float32 = new Float32Array(iterable); \n// Float32Array[1, 2, 3]\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.khronos.org/registry/typedarray/specs/latest/\" hreflang=\"en\">Typed Array Specification</a></td> <td><span class=\"spec-Obsolete\">Obsolete</span></td> <td>Superseded by ECMAScript 2015.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#table-49\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'TypedArray constructors' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition in an ECMA standard. Specified that <code>new</code> is required.</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#table-49\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'TypedArray constructors' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td>ECMAScript 2017 changed the <code>Float32Array</code> constructor to use the <code>ToIndex</code> operation and allows constructors with no arguments.</td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 7</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> 10</td>\n<td class=\"bc-supports-yes\"> 11.6</td>\n<td class=\"bc-supports-yes\"> 5.1</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<code>Float32Array()</code> without <code>new</code> throws</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 44</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td> ? </td>\n</tr>\n<tr>\n<th scope=\"row\">Iterable in constructor</th>\n<td> ? </td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 52</td>\n<td> ? </td>\n<td> ? </td>\n<td> ? </td>\n</tr>\n<tr>\n<th scope=\"row\">Constructor without arguments</th>\n<td> ? </td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 55</td>\n<td> ? </td>\n<td> ? </td>\n<td> ? </td>\n</tr>\n</tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> 11.6</td>\n<td class=\"bc-supports-yes\"> 4.2</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<code>Float32Array()</code> without <code>new</code> throws</th>\n<td> ? </td>\n<td> ? </td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 44</td>\n<td> ? </td>\n<td> ? </td>\n<td> ? </td>\n</tr>\n<tr>\n<th scope=\"row\">Iterable in constructor</th>\n<td> ? </td>\n<td> ? </td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 52</td>\n<td> ? </td>\n<td> ? </td>\n<td> ? </td>\n</tr>\n<tr>\n<th scope=\"row\">Constructor without arguments</th>\n<td> ? </td>\n<td> ? </td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 55</td>\n<td> ? </td>\n<td> ? </td>\n<td> ? </td>\n</tr>\n</tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 0.10</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<code>Float32Array()</code> without <code>new</code> throws</th>\n<td class=\"bc-supports-yes\"> 0.12</td>\n</tr>\n<tr>\n<th scope=\"row\">Iterable in constructor</th>\n<td class=\"bc-supports-yes\"> 4.0.0</td>\n</tr>\n<tr>\n<th scope=\"row\">Constructor without arguments</th>\n<td> ? </td>\n</tr>\n</tbody>\n</table>\n</div> <h2 id=\"Compatibility_notes\">Compatibility notes</h2> <p>Starting with ECMAScript 2015, <code>Float32Array</code> constructors require to be constructed with a <a href=\"../operators/new\"><code>new</code></a> operator. Calling a <code>Float32Array</code> constructor as a function without <code>new</code>, will throw a <a href=\"typeerror\"><code>TypeError</code></a> from now on.</p> <pre data-language=\"js\">var dv = Float32Array([1, 2, 3]);\n// TypeError: calling a builtin Float32Array constructor\n// without new is forbidden</pre> <pre data-language=\"js\">var dv = new Float32Array([1, 2, 3]);</pre> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Typed_arrays\">JavaScript typed arrays</a></li> <li><a href=\"arraybuffer\"><code>ArrayBuffer</code></a></li> <li><a href=\"dataview\"><code>DataView</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Float32Array$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Float32Array\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Float32Array</a>\n  </p>\n</div>\n","global_objects/arraybuffer":"<h1>ArrayBuffer</h1> <p>The <code>ArrayBuffer</code> object is used to represent a generic, fixed-length raw binary data buffer. You cannot directly manipulate the contents of an <code>ArrayBuffer</code>; instead, you create one of the <a href=\"typedarray\">typed array objects</a> or a <a href=\"dataview\"><code>DataView</code></a> object which represents the buffer in a specific format, and use that to read and write the contents of the buffer.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/arraybuffer-constructor.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\">new ArrayBuffer(length)\n</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><code>length</code></dt> <dd>The size, in bytes, of the array buffer to create.</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p>A new <code>ArrayBuffer</code> object of the specified size. Its contents are initialized to 0.</p> <h3 id=\"Exceptions\">Exceptions</h3> <p>A <a href=\"rangeerror\"><code>RangeError</code></a> is thrown if the <code>length</code> is larger than <a href=\"number/max_safe_integer\"><code>Number.MAX_SAFE_INTEGER</code></a> (&gt;= 2 ** 53) or negative.</p> <h2 id=\"Description\">Description</h2> <p>The <code>ArrayBuffer</code> constructor creates a new <code>ArrayBuffer</code> of the given length in bytes.</p> <h3 id=\"Getting_an_array_buffer_from_existing_data\">Getting an array buffer from existing data</h3> <ul> <li><a href=\"https://developer.mozilla.org/en-US/docs/Web/API/WindowBase64/Base64_encoding_and_decoding#Appendix.3A_Decode_a_Base64_string_to_Uint8Array_or_ArrayBuffer\">From a Base64 string</a></li> <li><a href=\"https://developer.mozilla.org/en-US/docs/Web/API/FileReader#readAsArrayBuffer()\">From a local file</a></li> </ul> <h2 id=\"Properties\">Properties</h2> <dl> <dt><code>ArrayBuffer.length</code></dt> <dd>The <code>ArrayBuffer</code> constructor's length property whose value is 1.</dd> <dt><a href=\"arraybuffer/@@species\"><code>get ArrayBuffer[@@species]</code></a></dt> <dd>The constructor function that is used to create derived objects.</dd> <dt><a href=\"arraybuffer/prototype\"><code>ArrayBuffer.prototype</code></a></dt> <dd>Allows the addition of properties to all <code>ArrayBuffer</code> objects.</dd> </dl> <h2 id=\"Methods\">Methods</h2> <dl> <dt><a href=\"arraybuffer/isview\"><code>ArrayBuffer.isView(arg)</code></a></dt> <dd>Returns <code>true</code> if <code>arg</code> is one of the ArrayBuffer views, such as <a href=\"typedarray\">typed array objects</a> or a <a href=\"dataview\"><code>DataView</code></a>. Returns <code>false</code> otherwise.</dd> <dt>\n<a href=\"arraybuffer/transfer\"><code>ArrayBuffer.transfer(oldBuffer [, newByteLength])</code></a> \n</dt> <dd> <div id=\"file-arraybuffer-transfer-LC6\" class=\"line\">Returns a new <code>ArrayBuffer</code> whose contents are taken from the <code>oldBuffer</code>'s data and then is either truncated or zero-extended by <code>newByteLength</code>.</div> </dd> </dl> <h2 id=\"Instances\">Instances</h2> <p>All <code>ArrayBuffer</code> instances inherit from <a href=\"arraybuffer/prototype\"><code>ArrayBuffer.prototype</code></a>.</p> <h3 id=\"Properties_2\">Properties</h3> <dl> <dt>ArrayBuffer.prototype.constructor</dt> <dd>Specifies the function that creates an object's prototype. The initial value is the standard built-in <code>ArrayBuffer</code> constructor.</dd> <dt>\n<a href=\"arraybuffer/bytelength\"><code>ArrayBuffer.prototype.byteLength</code></a> <span class=\"inlineIndicator readOnly readOnlyInline\">Read only </span>\n</dt> <dd>The size, in bytes, of the array. This is established when the array is constructed and cannot be changed. <strong>Read only.</strong>\n</dd> </dl> <h3 id=\"Methods_2\">Methods</h3> <dl> <dt><a href=\"arraybuffer/slice\"><code>ArrayBuffer.prototype.slice()</code></a></dt> <dd>Returns a new <code>ArrayBuffer</code> whose contents are a copy of this <code>ArrayBuffer</code>'s bytes from <code>begin</code>, inclusive, up to <code>end</code>, exclusive. If either <code>begin</code> or <code>end</code> is negative, it refers to an index from the end of the array, as opposed to from the beginning.</dd> </dl> <dl> <dt>\n<a href=\"arraybuffer/slice\"><code>ArrayBuffer.slice()</code></a> \n</dt> <dd>Has the same functionality as <a href=\"arraybuffer/slice\"><code>ArrayBuffer.prototype.slice()</code></a>.</dd> </dl> <h2 id=\"Example\">Example</h2> <p>In this example, we create a 8-byte buffer with a <a href=\"int32array\"><code>Int32Array</code></a> view referring to the buffer:</p> <pre data-language=\"js\">var buffer = new ArrayBuffer(8);\nvar view   = new Int32Array(buffer);</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.khronos.org/registry/typedarray/specs/latest/\" hreflang=\"en\">Typed Array Specification</a></td> <td><span class=\"spec-Obsolete\">Obsolete</span></td> <td>Superseded by ECMAScript 6.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-arraybuffer-constructor\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'ArrayBuffer' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition in an ECMA standard. Specified that <code>new</code> is required.</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-arraybuffer-constructor\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'ArrayBuffer' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 7</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> 10</td>\n<td class=\"bc-supports-yes\"> 11.6</td>\n<td class=\"bc-supports-yes\"> 5.1</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<code>ArrayBuffer()</code> without <code>new</code> throws</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 44</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td> ? </td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer/byteLength\"><code>byteLength</code></a></th>\n<td class=\"bc-supports-yes\"> 7</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> 10</td>\n<td class=\"bc-supports-yes\"> 11.6</td>\n<td class=\"bc-supports-yes\"> 5.1</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer/isView\"><code>isView</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 29</td>\n<td class=\"bc-supports-yes\"> 11</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer/prototype\"><code>prototype</code></a></th>\n<td class=\"bc-supports-yes\"> 7</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> 10</td>\n<td class=\"bc-supports-yes\"> 11.6</td>\n<td class=\"bc-supports-yes\"> 5.1</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer/slice\"><code>slice</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes bc-has-history\"> 12\n<section class=\"bc-history\" id=\"sect1\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 12\n</dt>\n<dd> The non-standard <code>ArrayBuffer.slice()</code> method has been removed in Firefox 53 (but the standardized version <code>ArrayBuffer.prototype.slice()</code> is kept.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-yes\"> 11</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 6</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer/transfer\"><code>transfer</code></a> \n</th>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer/@@species\"><code>@@species</code></a></th>\n<td> ? </td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 48</td>\n<td> ? </td>\n<td> ? </td>\n<td> ? </td>\n</tr>\n</tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> 11.6</td>\n<td class=\"bc-supports-yes\"> 4.2</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<code>ArrayBuffer()</code> without <code>new</code> throws</th>\n<td> ? </td>\n<td> ? </td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 44</td>\n<td> ? </td>\n<td> ? </td>\n<td> ? </td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer/byteLength\"><code>byteLength</code></a></th>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> 11.6</td>\n<td class=\"bc-supports-yes\"> 4.2</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer/isView\"><code>isView</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 29</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer/prototype\"><code>prototype</code></a></th>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> 11.6</td>\n<td class=\"bc-supports-yes\"> 4.2</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer/slice\"><code>slice</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes bc-has-history\"> 14\n<section class=\"bc-history\" id=\"sect2\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 14\n</dt>\n<dd> The non-standard <code>ArrayBuffer.slice()</code> method has been removed in Firefox 53 (but the standardized version <code>ArrayBuffer.prototype.slice()</code> is kept.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 6</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer/transfer\"><code>transfer</code></a> \n</th>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer/@@species\"><code>@@species</code></a></th>\n<td> ? </td>\n<td> ? </td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 48</td>\n<td> ? </td>\n<td> ? </td>\n<td> ? </td>\n</tr>\n</tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<code>ArrayBuffer()</code> without <code>new</code> throws</th>\n<td class=\"bc-supports-yes\"> 0.12</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer/byteLength\"><code>byteLength</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer/isView\"><code>isView</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer/prototype\"><code>prototype</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer/slice\"><code>slice</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer/transfer\"><code>transfer</code></a> \n</th>\n<td class=\"bc-supports-no\"> No</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer/@@species\"><code>@@species</code></a></th>\n<td class=\"bc-supports-yes bc-has-history\"> 6.5.0\n<section class=\"bc-history\" id=\"sect3\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 6.5.0\n</dt>\n\n<dt class=\"bc-supports-yes bc-supports\"> 6.0.0<div class=\"bc-icons\">Disabled </div>\n</dt>\n<dd>Disabled From version 6.0.0: this feature is behind the <code>--harmony</code> runtime flag.</dd>\n</dl></section>\n</td>\n</tr>\n</tbody>\n</table>\n</div> <h2 id=\"Compatibility_notes\">Compatibility notes</h2> <p>Starting with ECMAScript 2015, <code>ArrayBuffer</code> constructors require to be constructed with a <a href=\"../operators/new\"><code>new</code></a> operator. Calling an <code>ArrayBuffer</code> constructor as a function without <code>new</code>, will throw a <a href=\"typeerror\"><code>TypeError</code></a> from now on.</p> <pre data-language=\"js\">var dv = ArrayBuffer(10);\n// TypeError: calling a builtin ArrayBuffer constructor \n// without new is forbidden</pre> <pre data-language=\"js\">var dv = new ArrayBuffer(10);</pre> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Typed_arrays\">JavaScript typed arrays</a></li> <li><a href=\"sharedarraybuffer\"><code>SharedArrayBuffer</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer</a>\n  </p>\n</div>\n","global_objects/int16array":"<h1>Int16Array</h1> <p>The <code>Int16Array</code> typed array represents an array of twos-complement 16-bit signed integers in the platform byte order. If control over byte order is needed, use <a href=\"dataview\"><code>DataView</code></a> instead. The contents are initialized to <code>0</code>. Once established, you can reference elements in the array using the object's methods, or using standard array index syntax (that is, using bracket notation).</p> <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\">new Int16Array(); // new in ES2017\nnew Int16Array(length);\nnew Int16Array(typedArray);\nnew Int16Array(object);\nnew Int16Array(buffer [, byteOffset [, length]]);</pre> <p>For more information about the constructor syntax and the parameters, see <em><a href=\"typedarray#Syntax\">TypedArray</a></em>.</p> <h2 id=\"Properties\">Properties</h2> <dl> <dt><a href=\"typedarray/bytes_per_element\"><code>Int16Array.BYTES_PER_ELEMENT</code></a></dt> <dd>Returns a number value of the element size. <code>2</code> in the case of an <code>Int16Array</code>.</dd> <dt>Int16Array.length</dt> <dd>Static length property whose value is 0. For the actual length (number of elements), see <a href=\"typedarray/length\"><code>Int16Array.prototype.length</code></a>.</dd> <dt><a href=\"typedarray/name\"><code>Int16Array.name</code></a></dt> <dd>Returns the string value of the constructor name. In the case of the <code>Int16Array</code> type: \"Int16Array\".</dd> <dt><a href=\"typedarray/prototype\"><code>Int16Array.prototype</code></a></dt> <dd>Prototype for the <em>TypedArray</em> objects.</dd> </dl> <h2 id=\"Methods\">Methods</h2> <dl> <dt><a href=\"typedarray/from\"><code>Int16Array.from()</code></a></dt> <dd>Creates a new <code>Int16Array</code> from an array-like or iterable object. See also <a href=\"array/from\"><code>Array.from()</code></a>.</dd> <dt><a href=\"typedarray/of\"><code>Int16Array.of()</code></a></dt> <dd>Creates a new <code>Int16Array</code> with a variable number of arguments. See also <a href=\"array/of\"><code>Array.of()</code></a>.</dd> </dl> <h2 id=\"Int16Array_prototype\">\n<code>Int16Array</code> prototype</h2> <p>All <code>Int16Array</code> objects inherit from <a href=\"typedarray/prototype\"><code>%TypedArray%.prototype</code></a>.</p> <h3 id=\"Properties_2\">Properties</h3> <dl> <dt><code>Int16Array.prototype.constructor</code></dt> <dd>Returns the function that created an instance's prototype. This is the <code>Int16Array</code> constructor by default.</dd> <dt>\n<a href=\"typedarray/buffer\"><code>Int16Array.prototype.buffer</code></a> <span class=\"inlineIndicator readOnly readOnlyInline\">Read only </span>\n</dt> <dd>Returns the <a href=\"arraybuffer\"><code>ArrayBuffer</code></a> referenced by the <code>Int16Array</code> Fixed at construction time and thus <strong>read only</strong>.</dd> <dt>\n<a href=\"typedarray/bytelength\"><code>Int16Array.prototype.byteLength</code></a> <span class=\"inlineIndicator readOnly readOnlyInline\">Read only </span>\n</dt> <dd>Returns the length (in bytes) of the <code>Int16Array</code> from the start of its <a href=\"arraybuffer\"><code>ArrayBuffer</code></a>. Fixed at construction time and thus <strong>read only.</strong>\n</dd> <dt>\n<a href=\"typedarray/byteoffset\"><code>Int16Array.prototype.byteOffset</code></a> <span class=\"inlineIndicator readOnly readOnlyInline\">Read only </span>\n</dt> <dd>Returns the offset (in bytes) of the <code>Int16Array</code> from the start of its <a href=\"arraybuffer\"><code>ArrayBuffer</code></a>. Fixed at construction time and thus <strong>read only.</strong>\n</dd> <dt>\n<a href=\"typedarray/length\"><code>Int16Array.prototype.length</code></a> <span class=\"inlineIndicator readOnly readOnlyInline\">Read only </span>\n</dt> <dd>Returns the number of elements hold in the <code>Int16Array</code>. Fixed at construction time and thus <strong>read only.</strong>\n</dd> </dl> <h3 id=\"Methods_2\">Methods</h3> <dl> <dt><a href=\"typedarray/copywithin\"><code>Int16Array.prototype.copyWithin()</code></a></dt> <dd>Copies a sequence of array elements within the array. See also <a href=\"array/copywithin\"><code>Array.prototype.copyWithin()</code></a>.</dd> <dt><a href=\"typedarray/entries\"><code>Int16Array.prototype.entries()</code></a></dt> <dd>Returns a new <code>Array Iterator</code> object that contains the key/value pairs for each index in the array. See also <a href=\"array/entries\"><code>Array.prototype.entries()</code></a>.</dd> <dt><a href=\"typedarray/every\"><code>Int16Array.prototype.every()</code></a></dt> <dd>Tests whether all elements in the array pass the test provided by a function. See also <a href=\"array/every\"><code>Array.prototype.every()</code></a>.</dd> <dt><a href=\"typedarray/fill\"><code>Int16Array.prototype.fill()</code></a></dt> <dd>Fills all the elements of an array from a start index to an end index with a static value. See also <a href=\"array/fill\"><code>Array.prototype.fill()</code></a>.</dd> <dt><a href=\"typedarray/filter\"><code>Int16Array.prototype.filter()</code></a></dt> <dd>Creates a new array with all of the elements of this array for which the provided filtering function returns true. See also <a href=\"array/filter\"><code>Array.prototype.filter()</code></a>.</dd> <dt><a href=\"typedarray/find\"><code>Int16Array.prototype.find()</code></a></dt> <dd>Returns the found value in the array, if an element in the array satisfies the provided testing function or <code>undefined</code> if not found. See also <a href=\"array/find\"><code>Array.prototype.find()</code></a>.</dd> <dt><a href=\"typedarray/findindex\"><code>Int16Array.prototype.findIndex()</code></a></dt> <dd>Returns the found index in the array, if an element in the array satisfies the provided testing function or -1 if not found. See also <a href=\"array/findindex\"><code>Array.prototype.findIndex()</code></a>.</dd> <dt><a href=\"typedarray/foreach\"><code>Int16Array.prototype.forEach()</code></a></dt> <dd>Calls a function for each element in the array. See also <a href=\"array/foreach\"><code>Array.prototype.forEach()</code></a>.</dd> <dt>\n<a href=\"typedarray/includes\"><code>Int16Array.prototype.includes()</code></a> \n</dt> <dd>Determines whether a typed array includes a certain element, returning <code>true</code> or <code>false</code> as appropriate. See also <a href=\"array/includes\"><code>Array.prototype.includes()</code></a>.</dd> <dt><a href=\"typedarray/indexof\"><code>Int16Array.prototype.indexOf()</code></a></dt> <dd>Returns the first (least) index of an element within the array equal to the specified value, or -1 if none is found. See also <a href=\"array/indexof\"><code>Array.prototype.indexOf()</code></a>.</dd> <dt><a href=\"typedarray/join\"><code>Int16Array.prototype.join()</code></a></dt> <dd>Joins all elements of an array into a string. See also <a href=\"array/join\"><code>Array.prototype.join()</code></a>.</dd> <dt><a href=\"typedarray/keys\"><code>Int16Array.prototype.keys()</code></a></dt> <dd>Returns a new <code>Array Iterator</code> that contains the keys for each index in the array. See also <a href=\"array/keys\"><code>Array.prototype.keys()</code></a>.</dd> <dt><a href=\"typedarray/lastindexof\"><code>Int16Array.prototype.lastIndexOf()</code></a></dt> <dd>Returns the last (greatest) index of an element within the array equal to the specified value, or -1 if none is found. See also <a href=\"array/lastindexof\"><code>Array.prototype.lastIndexOf()</code></a>.</dd> <dt><a href=\"typedarray/map\"><code>Int16Array.prototype.map()</code></a></dt> <dd>Creates a new array with the results of calling a provided function on every element in this array. See also <a href=\"array/map\"><code>Array.prototype.map()</code></a>.</dd> <dt>\n<a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/move\"><code>Int16Array.prototype.move()</code></a>  <span class=\"inlineIndicator unimplemented unimplementedInline\">Unimplemented</span>\n</dt> <dd>Former non-standard version of <a href=\"typedarray/copywithin\"><code>Int16Array.prototype.copyWithin()</code></a>.</dd> <dt><a href=\"typedarray/reduce\"><code>Int16Array.prototype.reduce()</code></a></dt> <dd>Apply a function against an accumulator and each value of the array (from left-to-right) as to reduce it to a single value. See also <a href=\"array/reduce\"><code>Array.prototype.reduce()</code></a>.</dd> <dt><a href=\"typedarray/reduceright\"><code>Int16Array.prototype.reduceRight()</code></a></dt> <dd>Apply a function against an accumulator and each value of the array (from right-to-left) as to reduce it to a single value. See also <a href=\"array/reduceright\"><code>Array.prototype.reduceRight()</code></a>.</dd> <dt><a href=\"typedarray/reverse\"><code>Int16Array.prototype.reverse()</code></a></dt> <dd>Reverses the order of the elements of an array — the first becomes the last, and the last becomes the first. See also <a href=\"array/reverse\"><code>Array.prototype.reverse()</code></a>.</dd> <dt><a href=\"typedarray/set\"><code>Int16Array.prototype.set()</code></a></dt> <dd>Stores multiple values in the typed array, reading input values from a specified array.</dd> <dt><a href=\"typedarray/slice\"><code>Int16Array.prototype.slice()</code></a></dt> <dd>Extracts a section of an array and returns a new array. See also <a href=\"array/slice\"><code>Array.prototype.slice()</code></a>.</dd> <dt><a href=\"typedarray/some\"><code>Int16Array.prototype.some()</code></a></dt> <dd>Returns true if at least one element in this array satisfies the provided testing function. See also <a href=\"array/some\"><code>Array.prototype.some()</code></a>.</dd> <dt><a href=\"typedarray/sort\"><code>Int16Array.prototype.sort()</code></a></dt> <dd>Sorts the elements of an array in place and returns the array. See also <a href=\"array/sort\"><code>Array.prototype.sort()</code></a>.</dd> <dt><a href=\"typedarray/subarray\"><code>Int16Array.prototype.subarray()</code></a></dt> <dd>Returns a new <code>Int16Array</code> from the given start and end element index.</dd> <dt><a href=\"typedarray/values\"><code>Int16Array.prototype.values()</code></a></dt> <dd>Returns a new <code>Array Iterator</code> object that contains the values for each index in the array. See also <a href=\"array/values\"><code>Array.prototype.values()</code></a>.</dd> <dt><a href=\"typedarray/tolocalestring\"><code>Int16Array.prototype.toLocaleString()</code></a></dt> <dd>Returns a localized string representing the array and its elements. See also <a href=\"array/tolocalestring\"><code>Array.prototype.toLocaleString()</code></a>.</dd> <dt><a href=\"typedarray/tostring\"><code>Int16Array.prototype.toString()</code></a></dt> <dd>Returns a string representing the array and its elements. See also <a href=\"array/tostring\"><code>Array.prototype.toString()</code></a>.</dd> <dt><a href=\"typedarray/@@iterator\"><code>Int16Array.prototype[@@iterator]()</code></a></dt> <dd>Returns a new <code>Array Iterator</code> object that contains the values for each index in the array.</dd> </dl> <h2 id=\"Examples\">Examples</h2> <p>Different ways to create an <code>Int16Array</code>:</p> <pre data-language=\"js\">// From a length\nvar int16 = new Int16Array(2);\nint16[0] = 42;\nconsole.log(int16[0]); // 42\nconsole.log(int16.length); // 2\nconsole.log(int16.BYTES_PER_ELEMENT); // 2\n\n// From an array\nvar arr = new Int16Array([21,31]);\nconsole.log(arr[1]); // 31\n\n// From another TypedArray\nvar x = new Int16Array([21, 31]);\nvar y = new Int16Array(x);\nconsole.log(y[0]); // 21\n\n// From an ArrayBuffer\nvar buffer = new ArrayBuffer(8);\nvar z = new Int16Array(buffer, 0, 4);\n\n// From an iterable\nvar iterable = function*(){ yield* [1,2,3]; }();\nvar int16 = new Int16Array(iterable);\n// Int16Array[1, 2, 3]\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.khronos.org/registry/typedarray/specs/latest/\" hreflang=\"en\">Typed Array Specification</a></td> <td><span class=\"spec-Obsolete\">Obsolete</span></td> <td>Superseded by ECMAScript 2015.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#table-49\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'TypedArray constructors' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition in an ECMA standard. Specified that <code>new</code> is required.</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#table-49\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'TypedArray constructors' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td>ECMAScript 2017 changed the <code>Int16Array</code> constructor to use the <code>ToIndex</code> operation and allows constructors with no arguments.</td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 7</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> 10</td>\n<td class=\"bc-supports-yes\"> 11.6</td>\n<td class=\"bc-supports-yes\"> 5.1</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<code>Int16Array()</code> without <code>new</code> throws</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 44</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td> ? </td>\n</tr>\n<tr>\n<th scope=\"row\">Iterable in constructor</th>\n<td> ? </td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 52</td>\n<td> ? </td>\n<td> ? </td>\n<td> ? </td>\n</tr>\n<tr>\n<th scope=\"row\">Constructor without arguments</th>\n<td> ? </td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 55</td>\n<td> ? </td>\n<td> ? </td>\n<td> ? </td>\n</tr>\n</tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> 11.6</td>\n<td class=\"bc-supports-yes\"> 4.2</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<code>Int16Array()</code> without <code>new</code> throws</th>\n<td> ? </td>\n<td> ? </td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 44</td>\n<td> ? </td>\n<td> ? </td>\n<td> ? </td>\n</tr>\n<tr>\n<th scope=\"row\">Iterable in constructor</th>\n<td> ? </td>\n<td> ? </td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 52</td>\n<td> ? </td>\n<td> ? </td>\n<td> ? </td>\n</tr>\n<tr>\n<th scope=\"row\">Constructor without arguments</th>\n<td> ? </td>\n<td> ? </td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 55</td>\n<td> ? </td>\n<td> ? </td>\n<td> ? </td>\n</tr>\n</tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 0.10</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<code>Int16Array()</code> without <code>new</code> throws</th>\n<td class=\"bc-supports-yes\"> 0.12</td>\n</tr>\n<tr>\n<th scope=\"row\">Iterable in constructor</th>\n<td class=\"bc-supports-yes\"> 4.0.0</td>\n</tr>\n<tr>\n<th scope=\"row\">Constructor without arguments</th>\n<td> ? </td>\n</tr>\n</tbody>\n</table>\n</div> <h2 id=\"Compatibility_notes\">Compatibility notes</h2> <p>Starting with ECMAScript 2015, <code>Int16Array</code> constructors require to be constructed with a <a href=\"../operators/new\"><code>new</code></a> operator. Calling a <code>Int16Array</code> constructor as a function without <code>new</code>, will throw a <a href=\"typeerror\"><code>TypeError</code></a> from now on.</p> <pre data-language=\"js\">var dv = Int16Array([1, 2, 3]);\n// TypeError: calling a builtin Int16Array constructor\n// without new is forbidden</pre> <pre data-language=\"js\">var dv = new Int16Array([1, 2, 3]);</pre> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Typed_arrays\">JavaScript typed arrays</a></li> <li><a href=\"arraybuffer\"><code>ArrayBuffer</code></a></li> <li><a href=\"dataview\"><code>DataView</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Int16Array$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Int16Array\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Int16Array</a>\n  </p>\n</div>\n","global_objects/float64array":"<h1>Float64Array</h1> <p>The <code>Float64Array</code> typed array represents an array of 64-bit floating point numbers (corresponding to the C <code>double</code> data type) in the platform byte order. If control over byte order is needed, use <a href=\"dataview\"><code>DataView</code></a> instead. The contents are initialized to <code>0</code>. Once established, you can reference elements in the array using the object's methods, or using standard array index syntax (that is, using bracket notation).</p> <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\">new Float64Array(); // new in ES2017\nnew Float64Array(length);\nnew Float64Array(typedArray);\nnew Float64Array(object);\nnew Float64Array(buffer [, byteOffset [, length]]);</pre> <p>For more information about the constructor syntax and the parameters, see <em><a href=\"typedarray#Syntax\">TypedArray</a></em>.</p> <h2 id=\"Properties\">Properties</h2> <dl> <dt><a href=\"typedarray/bytes_per_element\"><code>Float64Array.BYTES_PER_ELEMENT</code></a></dt> <dd>Returns a number value of the element size. <code>8</code> in the case of an <code>Float64Array</code>.</dd> <dt>Float64Array.length</dt> <dd>Static length property whose value is 0. For the actual length (number of elements), see <a href=\"typedarray/length\"><code>Float64Array.prototype.length</code></a>.</dd> <dt><a href=\"typedarray/name\"><code>Float64Array.name</code></a></dt> <dd>Returns the string value of the constructor name. In the case of the <code>Float64Array</code> type: \"Float64Array\".</dd> <dt><a href=\"typedarray/prototype\"><code>Float64Array.prototype</code></a></dt> <dd>Prototype for the <em>TypedArray</em> objects.</dd> </dl> <h2 id=\"Methods\">Methods</h2> <dl> <dt><a href=\"typedarray/from\"><code>Float64Array.from()</code></a></dt> <dd>Creates a new <code>Float64Array</code> from an array-like or iterable object. See also <a href=\"array/from\"><code>Array.from()</code></a>.</dd> <dt><a href=\"typedarray/of\"><code>Float64Array.of()</code></a></dt> <dd>Creates a new <code>Float64Array</code> with a variable number of arguments. See also <a href=\"array/of\"><code>Array.of()</code></a>.</dd> </dl> <h2 id=\"Float64Array_prototype\">\n<code>Float64Array</code> prototype</h2> <p>All <code>Float64Array</code> objects inherit from <a href=\"typedarray/prototype\"><code>%TypedArray%.prototype</code></a>.</p> <h3 id=\"Properties_2\">Properties</h3> <dl> <dt><code>Float64Array.prototype.constructor</code></dt> <dd>Returns the function that created an instance's prototype. This is the <code>Float64Array</code> constructor by default.</dd> <dt>\n<a href=\"typedarray/buffer\"><code>Float64Array.prototype.buffer</code></a> <span class=\"inlineIndicator readOnly readOnlyInline\">Read only </span>\n</dt> <dd>Returns the <a href=\"arraybuffer\"><code>ArrayBuffer</code></a> referenced by the <code>Float64Array</code> Fixed at construction time and thus <strong>read only</strong>.</dd> <dt>\n<a href=\"typedarray/bytelength\"><code>Float64Array.prototype.byteLength</code></a> <span class=\"inlineIndicator readOnly readOnlyInline\">Read only </span>\n</dt> <dd>Returns the length (in bytes) of the <code>Float64Array</code> from the start of its <a href=\"arraybuffer\"><code>ArrayBuffer</code></a>. Fixed at construction time and thus <strong>read only.</strong>\n</dd> <dt>\n<a href=\"typedarray/byteoffset\"><code>Float64Array.prototype.byteOffset</code></a> <span class=\"inlineIndicator readOnly readOnlyInline\">Read only </span>\n</dt> <dd>Returns the offset (in bytes) of the <code>Float64Array</code> from the start of its <a href=\"arraybuffer\"><code>ArrayBuffer</code></a>. Fixed at construction time and thus <strong>read only.</strong>\n</dd> <dt>\n<a href=\"typedarray/length\"><code>Float64Array.prototype.length</code></a> <span class=\"inlineIndicator readOnly readOnlyInline\">Read only </span>\n</dt> <dd>Returns the number of elements hold in the <code>Float64Array</code>. Fixed at construction time and thus <strong>read only.</strong>\n</dd> </dl> <h3 id=\"Methods_2\">Methods</h3> <dl> <dt><a href=\"typedarray/copywithin\"><code>Float64Array.prototype.copyWithin()</code></a></dt> <dd>Copies a sequence of array elements within the array. See also <a href=\"array/copywithin\"><code>Array.prototype.copyWithin()</code></a>.</dd> <dt><a href=\"typedarray/entries\"><code>Float64Array.prototype.entries()</code></a></dt> <dd>Returns a new <code>Array Iterator</code> object that contains the key/value pairs for each index in the array. See also <a href=\"array/entries\"><code>Array.prototype.entries()</code></a>.</dd> <dt><a href=\"typedarray/every\"><code>Float64Array.prototype.every()</code></a></dt> <dd>Tests whether all elements in the array pass the test provided by a function. See also <a href=\"array/every\"><code>Array.prototype.every()</code></a>.</dd> <dt><a href=\"typedarray/fill\"><code>Float64Array.prototype.fill()</code></a></dt> <dd>Fills all the elements of an array from a start index to an end index with a static value. See also <a href=\"array/fill\"><code>Array.prototype.fill()</code></a>.</dd> <dt><a href=\"typedarray/filter\"><code>Float64Array.prototype.filter()</code></a></dt> <dd>Creates a new array with all of the elements of this array for which the provided filtering function returns true. See also <a href=\"array/filter\"><code>Array.prototype.filter()</code></a>.</dd> <dt><a href=\"typedarray/find\"><code>Float64Array.prototype.find()</code></a></dt> <dd>Returns the found value in the array, if an element in the array satisfies the provided testing function or <code>undefined</code> if not found. See also <a href=\"array/find\"><code>Array.prototype.find()</code></a>.</dd> <dt><a href=\"typedarray/findindex\"><code>Float64Array.prototype.findIndex()</code></a></dt> <dd>Returns the found index in the array, if an element in the array satisfies the provided testing function or -1 if not found. See also <a href=\"array/findindex\"><code>Array.prototype.findIndex()</code></a>.</dd> <dt><a href=\"typedarray/foreach\"><code>Float64Array.prototype.forEach()</code></a></dt> <dd>Calls a function for each element in the array. See also <a href=\"array/foreach\"><code>Array.prototype.forEach()</code></a>.</dd> <dt>\n<a href=\"typedarray/includes\"><code>Float64Array.prototype.includes()</code></a> \n</dt> <dd>Determines whether a typed array includes a certain element, returning <code>true</code> or <code>false</code> as appropriate. See also <a href=\"array/includes\"><code>Array.prototype.includes()</code></a>.</dd> <dt><a href=\"typedarray/indexof\"><code>Float64Array.prototype.indexOf()</code></a></dt> <dd>Returns the first (least) index of an element within the array equal to the specified value, or -1 if none is found. See also <a href=\"array/indexof\"><code>Array.prototype.indexOf()</code></a>.</dd> <dt><a href=\"typedarray/join\"><code>Float64Array.prototype.join()</code></a></dt> <dd>Joins all elements of an array into a string. See also <a href=\"array/join\"><code>Array.prototype.join()</code></a>.</dd> <dt><a href=\"typedarray/keys\"><code>Float64Array.prototype.keys()</code></a></dt> <dd>Returns a new <code>Array Iterator</code> that contains the keys for each index in the array. See also <a href=\"array/keys\"><code>Array.prototype.keys()</code></a>.</dd> <dt><a href=\"typedarray/lastindexof\"><code>Float64Array.prototype.lastIndexOf()</code></a></dt> <dd>Returns the last (greatest) index of an element within the array equal to the specified value, or -1 if none is found. See also <a href=\"array/lastindexof\"><code>Array.prototype.lastIndexOf()</code></a>.</dd> <dt><a href=\"typedarray/map\"><code>Float64Array.prototype.map()</code></a></dt> <dd>Creates a new array with the results of calling a provided function on every element in this array. See also <a href=\"array/map\"><code>Array.prototype.map()</code></a>.</dd> <dt>\n<a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/move\"><code>Float64Array.prototype.move()</code></a>  <span class=\"inlineIndicator unimplemented unimplementedInline\">Unimplemented</span>\n</dt> <dd>Former non-standard version of <a href=\"typedarray/copywithin\"><code>Float64Array.prototype.copyWithin()</code></a>.</dd> <dt><a href=\"typedarray/reduce\"><code>Float64Array.prototype.reduce()</code></a></dt> <dd>Apply a function against an accumulator and each value of the array (from left-to-right) as to reduce it to a single value. See also <a href=\"array/reduce\"><code>Array.prototype.reduce()</code></a>.</dd> <dt><a href=\"typedarray/reduceright\"><code>Float64Array.prototype.reduceRight()</code></a></dt> <dd>Apply a function against an accumulator and each value of the array (from right-to-left) as to reduce it to a single value. See also <a href=\"array/reduceright\"><code>Array.prototype.reduceRight()</code></a>.</dd> <dt><a href=\"typedarray/reverse\"><code>Float64Array.prototype.reverse()</code></a></dt> <dd>Reverses the order of the elements of an array — the first becomes the last, and the last becomes the first. See also <a href=\"array/reverse\"><code>Array.prototype.reverse()</code></a>.</dd> <dt><a href=\"typedarray/set\"><code>Float64Array.prototype.set()</code></a></dt> <dd>Stores multiple values in the typed array, reading input values from a specified array.</dd> <dt><a href=\"typedarray/slice\"><code>Float64Array.prototype.slice()</code></a></dt> <dd>Extracts a section of an array and returns a new array. See also <a href=\"array/slice\"><code>Array.prototype.slice()</code></a>.</dd> <dt><a href=\"typedarray/some\"><code>Float64Array.prototype.some()</code></a></dt> <dd>Returns true if at least one element in this array satisfies the provided testing function. See also <a href=\"array/some\"><code>Array.prototype.some()</code></a>.</dd> <dt><a href=\"typedarray/sort\"><code>Float64Array.prototype.sort()</code></a></dt> <dd>Sorts the elements of an array in place and returns the array. See also <a href=\"array/sort\"><code>Array.prototype.sort()</code></a>.</dd> <dt><a href=\"typedarray/subarray\"><code>Float64Array.prototype.subarray()</code></a></dt> <dd>Returns a new <code>Float64Array</code> from the given start and end element index.</dd> <dt><a href=\"typedarray/values\"><code>Float64Array.prototype.values()</code></a></dt> <dd>Returns a new <code>Array Iterator</code> object that contains the values for each index in the array. See also <a href=\"array/values\"><code>Array.prototype.values()</code></a>.</dd> <dt><a href=\"typedarray/tolocalestring\"><code>Float64Array.prototype.toLocaleString()</code></a></dt> <dd>Returns a localized string representing the array and its elements. See also <a href=\"array/tolocalestring\"><code>Array.prototype.toLocaleString()</code></a>.</dd> <dt><a href=\"typedarray/tostring\"><code>Float64Array.prototype.toString()</code></a></dt> <dd>Returns a string representing the array and its elements. See also <a href=\"array/tostring\"><code>Array.prototype.toString()</code></a>.</dd> <dt><a href=\"typedarray/@@iterator\"><code>Float64Array.prototype[@@iterator]()</code></a></dt> <dd>Returns a new <code>Array Iterator</code> object that contains the values for each index in the array.</dd> </dl> <h2 id=\"Examples\">Examples</h2> <p>Different ways to create a <code>Float64Array</code>:</p> <pre data-language=\"js\">// From a length\nvar float64 = new Float64Array(2);\nfloat64[0] = 42;\nconsole.log(float64[0]); // 42\nconsole.log(float64.length); // 2\nconsole.log(float64.BYTES_PER_ELEMENT); // 8\n\n// From an array\nvar arr = new Float64Array([21,31]);\nconsole.log(arr[1]); // 31\n\n// From another TypedArray\nvar x = new Float64Array([21, 31]);\nvar y = new Float64Array(x);\nconsole.log(y[0]); // 21\n\n// From an ArrayBuffer\nvar buffer = new ArrayBuffer(32);\nvar z = new Float64Array(buffer, 0, 4);\n\n// From an iterable \nvar iterable = function*(){ yield* [1,2,3]; }();\nvar float64 = new Float64Array(iterable);\n// Float64Array[1, 2, 3]\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.khronos.org/registry/typedarray/specs/latest/\" hreflang=\"en\">Typed Array Specification</a></td> <td><span class=\"spec-Obsolete\">Obsolete</span></td> <td>Superseded by ECMAScript 2015.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#table-49\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'TypedArray constructors' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition in an ECMA standard. Specified that <code>new</code> is required.</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#table-49\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'TypedArray constructors' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td>ECMAScript 2017 changed the <code>Float64Array</code> constructor to use the <code>ToIndex</code> operation and allows constructors with no arguments.</td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 7</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> 10</td>\n<td class=\"bc-supports-yes\"> 11.6</td>\n<td class=\"bc-supports-yes\"> 5.1</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<code>Float64Array()</code> without <code>new</code> throws</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 44</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td> ? </td>\n</tr>\n<tr>\n<th scope=\"row\">Iterable in constructor</th>\n<td> ? </td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 52</td>\n<td> ? </td>\n<td> ? </td>\n<td> ? </td>\n</tr>\n<tr>\n<th scope=\"row\">Constructor without arguments</th>\n<td> ? </td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 55</td>\n<td> ? </td>\n<td> ? </td>\n<td> ? </td>\n</tr>\n</tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> 11.6</td>\n<td class=\"bc-supports-yes\"> 4.2</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<code>Float64Array()</code> without <code>new</code> throws</th>\n<td> ? </td>\n<td> ? </td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 44</td>\n<td> ? </td>\n<td> ? </td>\n<td> ? </td>\n</tr>\n<tr>\n<th scope=\"row\">Iterable in constructor</th>\n<td> ? </td>\n<td> ? </td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 52</td>\n<td> ? </td>\n<td> ? </td>\n<td> ? </td>\n</tr>\n<tr>\n<th scope=\"row\">Constructor without arguments</th>\n<td> ? </td>\n<td> ? </td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 55</td>\n<td> ? </td>\n<td> ? </td>\n<td> ? </td>\n</tr>\n</tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 0.10</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<code>Float64Array()</code> without <code>new</code> throws</th>\n<td class=\"bc-supports-yes\"> 0.12</td>\n</tr>\n<tr>\n<th scope=\"row\">Iterable in constructor</th>\n<td class=\"bc-supports-yes\"> 4.0.0</td>\n</tr>\n<tr>\n<th scope=\"row\">Constructor without arguments</th>\n<td> ? </td>\n</tr>\n</tbody>\n</table>\n</div> <h2 id=\"Compatibility_notes\">Compatibility notes</h2> <p>Starting with ECMAScript 2015, <code>Float64Array</code> constructors require to be constructed with a <a href=\"../operators/new\"><code>new</code></a> operator. Calling a <code>Float64Array</code> constructor as a function without <code>new</code>, will throw a <a href=\"typeerror\"><code>TypeError</code></a> from now on.</p> <pre data-language=\"js\">var dv = Float64Array([1, 2, 3]);\n// TypeError: calling a builtin Float64Array constructor\n// without new is forbidden</pre> <pre data-language=\"js\">var dv = new Float64Array([1, 2, 3]);</pre> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Typed_arrays\">JavaScript typed arrays</a></li> <li><a href=\"arraybuffer\"><code>ArrayBuffer</code></a></li> <li><a href=\"dataview\"><code>DataView</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Float64Array$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Float64Array\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Float64Array</a>\n  </p>\n</div>\n","global_objects/infinity":"<h1>Infinity</h1> <p>The global <code><strong>Infinity</strong></code> property is a numeric value representing infinity.</p> <div class=\"_table\"><table class=\"standard-table\"> <thead> <tr> <th colspan=\"2\" class=\"header\">Property attributes of <code>Infinity</code>\n</th> </tr> </thead> <tbody> <tr> <td>Writable</td> <td>no</td> </tr> <tr> <td>Enumerable</td> <td>no</td> </tr> <tr> <td>Configurable</td> <td>no</td> </tr> </tbody> </table></div> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/globalprops-infinity.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\">Infinity </pre> <h2 id=\"Description\">Description</h2> <p><code>Infinity</code> is a property of the <em>global object</em>, or in other words, a variable in global scope.</p> <p>The initial value of <code>Infinity</code> is <a href=\"number/positive_infinity\"><code>Number.POSITIVE_INFINITY</code></a>. The value <code>Infinity</code> (positive infinity) is greater than any other number. Mathematically, this value behaves the same as infinity; for example, any positive number multiplied by <code>Infinity</code> equals <code>Infinity</code>, and any number divided by <code>Infinity</code> equals 0.</p> <p>As defined by the ECMAScript 5 specification, <code>Infinity</code> is read-only (implemented in JavaScript 1.8.5 / Firefox 4).</p> <h2 id=\"Examples\">Examples</h2> <pre data-language=\"js\">console.log(Infinity          ); /* Infinity */  \nconsole.log(Infinity + 1      ); /* Infinity */  \nconsole.log(Math.pow(10, 1000)); /* Infinity */  \nconsole.log(Math.log(0)       ); /* -Infinity */  \nconsole.log(1 / Infinity      ); /* 0 */  \n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/publications/files/ECMA-ST-ARCH/ECMA-262,%201st%20edition,%20June%201997.pdf\" hreflang=\"en\">ECMAScript 1st Edition (ECMA-262)</a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition. Implemented in JavaScript 1.3</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/5.1/#sec-15.1.1.2\" hreflang=\"en\">ECMAScript 5.1 (ECMA-262)<br><small>The definition of 'Infinity' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-value-properties-of-the-global-object-infinity\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Infinity' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-value-properties-of-the-global-object-infinity\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Infinity' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"number/negative_infinity\"><code>Number.NEGATIVE_INFINITY</code></a></li> <li><a href=\"number/positive_infinity\"><code>Number.POSITIVE_INFINITY</code></a></li> <li><a href=\"number/isfinite\"><code>Number.isFinite</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Infinity$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Infinity\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Infinity</a>\n  </p>\n</div>\n","global_objects/int32array":"<h1>Int32Array</h1> <p>The <code>Int32Array</code> typed array represents an array of twos-complement 32-bit signed integers in the platform byte order. If control over byte order is needed, use <a href=\"dataview\"><code>DataView</code></a> instead. The contents are initialized to <code>0</code>. Once established, you can reference elements in the array using the object's methods, or using standard array index syntax (that is, using bracket notation).</p> <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\">new Int32Array(); // new in ES2017\nnew Int32Array(length);\nnew Int32Array(typedArray);\nnew Int32Array(object);\nnew Int32Array(buffer [, byteOffset [, length]]);</pre> <p>For more information about the constructor syntax and the parameters, see <em><a href=\"typedarray#Syntax\">TypedArray</a></em>.</p> <h2 id=\"Properties\">Properties</h2> <dl> <dt><a href=\"typedarray/bytes_per_element\"><code>Int32Array.BYTES_PER_ELEMENT</code></a></dt> <dd>Returns a number value of the element size. <code>4</code> in the case of an <code>Int32Array</code>.</dd> <dt>Int32Array.length</dt> <dd>Static length property whose value is 0. For the actual length (number of elements), see <a href=\"typedarray/length\"><code>Int32Array.prototype.length</code></a>.</dd> <dt><a href=\"typedarray/name\"><code>Int32Array.name</code></a></dt> <dd>Returns the string value of the constructor name. In the case of the <code>Int32Array</code> type: \"Int32Array\".</dd> <dt><a href=\"typedarray/prototype\"><code>Int32Array.prototype</code></a></dt> <dd>Prototype for the <em>TypedArray</em> objects.</dd> </dl> <h2 id=\"Methods\">Methods</h2> <dl> <dt><a href=\"typedarray/from\"><code>Int32Array.from()</code></a></dt> <dd>Creates a new <code>Int32Array</code> from an array-like or iterable object. See also <a href=\"array/from\"><code>Array.from()</code></a>.</dd> <dt><a href=\"typedarray/of\"><code>Int32Array.of()</code></a></dt> <dd>Creates a new <code>Int32Array</code> with a variable number of arguments. See also <a href=\"array/of\"><code>Array.of()</code></a>.</dd> </dl> <h2 id=\"Int32Array_prototype\">\n<code>Int32Array</code> prototype</h2> <p>All <code>Int32Array</code> objects inherit from <a href=\"typedarray/prototype\"><code>%TypedArray%.prototype</code></a>.</p> <h3 id=\"Properties_2\">Properties</h3> <dl> <dt><code>Int32Array.prototype.constructor</code></dt> <dd>Returns the function that created an instance's prototype. This is the <code>Int32Array</code> constructor by default.</dd> <dt>\n<a href=\"typedarray/buffer\"><code>Int32Array.prototype.buffer</code></a> <span class=\"inlineIndicator readOnly readOnlyInline\">Read only </span>\n</dt> <dd>Returns the <a href=\"arraybuffer\"><code>ArrayBuffer</code></a> referenced by the <code>Int32Array</code> Fixed at construction time and thus <strong>read only</strong>.</dd> <dt>\n<a href=\"typedarray/bytelength\"><code>Int32Array.prototype.byteLength</code></a> <span class=\"inlineIndicator readOnly readOnlyInline\">Read only </span>\n</dt> <dd>Returns the length (in bytes) of the <code>Int32Array</code> from the start of its <a href=\"arraybuffer\"><code>ArrayBuffer</code></a>. Fixed at construction time and thus <strong>read only.</strong>\n</dd> <dt>\n<a href=\"typedarray/byteoffset\"><code>Int32Array.prototype.byteOffset</code></a> <span class=\"inlineIndicator readOnly readOnlyInline\">Read only </span>\n</dt> <dd>Returns the offset (in bytes) of the <code>Int32Array</code> from the start of its <a href=\"arraybuffer\"><code>ArrayBuffer</code></a>. Fixed at construction time and thus <strong>read only.</strong>\n</dd> <dt>\n<a href=\"typedarray/length\"><code>Int32Array.prototype.length</code></a> <span class=\"inlineIndicator readOnly readOnlyInline\">Read only </span>\n</dt> <dd>Returns the number of elements hold in the <code>Int32Array</code>. Fixed at construction time and thus <strong>read only.</strong>\n</dd> </dl> <h3 id=\"Methods_2\">Methods</h3> <dl> <dt><a href=\"typedarray/copywithin\"><code>Int32Array.prototype.copyWithin()</code></a></dt> <dd>Copies a sequence of array elements within the array. See also <a href=\"array/copywithin\"><code>Array.prototype.copyWithin()</code></a>.</dd> <dt><a href=\"typedarray/entries\"><code>Int32Array.prototype.entries()</code></a></dt> <dd>Returns a new <code>Array Iterator</code> object that contains the key/value pairs for each index in the array. See also <a href=\"array/entries\"><code>Array.prototype.entries()</code></a>.</dd> <dt><a href=\"typedarray/every\"><code>Int32Array.prototype.every()</code></a></dt> <dd>Tests whether all elements in the array pass the test provided by a function. See also <a href=\"array/every\"><code>Array.prototype.every()</code></a>.</dd> <dt><a href=\"typedarray/fill\"><code>Int32Array.prototype.fill()</code></a></dt> <dd>Fills all the elements of an array from a start index to an end index with a static value. See also <a href=\"array/fill\"><code>Array.prototype.fill()</code></a>.</dd> <dt><a href=\"typedarray/filter\"><code>Int32Array.prototype.filter()</code></a></dt> <dd>Creates a new array with all of the elements of this array for which the provided filtering function returns true. See also <a href=\"array/filter\"><code>Array.prototype.filter()</code></a>.</dd> <dt><a href=\"typedarray/find\"><code>Int32Array.prototype.find()</code></a></dt> <dd>Returns the found value in the array, if an element in the array satisfies the provided testing function or <code>undefined</code> if not found. See also <a href=\"array/find\"><code>Array.prototype.find()</code></a>.</dd> <dt><a href=\"typedarray/findindex\"><code>Int32Array.prototype.findIndex()</code></a></dt> <dd>Returns the found index in the array, if an element in the array satisfies the provided testing function or -1 if not found. See also <a href=\"array/findindex\"><code>Array.prototype.findIndex()</code></a>.</dd> <dt><a href=\"typedarray/foreach\"><code>Int32Array.prototype.forEach()</code></a></dt> <dd>Calls a function for each element in the array. See also <a href=\"array/foreach\"><code>Array.prototype.forEach()</code></a>.</dd> <dt>\n<a href=\"typedarray/includes\"><code>Int32Array.prototype.includes()</code></a> \n</dt> <dd>Determines whether a typed array includes a certain element, returning <code>true</code> or <code>false</code> as appropriate. See also <a href=\"array/includes\"><code>Array.prototype.includes()</code></a>.</dd> <dt><a href=\"typedarray/indexof\"><code>Int32Array.prototype.indexOf()</code></a></dt> <dd>Returns the first (least) index of an element within the array equal to the specified value, or -1 if none is found. See also <a href=\"array/indexof\"><code>Array.prototype.indexOf()</code></a>.</dd> <dt><a href=\"typedarray/join\"><code>Int32Array.prototype.join()</code></a></dt> <dd>Joins all elements of an array into a string. See also <a href=\"array/join\"><code>Array.prototype.join()</code></a>.</dd> <dt><a href=\"typedarray/keys\"><code>Int32Array.prototype.keys()</code></a></dt> <dd>Returns a new <code>Array Iterator</code> that contains the keys for each index in the array. See also <a href=\"array/keys\"><code>Array.prototype.keys()</code></a>.</dd> <dt><a href=\"typedarray/lastindexof\"><code>Int32Array.prototype.lastIndexOf()</code></a></dt> <dd>Returns the last (greatest) index of an element within the array equal to the specified value, or -1 if none is found. See also <a href=\"array/lastindexof\"><code>Array.prototype.lastIndexOf()</code></a>.</dd> <dt><a href=\"typedarray/map\"><code>Int32Array.prototype.map()</code></a></dt> <dd>Creates a new array with the results of calling a provided function on every element in this array. See also <a href=\"array/map\"><code>Array.prototype.map()</code></a>.</dd> <dt>\n<a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/move\"><code>Int32Array.prototype.move()</code></a>  <span class=\"inlineIndicator unimplemented unimplementedInline\">Unimplemented</span>\n</dt> <dd>Former non-standard version of <a href=\"typedarray/copywithin\"><code>Int32Array.prototype.copyWithin()</code></a>.</dd> <dt><a href=\"typedarray/reduce\"><code>Int32Array.prototype.reduce()</code></a></dt> <dd>Apply a function against an accumulator and each value of the array (from left-to-right) as to reduce it to a single value. See also <a href=\"array/reduce\"><code>Array.prototype.reduce()</code></a>.</dd> <dt><a href=\"typedarray/reduceright\"><code>Int32Array.prototype.reduceRight()</code></a></dt> <dd>Apply a function against an accumulator and each value of the array (from right-to-left) as to reduce it to a single value. See also <a href=\"array/reduceright\"><code>Array.prototype.reduceRight()</code></a>.</dd> <dt><a href=\"typedarray/reverse\"><code>Int32Array.prototype.reverse()</code></a></dt> <dd>Reverses the order of the elements of an array — the first becomes the last, and the last becomes the first. See also <a href=\"array/reverse\"><code>Array.prototype.reverse()</code></a>.</dd> <dt><a href=\"typedarray/set\"><code>Int32Array.prototype.set()</code></a></dt> <dd>Stores multiple values in the typed array, reading input values from a specified array.</dd> <dt><a href=\"typedarray/slice\"><code>Int32Array.prototype.slice()</code></a></dt> <dd>Extracts a section of an array and returns a new array. See also <a href=\"array/slice\"><code>Array.prototype.slice()</code></a>.</dd> <dt><a href=\"typedarray/some\"><code>Int32Array.prototype.some()</code></a></dt> <dd>Returns true if at least one element in this array satisfies the provided testing function. See also <a href=\"array/some\"><code>Array.prototype.some()</code></a>.</dd> <dt><a href=\"typedarray/sort\"><code>Int32Array.prototype.sort()</code></a></dt> <dd>Sorts the elements of an array in place and returns the array. See also <a href=\"array/sort\"><code>Array.prototype.sort()</code></a>.</dd> <dt><a href=\"typedarray/subarray\"><code>Int32Array.prototype.subarray()</code></a></dt> <dd>Returns a new <code>Int32Array</code> from the given start and end element index.</dd> <dt><a href=\"typedarray/values\"><code>Int32Array.prototype.values()</code></a></dt> <dd>Returns a new <code>Array Iterator</code> object that contains the values for each index in the array. See also <a href=\"array/values\"><code>Array.prototype.values()</code></a>.</dd> <dt><a href=\"typedarray/tolocalestring\"><code>Int32Array.prototype.toLocaleString()</code></a></dt> <dd>Returns a localized string representing the array and its elements. See also <a href=\"array/tolocalestring\"><code>Array.prototype.toLocaleString()</code></a>.</dd> <dt><a href=\"typedarray/tostring\"><code>Int32Array.prototype.toString()</code></a></dt> <dd>Returns a string representing the array and its elements. See also <a href=\"array/tostring\"><code>Array.prototype.toString()</code></a>.</dd> <dt><a href=\"typedarray/@@iterator\"><code>Int32Array.prototype[@@iterator]()</code></a></dt> <dd>Returns a new <code>Array Iterator</code> object that contains the values for each index in the array.</dd> </dl> <h2 id=\"Examples\">Examples</h2> <p>Different ways to create an <code>Int32Array</code>:</p> <pre data-language=\"js\">// From a length\nvar int32 = new Int32Array(2);\nint32[0] = 42;\nconsole.log(int32[0]); // 42\nconsole.log(int32.length); // 2\nconsole.log(int32.BYTES_PER_ELEMENT); // 4\n\n// From an array\nvar arr = new Int32Array([21,31]);\nconsole.log(arr[1]); // 31\n\n// From another TypedArray\nvar x = new Int32Array([21, 31]);\nvar y = new Int32Array(x);\nconsole.log(y[0]); // 21\n\n// From an ArrayBuffer\nvar buffer = new ArrayBuffer(16);\nvar z = new Int32Array(buffer, 0, 4);\n\n// From an iterable \nvar iterable = function*(){ yield* [1,2,3]; }(); \nvar int32 = new Int32Array(iterable);\n// Int32Array[1, 2, 3] \n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.khronos.org/registry/typedarray/specs/latest/\" hreflang=\"en\">Typed Array Specification</a></td> <td><span class=\"spec-Obsolete\">Obsolete</span></td> <td>Superseded by ECMAScript 2015.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#table-49\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'TypedArray constructors' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition in an ECMA standard. Specified that <code>new</code> is required.</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#table-49\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'TypedArray constructors' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td>ECMAScript 2017 changed the <code>Int32Array</code> constructor to use the <code>ToIndex</code> operation and allows constructors with no arguments.</td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 7</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> 10</td>\n<td class=\"bc-supports-yes\"> 11.6</td>\n<td class=\"bc-supports-yes\"> 5.1</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<code>Int32Array()</code> without <code>new</code> throws</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 44</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td> ? </td>\n</tr>\n<tr>\n<th scope=\"row\">Iterable in constructor</th>\n<td> ? </td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 52</td>\n<td> ? </td>\n<td> ? </td>\n<td> ? </td>\n</tr>\n<tr>\n<th scope=\"row\">Constructor without arguments</th>\n<td> ? </td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 55</td>\n<td> ? </td>\n<td> ? </td>\n<td> ? </td>\n</tr>\n</tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> 11.6</td>\n<td class=\"bc-supports-yes\"> 4.2</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<code>Int32Array()</code> without <code>new</code> throws</th>\n<td> ? </td>\n<td> ? </td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 44</td>\n<td> ? </td>\n<td> ? </td>\n<td> ? </td>\n</tr>\n<tr>\n<th scope=\"row\">Iterable in constructor</th>\n<td> ? </td>\n<td> ? </td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 52</td>\n<td> ? </td>\n<td> ? </td>\n<td> ? </td>\n</tr>\n<tr>\n<th scope=\"row\">Constructor without arguments</th>\n<td> ? </td>\n<td> ? </td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 55</td>\n<td> ? </td>\n<td> ? </td>\n<td> ? </td>\n</tr>\n</tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 0.10</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<code>Int32Array()</code> without <code>new</code> throws</th>\n<td class=\"bc-supports-yes\"> 0.12</td>\n</tr>\n<tr>\n<th scope=\"row\">Iterable in constructor</th>\n<td class=\"bc-supports-yes\"> 4.0.0</td>\n</tr>\n<tr>\n<th scope=\"row\">Constructor without arguments</th>\n<td> ? </td>\n</tr>\n</tbody>\n</table>\n</div> <h2 id=\"Compatibility_notes\">Compatibility notes</h2> <p>Starting with ECMAScript 2015, <code>Int32Array</code> constructors require to be constructed with a <a href=\"../operators/new\"><code>new</code></a> operator. Calling a <code>Int32Array</code> constructor as a function without <code>new</code>, will throw a <a href=\"typeerror\"><code>TypeError</code></a> from now on.</p> <pre data-language=\"js\">var dv = Int32Array([1, 2, 3]);\n// TypeError: calling a builtin Int32Array constructor\n// without new is forbidden</pre> <pre data-language=\"js\">var dv = new Int32Array([1, 2, 3]);</pre> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Typed_arrays\">JavaScript typed arrays</a></li> <li><a href=\"arraybuffer\"><code>ArrayBuffer</code></a></li> <li><a href=\"dataview\"><code>DataView</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Int32Array$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Int32Array\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Int32Array</a>\n  </p>\n</div>\n","global_objects/int8array":"<h1>Int8Array</h1> <p>The <code>Int8Array</code> typed array represents an array of twos-complement 8-bit signed integers. The contents are initialized to <code>0</code>. Once established, you can reference elements in the array using the object's methods, or using standard array index syntax (that is, using bracket notation).</p> <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\">new Int8Array(); // new in ES2017\nnew Int8Array(length);\nnew Int8Array(typedArray);\nnew Int8Array(object);\nnew Int8Array(buffer [, byteOffset [, length]]);</pre> <p>For more information about the constructor syntax and the parameters, see <em><a href=\"typedarray#Syntax\">TypedArray</a></em>.</p> <h2 id=\"Properties\">Properties</h2> <dl> <dt><a href=\"typedarray/bytes_per_element\"><code>Int8Array.BYTES_PER_ELEMENT</code></a></dt> <dd>Returns a number value of the element size. <code>1</code> in the case of an <code>Int8Array</code>.</dd> <dt>Int8Array.length</dt> <dd>Static length property whose value is 0. For the actual length (number of elements), see <a href=\"typedarray/length\"><code>Int8Array.prototype.length</code></a>.</dd> <dt><a href=\"typedarray/name\"><code>Int8Array.name</code></a></dt> <dd>Returns the string value of the constructor name. In the case of the <code>Int8Array</code> type: \"Int8Array\".</dd> <dt><a href=\"typedarray/prototype\"><code>Int8Array.prototype</code></a></dt> <dd>Prototype for the <em>TypedArray</em> objects.</dd> </dl> <h2 id=\"Methods\">Methods</h2> <dl> <dt><a href=\"typedarray/from\"><code>Int8Array.from()</code></a></dt> <dd>Creates a new <code>Int8Array</code> from an array-like or iterable object. See also <a href=\"array/from\"><code>Array.from()</code></a>.</dd> <dt><a href=\"typedarray/of\"><code>Int8Array.of()</code></a></dt> <dd>Creates a new <code>Int8Array</code> with a variable number of arguments. See also <a href=\"array/of\"><code>Array.of()</code></a>.</dd> </dl> <h2 id=\"Int8Array_prototype\">\n<code>Int8Array</code> prototype</h2> <p>All <code>Int8Array</code> objects inherit from <a href=\"typedarray/prototype\"><code>%TypedArray%.prototype</code></a>.</p> <h3 id=\"Properties_2\">Properties</h3> <dl> <dt><code>Int8Array.prototype.constructor</code></dt> <dd>Returns the function that created an instance's prototype. This is the <code>Int8Array</code> constructor by default.</dd> <dt>\n<a href=\"typedarray/buffer\"><code>Int8Array.prototype.buffer</code></a> <span class=\"inlineIndicator readOnly readOnlyInline\">Read only </span>\n</dt> <dd>Returns the <a href=\"arraybuffer\"><code>ArrayBuffer</code></a> referenced by the <code>Int8Array</code> Fixed at construction time and thus <strong>read only</strong>.</dd> <dt>\n<a href=\"typedarray/bytelength\"><code>Int8Array.prototype.byteLength</code></a> <span class=\"inlineIndicator readOnly readOnlyInline\">Read only </span>\n</dt> <dd>Returns the length (in bytes) of the <code>Int8Array</code> from the start of its <a href=\"arraybuffer\"><code>ArrayBuffer</code></a>. Fixed at construction time and thus <strong>read only.</strong>\n</dd> <dt>\n<a href=\"typedarray/byteoffset\"><code>Int8Array.prototype.byteOffset</code></a> <span class=\"inlineIndicator readOnly readOnlyInline\">Read only </span>\n</dt> <dd>Returns the offset (in bytes) of the <code>Int8Array</code> from the start of its <a href=\"arraybuffer\"><code>ArrayBuffer</code></a>. Fixed at construction time and thus <strong>read only.</strong>\n</dd> <dt>\n<a href=\"typedarray/length\"><code>Int8Array.prototype.length</code></a> <span class=\"inlineIndicator readOnly readOnlyInline\">Read only </span>\n</dt> <dd>Returns the number of elements hold in the <code>Int8Array</code>. Fixed at construction time and thus <strong>read only.</strong>\n</dd> </dl> <h3 id=\"Methods_2\">Methods</h3> <dl> <dt><a href=\"typedarray/copywithin\"><code>Int8Array.prototype.copyWithin()</code></a></dt> <dd>Copies a sequence of array elements within the array. See also <a href=\"array/copywithin\"><code>Array.prototype.copyWithin()</code></a>.</dd> <dt><a href=\"typedarray/entries\"><code>Int8Array.prototype.entries()</code></a></dt> <dd>Returns a new <code>Array Iterator</code> object that contains the key/value pairs for each index in the array. See also <a href=\"array/entries\"><code>Array.prototype.entries()</code></a>.</dd> <dt><a href=\"typedarray/every\"><code>Int8Array.prototype.every()</code></a></dt> <dd>Tests whether all elements in the array pass the test provided by a function. See also <a href=\"array/every\"><code>Array.prototype.every()</code></a>.</dd> <dt><a href=\"typedarray/fill\"><code>Int8Array.prototype.fill()</code></a></dt> <dd>Fills all the elements of an array from a start index to an end index with a static value. See also <a href=\"array/fill\"><code>Array.prototype.fill()</code></a>.</dd> <dt><a href=\"typedarray/filter\"><code>Int8Array.prototype.filter()</code></a></dt> <dd>Creates a new array with all of the elements of this array for which the provided filtering function returns true. See also <a href=\"array/filter\"><code>Array.prototype.filter()</code></a>.</dd> <dt><a href=\"typedarray/find\"><code>Int8Array.prototype.find()</code></a></dt> <dd>Returns the found value in the array, if an element in the array satisfies the provided testing function or <code>undefined</code> if not found. See also <a href=\"array/find\"><code>Array.prototype.find()</code></a>.</dd> <dt><a href=\"typedarray/findindex\"><code>Int8Array.prototype.findIndex()</code></a></dt> <dd>Returns the found index in the array, if an element in the array satisfies the provided testing function or -1 if not found. See also <a href=\"array/findindex\"><code>Array.prototype.findIndex()</code></a>.</dd> <dt><a href=\"typedarray/foreach\"><code>Int8Array.prototype.forEach()</code></a></dt> <dd>Calls a function for each element in the array. See also <a href=\"array/foreach\"><code>Array.prototype.forEach()</code></a>.</dd> <dt>\n<a href=\"typedarray/includes\"><code>Int8Array.prototype.includes()</code></a> \n</dt> <dd>Determines whether a typed array includes a certain element, returning <code>true</code> or <code>false</code> as appropriate. See also <a href=\"array/includes\"><code>Array.prototype.includes()</code></a>.</dd> <dt><a href=\"typedarray/indexof\"><code>Int8Array.prototype.indexOf()</code></a></dt> <dd>Returns the first (least) index of an element within the array equal to the specified value, or -1 if none is found. See also <a href=\"array/indexof\"><code>Array.prototype.indexOf()</code></a>.</dd> <dt><a href=\"typedarray/join\"><code>Int8Array.prototype.join()</code></a></dt> <dd>Joins all elements of an array into a string. See also <a href=\"array/join\"><code>Array.prototype.join()</code></a>.</dd> <dt><a href=\"typedarray/keys\"><code>Int8Array.prototype.keys()</code></a></dt> <dd>Returns a new <code>Array Iterator</code> that contains the keys for each index in the array. See also <a href=\"array/keys\"><code>Array.prototype.keys()</code></a>.</dd> <dt><a href=\"typedarray/lastindexof\"><code>Int8Array.prototype.lastIndexOf()</code></a></dt> <dd>Returns the last (greatest) index of an element within the array equal to the specified value, or -1 if none is found. See also <a href=\"array/lastindexof\"><code>Array.prototype.lastIndexOf()</code></a>.</dd> <dt><a href=\"typedarray/map\"><code>Int8Array.prototype.map()</code></a></dt> <dd>Creates a new array with the results of calling a provided function on every element in this array. See also <a href=\"array/map\"><code>Array.prototype.map()</code></a>.</dd> <dt>\n<a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/move\"><code>Int8Array.prototype.move()</code></a>  <span class=\"inlineIndicator unimplemented unimplementedInline\">Unimplemented</span>\n</dt> <dd>Former non-standard version of <a href=\"typedarray/copywithin\"><code>Int8Array.prototype.copyWithin()</code></a>.</dd> <dt><a href=\"typedarray/reduce\"><code>Int8Array.prototype.reduce()</code></a></dt> <dd>Apply a function against an accumulator and each value of the array (from left-to-right) as to reduce it to a single value. See also <a href=\"array/reduce\"><code>Array.prototype.reduce()</code></a>.</dd> <dt><a href=\"typedarray/reduceright\"><code>Int8Array.prototype.reduceRight()</code></a></dt> <dd>Apply a function against an accumulator and each value of the array (from right-to-left) as to reduce it to a single value. See also <a href=\"array/reduceright\"><code>Array.prototype.reduceRight()</code></a>.</dd> <dt><a href=\"typedarray/reverse\"><code>Int8Array.prototype.reverse()</code></a></dt> <dd>Reverses the order of the elements of an array — the first becomes the last, and the last becomes the first. See also <a href=\"array/reverse\"><code>Array.prototype.reverse()</code></a>.</dd> <dt><a href=\"typedarray/set\"><code>Int8Array.prototype.set()</code></a></dt> <dd>Stores multiple values in the typed array, reading input values from a specified array.</dd> <dt><a href=\"typedarray/slice\"><code>Int8Array.prototype.slice()</code></a></dt> <dd>Extracts a section of an array and returns a new array. See also <a href=\"array/slice\"><code>Array.prototype.slice()</code></a>.</dd> <dt><a href=\"typedarray/some\"><code>Int8Array.prototype.some()</code></a></dt> <dd>Returns true if at least one element in this array satisfies the provided testing function. See also <a href=\"array/some\"><code>Array.prototype.some()</code></a>.</dd> <dt><a href=\"typedarray/sort\"><code>Int8Array.prototype.sort()</code></a></dt> <dd>Sorts the elements of an array in place and returns the array. See also <a href=\"array/sort\"><code>Array.prototype.sort()</code></a>.</dd> <dt><a href=\"typedarray/subarray\"><code>Int8Array.prototype.subarray()</code></a></dt> <dd>Returns a new <code>Int8Array</code> from the given start and end element index.</dd> <dt><a href=\"typedarray/values\"><code>Int8Array.prototype.values()</code></a></dt> <dd>Returns a new <code>Array Iterator</code> object that contains the values for each index in the array. See also <a href=\"array/values\"><code>Array.prototype.values()</code></a>.</dd> <dt><a href=\"typedarray/tolocalestring\"><code>Int8Array.prototype.toLocaleString()</code></a></dt> <dd>Returns a localized string representing the array and its elements. See also <a href=\"array/tolocalestring\"><code>Array.prototype.toLocaleString()</code></a>.</dd> <dt><a href=\"typedarray/tostring\"><code>Int8Array.prototype.toString()</code></a></dt> <dd>Returns a string representing the array and its elements. See also <a href=\"array/tostring\"><code>Array.prototype.toString()</code></a>.</dd> <dt><a href=\"typedarray/@@iterator\"><code>Int8Array.prototype[@@iterator]()</code></a></dt> <dd>Returns a new <code>Array Iterator</code> object that contains the values for each index in the array.</dd> </dl> <h2 id=\"Examples\">Examples</h2> <p>Different ways to create an <code>Int8Array</code>:</p> <pre data-language=\"js\">// From a length\nvar int8 = new Int8Array(2);\nint8[0] = 42;\nconsole.log(int8[0]); // 42\nconsole.log(int8.length); // 2\nconsole.log(int8.BYTES_PER_ELEMENT); // 1\n\n// From an array\nvar arr = new Int8Array([21,31]);\nconsole.log(arr[1]); // 31\n\n// From another TypedArray\nvar x = new Int8Array([21, 31]);\nvar y = new Int8Array(x);\nconsole.log(y[0]); // 21\n\n// From an ArrayBuffer\nvar buffer = new ArrayBuffer(8);\nvar z = new Int8Array(buffer, 1, 4);\n\n// From an iterable\nvar iterable = function*(){ yield* [1,2,3]; }();\nvar int8 = new Int8Array(iterable);\n// Int8Array[1, 2, 3]\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.khronos.org/registry/typedarray/specs/latest/\" hreflang=\"en\">Typed Array Specification</a></td> <td><span class=\"spec-Obsolete\">Obsolete</span></td> <td>Superseded by ECMAScript 2015.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#table-49\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'TypedArray constructors' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition in an ECMA standard. Specified that <code>new</code> is required.</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#table-49\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'TypedArray constructors' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td>ECMAScript 2017 changed the <code>Int8Array</code> constructor to use the <code>ToIndex</code> operation and allows constructors with no arguments.</td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 7</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> 10</td>\n<td class=\"bc-supports-yes\"> 11.6</td>\n<td class=\"bc-supports-yes\"> 5.1</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<code>Int8Array()</code> without <code>new</code> throws</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 44</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td> ? </td>\n</tr>\n<tr>\n<th scope=\"row\">Iterable in constructor</th>\n<td> ? </td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 52</td>\n<td> ? </td>\n<td> ? </td>\n<td> ? </td>\n</tr>\n<tr>\n<th scope=\"row\">Constructor without arguments</th>\n<td> ? </td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 55</td>\n<td> ? </td>\n<td> ? </td>\n<td> ? </td>\n</tr>\n</tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> 11.6</td>\n<td class=\"bc-supports-yes\"> 4.2</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<code>Int8Array()</code> without <code>new</code> throws</th>\n<td> ? </td>\n<td> ? </td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 44</td>\n<td> ? </td>\n<td> ? </td>\n<td> ? </td>\n</tr>\n<tr>\n<th scope=\"row\">Iterable in constructor</th>\n<td> ? </td>\n<td> ? </td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 52</td>\n<td> ? </td>\n<td> ? </td>\n<td> ? </td>\n</tr>\n<tr>\n<th scope=\"row\">Constructor without arguments</th>\n<td> ? </td>\n<td> ? </td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 55</td>\n<td> ? </td>\n<td> ? </td>\n<td> ? </td>\n</tr>\n</tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 0.10</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<code>Int8Array()</code> without <code>new</code> throws</th>\n<td class=\"bc-supports-yes\"> 0.12</td>\n</tr>\n<tr>\n<th scope=\"row\">Iterable in constructor</th>\n<td class=\"bc-supports-yes\"> 4.0.0</td>\n</tr>\n<tr>\n<th scope=\"row\">Constructor without arguments</th>\n<td> ? </td>\n</tr>\n</tbody>\n</table>\n</div> <h2 id=\"Compatibility_notes\">Compatibility notes</h2> <p>Starting with ECMAScript 2015, <code>Int8Array</code> constructors require to be constructed with a <a href=\"../operators/new\"><code>new</code></a> operator. Calling a <code>Int8Array</code> constructor as a function without <code>new</code>, will throw a <a href=\"typeerror\"><code>TypeError</code></a> from now on.</p> <pre data-language=\"js\">var dv = Int8Array([1, 2, 3]);\n// TypeError: calling a builtin Int8Array constructor \n// without new is forbidden</pre> <pre data-language=\"js\">var dv = new Int8Array([1, 2, 3]);</pre> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Typed_arrays\">JavaScript typed arrays</a></li> <li><a href=\"arraybuffer\"><code>ArrayBuffer</code></a></li> <li><a href=\"dataview\"><code>DataView</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Int8Array$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Int8Array\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Int8Array</a>\n  </p>\n</div>\n","global_objects/collator":"<h1>Intl.Collator</h1> <p>The <code>Intl.Collator</code> object is a constructor for collators, objects that enable language sensitive string comparison.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/intl-collator.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\">new Intl.Collator([<var>locales</var>[, <var>options</var>]])\nIntl.Collator.call(<var>this</var>[, <var>locales</var>[, <var>options</var>]])</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><code>locales</code></dt> <dd> <p>Optional. A string with a BCP 47 language tag, or an array of such strings. For the general form and interpretation of the <code>locales</code> argument, see the <a href=\"intl#Locale_identification_and_negotiation\">Intl page</a>. The following Unicode extension keys are allowed:</p> <dl> <dt><code>co</code></dt> <dd>Variant collations for certain locales. Possible values include: <code>\"big5han\"</code>, <code>\"dict\"</code>, <code>\"direct\"</code>, <code>\"ducet\"</code>, <code>\"gb2312\"</code>, <code>\"phonebk\"</code>, <code>\"phonetic\"</code>, <code>\"pinyin\"</code>, <code>\"reformed\"</code>, <code>\"searchjl\"</code>, <code>\"stroke\"</code>, <code>\"trad\"</code>, <code>\"unihan\"</code>. The <code>\"standard\"</code> and <code>\"search\"</code> values are ignored; they are replaced by the <code>options</code> property <code>usage</code> (see below).</dd> <dt><code>kn</code></dt> <dd>Whether numeric collation should be used, such that \"1\" &lt; \"2\" &lt; \"10\". Possible values are <code>\"true\"</code> and <code>\"false\"</code>. This option can be set through an <code>options</code> property or through a Unicode extension key; if both are provided, the <code>options</code> property takes precedence.</dd> <dt><code>kf</code></dt> <dd>Whether upper case or lower case should sort first. Possible values are <code>\"upper\"</code>, <code>\"lower\"</code>, or <code>\"false\"</code> (use the locale's default). This option can be set through an <code>options</code> property or through a Unicode extension key; if both are provided, the <code>options</code> property takes precedence.</dd> </dl> </dd> <dt><code>options</code></dt> <dd> <p>Optional. An object with some or all of the following properties:</p> <dl> <dt><code>localeMatcher</code></dt> <dd>The locale matching algorithm to use. Possible values are <code>\"lookup\"</code> and <code>\"best fit\"</code>; the default is <code>\"best fit\"</code>. For information about this option, see the <a href=\"intl#Locale_negotiation\">Intl page</a>.</dd> <dt><code>usage</code></dt> <dd>Whether the comparison is for sorting or for searching for matching strings. Possible values are <code>\"sort\"</code> and <code>\"search\"</code>; the default is <code>\"sort\"</code>.</dd> <dt><code>sensitivity</code></dt> <dd> <p>Which differences in the strings should lead to non-zero result values. Possible values are:</p> <ul> <li>\n<code>\"base\"</code>: Only strings that differ in base letters compare as unequal. Examples: <code>a ≠ b</code>, <code>a = á</code>, <code>a = A</code>.</li> <li>\n<code>\"accent\"</code>: Only strings that differ in base letters or accents and other diacritic marks compare as unequal. Examples: <code>a ≠ b</code>, <code>a ≠ á</code>, <code>a = A</code>.</li> <li>\n<code>\"case\"</code>: Only strings that differ in base letters or case compare as unequal. Examples: <code>a ≠ b</code>, <code>a = á</code>, <code>a ≠ A</code>.</li> <li>\n<code>\"variant\"</code>: Strings that differ in base letters, accents and other diacritic marks, or case compare as unequal. Other differences may also be taken into consideration. Examples: <code>a ≠ b</code>, <code>a ≠ á</code>, <code>a ≠ A</code>.</li> </ul> <p>The default is <code>\"variant\"</code> for usage <code>\"sort\"</code>; it's locale dependent for usage <code>\"search\"</code>.</p> </dd> <dt><code>ignorePunctuation</code></dt> <dd>Whether punctuation should be ignored. Possible values are <code>true</code> and <code>false</code>; the default is <code>false</code>.</dd> <dt><code>numeric</code></dt> <dd>Whether numeric collation should be used, such that \"1\" &lt; \"2\" &lt; \"10\". Possible values are <code>true</code> and <code>false</code>; the default is <code>false</code>. This option can be set through an <code>options</code> property or through a Unicode extension key; if both are provided, the <code>options</code> property takes precedence. Implementations are not required to support this property.</dd> <dt><code>caseFirst</code></dt> <dd>Whether upper case or lower case should sort first. Possible values are <code>\"upper\"</code>, <code>\"lower\"</code>, or <code>\"false\"</code> (use the locale's default); the default is <code>\"false\"</code>. This option can be set through an <code>options</code> property or through a Unicode extension key; if both are provided, the <code>options</code> property takes precedence. Implementations are not required to support this property.</dd> </dl> </dd> </dl> <h2 id=\"Description\">Description</h2> <p>The <code>Intl.Collator</code> object has the following properties and methods:</p> <h3 id=\"Properties\">Properties</h3> <dl> <dt><a href=\"collator/prototype\"><code>Intl.Collator.prototype</code></a></dt> <dd>Allows the addition of properties to all objects.</dd> </dl> <h3 id=\"Methods\">Methods</h3> <dl> <dt><a href=\"collator/supportedlocalesof\"><code>Intl.Collator.supportedLocalesOf()</code></a></dt> <dd>Returns an array containing those of the provided locales that are supported without having to fall back to the runtime's default locale.</dd> </dl> <h2 id=\"Collator_instances\">\n<code>Collator</code> instances</h2> <h3 id=\"Properties_2\">Properties</h3> <p><code>Collator</code> instances inherit the following properties from their prototype:</p> <dl> <dt><a href=\"collator/compare\"><code>Intl.Collator.prototype.compare</code></a></dt> <dd>Getter; returns a function that compares two strings according to the sort order of this <a href=\"collator\"><code>Intl.Collator</code></a> object.</dd> <dt><code>Intl.Collator.prototype.constructor</code></dt> <dd>A reference to <a href=\"collator\"><code>Intl.Collator</code></a>.</dd> </dl> <h3 id=\"Methods_2\">Methods</h3> <p><code>Collator</code> instances inherit the following methods from their prototype:</p> <dl> <dt><a href=\"collator/resolvedoptions\"><code>Intl.Collator.prototype.resolvedOptions()</code></a></dt> <dd>Returns a new object with properties reflecting the locale and collation options computed during initialization of the object.</dd> </dl> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Using_Collator\">Using <code>Collator</code>\n</h3> <p>The following example demonstrates the different potential results for a string occurring before, after, or at the same level as another:</p> <pre data-language=\"js\">console.log(new Intl.Collator().compare('a', 'c')); // → a negative value\nconsole.log(new Intl.Collator().compare('c', 'a')); // → a positive value\nconsole.log(new Intl.Collator().compare('a', 'a')); // → 0\n</pre> <p>Note that the results shown in the code above can vary between browsers and browser versions. This is because the values are implementation-specific. That is, the specification requires only that the before and after values are negative and positive.</p> <h3 id=\"Using_locales\">Using <code>locales</code>\n</h3> <p>The results provided by <a href=\"collator/compare\"><code>Collator.prototype.compare()</code></a> vary between languages. In order to get the sort order of the language used in the user interface of your application, make sure to specify that language (and possibly some fallback languages) using the <code>locales</code> argument:</p> <pre data-language=\"js\">// in German, ä sorts with a\nconsole.log(new Intl.Collator('de').compare('ä', 'z'));\n// → a negative value\n\n// in Swedish, ä sorts after z\nconsole.log(new Intl.Collator('sv').compare('ä', 'z'));\n// → a positive value\n</pre> <h3 id=\"Using_options\">Using <code>options</code>\n</h3> <p>The results provided by <a href=\"collator/compare\"><code>Collator.prototype.compare()</code></a> can be customized using the <code>options</code> argument:</p> <pre data-language=\"js\">// in German, ä has a as the base letter\nconsole.log(new Intl.Collator('de', { sensitivity: 'base' }).compare('ä', 'a'));\n// → 0\n\n// in Swedish, ä and a are separate base letters\nconsole.log(new Intl.Collator('sv', { sensitivity: 'base' }).compare('ä', 'a'));\n// → a positive value\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-402/1.0/#sec-10.1\" hreflang=\"en\">ECMAScript Internationalization API 1.0 (ECMA-402)<br><small>The definition of 'Intl.Collator' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-402/2.0/#sec-10.1\" hreflang=\"en\">ECMAScript Internationalization API 2.0 (ECMA-402)<br><small>The definition of 'Intl.Collator' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma402/#collator-objects\" hreflang=\"en\">ECMAScript Internationalization API 4.0 (ECMA-402)<br><small>The definition of 'Intl.Collator' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>   <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 24</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 29</td>\n<td class=\"bc-supports-yes\"> 11</td>\n<td class=\"bc-supports-yes\"> 15</td>\n<td class=\"bc-supports-yes\"> 10</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<code>caseFirst</code> option</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 55</td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 11</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Collator/prototype\"><code>prototype</code></a></th>\n<td class=\"bc-supports-yes\"> 24</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 29</td>\n<td class=\"bc-supports-yes\"> 11</td>\n<td class=\"bc-supports-yes\"> 15</td>\n<td class=\"bc-supports-yes\"> 10</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Collator/compare\"><code>compare</code></a></th>\n<td class=\"bc-supports-yes\"> 24</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 29</td>\n<td class=\"bc-supports-yes\"> 11</td>\n<td class=\"bc-supports-yes\"> 15</td>\n<td class=\"bc-supports-yes\"> 10</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Collator/resolvedOptions\"><code>resolvedOptions</code></a></th>\n<td class=\"bc-supports-yes\"> 24</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 29</td>\n<td class=\"bc-supports-yes\"> 11</td>\n<td class=\"bc-supports-yes\"> 15</td>\n<td class=\"bc-supports-yes\"> 10</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Collator/supportedLocalesOf\"><code>supportedLocalesOf</code></a></th>\n<td class=\"bc-supports-yes\"> 24</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 29</td>\n<td class=\"bc-supports-yes\"> 11</td>\n<td class=\"bc-supports-yes\"> 15</td>\n<td class=\"bc-supports-yes\"> 10</td>\n</tr>\n</tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 26</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 56</td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 10</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<code>caseFirst</code> option</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 56</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 11</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Collator/prototype\"><code>prototype</code></a></th>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 26</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 56</td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 10</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Collator/compare\"><code>compare</code></a></th>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 26</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 56</td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 10</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Collator/resolvedOptions\"><code>resolvedOptions</code></a></th>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 26</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 56</td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 10</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Collator/supportedLocalesOf\"><code>supportedLocalesOf</code></a></th>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 26</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 56</td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 10</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n</tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td> ? </td>\n</tr>\n<tr>\n<th scope=\"row\">\n<code>caseFirst</code> option</th>\n<td> ? </td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Collator/prototype\"><code>prototype</code></a></th>\n<td> ? </td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Collator/compare\"><code>compare</code></a></th>\n<td> ? </td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Collator/resolvedOptions\"><code>resolvedOptions</code></a></th>\n<td> ? </td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Collator/supportedLocalesOf\"><code>supportedLocalesOf</code></a></th>\n<td> ? </td>\n</tr>\n</tbody>\n</table>\n</div>  <h2 id=\"See_also\">See also</h2> <ul> <li>Introduction: <a href=\"http://norbertlindenberg.com/2012/12/ecmascript-internationalization-api/index.html\">The ECMAScript Internationalization API</a>\n</li> <li>Constructors <ul> <li><a href=\"collator\"><code>Intl.Collator</code></a></li> <li><a href=\"datetimeformat\"><code>Intl.DateTimeFormat</code></a></li> <li><a href=\"numberformat\"><code>Intl.NumberFormat</code></a></li> </ul> </li> <li>Methods <ul> <li><a href=\"string/localecompare\"><code>String.prototype.localeCompare()</code></a></li> <li><a href=\"number/tolocalestring\"><code>Number.prototype.toLocaleString()</code></a></li> <li><a href=\"date/tolocalestring\"><code>Date.prototype.toLocaleString()</code></a></li> <li><a href=\"date/tolocaledatestring\"><code>Date.prototype.toLocaleDateString()</code></a></li> <li><a href=\"date/tolocaletimestring\"><code>Date.prototype.toLocaleTimeString()</code></a></li> </ul> </li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Collator$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Collator\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Collator</a>\n  </p>\n</div>\n","global_objects/error":"<h1>Error</h1> <p>The <code>Error</code> constructor creates an error object. Instances of <code>Error</code> objects are thrown when runtime errors occur. The <code>Error</code> object can also be used as a base object for user-defined exceptions. See below for standard built-in error types.</p> <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\">new Error([<var>message</var>[, <var>fileName</var>[, <var>lineNumber</var>]]])</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><code>message</code></dt> <dd>Optional. A human-readable description of the error.</dd> <dt>\n<code>fileName</code> \n</dt> <dd>Optional. The value for the <code>fileName</code> property on the created <code>Error</code> object. Defaults to the name of the file containing the code that called the <code>Error()</code> constructor.</dd> <dt>\n<code>lineNumber</code> \n</dt> <dd>Optional. The value for the <code>lineNumber</code> property on the created <code>Error</code> object. Defaults to the line number containing the <code>Error()</code> constructor invocation.</dd> </dl> <h2 id=\"Description\">Description</h2> <p>Runtime errors result in new <code>Error</code> objects being created and thrown.</p> <p>This page documents the use of the <code>Error</code> object itself and its use as a constructor function. For a list of properties and methods inherited by <code>Error</code> instances, see <a href=\"error/prototype\"><code>Error.prototype</code></a>.</p> <h3 id=\"Used_as_a_function\">Used as a function</h3> <p>When <code>Error</code> is used like a function -- without <code>new</code>, it will return an <code>Error</code> object. Therefore, a mere call to <code>Error</code> will produce the same output that constructing an <code>Error</code> object via the <code>new</code> keyword would.</p> <pre data-language=\"js\">// this:\nconst x = Error('I was created using a function call!');\n​​​​// has the same functionality as this:\nconst y = new Error('I was constructed via the \"new\" keyword!');\n</pre> <h3 id=\"Error_types\">Error types</h3> <p>Besides the generic <code>Error</code> constructor, there are seven other core error constructors in JavaScript. For client-side exceptions, see <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Statements#Exception_handling_statements\">Exception handling statements</a>.</p> <dl> <dt><a href=\"evalerror\"><code>EvalError</code></a></dt> <dd>Creates an instance representing an error that occurs regarding the global function <a href=\"eval\"><code>eval()</code></a>.</dd> <dt>\n<a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/InternalError\"><code>InternalError</code></a> \n</dt> <dd>Creates an instance representing an error that occurs when an internal error in the JavaScript engine is thrown. E.g. \"too much recursion\".</dd> <dt><a href=\"rangeerror\"><code>RangeError</code></a></dt> <dd>Creates an instance representing an error that occurs when a numeric variable or parameter is outside of its valid range.</dd> <dt><a href=\"referenceerror\"><code>ReferenceError</code></a></dt> <dd>Creates an instance representing an error that occurs when de-referencing an invalid reference.</dd> <dt><a href=\"syntaxerror\"><code>SyntaxError</code></a></dt> <dd>Creates an instance representing a syntax error that occurs while parsing code in <a href=\"eval\"><code>eval()</code></a>.</dd> <dt><a href=\"typeerror\"><code>TypeError</code></a></dt> <dd>Creates an instance representing an error that occurs when a variable or parameter is not of a valid type.</dd> <dt><a href=\"urierror\"><code>URIError</code></a></dt> <dd>Creates an instance representing an error that occurs when <a href=\"encodeuri\"><code>encodeURI()</code></a> or <a href=\"decodeuri\"><code>decodeURI()</code></a> are passed invalid parameters.</dd> </dl> <h2 id=\"Properties\">Properties</h2> <dl> <dt><a href=\"error/prototype\"><code>Error.prototype</code></a></dt> <dd>Allows the addition of properties to <code>Error</code> instances.</dd> </dl> <h2 id=\"Methods\">Methods</h2> <p>The global <code>Error</code> object contains no methods of its own, however, it does inherit some methods from the prototype chain.</p> <h2 id=\"Error_instances\">Error instances</h2> <p>All <a href=\"error\"><code>Error</code></a> instances and instances of <a href=\"error#Error_types\">non-generic errors</a> inherit from <code>Error.prototype</code>. As with all constructor functions, you can use the prototype of the constructor to add properties or methods to all instances created with that constructor.</p> <h3 id=\"Properties_2\">Properties</h3> <h3 id=\"Standard_properties\">Standard properties</h3> <dl> <dt><code>Error.prototype.constructor</code></dt> <dd>Specifies the function that created an instance's prototype.</dd> <dt><a href=\"error/message\"><code>Error.prototype.message</code></a></dt> <dd>Error message.</dd> <dt><a href=\"error/name\"><code>Error.prototype.name</code></a></dt> <dd>Error name.</dd> </dl> <h3 id=\"Vendor-specific_extensions\">Vendor-specific extensions</h3> <div class=\"blockIndicator nonStandard nonStandardHeader\"> <p><strong> Non-standard</strong><br> This feature is non-standard and is not on a standards track. Do not use it on production sites facing the Web: it will not work for every user. There may also be large incompatibilities between implementations and the behavior may change in the future.</p> </div> <h4 id=\"Microsoft\">Microsoft</h4> <dl> <dt><a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/description\"><code>Error.prototype.description</code></a></dt> <dd>Error description. Similar to <a href=\"error/message\"><code>message</code></a>.</dd> <dt><a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/number\"><code>Error.prototype.number</code></a></dt> <dd>Error number.</dd> </dl> <h4 id=\"Mozilla\">Mozilla</h4> <dl> <dt><a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/fileName\"><code>Error.prototype.fileName</code></a></dt> <dd>Path to file that raised this error.</dd> <dt><a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/lineNumber\"><code>Error.prototype.lineNumber</code></a></dt> <dd>Line number in file that raised this error.</dd> <dt><a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/columnNumber\"><code>Error.prototype.columnNumber</code></a></dt> <dd>Column number in line that raised this error.</dd> <dt><a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/stack\"><code>Error.prototype.stack</code></a></dt> <dd>Stack trace.</dd> </dl> <h3 id=\"Methods_2\">Methods</h3> <dl> <dt>\n<a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/toSource\"><code>Error.prototype.toSource()</code></a> \n</dt> <dd>Returns a string containing the source of the specified <a href=\"error\"><code>Error</code></a> object; you can use this value to create a new object. Overrides the <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/toSource\"><code>Object.prototype.toSource()</code></a> method.</dd> <dt><a href=\"error/tostring\"><code>Error.prototype.toString()</code></a></dt> <dd>Returns a string representing the specified object. Overrides the <a href=\"object/tostring\"><code>Object.prototype.toString()</code></a> method.</dd> </dl> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Throwing_a_generic_error\">Throwing a generic error</h3> <p>Usually you create an <code>Error</code> object with the intention of raising it using the <a href=\"../statements/throw\"><code>throw</code></a> keyword. You can handle the error using the <a href=\"../statements/try...catch\"><code>try...catch</code></a> construct:</p> <pre data-language=\"js\">try {\n  throw new Error('Whoops!');\n} catch (e) {\n  console.log(e.name + ': ' + e.message);\n}\n</pre> <h3 id=\"Handling_a_specific_error\">Handling a specific error</h3> <p>You can choose to handle only specific error types by testing the error type with the error's <a href=\"object/constructor\"><code>constructor</code></a> property or, if you're writing for modern JavaScript engines, <a href=\"../operators/instanceof\"><code>instanceof</code></a> keyword:</p> <pre data-language=\"js\">try {\n  foo.bar();\n} catch (e) {\n  if (e instanceof EvalError) {\n    console.log(e.name + ': ' + e.message);\n  } else if (e instanceof RangeError) {\n    console.log(e.name + ': ' + e.message);\n  }\n  // ... etc\n}\n</pre> <h3 id=\"Custom_Error_Types\">Custom Error Types</h3> <p>You might want to define your own error types deriving from <code>Error</code> to be able to <code>throw new MyError()</code> and use <code>instanceof MyError</code> to check the kind of error in the exception handler. This results in cleaner and more consistent error handling code. See <a href=\"http://stackoverflow.com/questions/1382107/whats-a-good-way-to-extend-error-in-javascript\">\"What's a good way to extend Error in JavaScript?\"</a> on StackOverflow for an in-depth discussion.</p> <h4 id=\"ES6_Custom_Error_Class\">ES6 Custom Error Class</h4> <div class=\"warning\"> <p>Babel can handle Custom Error Class methods, but only when they are declared with <a href=\"object/defineproperty\">Object.defineProperty()</a>. Otherwise, Babel and other transpilers will not correctly handle the following code without <a href=\"https://github.com/loganfsmyth/babel-plugin-transform-builtin-extend\">additional configuration</a>.</p> </div> <div class=\"note\"> <p>Some browsers include the CustomError constructor in the stack trace when using ES2015 classes.</p> </div> <pre data-language=\"js\">class CustomError extends Error {\n  constructor(foo = 'bar', ...params) {\n    // Pass remaining arguments (including vendor specific ones) to parent constructor\n    super(...params);\n\n    // Maintains proper stack trace for where our error was thrown (only available on V8)\n    if (Error.captureStackTrace) {\n      Error.captureStackTrace(this, CustomError);\n    }\n\n    // Custom debugging information\n    this.foo = foo;\n    this.date = new Date();\n  }\n}\n\ntry {\n  throw new CustomError('baz', 'bazMessage');\n} catch(e){\n  console.log(e.foo); //baz\n  console.log(e.message); //bazMessage\n  console.log(e.stack); //stacktrace\n}</pre> <h4 id=\"ES5_Custom_Error_Object\">ES5 Custom Error Object</h4> <div class=\"warning\"> <p><strong>All</strong> browsers include the CustomError constructor in the stack trace when using a prototypal declaration.</p> </div> <pre data-language=\"js\">function CustomError(foo, message, fileName, lineNumber) {\n  var instance = new Error(message, fileName, lineNumber);\n  instance.foo = foo;\n  Object.setPrototypeOf(instance, Object.getPrototypeOf(this));\n  if (Error.captureStackTrace) {\n    Error.captureStackTrace(instance, CustomError);\n  }\n  return instance;\n}\n\nCustomError.prototype = Object.create(Error.prototype, {\n  constructor: {\n    value: Error,\n    enumerable: false,\n    writable: true,\n    configurable: true\n  }\n});\n\nif (Object.setPrototypeOf){\n  Object.setPrototypeOf(CustomError, Error);\n} else {\n  CustomError.__proto__ = Error;\n}\n\n\ntry {\n  throw new CustomError('baz', 'bazMessage');\n} catch(e){\n  console.log(e.foo); //baz\n  console.log(e.message) ;//bazMessage\n}</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/publications/files/ECMA-ST-ARCH/ECMA-262,%201st%20edition,%20June%201997.pdf\" hreflang=\"en\">ECMAScript 1st Edition (ECMA-262)</a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition. Implemented in JavaScript 1.1.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/5.1/#sec-15.11\" hreflang=\"en\">ECMAScript 5.1 (ECMA-262)<br><small>The definition of 'Error' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-error-objects\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Error' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-error-objects\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Error' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>   <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> 6</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Error/prototype\"><code>prototype</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> 6</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Error/columnNumber\"><code>columnNumber</code></a> \n</th>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Error/fileName\"><code>fileName</code></a> \n</th>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Error/lineNumber\"><code>lineNumber</code></a> \n</th>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Error/message\"><code>message</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> 6</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Error/name\"><code>name</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> 6</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Error/stack\"><code>stack</code></a> \n</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> 10</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 6</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Error/toSource\"><code>toSource</code></a> \n</th>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Error/toString\"><code>toString</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> 6</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n</tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Error/prototype\"><code>prototype</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Error/columnNumber\"><code>columnNumber</code></a> \n</th>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Error/fileName\"><code>fileName</code></a> \n</th>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Error/lineNumber\"><code>lineNumber</code></a> \n</th>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Error/message\"><code>message</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Error/name\"><code>name</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Error/stack\"><code>stack</code></a> \n</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 6</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Error/toSource\"><code>toSource</code></a> \n</th>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Error/toString\"><code>toString</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n</tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Error/prototype\"><code>prototype</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Error/columnNumber\"><code>columnNumber</code></a> \n</th>\n<td class=\"bc-supports-no\"> No</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Error/fileName\"><code>fileName</code></a> \n</th>\n<td class=\"bc-supports-no\"> No</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Error/lineNumber\"><code>lineNumber</code></a> \n</th>\n<td class=\"bc-supports-no\"> No</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Error/message\"><code>message</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Error/name\"><code>name</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Error/stack\"><code>stack</code></a> \n</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Error/toSource\"><code>toSource</code></a> \n</th>\n<td class=\"bc-supports-no\"> No</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Error/toString\"><code>toString</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n</tbody>\n</table>\n</div>  <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"error/prototype\"><code>Error.prototype</code></a></li> <li><a href=\"../statements/throw\"><code>throw</code></a></li> <li><a href=\"../statements/try...catch\"><code>try...catch</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error</a>\n  </p>\n</div>\n","global_objects/datetimeformat":"<h1>Intl.DateTimeFormat</h1> <p>The <code>Intl.DateTimeFormat</code> object is a constructor for objects that enable language-sensitive date and time formatting.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/intl-datetimeformat.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\">new Intl.DateTimeFormat([<var>locales</var>[, <var>options</var>]])\nIntl.DateTimeFormat.call(<var>this</var>[, <var>locales</var>[, <var>options</var>]])</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><code>locales</code></dt> <dd> <p>Optional. A string with a BCP 47 language tag, or an array of such strings. For the general form and interpretation of the <code>locales</code> argument, see the <a href=\"intl#Locale_identification_and_negotiation\">Intl page</a>. The following Unicode extension keys are allowed:</p> <dl> <dt><code>nu</code></dt> <dd>Numbering system. Possible values include: <code>\"arab\"</code>, <code>\"arabext\"</code>, <code>\"bali\"</code>, <code>\"beng\"</code>, <code>\"deva\"</code>, <code>\"fullwide\"</code>, <code>\"gujr\"</code>, <code>\"guru\"</code>, <code>\"hanidec\"</code>, <code>\"khmr\"</code>, <code>\"knda\"</code>, <code>\"laoo\"</code>, <code>\"latn\"</code>, <code>\"limb\"</code>, <code>\"mlym\"</code>, <code>\"mong\"</code>, <code>\"mymr\"</code>, <code>\"orya\"</code>, <code>\"tamldec\"</code>, <code>\"telu\"</code>, <code>\"thai\"</code>, <code>\"tibt\"</code>.</dd> <dt><code>ca</code></dt> <dd>Calendar. Possible values include: <code>\"buddhist\"</code>, <code>\"chinese\"</code>, <code>\"coptic\"</code>, <code>\"ethioaa\"</code>, <code>\"ethiopic\"</code>, <code>\"gregory\"</code>, <code>\"hebrew\"</code>, <code>\"indian\"</code>, <code>\"islamic\"</code>, <code>\"islamicc\"</code>, <code>\"iso8601\"</code>, <code>\"japanese\"</code>, <code>\"persian\"</code>, <code>\"roc\"</code>.</dd> <dt><code>hc</code></dt> <dd>Hour cycle. Possible values include: <code>\"h11\"</code>, <code>\"h12\"</code>, <code>\"h23\"</code>, <code>\"h24\"</code>.</dd> </dl> </dd> <dt><code>options</code></dt> <dd> <p>Optional. An object with some or all of the following properties:</p> <dl> <dt><code>localeMatcher</code></dt> <dd>The locale matching algorithm to use. Possible values are <code>\"lookup\"</code> and <code>\"best fit\"</code>; the default is <code>\"best fit\"</code>. For information about this option, see the <a href=\"intl#Locale_negotiation\">Intl page</a>.</dd> <dt><code>timeZone</code></dt> <dd>The time zone to use. The only value implementations must recognize is <code>\"UTC\"</code>; the default is the runtime's default time zone. Implementations may also recognize the time zone names of the <a href=\"https://www.iana.org/time-zones\">IANA time zone database</a>, such as <code>\"Asia/Shanghai\"</code>, <code>\"Asia/Kolkata\"</code>, <code>\"America/New_York\"</code>.</dd> <dt><code>hour12</code></dt> <dd>Whether to use 12-hour time (as opposed to 24-hour time). Possible values are <code>true</code> and <code>false</code>; the default is locale dependent. This option overrides the <code>hc</code> language tag and/or the <code>hourCycle</code> option in case both are present.</dd> <dt><code>hourCycle</code></dt> <dd>The hour cycle to use. Possible values are <code>\"h11\"</code>, <code>\"h12\"</code>, <code>\"h23\"</code>, or <code>\"h24\"</code>. This option overrides the <code>hc</code> language tag, if both are present, and the <code>hour12</code> option takes precedence in case both options have been specified.</dd> <dt><code>formatMatcher</code></dt> <dd>The format matching algorithm to use. Possible values are <code>\"basic\"</code> and <code>\"best fit\"</code>; the default is <code>\"best fit\"</code>. See the following paragraphs for information about the use of this property.</dd> </dl> <p>The following properties describe the date-time components to use in formatted output, and their desired representations. Implementations are required to support at least the following subsets:</p> <ul> <li>\n<code>weekday</code>, <code>year</code>, <code>month</code>, <code>day</code>, <code>hour</code>, <code>minute</code>, <code>second</code>\n</li> <li>\n<code>weekday</code>, <code>year</code>, <code>month</code>, <code>day</code>\n</li> <li>\n<code>year</code>, <code>month</code>, <code>day</code>\n</li> <li>\n<code>year</code>, <code>month</code>\n</li> <li>\n<code>month</code>, <code>day</code>\n</li> <li>\n<code>hour</code>, <code>minute</code>, <code>second</code>\n</li> <li>\n<code>hour</code>, <code>minute</code>\n</li> </ul> <p>Implementations may support other subsets, and requests will be negotiated against all available subset-representation combinations to find the best match. Two algorithms are available for this negotiation and selected by the <code>formatMatcher</code> property: A <a href=\"http://www.ecma-international.org/ecma-402/1.0/#BasicFormatMatcher\">fully specified <code>\"basic\"</code> algorithm</a> and an implementation-dependent <code>\"best fit\"</code> algorithm.</p> <dl> <dt><code>weekday</code></dt> <dd>The representation of the weekday. Possible values are <code>\"narrow\"</code>, <code>\"short\"</code>, <code>\"long\"</code>.</dd> <dt><code>era</code></dt> <dd>The representation of the era. Possible values are <code>\"narrow\"</code>, <code>\"short\"</code>, <code>\"long\"</code>.</dd> <dt><code>year</code></dt> <dd>The representation of the year. Possible values are <code>\"numeric\"</code>, <code>\"2-digit\"</code>.</dd> <dt><code>month</code></dt> <dd>The representation of the month. Possible values are <code>\"numeric\"</code>, <code>\"2-digit\"</code>, <code>\"narrow\"</code>, <code>\"short\"</code>, <code>\"long\"</code>.</dd> <dt><code>day</code></dt> <dd>The representation of the day. Possible values are <code>\"numeric\"</code>, <code>\"2-digit\"</code>.</dd> <dt><code>hour</code></dt> <dd>The representation of the hour. Possible values are <code>\"numeric\"</code>, <code>\"2-digit\"</code>.</dd> <dt><code>minute</code></dt> <dd>The representation of the minute. Possible values are <code>\"numeric\"</code>, <code>\"2-digit\"</code>.</dd> <dt><code>second</code></dt> <dd>The representation of the second. Possible values are <code>\"numeric\"</code>, <code>\"2-digit\"</code>.</dd> <dt><code>timeZoneName</code></dt> <dd>The representation of the time zone name. Possible values are <code>\"short\"</code>, <code>\"long\"</code>.</dd> </dl> <p class=\"noinclude\">The default value for each date-time component property is <a href=\"undefined\"><code>undefined</code></a>, but if all component properties are <a href=\"undefined\"><code>undefined</code></a>, then <code>year</code>, <code>month</code>, and <code>day</code> are assumed to be <code>\"numeric\"</code>.</p> </dd> </dl> <h2 id=\"Description\">Description</h2> <h3 id=\"Properties\">Properties</h3> <dl> <dt><a href=\"datetimeformat/prototype\"><code>Intl.DateTimeFormat.prototype</code></a></dt> <dd>Allows the addition of properties to all objects.</dd> </dl> <h3 id=\"Methods\">Methods</h3> <dl> <dt><a href=\"datetimeformat/supportedlocalesof\"><code>Intl.DateTimeFormat.supportedLocalesOf()</code></a></dt> <dd>Returns an array containing those of the provided locales that are supported without having to fall back to the runtime's default locale.</dd> </dl> <h2 id=\"DateTimeFormat_instances\">\n<code>DateTimeFormat</code> instances</h2> <h3 id=\"Properties_2\">Properties</h3> <p><code>DateTimeFormat</code> instances inherit the following properties from their prototype:</p> <dl> <dt><code>Intl.DateTimeFormat.prototype.constructor</code></dt> <dd>A reference to <a href=\"datetimeformat\"><code>Intl.DateTimeFormat</code></a>.</dd> <dt><a href=\"datetimeformat/format\"><code>Intl.DateTimeFormat.prototype.format</code></a></dt> <dd>Getter; returns a function that formats a date according to the locale and formatting options of this <a href=\"datetimeformat\"><code>DateTimeFormat</code></a> object.</dd> </dl> <h3 id=\"Methods_2\">Methods</h3> <p><code>DateTimeFormat</code> instances inherit the following methods from their prototype:</p> <dl> <dt><a href=\"datetimeformat/formattoparts\"><code>Intl.DateTimeFormat.prototype.formatToParts()</code></a></dt> <dd>Returns an <a href=\"array\"><code>Array</code></a> of objects representing the date string in parts that can be used for custom locale-aware formatting.</dd> <dt><a href=\"datetimeformat/resolvedoptions\"><code>Intl.DateTimeFormat.prototype.resolvedOptions()</code></a></dt> <dd>Returns a new object with properties reflecting the locale and formatting options computed during initialization of the object.</dd> </dl> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Using_DateTimeFormat\">Using <code>DateTimeFormat</code>\n</h3> <p>In basic use without specifying a locale, <code>DateTimeFormat</code> uses the default locale and default options.</p> <pre data-language=\"js\">var date = new Date(Date.UTC(2012, 11, 20, 3, 0, 0));\n\n// toLocaleString without arguments depends on the implementation,\n// the default locale, and the default time zone\nconsole.log(new Intl.DateTimeFormat().format(date));\n// → \"12/19/2012\" if run with en-US locale (language) and time zone America/Los_Angeles (UTC-0800)\n</pre> <h3 id=\"Using_locales\">Using <code>locales</code>\n</h3> <p>This example shows some of the variations in localized date and time formats. In order to get the format of the language used in the user interface of your application, make sure to specify that language (and possibly some fallback languages) using the <code>locales</code> argument:</p> <pre data-language=\"js\">var date = new Date(Date.UTC(2012, 11, 20, 3, 0, 0));\n\n// Results below use the time zone of America/Los_Angeles (UTC-0800, Pacific Standard Time)\n\n// US English uses month-day-year order\nconsole.log(new Intl.DateTimeFormat('en-US').format(date));\n// → \"12/19/2012\"\n\n// British English uses day-month-year order\nconsole.log(new Intl.DateTimeFormat('en-GB').format(date));\n// → \"19/12/2012\"\n\n// Korean uses year-month-day order\nconsole.log(new Intl.DateTimeFormat('ko-KR').format(date));\n// → \"2012. 12. 19.\"\n\n// Arabic in most Arabic speaking countries uses real Arabic digits\nconsole.log(new Intl.DateTimeFormat('ar-EG').format(date));\n// → \"١٩<span dir=\"rtl\">‏/١٢‏/٢٠١٢</span>\"\n\n// for Japanese, applications may want to use the Japanese calendar,\n// where 2012 was the year 24 of the Heisei era\nconsole.log(new Intl.DateTimeFormat('ja-JP-u-ca-japanese').format(date));\n// → \"24/12/19\"\n\n// when requesting a language that may not be supported, such as\n// Balinese, include a fallback language, in this case Indonesian\nconsole.log(new Intl.DateTimeFormat(['ban', 'id']).format(date));\n// → \"19/12/2012\"\n</pre> <h3 id=\"Using_options\">Using <code>options</code>\n</h3> <p>The date and time formats can be customized using the <code>options</code> argument:</p> <pre data-language=\"js\">var date = new Date(Date.UTC(2012, 11, 20, 3, 0, 0));\n\n// request a weekday along with a long date\nvar options = { weekday: 'long', year: 'numeric', month: 'long', day: 'numeric' };\nconsole.log(new Intl.DateTimeFormat('de-DE', options).format(date));\n// → \"Donnerstag, 20. Dezember 2012\"\n\n// an application may want to use UTC and make that visible\noptions.timeZone = 'UTC';\noptions.timeZoneName = 'short';\nconsole.log(new Intl.DateTimeFormat('en-US', options).format(date));\n// → \"Thursday, December 20, 2012, GMT\"\n\n// sometimes you want to be more precise\noptions = {\n  hour: 'numeric', minute: 'numeric', second: 'numeric', \n  timeZone: 'Australia/Sydney',\n  timeZoneName: 'short'\n};\nconsole.log(new Intl.DateTimeFormat('en-AU', options).format(date));\n// → \"2:00:00 pm AEDT\"\n\n// sometimes even the US needs 24-hour time\noptions = {\n  year: 'numeric', month: 'numeric', day: 'numeric',\n  hour: 'numeric', minute: 'numeric', second: 'numeric',\n  hour12: false,\n  timeZone: 'America/Los_Angeles' \n};\nconsole.log(new Intl.DateTimeFormat('en-US', options).format(date));\n// → \"12/19/2012, 19:00:00\"\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-402/1.0/#sec-12.1\" hreflang=\"en\">ECMAScript Internationalization API 1.0 (ECMA-402)<br><small>The definition of 'Intl.DateTimeFormat' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-402/2.0/#sec-12.1\" hreflang=\"en\">ECMAScript Internationalization API 2.0 (ECMA-402)<br><small>The definition of 'Intl.DateTimeFormat' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma402/#datetimeformat-objects\" hreflang=\"en\">ECMAScript Internationalization API 4.0 (ECMA-402)<br><small>The definition of 'Intl.DateTimeFormat' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>   <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 24</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 29</td>\n<td class=\"bc-supports-yes\"> 11</td>\n<td class=\"bc-supports-yes\"> 15</td>\n<td class=\"bc-supports-yes\"> 10</td>\n</tr>\n<tr>\n<th scope=\"row\">IANA time zone names in <code>timeZone</code> option</th>\n<td class=\"bc-supports-yes\"> 24</td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 52</td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 15</td>\n<td class=\"bc-supports-yes\"> 10</td>\n</tr>\n<tr>\n<th scope=\"row\"><code>hourCycle</code></th>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 58</td>\n<td> ? </td>\n<td> ? </td>\n<td> ? </td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/DateTimeFormat/prototype\"><code>prototype</code></a></th>\n<td class=\"bc-supports-yes\"> 24</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 29</td>\n<td class=\"bc-supports-yes\"> 11</td>\n<td class=\"bc-supports-yes\"> 15</td>\n<td class=\"bc-supports-yes\"> 10</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/DateTimeFormat/format\"><code>format</code></a></th>\n<td class=\"bc-supports-yes\"> 24</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 29</td>\n<td class=\"bc-supports-yes\"> 11</td>\n<td class=\"bc-supports-yes\"> 15</td>\n<td class=\"bc-supports-yes\"> 10</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/DateTimeFormat/formatToParts\"><code>formatToParts</code></a></th>\n<td class=\"bc-supports-yes bc-has-history\"> 57\n<section class=\"bc-history\" id=\"sect1\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 57\n</dt>\n\n<dt class=\"bc-supports-no bc-supports\">55 — 60<div class=\"bc-icons\">Disabled </div>\n</dt>\n<dd>Disabled From version 55 until version 60 (exclusive): this feature is behind the <code>--datetime-format-to-parts</code> runtime flag.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 51</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 11</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/DateTimeFormat/resolvedOptions\"><code>resolvedOptions</code></a></th>\n<td class=\"bc-supports-yes\"> 24</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 29</td>\n<td class=\"bc-supports-yes\"> 11</td>\n<td class=\"bc-supports-yes\"> 15</td>\n<td class=\"bc-supports-yes\"> 10</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Collator/supportedLocalesOf\"><code>supportedLocalesOf</code></a></th>\n<td class=\"bc-supports-yes\"> 24</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 29</td>\n<td class=\"bc-supports-yes\"> 11</td>\n<td class=\"bc-supports-yes\"> 15</td>\n<td class=\"bc-supports-yes\"> 10</td>\n</tr>\n</tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 26</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 56</td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 10</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">IANA time zone names in <code>timeZone</code> option</th>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 26</td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 56</td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 10</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><code>hourCycle</code></th>\n<td> ? </td>\n<td> ? </td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 58</td>\n<td> ? </td>\n<td> ? </td>\n<td> ? </td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/DateTimeFormat/prototype\"><code>prototype</code></a></th>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 26</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 56</td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 10</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/DateTimeFormat/format\"><code>format</code></a></th>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 26</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 56</td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 10</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/DateTimeFormat/formatToParts\"><code>formatToParts</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 57</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 56</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 11</td>\n<td class=\"bc-supports-yes\"> 7.0</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/DateTimeFormat/resolvedOptions\"><code>resolvedOptions</code></a></th>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 26</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 56</td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 10</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Collator/supportedLocalesOf\"><code>supportedLocalesOf</code></a></th>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 26</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 56</td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 10</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n</tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td> ? </td>\n</tr>\n<tr>\n<th scope=\"row\">IANA time zone names in <code>timeZone</code> option</th>\n<td> ? </td>\n</tr>\n<tr>\n<th scope=\"row\"><code>hourCycle</code></th>\n<td> ? </td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/DateTimeFormat/prototype\"><code>prototype</code></a></th>\n<td> ? </td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/DateTimeFormat/format\"><code>format</code></a></th>\n<td> ? </td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/DateTimeFormat/formatToParts\"><code>formatToParts</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/DateTimeFormat/resolvedOptions\"><code>resolvedOptions</code></a></th>\n<td> ? </td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Collator/supportedLocalesOf\"><code>supportedLocalesOf</code></a></th>\n<td> ? </td>\n</tr>\n</tbody>\n</table>\n</div>  <h2 id=\"See_also\">See also</h2> <ul> <li>Introduction: <a href=\"http://norbertlindenberg.com/2012/12/ecmascript-internationalization-api/index.html\">The ECMAScript Internationalization API</a>\n</li> <li>Constructors <ul> <li><a href=\"collator\"><code>Intl.Collator</code></a></li> <li><a href=\"datetimeformat\"><code>Intl.DateTimeFormat</code></a></li> <li><a href=\"numberformat\"><code>Intl.NumberFormat</code></a></li> </ul> </li> <li>Methods <ul> <li><a href=\"string/localecompare\"><code>String.prototype.localeCompare()</code></a></li> <li><a href=\"number/tolocalestring\"><code>Number.prototype.toLocaleString()</code></a></li> <li><a href=\"date/tolocalestring\"><code>Date.prototype.toLocaleString()</code></a></li> <li><a href=\"date/tolocaledatestring\"><code>Date.prototype.toLocaleDateString()</code></a></li> <li><a href=\"date/tolocaletimestring\"><code>Date.prototype.toLocaleTimeString()</code></a></li> </ul> </li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DateTimeFormat$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DateTimeFormat\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DateTimeFormat</a>\n  </p>\n</div>\n","global_objects/pluralrules":"<h1>PluralRules</h1> <p>The <code>Intl.PluralRules</code> object is a constructor for objects that enable plural sensitive formatting and plural language rules.</p> <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\">new Intl.PluralRules([<var>locales</var>[, <var>options</var>]])\n</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><code>locales</code></dt> <dd> <p>Optional. A string with a BCP 47 language tag, or an array of such strings. For the general form and interpretation of the <code>locales</code> argument, see the <a href=\"intl#Locale_identification_and_negotiation\">Intl page</a>.</p> </dd> <dt><code>options</code></dt> <dd> <p>Optional. An object with some or all of the following properties:</p> <dl> <dt><code>localeMatcher</code></dt> <dd>The locale matching algorithm to use. Possible values are <code>\"lookup\"</code> and <code>\"best fit\"</code>; the default is <code>\"best fit\"</code>. For information about this option, see the <a href=\"intl#Locale_negotiation\">Intl page</a>.</dd> <dt><code>type</code></dt> <dd>The type to use. Possible values are: <ul> <li>\n<code>\"cardinal\"</code> for cardinal numbers (refering to the quantity of things). This is the default value.</li> <li>\n<code>\"ordinal\"</code> for ordinal number (refering to the ordering or ranking of things, e.g. \"1st\", \"2nd\", \"3rd\" in English).</li> </ul> </dd> </dl> </dd> </dl> <h2 id=\"Description\">Description</h2> <h3 id=\"Properties\">Properties</h3> <dl> <dt><a href=\"pluralrules/prototype\"><code>Intl.PluralRules.prototype</code></a></dt> <dd>Allows the addition of properties to all objects.</dd> </dl> <h3 id=\"Methods\">Methods</h3> <dl> <dt><a href=\"pluralrules/supportedlocalesof\"><code>Intl.PluralRules.supportedLocalesOf()</code></a></dt> <dd>Returns an array containing those of the provided locales that are supported without having to fall back to the runtime's default locale.</dd> </dl> <h2 id=\"PluralRules_instances\">PluralRules instances</h2> <h3 id=\"Properties_2\">Properties</h3> <p><code>PluralRules</code> instances inherit the following properties from their prototype:</p> <dl> <dt><code>Intl.PluralRules.prototype.constructor</code></dt> <dd>A reference to <code>Intl.PluralRules</code>.</dd> </dl> <h3 id=\"Methods_2\">Methods</h3> <p><code>PluralRules</code> instances inherit the following methods from their prototype:</p> <dl> <dt><a href=\"pluralrules/resolvedoptions\"><code>Intl.PluralRules.prototype.resolvedOptions()</code></a></dt> <dd>Returns a new object with properties reflecting the locale and collation options computed during initialization of the object.</dd> <dt><a href=\"pluralrules/select\"><code>Intl.PluralRules.prototype.select()</code></a></dt> <dd>Returns a <a href=\"string\"><code>String</code></a> indicating which plurar rule to use for locale-aware formatting.</dd> </dl> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Basic_usage\">Basic usage</h3> <p>In basic use without specifying a locale, a formatted string in the default locale and with default options is returned. This is useful to distinguish between singular and plural forms, e.g. \"dog\" and \"dogs\".</p> <pre data-language=\"js\">var pr = new Intl.PluralRules();\n\npr.select(0);\n// → 'other' if in US English locale\n\npr.select(1); \n// → 'one' if in US English locale\n\npr.select(2);\n// → 'other' if in US English locale\n</pre> <h3 id=\"Using_locales\">Using locales</h3> <p>This example shows some of the variations in localized plural rules. In order to get the format of the language used in the user interface of your application, make sure to specify that language (and possibly some fallback languages) using the <code>locales</code> argument:</p> <pre data-language=\"js\">// Arabic has different plural rules\n\nnew Intl.PluralRules('ar-EG').select(0);\n// → 'zero'\nnew Intl.PluralRules('ar-EG').select(1); \n// → 'one'\nnew Intl.PluralRules('ar-EG').select(2);\n// → 'two'\nnew Intl.PluralRules('ar-EG').select(6);\n// → 'few'\nnew Intl.PluralRules('ar-EG').select(18);\n// → 'many'\n</pre> <h3 id=\"Using_options\">Using options</h3> <p>The results can be customized using the <code>options</code> argument, which has one property called <code>type</code> which you can set to <code>ordinal</code>. This is useful to figure out the ordinal indicator, e.g. \"1st\", \"2nd\", \"3rd\", \"4th\", \"42nd\" and so forth.</p> <pre data-language=\"js\">var pr = new Intl.PluralRules('en-US', { type: 'ordinal' });\n\npr.select(0);\n// → 'other'\npr.select(1);\n// → 'one'\npr.select(2);\n// → 'two'\npr.select(3);\n// → 'few'\npr.select(4);\n// → 'other'\npr.select(42);\n// → 'two'\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma402/#pluralrules-objects\">Intl Plural Rules Draft</a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td>Initial definition</td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>   <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 63</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 58</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 50</td>\n<td class=\"bc-supports-no\"> No</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/PluralRules/prototype\"><code>prototype</code></a></th>\n<td class=\"bc-supports-yes\"> 63</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 58</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 50</td>\n<td class=\"bc-supports-no\"> No</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/PluralRules/resolvedOptions\"><code>resolvedOptions</code></a></th>\n<td class=\"bc-supports-yes\"> 63</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 58</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 50</td>\n<td class=\"bc-supports-no\"> No</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/PluralRules/select\"><code>select</code></a></th>\n<td class=\"bc-supports-yes\"> 63</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 58</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 50</td>\n<td class=\"bc-supports-no\"> No</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/PluralRules/supportedLocalesOf\"><code>supportedLocalesOf</code></a></th>\n<td class=\"bc-supports-yes\"> 63</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 58</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 50</td>\n<td class=\"bc-supports-no\"> No</td>\n</tr>\n</tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 63</td>\n<td class=\"bc-supports-yes\"> 63</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 58</td>\n<td class=\"bc-supports-yes\"> 50</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/PluralRules/prototype\"><code>prototype</code></a></th>\n<td class=\"bc-supports-yes\"> 63</td>\n<td class=\"bc-supports-yes\"> 63</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 58</td>\n<td class=\"bc-supports-yes\"> 50</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/PluralRules/resolvedOptions\"><code>resolvedOptions</code></a></th>\n<td class=\"bc-supports-yes\"> 63</td>\n<td class=\"bc-supports-yes\"> 63</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 58</td>\n<td class=\"bc-supports-yes\"> 50</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/PluralRules/select\"><code>select</code></a></th>\n<td class=\"bc-supports-yes\"> 63</td>\n<td class=\"bc-supports-yes\"> 63</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 58</td>\n<td class=\"bc-supports-yes\"> 50</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/PluralRules/supportedLocalesOf\"><code>supportedLocalesOf</code></a></th>\n<td class=\"bc-supports-yes\"> 63</td>\n<td class=\"bc-supports-yes\"> 63</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 58</td>\n<td class=\"bc-supports-yes\"> 50</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n</tr>\n</tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-no\"> No</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/PluralRules/prototype\"><code>prototype</code></a></th>\n<td class=\"bc-supports-no\"> No</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/PluralRules/resolvedOptions\"><code>resolvedOptions</code></a></th>\n<td class=\"bc-supports-no\"> No</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/PluralRules/select\"><code>select</code></a></th>\n<td class=\"bc-supports-no\"> No</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/PluralRules/supportedLocalesOf\"><code>supportedLocalesOf</code></a></th>\n<td class=\"bc-supports-no\"> No</td>\n</tr>\n</tbody>\n</table>\n</div>  <h2 id=\"See_also\">See also</h2> <ul> <li>Introduction: <a href=\"http://norbertlindenberg.com/2012/12/ecmascript-internationalization-api/index.html\">The ECMAScript Internationalization API</a>\n</li> <li>Constructors <ul> <li><a href=\"collator\"><code>Intl.Collator</code></a></li> <li><a href=\"datetimeformat\"><code>Intl.DateTimeFormat</code></a></li> <li><a href=\"numberformat\"><code>Intl.NumberFormat</code></a></li> </ul> </li> <li>Methods <ul> <li><a href=\"string/localecompare\"><code>String.prototype.localeCompare()</code></a></li> <li><a href=\"number/tolocalestring\"><code>Number.prototype.toLocaleString()</code></a></li> <li><a href=\"date/tolocalestring\"><code>Date.prototype.toLocaleString()</code></a></li> <li><a href=\"date/tolocaledatestring\"><code>Date.prototype.toLocaleDateString()</code></a></li> <li><a href=\"date/tolocaletimestring\"><code>Date.prototype.toLocaleTimeString()</code></a></li> </ul> </li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/PluralRules$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/PluralRules\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/PluralRules</a>\n  </p>\n</div>\n","global_objects/rangeerror":"<h1>RangeError</h1> <p>The <code><strong>RangeError</strong></code> object indicates an error when a value is not in the set or range of allowed values.</p> <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\">new RangeError([<var>message</var>[, <var>fileName</var>[, <var>lineNumber</var>]]])</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><code>message</code></dt> <dd>Optional. Human-readable description of the error</dd> <dt>\n<code>fileName</code> \n</dt> <dd>Optional. The name of the file containing the code that caused the exception</dd> <dt>\n<code>lineNumber</code> \n</dt> <dd>Optional. The line number of the code that caused the exception</dd> </dl> <h2 id=\"Description\">Description</h2> <p>A <code>RangeError</code> is thrown when trying to pass a value as an argument to a function that does not allow a range that includes the value. This can be encountered when passing a value that is not one of the allowed string values to <a href=\"string/normalize\"><code>String.prototype.normalize()</code></a>, or when attempting to create an array of an illegal length with the <a href=\"array\"><code>Array</code></a> constructor, or when passing bad values to the numeric methods <a href=\"number/toexponential\"><code>Number.toExponential()</code></a>, <a href=\"number/tofixed\"><code>Number.toFixed()</code></a> or <a href=\"number/toprecision\"><code>Number.toPrecision()</code></a>.</p> <h2 id=\"Properties\">Properties</h2> <dl> <dt><a href=\"rangeerror/prototype\"><code>RangeError.prototype</code></a></dt> <dd>Allows the addition of properties to an <code>RangeError</code> object.</dd> </dl> <h2 id=\"Methods\">Methods</h2> <p>The global <code>RangeError</code> contains no methods of its own, however, it does inherit some methods through the prototype chain.</p> <h2 id=\"RangeError_instances\">\n<code>RangeError</code> instances</h2> <h3 id=\"Properties_2\">Properties</h3> <dl> <dt><code>RangeError.prototype.constructor</code></dt> <dd>Specifies the function that created an instance's prototype.</dd> <dt><a href=\"error/message\"><code>RangeError.prototype.message</code></a></dt> <dd>Error message. Although ECMA-262 specifies that <a href=\"rangeerror\"><code>RangeError</code></a> should provide its own <code>message</code> property, in <a href=\"https://developer.mozilla.org/en-US/docs/Mozilla/Projects/SpiderMonkey\">SpiderMonkey</a>, it inherits <a href=\"error/message\"><code>Error.prototype.message</code></a>.</dd> <dt><a href=\"error/name\"><code>RangeError.prototype.name</code></a></dt> <dd>Error name. Inherited from <a href=\"error\"><code>Error</code></a>.</dd> <dt><a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/fileName\"><code>RangeError.prototype.fileName</code></a></dt> <dd>Path to file that raised this error. Inherited from <a href=\"error\"><code>Error</code></a>.</dd> <dt><a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/lineNumber\"><code>RangeError.prototype.lineNumber</code></a></dt> <dd>Line number in file that raised this error. Inherited from <a href=\"error\"><code>Error</code></a>.</dd> <dt><a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/columnNumber\"><code>RangeError.prototype.columnNumber</code></a></dt> <dd>Column number in line that raised this error. Inherited from <a href=\"error\"><code>Error</code></a>.</dd> <dt><a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/stack\"><code>RangeError.prototype.stack</code></a></dt> <dd>Stack trace. Inherited from <a href=\"error\"><code>Error</code></a>.</dd> </dl> <h3 id=\"Methods_2\">Methods</h3> <p>Although the <a href=\"rangeerror\"><code>RangeError</code></a> prototype object does not contain any methods of its own, <a href=\"rangeerror\"><code>RangeError</code></a> instances do inherit some methods through the prototype chain.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Using_RangeError_(for_numeric_values)\">Using <code>RangeError</code> (for numeric values)</h3> <pre data-language=\"js\">function check(n)\n{\n    if(!(n &gt;= -500 &amp;&amp; n &lt;= 500))\n    {\n        throw new RangeError(\"The argument must be between -500 and 500.\");\n    }\n}\n\ntry\n{\n    check(2000);\n}\ncatch(error)\n{\n    if(error instanceof RangeError)\n    {\n        // Handle the error.\n    }\n}</pre> <h3 id=\"Using_RangeError_(for_non-numeric_values)\">Using <code>RangeError</code> (for non-numeric values)</h3> <pre data-language=\"js\">function check(value)\n{\n    if([\"apple\", \"banana\", \"carrot\"].includes(value) === false)\n    {\n        throw new RangeError(\"The argument must be an \\\"apple\\\", \\\"banana\\\", or \\\"carrot\\\".\");\n    }\n}\n\ntry\n{\n    check(\"cabbage\");\n}\ncatch(error)\n{\n    if(error instanceof RangeError)\n    {\n        // Handle the error.\n    }\n}\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/publications/files/ECMA-ST-ARCH/ECMA-262,%203rd%20edition,%20December%201999.pdf\" hreflang=\"en\">ECMAScript 3rd Edition (ECMA-262)</a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/5.1/#sec-15.11.6.2\" hreflang=\"en\">ECMAScript 5.1 (ECMA-262)<br><small>The definition of 'RangeError' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-native-error-types-used-in-this-standard-rangeerror\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'RangeError' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-native-error-types-used-in-this-standard-rangeerror\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'RangeError' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>   <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div>  <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"error\"><code>Error</code></a></li> <li><a href=\"rangeerror/prototype\"><code>RangeError.prototype</code></a></li> <li><a href=\"array\"><code>Array</code></a></li> <li><a href=\"number/toexponential\"><code>Number.toExponential()</code></a></li> <li><a href=\"number/tofixed\"><code>Number.toFixed()</code></a></li> <li><a href=\"number/toprecision\"><code>Number.toPrecision()</code></a></li> <li><a href=\"string/normalize\"><code>String.prototype.normalize()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RangeError$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RangeError\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RangeError</a>\n  </p>\n</div>\n","global_objects/referenceerror":"<h1>ReferenceError</h1> <p>The <code><strong>ReferenceError</strong></code> object represents an error when a non-existent variable is referenced.</p> <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\">new ReferenceError([<var>message</var>[, <var>fileName</var>[, <var>lineNumber</var>]]])</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><code>message</code></dt> <dd>Optional. Human-readable description of the error</dd> <dt>\n<code>fileName</code> \n</dt> <dd>Optional. The name of the file containing the code that caused the exception</dd> <dt>\n<code>lineNumber</code> \n</dt> <dd>Optional. The line number of the code that caused the exception</dd> </dl> <h2 id=\"Description\">Description</h2> <p>A <code>ReferenceError</code> is thrown when trying to dereference a variable that has not been declared.</p> <h2 id=\"Properties\">Properties</h2> <dl> <dt><a href=\"referenceerror/prototype\"><code>ReferenceError.prototype</code></a></dt> <dd>Allows the addition of properties to an <code>ReferenceError</code> object.</dd> </dl> <h2 id=\"ReferenceError_instances\">\n<code>ReferenceError</code> instances</h2> <h3 id=\"Properties_2\">Properties</h3> <dl> <dt><code>ReferenceError.prototype.constructor</code></dt> <dd>Specifies the function that created an instance's prototype.</dd> <dt><a href=\"error/message\"><code>ReferenceError.prototype.message</code></a></dt> <dd>Error message. Although ECMA-262 specifies that <a href=\"referenceerror\"><code>ReferenceError</code></a> should provide its own <code>message</code> property, in <a href=\"https://developer.mozilla.org/en-US/docs/Mozilla/Projects/SpiderMonkey\">SpiderMonkey</a>, it inherits <a href=\"error/message\"><code>Error.prototype.message</code></a>.</dd> <dt><a href=\"error/name\"><code>ReferenceError.prototype.name</code></a></dt> <dd>Error name. Inherited from <a href=\"error\"><code>Error</code></a>.</dd> <dt><a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/fileName\"><code>ReferenceError.prototype.fileName</code></a></dt> <dd>Path to file that raised this error. Inherited from <a href=\"error\"><code>Error</code></a>.</dd> <dt><a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/lineNumber\"><code>ReferenceError.prototype.lineNumber</code></a></dt> <dd>Line number in file that raised this error. Inherited from <a href=\"error\"><code>Error</code></a>.</dd> <dt><a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/columnNumber\"><code>ReferenceError.prototype.columnNumber</code></a></dt> <dd>Column number in line that raised this error. Inherited from <a href=\"error\"><code>Error</code></a>.</dd> <dt><a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/stack\"><code>ReferenceError.prototype.stack</code></a></dt> <dd>Stack trace. Inherited from <a href=\"error\"><code>Error</code></a>.</dd> </dl> <h3 id=\"Methods\">Methods</h3> <p>Although the <a href=\"referenceerror\"><code>ReferenceError</code></a> prototype object does not contain any methods of its own, <a href=\"referenceerror\"><code>ReferenceError</code></a> instances do inherit some methods through the prototype chain.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Catching_a_ReferenceError\">Catching a <code>ReferenceError</code>\n</h3> <pre data-language=\"js\">try {\n  var a = undefinedVariable;\n} catch (e) {\n  console.log(e instanceof ReferenceError); // true\n  console.log(e.message);                   // \"undefinedVariable is not defined\"\n  console.log(e.name);                      // \"ReferenceError\"\n  console.log(e.fileName);                  // \"Scratchpad/1\"\n  console.log(e.lineNumber);                // 2\n  console.log(e.columnNumber);              // 6\n  console.log(e.stack);                     // \"@Scratchpad/2:2:7\\n\"\n}\n</pre> <h3 id=\"Creating_a_ReferenceError\">Creating a <code>ReferenceError</code>\n</h3> <pre data-language=\"js\">try {\n  throw new ReferenceError('Hello', 'someFile.js', 10);\n} catch (e) {\n  console.log(e instanceof ReferenceError); // true\n  console.log(e.message);                   // \"Hello\"\n  console.log(e.name);                      // \"ReferenceError\"\n  console.log(e.fileName);                  // \"someFile.js\"\n  console.log(e.lineNumber);                // 10\n  console.log(e.columnNumber);              // 0\n  console.log(e.stack);                     // \"@Scratchpad/2:2:9\\n\"\n}\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/publications/files/ECMA-ST-ARCH/ECMA-262,%203rd%20edition,%20December%201999.pdf\" hreflang=\"en\">ECMAScript 3rd Edition (ECMA-262)</a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/5.1/#sec-15.11.6.3\" hreflang=\"en\">ECMAScript 5.1 (ECMA-262)<br><small>The definition of 'ReferenceError' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-native-error-types-used-in-this-standard-referenceerror\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'ReferenceError' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-native-error-types-used-in-this-standard-referenceerror\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'ReferenceError' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>   <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div>  <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"error\"><code>Error</code></a></li> <li><a href=\"referenceerror/prototype\"><code>ReferenceError.prototype</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ReferenceError$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ReferenceError\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ReferenceError</a>\n  </p>\n</div>\n","global_objects/function":"<h1>Function</h1> <p>The <code>Function</code> creates a new <code>Function</code> object. Calling the constructor directly can create functions dynamically, but suffers from security and similar (but far less significant) performance issues to <a href=\"eval\"><code>eval</code></a>. However, unlike eval, the Function constructor creates functions which execute in the global scope only.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/function-constructor.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <p>Every JavaScript function is actually a <code>Function</code> object. This can be seen with the code <code>(function(){}).constructor === Function</code> which returns true.</p> <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\">new Function ([<var>arg1</var>[, <var>arg2</var>[, ...<var>argN</var>]],] <var>functionBody</var>)</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><code>arg1, arg2, ... arg<em>N</em></code></dt> <dd>Names to be used by the function as formal argument names. Each must be a string that corresponds to a valid JavaScript identifier or a list of such strings separated with a comma; for example \"<code>x</code>\", \"<code>theValue</code>\", or \"<code>a,b</code>\".</dd> <dt><code>functionBody</code></dt> <dd>A string containing the JavaScript statements comprising the function definition.</dd> </dl> <h2 id=\"Description\">Description</h2> <p><code>Function</code> objects created with the <code>Function</code> constructor are parsed when the function is created. This is less efficient than declaring a function with a <a href=\"../operators/function\">function expression</a> or <a href=\"../statements/function\">function statement</a> and calling it within your code because such functions are parsed with the rest of the code.</p> <p>All arguments passed to the function are treated as the names of the identifiers of the parameters in the function to be created, in the order in which they are passed.</p> <p>Invoking the <code>Function</code> constructor as a function (without using the <code>new</code> operator) has the same effect as invoking it as a constructor.</p> <h2 id=\"Properties_and_Methods_of_Function\">Properties and Methods of <code>Function</code>\n</h2> <p>The global <code>Function</code> object has no methods or properties of its own. However, since it is a function itself, it does inherit some methods and properties through the prototype chain from <a href=\"function/prototype\"><code>Function.prototype</code></a>.</p> <h2 id=\"Function_prototype_object\">\n<code>Function</code> prototype object</h2> <h3 id=\"Properties\">Properties</h3> <dl> <dt>\n<a href=\"function/arguments\"><code>Function.prototype.arguments</code></a> \n</dt> <dd>An array corresponding to the arguments passed to a function. This is deprecated as property of <a href=\"function\"><code>Function</code></a>. Use the <a href=\"../functions/arguments\"><code>arguments</code></a> object available within the function instead.</dd> <dt><s class=\"obsoleteElement\"><a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/arity\"><code>Function.arity</code></a> </s></dt> <dd><s class=\"obsoleteElement\">Used to specifiy the number of arguments expected by the function, but has been removed. Use the <a href=\"function/length\"><code>length</code></a> property instead.</s></dd> <dt>\n<a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/caller\"><code>Function.prototype.caller</code></a> \n</dt> <dd>Specifies the function that invoked the currently executing function.</dd> <dt><a href=\"function/length\"><code>Function.prototype.length</code></a></dt> <dd>Specifies the number of arguments expected by the function.</dd> <dt><a href=\"function/name\"><code>Function.prototype.name</code></a></dt> <dd>The name of the function.</dd> <dt>\n<a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/displayName\"><code>Function.displayName</code></a> \n</dt> <dd>The display name of the function.</dd> <dt><code>Function.prototype.constructor</code></dt> <dd>Specifies the function that creates an object's prototype. See <a href=\"object/constructor\"><code>Object.prototype.constructor</code></a> for more details.</dd> </dl> <h3 id=\"Methods\">Methods</h3> <dl> <dt><a href=\"function/apply\"><code>Function.prototype.apply()</code></a></dt> <dd>Calls a function and sets its <em>this</em> to the provided value, arguments can be passed as an <a href=\"array\"><code>Array</code></a> object.</dd> <dt><a href=\"function/bind\"><code>Function.prototype.bind()</code></a></dt> <dd>Creates a new function which, when called, has its <em>this</em> set to the provided value, with a given sequence of arguments preceding any provided when the new function was called.</dd> <dt><a href=\"function/call\"><code>Function.prototype.call()</code></a></dt> <dd>Calls (executes) a function and sets its <em>this</em> to the provided value, arguments can be passed as they are.</dd> <dt>\n<a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/isGenerator\"><code>Function.prototype.isGenerator()</code></a> \n</dt> <dd>Returns <code>true</code> if the function is a <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Iterators_and_Generators\">generator</a>; otherwise returns <code>false</code>.</dd> <dt>\n<a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/toSource\"><code>Function.prototype.toSource()</code></a> \n</dt> <dd>Returns a string representing the source code of the function. Overrides the <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/toSource\"><code>Object.prototype.toSource</code></a> method.</dd> <dt><a href=\"function/tostring\"><code>Function.prototype.toString()</code></a></dt> <dd>Returns a string representing the source code of the function. Overrides the <a href=\"object/tostring\"><code>Object.prototype.toString</code></a> method.</dd> </dl> <h2 id=\"Function_instances\">\n<code>Function</code> instances</h2> <p><code>Function</code> instances inherit methods and properties from <a href=\"function/prototype\"><code>Function.prototype</code></a>. As with all constructors, you can change the constructor's prototype object to make changes to all <code>Function</code> instances.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Specifying_arguments_with_the_Function_constructor\">Specifying arguments with the <code>Function</code> constructor</h3> <p>The following code creates a <code>Function</code> object that takes two arguments.</p> <pre data-language=\"js\">// Example can be run directly in your JavaScript console\n\n// Create a function that takes two arguments and returns the sum of those arguments\nvar adder = new Function('a', 'b', 'return a + b');\n\n// Call the function\nadder(2, 6);\n// &gt; 8\n</pre> <p>The arguments \"<code>a</code>\" and \"<code>b</code>\" are formal argument names that are used in the function body, \"<code>return a + b</code>\".</p> <h3 id=\"Difference_between_Function_constructor_and_function_declaration\">Difference between Function constructor and function declaration</h3> <p>Functions created with the <code>Function</code> constructor do not create closures to their creation contexts; they always are created in the global scope. When running them, they will only be able to access their own local variables and global ones, not the ones from the scope in which the <code>Function</code> constructor was created. This is different from using <a href=\"eval\"><code>eval</code></a> with code for a function expression.</p> <pre data-language=\"js\">var x = 10;\n\nfunction createFunction1() {\n    var x = 20;\n    return new Function('return x;'); // this |x| refers global |x|\n}\n\nfunction createFunction2() {\n    var x = 20;\n    function f() {\n        return x; // this |x| refers local |x| above\n    }\n    return f;\n}\n\nvar f1 = createFunction1();\nconsole.log(f1());          // 10\nvar f2 = createFunction2();\nconsole.log(f2());          // 20\n</pre> <p>While this code works in web browsers, <code>f1()</code> will produce a <code>ReferenceError</code> in Node.js, as <code>x</code> will not be found. This is because the top-level scope in Node is not the global scope, and <code>x</code> will be local to the module.</p> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/publications/files/ECMA-ST-ARCH/ECMA-262,%201st%20edition,%20June%201997.pdf\" hreflang=\"en\">ECMAScript 1st Edition (ECMA-262)</a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition. Implemented in JavaScript 1.0.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/5.1/#sec-15.3\" hreflang=\"en\">ECMAScript 5.1 (ECMA-262)<br><small>The definition of 'Function' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-function-objects\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Function' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-function-objects\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Function' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>   <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Function/arguments\"><code>arguments</code></a> \n</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Function/arity\"><code>arity</code></a> \n</th>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Function/caller\"><code>caller</code></a> \n</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> 8</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Function/displayName\"><code>displayName</code></a> \n</th>\n<td> ? </td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 13</td>\n<td> ? </td>\n<td> ? </td>\n<td> ? </td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Function/length\"><code>length</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Function/name\"><code>name</code></a></th>\n<td class=\"bc-supports-yes\"> 15</td>\n<td class=\"bc-supports-yes\"> 14</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Function/prototype\"><code>prototype</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Function/apply\"><code>apply</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Function/bind\"><code>bind</code></a></th>\n<td class=\"bc-supports-yes\"> 7</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> 9</td>\n<td class=\"bc-supports-yes\"> 11.6</td>\n<td class=\"bc-supports-yes\"> 5.1</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Function/call\"><code>call</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Function/isGenerator\"><code>isGenerator</code></a> \n</th>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\">5 — 58</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Function/toSource\"><code>toSource</code></a> \n</th>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Function/toString\"><code>toString</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> 5</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n</tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Function/arguments\"><code>arguments</code></a> \n</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Function/arity\"><code>arity</code></a> \n</th>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Function/caller\"><code>caller</code></a> \n</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Function/displayName\"><code>displayName</code></a> \n</th>\n<td> ? </td>\n<td> ? </td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 14</td>\n<td> ? </td>\n<td> ? </td>\n<td> ? </td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Function/length\"><code>length</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Function/name\"><code>name</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Function/prototype\"><code>prototype</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Function/apply\"><code>apply</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Function/bind\"><code>bind</code></a></th>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> 18</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> 11.5</td>\n<td class=\"bc-supports-yes\"> 6</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Function/call\"><code>call</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Function/isGenerator\"><code>isGenerator</code></a> \n</th>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\">5 — 58</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Function/toSource\"><code>toSource</code></a> \n</th>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Function/toString\"><code>toString</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n</tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Function/arguments\"><code>arguments</code></a> \n</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Function/arity\"><code>arity</code></a> \n</th>\n<td class=\"bc-supports-no\"> No</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Function/caller\"><code>caller</code></a> \n</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Function/displayName\"><code>displayName</code></a> \n</th>\n<td> ? </td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Function/length\"><code>length</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Function/name\"><code>name</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Function/prototype\"><code>prototype</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Function/apply\"><code>apply</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Function/bind\"><code>bind</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Function/call\"><code>call</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Function/isGenerator\"><code>isGenerator</code></a> \n</th>\n<td class=\"bc-supports-no\"> No</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Function/toSource\"><code>toSource</code></a> \n</th>\n<td class=\"bc-supports-no\"> No</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Function/toString\"><code>toString</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n</tbody>\n</table>\n</div>  <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"../functions\"><code>Functions and function scope</code></a></li> <li><a href=\"../statements/function\"><code>function statement</code></a></li> <li><a href=\"../operators/function\"><code>function expression</code></a></li> <li><a href=\"../statements/function*\"><code>function* statement</code></a></li> <li><a href=\"../operators/function*\"><code>function* expression</code></a></li> <li><a href=\"asyncfunction\"><code>AsyncFunction</code></a></li> <li><a href=\"generatorfunction\"><code>GeneratorFunction</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function</a>\n  </p>\n</div>\n","global_objects/nan":"<h1>NaN</h1> <p>The global <code><strong>NaN</strong></code> property is a value representing Not-A-Number.</p> <div class=\"_table\"><table class=\"standard-table\"> <thead> <tr> <th colspan=\"2\" class=\"header\">Property attributes of <code>NaN</code>\n</th> </tr> </thead> <tbody> <tr> <td>Writable</td> <td>no</td> </tr> <tr> <td>Enumerable</td> <td>no</td> </tr> <tr> <td>Configurable</td> <td>no</td> </tr> </tbody> </table></div> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/globalprops-nan.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\">NaN</pre> <h2 id=\"Description\">Description</h2> <p><code>NaN</code> is a property of the <em>global object</em>.</p> <p>The initial value of <code>NaN</code> is Not-A-Number — the same as the value of <a href=\"number/nan\"><code>Number.NaN</code></a>. In modern browsers, <code>NaN</code> is a non-configurable, non-writable property. Even when this is not the case, avoid overriding it.</p> <p>It is rather rare to use <code>NaN</code> in a program. It is the returned value when <a href=\"math\"><code>Math</code></a> functions fail (<code>Math.sqrt(-1)</code>) or when a function trying to parse a number fails (<code>parseInt(\"blabla\")</code>).</p> <h3 id=\"Testing_against_NaN\">Testing against <code>NaN</code>\n</h3> <p><code>NaN</code> compares unequal (via <code>==</code>, <code>!=</code>, <code>===</code>, and <code>!==</code>) to any other value -- including to another NaN value. Use <a href=\"number/isnan\"><code>Number.isNaN()</code></a> or <a href=\"isnan\"><code>isNaN()</code></a> to most clearly determine whether a value is NaN. Or perform a self-comparison: NaN, and only NaN, will compare unequal to itself.</p> <pre data-language=\"js\">NaN === NaN;        // false\nNumber.NaN === NaN; // false\nisNaN(NaN);         // true\nisNaN(Number.NaN);  // true\n\nfunction valueIsNaN(v) { return v !== v; }\nvalueIsNaN(1);          // false\nvalueIsNaN(NaN);        // true\nvalueIsNaN(Number.NaN); // true\n</pre> <p>However, do note the difference between <code>isNaN()</code> and <code>Number.isNaN():</code> the former will return <code>true</code> if the value is currently <code>NaN</code>, or if it is going to be <code>NaN</code> after it is coerced to a number, while the latter will return <code>true</code> only if the value is currently <code>NaN:</code></p> <pre data-language=\"js\">isNaN('hello world'); // returns 'true'.\nNumber.isNaN('hello world'); // returns 'false'.\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/publications/files/ECMA-ST-ARCH/ECMA-262,%201st%20edition,%20June%201997.pdf\" hreflang=\"en\">ECMAScript 1st Edition (ECMA-262)</a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition. Implemented in JavaScript 1.3</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/5.1/#sec-15.1.1.1\" hreflang=\"en\">ECMAScript 5.1 (ECMA-262)<br><small>The definition of 'NaN' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-value-properties-of-the-global-object-nan\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'NaN' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-value-properties-of-the-global-object-nan\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'NaN' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"number/nan\"><code>Number.NaN</code></a></li> <li><a href=\"number/isnan\"><code>Number.isNaN()</code></a></li> <li><a href=\"isnan\"><code>isNaN()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/NaN$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/NaN\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/NaN</a>\n  </p>\n</div>\n","global_objects/typeerror":"<h1>TypeError</h1> <p>The <code><strong>TypeError</strong></code> object represents an error when a value is not of the expected type.</p> <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\">new TypeError([<var>message</var>[, <var>fileName</var>[, <var>lineNumber</var>]]])</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><code>message</code></dt> <dd>Optional. Human-readable description of the error</dd> <dt>\n<code>fileName</code> \n</dt> <dd>Optional. The name of the file containing the code that caused the exception</dd> <dt>\n<code>lineNumber</code> \n</dt> <dd>Optional. The line number of the code that caused the exception</dd> </dl> <h2 id=\"Description\">Description</h2> <p>A <code>TypeError</code> is thrown when an operand or argument passed to a function is incompatible with the type expected by that operator or function.</p> <h2 id=\"Properties\">Properties</h2> <dl> <dt><a href=\"typeerror/prototype\"><code>TypeError.prototype</code></a></dt> <dd>Allows the addition of properties to a <code>TypeError</code> object.</dd> </dl> <h2 id=\"Methods\">Methods</h2> <p>The global <code>TypeError</code> contains no methods of its own, however, it does inherit some methods through the prototype chain.</p> <h2 id=\"TypeError_instances\">\n<code>TypeError</code> instances</h2> <h3 id=\"Properties_2\">Properties</h3> <dl> <dt><code>TypeError.prototype.constructor</code></dt> <dd>Specifies the function that created an instance's prototype.</dd> <dt><a href=\"error/message\"><code>TypeError.prototype.message</code></a></dt> <dd>Error message. Although ECMA-262 specifies that <a href=\"typeerror\"><code>TypeError</code></a> should provide its own <code>message</code> property, in <a href=\"https://developer.mozilla.org/en-US/docs/Mozilla/Projects/SpiderMonkey\">SpiderMonkey</a>, it inherits <a href=\"error/message\"><code>Error.prototype.message</code></a>.</dd> <dt><a href=\"error/name\"><code>TypeError.prototype.name</code></a></dt> <dd>Error name. Inherited from <a href=\"error\"><code>Error</code></a>.</dd> <dt><a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/fileName\"><code>TypeError.prototype.fileName</code></a></dt> <dd>Path to file that raised this error. Inherited from <a href=\"error\"><code>Error</code></a>.</dd> <dt><a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/lineNumber\"><code>TypeError.prototype.lineNumber</code></a></dt> <dd>Line number in file that raised this error. Inherited from <a href=\"error\"><code>Error</code></a>.</dd> <dt><a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/columnNumber\"><code>TypeError.prototype.columnNumber</code></a></dt> <dd>Column number in line that raised this error. Inherited from <a href=\"error\"><code>Error</code></a>.</dd> <dt><a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/stack\"><code>TypeError.prototype.stack</code></a></dt> <dd>Stack trace. Inherited from <a href=\"error\"><code>Error</code></a>.</dd> </dl> <h3 id=\"Methods_2\">Methods</h3> <p>Although the <a href=\"typeerror\"><code>TypeError</code></a> prototype object does not contain any methods of its own, <a href=\"typeerror\"><code>TypeError</code></a> instances do inherit some methods through the prototype chain.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Catching_a_TypeError\">Catching a <code>TypeError</code>\n</h3> <pre data-language=\"js\">try {\n  null.f();\n} catch (e) {\n  console.log(e instanceof TypeError); // true\n  console.log(e.message);              // \"null has no properties\"\n  console.log(e.name);                 // \"TypeError\"\n  console.log(e.fileName);             // \"Scratchpad/1\"\n  console.log(e.lineNumber);           // 2\n  console.log(e.columnNumber);         // 2\n  console.log(e.stack);                // \"@Scratchpad/2:2:3\\n\"\n}\n</pre> <h3 id=\"Creating_a_TypeError\">Creating a <code>TypeError</code>\n</h3> <pre data-language=\"js\">try {\n  throw new TypeError('Hello', \"someFile.js\", 10);\n} catch (e) {\n  console.log(e instanceof TypeError); // true\n  console.log(e.message);              // \"Hello\"\n  console.log(e.name);                 // \"TypeError\"\n  console.log(e.fileName);             // \"someFile.js\"\n  console.log(e.lineNumber);           // 10\n  console.log(e.columnNumber);         // 0\n  console.log(e.stack);                // \"@Scratchpad/2:2:9\\n\"\n}\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/publications/files/ECMA-ST-ARCH/ECMA-262,%203rd%20edition,%20December%201999.pdf#sec-15.11.6.5\" hreflang=\"en\">ECMAScript 3rd Edition (ECMA-262)<br><small>The definition of 'TypeError' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/5.1/#sec-15.11.6.5\" hreflang=\"en\">ECMAScript 5.1 (ECMA-262)<br><small>The definition of 'TypeError' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-native-error-types-used-in-this-standard-typeerror\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'TypeError' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-native-error-types-used-in-this-standard-typeerror\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'TypeError' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>   <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div>  <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"error\"><code>Error</code></a></li> <li><a href=\"typeerror/prototype\"><code>TypeError.prototype</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypeError$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypeError\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypeError</a>\n  </p>\n</div>\n","global_objects/reflect":"<h1>Reflect</h1> <p><strong>Reflect</strong> is a built-in object that provides methods for interceptable JavaScript operations. The methods are the same as those of <a href=\"proxy/handler\">proxy handlers</a>. <code>Reflect</code> is not a function object, so it's not constructible.</p> <h2 id=\"Description\">Description</h2> <p>Unlike most global objects, <code>Reflect</code> is not a constructor. You cannot use it with a <a href=\"../operators/new\"><code>new</code> operator</a> or invoke the <code>Reflect</code> object as a function. All properties and methods of <code>Reflect</code> are static (just like the <a href=\"math\"><code>Math</code></a> object).</p> <h2 id=\"Methods\">Methods</h2> <p>The <code>Reflect</code> object provides the following static functions which have the same names as the <a href=\"proxy/handler\">proxy handler methods</a>. Some of these methods are the same as corresponding methods on <a href=\"object\"><code>Object</code></a>.</p> <dl> <dt><a href=\"reflect/apply\"><code>Reflect.apply()</code></a></dt> <dd>Calls a target function with arguments as specified by the <code>args</code> parameter. See also <a href=\"function/apply\"><code>Function.prototype.apply()</code></a>.</dd> <dt><a href=\"reflect/construct\"><code>Reflect.construct()</code></a></dt> <dd> The <a href=\"../operators/new\"><code>new</code> operator</a> as a function. Equivalent to calling <code>new target(...args)</code>. Provides also the optional possibility to specify a different prototype.</dd> <dt><a href=\"reflect/defineproperty\"><code>Reflect.defineProperty()</code></a></dt> <dd>Similar to <a href=\"object/defineproperty\"><code>Object.defineProperty()</code></a>. Returns a <a href=\"boolean\"><code>Boolean</code></a>.</dd> <dt><a href=\"reflect/deleteproperty\"><code>Reflect.deleteProperty()</code></a></dt> <dd>The <a href=\"../operators/delete\"><code>delete</code> operator</a> as a function. Equivalent to calling <code>delete target[name]</code>.</dd> <dt><a href=\"reflect/get\"><code>Reflect.get()</code></a></dt> <dd>A function that returns the value of properties.</dd> <dt><a href=\"reflect/getownpropertydescriptor\"><code>Reflect.getOwnPropertyDescriptor()</code></a></dt> <dd>Similar to <a href=\"object/getownpropertydescriptor\"><code>Object.getOwnPropertyDescriptor()</code></a>. Returns a property descriptor of the given property if it exists on the object, <a href=\"undefined\"><code>undefined</code></a> otherwise.</dd> <dt><a href=\"reflect/getprototypeof\"><code>Reflect.getPrototypeOf()</code></a></dt> <dd>Same as <a href=\"object/getprototypeof\"><code>Object.getPrototypeOf()</code></a>.</dd> <dt><a href=\"reflect/has\"><code>Reflect.has()</code></a></dt> <dd>The <a href=\"../operators/in\"><code>in</code> operator</a> as function. Returns a boolean indicating whether an own or inherited property exists.</dd> <dt><a href=\"reflect/isextensible\"><code>Reflect.isExtensible()</code></a></dt> <dd>Same as <a href=\"object/isextensible\"><code>Object.isExtensible()</code></a>.</dd> <dt><a href=\"reflect/ownkeys\"><code>Reflect.ownKeys()</code></a></dt> <dd>Returns an array of the target object's own (not inherited) property keys.</dd> <dt><a href=\"reflect/preventextensions\"><code>Reflect.preventExtensions()</code></a></dt> <dd>Similar to <a href=\"object/preventextensions\"><code>Object.preventExtensions()</code></a>. Returns a <a href=\"boolean\"><code>Boolean</code></a>.</dd> <dt><a href=\"reflect/set\"><code>Reflect.set()</code></a></dt> <dd>A function that assigns values to properties. Returns a <a href=\"boolean\"><code>Boolean</code></a> that is <code>true</code> if the update was successful.</dd> <dt><a href=\"reflect/setprototypeof\"><code>Reflect.setPrototypeOf()</code></a></dt> <dd>A function that sets the prototype of an object.</dd> </dl> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-reflect-object\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Reflect' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-reflect-object\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Reflect' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td>Reflect.enumerate has been removed.</td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 49</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 42</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 36</td>\n<td class=\"bc-supports-yes\"> 10</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Reflect/apply\"><code>apply</code></a></th>\n<td class=\"bc-supports-yes\"> 49</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 42</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 36</td>\n<td class=\"bc-supports-yes\"> 10</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Reflect/construct\"><code>construct</code></a></th>\n<td class=\"bc-supports-yes\"> 49</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 42</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 36</td>\n<td class=\"bc-supports-yes\"> 10</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Reflect/defineProperty\"><code>defineProperty</code></a></th>\n<td class=\"bc-supports-yes\"> 49</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 42</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 36</td>\n<td class=\"bc-supports-yes\"> 10</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Reflect/deleteProperty\"><code>deleteProperty</code></a></th>\n<td class=\"bc-supports-yes\"> 49</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 42</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 36</td>\n<td class=\"bc-supports-yes\"> 10</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Reflect/enumerate\"><code>enumerate</code></a> \n</th>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\">? — 15</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Reflect/get\"><code>get</code></a></th>\n<td class=\"bc-supports-yes\"> 49</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 42</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 36</td>\n<td class=\"bc-supports-yes\"> 10</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Reflect/getOwnPropertyDescriptor\"><code>getOwnPropertyDescriptor</code></a></th>\n<td class=\"bc-supports-yes\"> 49</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 42</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 36</td>\n<td class=\"bc-supports-yes\"> 10</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Reflect/getPrototypeOf\"><code>getPrototypeOf</code></a></th>\n<td class=\"bc-supports-yes\"> 49</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 42</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 36</td>\n<td class=\"bc-supports-yes\"> 10</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Reflect/has\"><code>has</code></a></th>\n<td class=\"bc-supports-yes\"> 49</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 42</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 36</td>\n<td class=\"bc-supports-yes\"> 10</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Reflect/isExtensible\"><code>isExtensible</code></a></th>\n<td class=\"bc-supports-yes\"> 49</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 42</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 36</td>\n<td class=\"bc-supports-yes\"> 10</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Reflect/ownKeys\"><code>ownKeys</code></a></th>\n<td class=\"bc-supports-yes\"> 49</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 42</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 36</td>\n<td class=\"bc-supports-yes\"> 10</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Reflect/preventExtensions\"><code>preventExtensions</code></a></th>\n<td class=\"bc-supports-yes\"> 49</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 42</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 36</td>\n<td class=\"bc-supports-yes\"> 10</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Reflect/set\"><code>set</code></a></th>\n<td class=\"bc-supports-yes\"> 49</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 42</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 36</td>\n<td class=\"bc-supports-yes\"> 10</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Reflect/setPrototypeOf\"><code>setPrototypeOf</code></a></th>\n<td class=\"bc-supports-yes\"> 49</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 42</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 36</td>\n<td class=\"bc-supports-yes\"> 10</td>\n</tr>\n</tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 49</td>\n<td class=\"bc-supports-yes\"> 49</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 42</td>\n<td class=\"bc-supports-yes\"> 36</td>\n<td class=\"bc-supports-yes\"> 10</td>\n<td class=\"bc-supports-yes\"> 5.0</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Reflect/apply\"><code>apply</code></a></th>\n<td class=\"bc-supports-yes\"> 49</td>\n<td class=\"bc-supports-yes\"> 49</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 42</td>\n<td class=\"bc-supports-yes\"> 36</td>\n<td class=\"bc-supports-yes\"> 10</td>\n<td class=\"bc-supports-yes\"> 5.0</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Reflect/construct\"><code>construct</code></a></th>\n<td class=\"bc-supports-yes\"> 49</td>\n<td class=\"bc-supports-yes\"> 49</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 42</td>\n<td class=\"bc-supports-yes\"> 36</td>\n<td class=\"bc-supports-yes\"> 10</td>\n<td class=\"bc-supports-yes\"> 5.0</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Reflect/defineProperty\"><code>defineProperty</code></a></th>\n<td class=\"bc-supports-yes\"> 49</td>\n<td class=\"bc-supports-yes\"> 49</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 42</td>\n<td class=\"bc-supports-yes\"> 36</td>\n<td class=\"bc-supports-yes\"> 10</td>\n<td class=\"bc-supports-yes\"> 5.0</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Reflect/deleteProperty\"><code>deleteProperty</code></a></th>\n<td class=\"bc-supports-yes\"> 49</td>\n<td class=\"bc-supports-yes\"> 49</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 42</td>\n<td class=\"bc-supports-yes\"> 36</td>\n<td class=\"bc-supports-yes\"> 10</td>\n<td class=\"bc-supports-yes\"> 5.0</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Reflect/enumerate\"><code>enumerate</code></a> \n</th>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Reflect/get\"><code>get</code></a></th>\n<td class=\"bc-supports-yes\"> 49</td>\n<td class=\"bc-supports-yes\"> 49</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 42</td>\n<td class=\"bc-supports-yes\"> 36</td>\n<td class=\"bc-supports-yes\"> 10</td>\n<td class=\"bc-supports-yes\"> 5.0</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Reflect/getOwnPropertyDescriptor\"><code>getOwnPropertyDescriptor</code></a></th>\n<td class=\"bc-supports-yes\"> 49</td>\n<td class=\"bc-supports-yes\"> 49</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 42</td>\n<td class=\"bc-supports-yes\"> 36</td>\n<td class=\"bc-supports-yes\"> 10</td>\n<td class=\"bc-supports-yes\"> 5.0</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Reflect/getPrototypeOf\"><code>getPrototypeOf</code></a></th>\n<td class=\"bc-supports-yes\"> 49</td>\n<td class=\"bc-supports-yes\"> 49</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 42</td>\n<td class=\"bc-supports-yes\"> 36</td>\n<td class=\"bc-supports-yes\"> 10</td>\n<td class=\"bc-supports-yes\"> 5.0</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Reflect/has\"><code>has</code></a></th>\n<td class=\"bc-supports-yes\"> 49</td>\n<td class=\"bc-supports-yes\"> 49</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 42</td>\n<td class=\"bc-supports-yes\"> 36</td>\n<td class=\"bc-supports-yes\"> 10</td>\n<td class=\"bc-supports-yes\"> 5.0</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Reflect/isExtensible\"><code>isExtensible</code></a></th>\n<td class=\"bc-supports-yes\"> 49</td>\n<td class=\"bc-supports-yes\"> 49</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 42</td>\n<td class=\"bc-supports-yes\"> 36</td>\n<td class=\"bc-supports-yes\"> 10</td>\n<td class=\"bc-supports-yes\"> 5.0</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Reflect/ownKeys\"><code>ownKeys</code></a></th>\n<td class=\"bc-supports-yes\"> 49</td>\n<td class=\"bc-supports-yes\"> 49</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 42</td>\n<td class=\"bc-supports-yes\"> 36</td>\n<td class=\"bc-supports-yes\"> 10</td>\n<td class=\"bc-supports-yes\"> 5.0</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Reflect/preventExtensions\"><code>preventExtensions</code></a></th>\n<td class=\"bc-supports-yes\"> 49</td>\n<td class=\"bc-supports-yes\"> 49</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 42</td>\n<td class=\"bc-supports-yes\"> 36</td>\n<td class=\"bc-supports-yes\"> 10</td>\n<td class=\"bc-supports-yes\"> 5.0</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Reflect/set\"><code>set</code></a></th>\n<td class=\"bc-supports-yes\"> 49</td>\n<td class=\"bc-supports-yes\"> 49</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 42</td>\n<td class=\"bc-supports-yes\"> 36</td>\n<td class=\"bc-supports-yes\"> 10</td>\n<td class=\"bc-supports-yes\"> 5.0</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Reflect/setPrototypeOf\"><code>setPrototypeOf</code></a></th>\n<td class=\"bc-supports-yes\"> 49</td>\n<td class=\"bc-supports-yes\"> 49</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 42</td>\n<td class=\"bc-supports-yes\"> 36</td>\n<td class=\"bc-supports-yes\"> 10</td>\n<td class=\"bc-supports-yes\"> 5.0</td>\n</tr>\n</tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 6.0.0</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Reflect/apply\"><code>apply</code></a></th>\n<td class=\"bc-supports-yes\"> 6.0.0</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Reflect/construct\"><code>construct</code></a></th>\n<td class=\"bc-supports-yes\"> 6.0.0</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Reflect/defineProperty\"><code>defineProperty</code></a></th>\n<td class=\"bc-supports-yes\"> 6.0.0</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Reflect/deleteProperty\"><code>deleteProperty</code></a></th>\n<td class=\"bc-supports-yes\"> 6.0.0</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Reflect/enumerate\"><code>enumerate</code></a> \n</th>\n<td class=\"bc-supports-no\"> No</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Reflect/get\"><code>get</code></a></th>\n<td class=\"bc-supports-yes\"> 6.0.0</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Reflect/getOwnPropertyDescriptor\"><code>getOwnPropertyDescriptor</code></a></th>\n<td class=\"bc-supports-yes\"> 6.0.0</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Reflect/getPrototypeOf\"><code>getPrototypeOf</code></a></th>\n<td class=\"bc-supports-yes\"> 6.0.0</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Reflect/has\"><code>has</code></a></th>\n<td class=\"bc-supports-yes\"> 6.0.0</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Reflect/isExtensible\"><code>isExtensible</code></a></th>\n<td class=\"bc-supports-yes\"> 6.0.0</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Reflect/ownKeys\"><code>ownKeys</code></a></th>\n<td class=\"bc-supports-yes\"> 6.0.0</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Reflect/preventExtensions\"><code>preventExtensions</code></a></th>\n<td class=\"bc-supports-yes\"> 6.0.0</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Reflect/set\"><code>set</code></a></th>\n<td class=\"bc-supports-yes\"> 6.0.0</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Reflect/setPrototypeOf\"><code>setPrototypeOf</code></a></th>\n<td class=\"bc-supports-yes\"> 6.0.0</td>\n</tr>\n</tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li>The <a href=\"proxy\"><code>Proxy</code></a> global object.</li> <li>The <a href=\"proxy/handler\"><code>handler</code></a> object.</li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect</a>\n  </p>\n</div>\n","global_objects/syntaxerror":"<h1>SyntaxError</h1> <p>The <code><strong>SyntaxError</strong></code> object represents an error when trying to interpret syntactically invalid code.</p> <h2 id=\"Description\">Description</h2> <p>A <code>SyntaxError</code> is thrown when the JavaScript engine encounters tokens or token order that does not conform to the syntax of the language when parsing code.</p> <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\">new SyntaxError([<var>message</var>[, <var>fileName</var>[, <var>lineNumber</var>]]])</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt>\n<code>message</code> <span class=\"inlineIndicator optional optionalInline\">Optional</span>\n</dt> <dd>Human-readable description of the error</dd> <dt>\n<code>fileName</code> <span class=\"inlineIndicator optional optionalInline\">Optional</span> \n</dt> <dd>The name of the file containing the code that caused the exception</dd> <dt>\n<code>lineNumber</code> <span class=\"inlineIndicator optional optionalInline\">Optional</span> \n</dt> <dd>The line number of the code that caused the exception</dd> </dl> <h2 id=\"Properties\">Properties</h2> <dl> <dt><a href=\"syntaxerror/prototype\"><code>SyntaxError.prototype</code></a></dt> <dd>Allows the addition of properties to a <code>SyntaxError</code> object.</dd> </dl> <h2 id=\"Methods\">Methods</h2> <p>The global <code>SyntaxError</code> contains no methods of its own, however, it does inherit some methods through the prototype chain.</p> <h2 id=\"SyntaxError_instances\">\n<code>SyntaxError</code> instances</h2> <h3 id=\"Properties_2\">Properties</h3> <dl> <dt><code>SyntaxError.prototype.constructor</code></dt> <dd>Specifies the function that created an instance's prototype.</dd> <dt><a href=\"error/message\"><code>SyntaxError.prototype.message</code></a></dt> <dd>Error message. Although ECMA-262 specifies that <a href=\"syntaxerror\"><code>SyntaxError</code></a> should provide its own <code>message</code> property, in <a href=\"https://developer.mozilla.org/en-US/docs/Mozilla/Projects/SpiderMonkey\">SpiderMonkey</a>, it inherits <a href=\"error/message\"><code>Error.prototype.message</code></a>.</dd> <dt><a href=\"error/name\"><code>SyntaxError.prototype.name</code></a></dt> <dd>Error name. Inherited from <a href=\"error\"><code>Error</code></a>.</dd> <dt><a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/fileName\"><code>SyntaxError.prototype.fileName</code></a></dt> <dd>Path to file that raised this error. Inherited from <a href=\"error\"><code>Error</code></a>.</dd> <dt><a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/lineNumber\"><code>SyntaxError.prototype.lineNumber</code></a></dt> <dd>Line number in file that raised this error. Inherited from <a href=\"error\"><code>Error</code></a>.</dd> <dt><a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/columnNumber\"><code>SyntaxError.prototype.columnNumber</code></a></dt> <dd>Column number in line that raised this error. Inherited from <a href=\"error\"><code>Error</code></a>.</dd> <dt><a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/stack\"><code>SyntaxError.prototype.stack</code></a></dt> <dd>Stack trace. Inherited from <a href=\"error\"><code>Error</code></a>.</dd> </dl> <h3 id=\"Methods_2\">Methods</h3> <p>Although the <a href=\"syntaxerror\"><code>SyntaxError</code></a> prototype object does not contain any methods of its own, <a href=\"syntaxerror\"><code>SyntaxError</code></a> instances do inherit some methods through the prototype chain.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Catching_a_SyntaxError\">Catching a <code>SyntaxError</code>\n</h3> <pre data-language=\"js\">try {\n  eval('hoo bar');\n} catch (e) {\n  console.log(e instanceof SyntaxError); // true\n  console.log(e.message);                // \"missing ; before statement\"\n  console.log(e.name);                   // \"SyntaxError\"\n  console.log(e.fileName);               // \"Scratchpad/1\"\n  console.log(e.lineNumber);             // 1\n  console.log(e.columnNumber);           // 4\n  console.log(e.stack);                  // \"@Scratchpad/1:2:3\\n\"\n}\n</pre> <h3 id=\"Creating_a_SyntaxError\">Creating a <code>SyntaxError</code>\n</h3> <pre data-language=\"js\">try {\n  throw new SyntaxError('Hello', 'someFile.js', 10);\n} catch (e) {\n  console.log(e instanceof SyntaxError); // true\n  console.log(e.message);                // \"Hello\"\n  console.log(e.name);                   // \"SyntaxError\"\n  console.log(e.fileName);               // \"someFile.js\"\n  console.log(e.lineNumber);             // 10\n  console.log(e.columnNumber);           // 0\n  console.log(e.stack);                  // \"@Scratchpad/2:11:9\\n\"\n}\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/publications/files/ECMA-ST-ARCH/ECMA-262,%203rd%20edition,%20December%201999.pdf\" hreflang=\"en\">ECMAScript 3rd Edition (ECMA-262)</a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/5.1/#sec-15.11.6.4\" hreflang=\"en\">ECMAScript 5.1 (ECMA-262)<br><small>The definition of 'SyntaxError' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-native-error-types-used-in-this-standard-syntaxerror\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'SyntaxError' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-native-error-types-used-in-this-standard-syntaxerror\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'SyntaxError' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>   <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div>  <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"error\"><code>Error</code></a></li> <li><a href=\"syntaxerror/prototype\"><code>SyntaxError.prototype</code></a></li> <li><a href=\"https://gist.github.com/ramsunvtech/7b10137ea1526b7b25ddcf2ad8582fbf\">Venkat.R - Various Syntax Error for var variables</a></li> <li><a href=\"https://gist.github.com/ramsunvtech/879e8b5800f319be432b48753eedf6c8\">Venkat.R - Various Syntax Error for let variables</a></li> <li><a href=\"https://gist.github.com/ramsunvtech/80e75ee317653895a33be69883233bd2\">Venkat.R - Various Syntax Error for const variables</a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SyntaxError$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SyntaxError\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SyntaxError</a>\n  </p>\n</div>\n","global_objects/urierror":"<h1>URIError</h1> <p>The <code><strong>URIError</strong></code> object represents an error when a global URI handling function was used in a wrong way.</p> <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\">new URIError([<var>message</var>[, <var>fileName</var>[, <var>lineNumber</var>]]])</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><code>message</code></dt> <dd>Optional. Human-readable description of the error</dd> <dt>\n<code>fileName</code> \n</dt> <dd>Optional. The name of the file containing the code that caused the exception</dd> <dt>\n<code>lineNumber</code> \n</dt> <dd>Optional. The line number of the code that caused the exception</dd> </dl> <h2 id=\"Description\">Description</h2> <p>A <code>URIError</code> is thrown when the global URI handling functions are passed a malformed URI.</p> <h2 id=\"Properties\">Properties</h2> <dl> <dt><a href=\"urierror/prototype\"><code>URIError.prototype</code></a></dt> <dd>Allows the addition of properties to a <code>URIError</code> object.</dd> </dl> <h2 id=\"Methods\">Methods</h2> <p>The global <code>URIError</code> contains no methods of its own, however, it does inherit some methods through the prototype chain.</p> <h2 id=\"URIError_instances\">\n<code>URIError</code> instances</h2> <h3 id=\"Properties_2\">Properties</h3> <dl> <dt><code>URIError.prototype.constructor</code></dt> <dd>Specifies the function that created an instance's prototype.</dd> <dt><a href=\"error/message\"><code>URIError.prototype.message</code></a></dt> <dd>Error message. Although ECMA-262 specifies that <a href=\"urierror\"><code>URIError</code></a> should provide its own <code>message</code> property, in <a href=\"https://developer.mozilla.org/en-US/docs/Mozilla/Projects/SpiderMonkey\">SpiderMonkey</a>, it inherits <a href=\"error/message\"><code>Error.prototype.message</code></a>.</dd> <dt><a href=\"error/name\"><code>URIError.prototype.name</code></a></dt> <dd>Error name. Inherited from <a href=\"error\"><code>Error</code></a>.</dd> <dt><a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/fileName\"><code>URIError.prototype.fileName</code></a></dt> <dd>Path to file that raised this error. Inherited from <a href=\"error\"><code>Error</code></a>.</dd> <dt><a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/lineNumber\"><code>URIError.prototype.lineNumber</code></a></dt> <dd>Line number in file that raised this error. Inherited from <a href=\"error\"><code>Error</code></a>.</dd> <dt><a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/columnNumber\"><code>URIError.prototype.columnNumber</code></a></dt> <dd>Column number in line that raised this error. Inherited from <a href=\"error\"><code>Error</code></a>.</dd> <dt><a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/stack\"><code>URIError.prototype.stack</code></a></dt> <dd>Stack trace. Inherited from <a href=\"error\"><code>Error</code></a>.</dd> </dl> <h3 id=\"Methods_2\">Methods</h3> <p>Although the <a href=\"urierror\"><code>URIError</code></a> prototype object does not contain any methods of its own, <a href=\"urierror\"><code>URIError</code></a> instances do inherit some methods through the prototype chain.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Catching_an_URIError\">Catching an <code>URIError</code>\n</h3> <pre data-language=\"js\">try {\n  decodeURIComponent('%');\n} catch (e) {\n  console.log(e instanceof URIError); // true\n  console.log(e.message);             // \"malformed URI sequence\"\n  console.log(e.name);                // \"URIError\"\n  console.log(e.fileName);            // \"Scratchpad/1\"\n  console.log(e.lineNumber);          // 2\n  console.log(e.columnNumber);        // 2\n  console.log(e.stack);               // \"@Scratchpad/2:2:3\\n\"\n}\n</pre> <h3 id=\"Creating_an_URIError\">Creating an <code>URIError</code>\n</h3> <pre data-language=\"js\">try {\n  throw new URIError('Hello', 'someFile.js', 10);\n} catch (e) {\n  console.log(e instanceof URIError); // true\n  console.log(e.message);             // \"Hello\"\n  console.log(e.name);                // \"URIError\"\n  console.log(e.fileName);            // \"someFile.js\"\n  console.log(e.lineNumber);          // 10\n  console.log(e.columnNumber);        // 0\n  console.log(e.stack);               // \"@Scratchpad/2:2:9\\n\"\n}\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/publications/files/ECMA-ST-ARCH/ECMA-262,%203rd%20edition,%20December%201999.pdf#sec-15.11.6.6\" hreflang=\"en\">ECMAScript 3rd Edition (ECMA-262)<br><small>The definition of 'URIError' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/5.1/#sec-15.11.6.6\" hreflang=\"en\">ECMAScript 5.1 (ECMA-262)<br><small>The definition of 'URIError' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-native-error-types-used-in-this-standard-urierror\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'URIError' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-native-error-types-used-in-this-standard-urierror\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'URIError' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>   <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div>  <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"error\"><code>Error</code></a></li> <li><a href=\"urierror/prototype\"><code>URIError.prototype</code></a></li> <li><a href=\"decodeuri\"><code>decodeURI()</code></a></li> <li><a href=\"decodeuricomponent\"><code>decodeURIComponent()</code></a></li> <li><a href=\"encodeuri\"><code>encodeURI()</code></a></li> <li><a href=\"encodeuricomponent\"><code>encodeURIComponent()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/URIError$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/URIError\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/URIError</a>\n  </p>\n</div>\n","global_objects/map":"<h1>Map</h1> <p>The <code>Map</code> object holds key-value pairs and remembers the original insertion order of the keys. Any value (both objects and <a href=\"https://developer.mozilla.org/en-US/docs/Glossary/Primitive\">primitive values</a>) may be used as either a key or a value.</p> <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\">new Map([<em>iterable</em>])</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><code>iterable</code></dt> <dd>An <a href=\"array\"><code>Array</code></a> or other <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/iterable\">iterable</a> object whose elements are key-value pairs (arrays with two elements, e.g. <code>[[ 1, 'one' ],[ 2, 'two' ]]</code>). Each key-value pair is added to the new <code>Map</code>; <code>null</code> values are treated as <code>undefined</code>.</dd> </dl> <h2 id=\"Description\">Description</h2> <p>A <code>Map</code> object iterates its elements in insertion order — a <a href=\"../statements/for...of\"><code>for...of</code></a> loop returns an array of <code>[key, value]</code> for each iteration.<br> </p> <h3 id=\"Key_equality\">Key equality</h3> <p>Key equality is based on the \"SameValueZero\" algorithm: <code>NaN</code> is considered the same as <code>NaN</code> (even though <code>NaN !== NaN</code>) and all other values are considered equal according to the semantics of the <code>===</code> operator. In the current ECMAScript specification <code>-0</code> and <code>+0</code> are considered equal, although this was not so in earlier drafts. See \"Value equality for -0 and 0\" in the <a href=\"#Browser_compatibility\">browser compatibility</a> table for details.</p> <h3 id=\"Objects_and_maps_compared\">Objects and maps compared</h3> <p><a href=\"object\"><code>Objects</code></a> are similar to <code>Maps</code> in that both let you set keys to values, retrieve those values, delete keys, and detect whether something is stored at a key. Because of this (and because there were no built-in alternatives), <code>Object</code>s have been used as <code>Maps</code> historically; however, there are important differences that make using a <code>Map</code> preferable in certain cases:</p> <ul> <li>The keys of an <code>Object</code> are <a href=\"string\"><code>Strings</code></a> and <a href=\"symbol\"><code>Symbols</code></a>, whereas they can be any value for a <code>Map</code>, including functions, objects, and any primitive.</li> <li>The keys in Map are ordered while keys added to object are not. Thus, when iterating over it, a Map object returns keys in order of insertion.</li> <li>You can get the size of a <code>Map</code> easily with the <code>size</code> property, while the number of properties in an <code>Object</code> must be determined manually.</li> <li>A <code>Map</code> is an <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/iterable\">iterable</a> and can thus be directly iterated, whereas iterating over an <code>Object</code> requires obtaining its keys in some fashion and iterating over them.</li> <li>An <code>Object</code> has a prototype, so there are default keys in the map that could collide with your keys if you're not careful. As of ES5 this can be bypassed by using <code>map = Object.create(null)</code>, but this is seldom done.</li> <li>A <code>Map</code> may perform better in scenarios involving frequent addition and removal of key pairs.</li> </ul> <h2 id=\"Properties\">Properties</h2> <dl> <dt><code>Map.length</code></dt> <dd>The value of the <code>length</code> property is 0.</dd> <dt><a href=\"map/@@species\"><code>get Map[@@species]</code></a></dt> <dd>The constructor function that is used to create derived objects.</dd> <dt><a href=\"map/prototype\"><code>Map.prototype</code></a></dt> <dd>Represents the prototype for the <code>Map</code> constructor. Allows the addition of properties to all <code>Map</code> objects.</dd> </dl> <h2 id=\"Map_instances\">\n<code>Map</code> instances</h2> <p>All <code>Map</code> instances inherit from <a href=\"map/prototype\"><code>Map.prototype</code></a>.</p> <h3 id=\"Properties_2\">Properties</h3> <dl> <dt><code>Map.prototype.constructor</code></dt> <dd>Returns the function that created an instance's prototype. This is the <a href=\"map\"><code>Map</code></a> function by default.</dd> <dt><a href=\"map/size\"><code>Map.prototype.size</code></a></dt> <dd>Returns the number of key/value pairs in the <code>Map</code> object.</dd> </dl> <h3 id=\"Methods\">Methods</h3> <dl> <dt><a href=\"map/clear\"><code>Map.prototype.clear()</code></a></dt> <dd>Removes all key/value pairs from the <code>Map</code> object.</dd> <dt><a href=\"map/delete\"><code>Map.prototype.delete(key)</code></a></dt> <dd>Returns <code>true</code> if an element in the <code>Map</code> object existed and has been removed, or <code>false</code> if the element does not exist. <code>Map.prototype.has(key)</code> will return <code>false</code> afterwards.</dd> <dt><a href=\"map/entries\"><code>Map.prototype.entries()</code></a></dt> <dd>Returns a new <code>Iterator</code> object that contains<code>[key, value]</code> for each element in the <code>Map</code> object in insertion order.</dd> <dt><a href=\"map/foreach\"><code>Map.prototype.forEach(callbackFn[, thisArg])</code></a></dt> <dd>Calls callbackFn once for each key-value pair present in the <code>Map</code> object, in insertion order. If a thisArg parameter is provided to forEach, it will be used as the this value for each callback.</dd> <dt><a href=\"map/get\"><code>Map.prototype.get(key)</code></a></dt> <dd>Returns the value associated to the <code>key</code>, or <code>undefined</code> if there is none.</dd> <dt><a href=\"map/has\"><code>Map.prototype.has(key)</code></a></dt> <dd>Returns a boolean asserting whether a value has been associated to the <code>key</code> in the <code>Map</code> object or not.</dd> <dt><a href=\"map/keys\"><code>Map.prototype.keys()</code></a></dt> <dd>Returns a new <code>Iterator</code> object that contains the <strong>keys</strong> for each element in the <code>Map</code> object in insertion order.</dd> <dt><a href=\"map/set\"><code>Map.prototype.set(key, value)</code></a></dt> <dd>Sets the value for the <code>key</code> in the <code>Map</code> object. Returns the <code>Map</code> object.</dd> <dt><a href=\"map/values\"><code>Map.prototype.values()</code></a></dt> <dd>Returns a new <code>Iterator</code> object that contains the <strong>values</strong> for each element in the <code>Map</code> object in insertion order.</dd> <dt><a href=\"map/@@iterator\"><code>Map.prototype[@@iterator]()</code></a></dt> <dd>Returns a new <code>Iterator</code> object that contains<code>[key, value]</code> for each element in the <code>Map</code> object in insertion order.</dd> </dl> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Using_the_Map_object\">Using the <code>Map</code> object</h3> <pre data-language=\"js\">var myMap = new Map();\n\nvar keyString = 'a string',\n    keyObj = {},\n    keyFunc = function() {};\n\n// setting the values\nmyMap.set(keyString, \"value associated with 'a string'\");\nmyMap.set(keyObj, 'value associated with keyObj');\nmyMap.set(keyFunc, 'value associated with keyFunc');\n\nmyMap.size; // 3\n\n// getting the values\nmyMap.get(keyString);    // \"value associated with 'a string'\"\nmyMap.get(keyObj);       // \"value associated with keyObj\"\nmyMap.get(keyFunc);      // \"value associated with keyFunc\"\n\nmyMap.get('a string');   // \"value associated with 'a string'\"\n                         // because keyString === 'a string'\nmyMap.get({});           // undefined, because keyObj !== {}\nmyMap.get(function() {}) // undefined, because keyFunc !== function () {}\n</pre> <h3 id=\"Using_NaN_as_Map_keys\">Using <code>NaN</code> as <code>Map</code> keys</h3> <p><code>NaN</code> can also be used as a key. Even though every <code>NaN</code> is not equal to itself (<code>NaN !== NaN</code> is true), the following example works because <code>NaN</code>s are indistinguishable from each other:</p> <pre data-language=\"js\">var myMap = new Map();\nmyMap.set(NaN, 'not a number');\n\nmyMap.get(NaN); // \"not a number\"\n\nvar otherNaN = Number('foo');\nmyMap.get(otherNaN); // \"not a number\"\n</pre> <h3 id=\"Iterating_Maps_with_for..of\">Iterating <code>Maps</code> with <code>for..of</code>\n</h3> <p>Maps can be iterated using a <code>for..of</code> loop:</p> <pre data-language=\"js\">var myMap = new Map();\nmyMap.set(0, 'zero');\nmyMap.set(1, 'one');\nfor (var [key, value] of myMap) {\n  console.log(key + ' = ' + value);\n}\n// 0 = zero\n// 1 = one\n\nfor (var key of myMap.keys()) {\n  console.log(key);\n}\n// 0\n// 1\n\nfor (var value of myMap.values()) {\n  console.log(value);\n}\n// zero\n// one\n\nfor (var [key, value] of myMap.entries()) {\n  console.log(key + ' = ' + value);\n}\n// 0 = zero\n// 1 = one\n</pre> <h3 id=\"Iterating_Maps_with_forEach()\">Iterating <code>Maps</code> with <code>forEach()</code>\n</h3> <p>Maps can be iterated using the <code>forEach()</code> method:</p> <pre data-language=\"js\">myMap.forEach(function(value, key) {\n  console.log(key + ' = ' + value);\n});\n// Will show 2 logs; first with \"0 = zero\" and second with \"1 = one\"\n</pre> <h3 id=\"Relation_with_Array_objects\">Relation with <code>Array</code> objects</h3> <pre data-language=\"js\">var kvArray = [['key1', 'value1'], ['key2', 'value2']];\n\n// Use the regular Map constructor to transform a 2D key-value Array into a map\nvar myMap = new Map(kvArray);\n\nmyMap.get('key1'); // returns \"value1\"\n\n// Use the Array.from function to transform a map into a 2D key-value Array\nconsole.log(Array.from(myMap)); // Will show you exactly the same Array as kvArray\n\n// Or use the keys or values iterators and convert them to an array\nconsole.log(Array.from(myMap.keys())); // Will show [\"key1\", \"key2\"]\n</pre> <h3 id=\"Cloning_and_merging_Maps\">Cloning and merging <code>Maps</code>\n</h3> <p>Just like Arrays, Maps can be cloned:</p> <pre data-language=\"js\">var original = new Map([\n  [1, 'one']\n]);\n\nvar clone = new Map(original);\n\nconsole.log(clone.get(1)); // one\nconsole.log(original === clone); // false. Useful for shallow comparison</pre> <p>Keep in mind that the <em>data</em> itself is not cloned</p> <p>Maps can be merged, maintaining key uniqueness:</p> <pre data-language=\"js\">var first = new Map([\n  [1, 'one'],\n  [2, 'two'],\n  [3, 'three'],\n]);\n\nvar second = new Map([\n  [1, 'uno'],\n  [2, 'dos']\n]);\n\n// Merge two maps. The last repeated key wins.\n// Spread operator essentially converts a Map to an Array\nvar merged = new Map([...first, ...second]);\n\nconsole.log(merged.get(1)); // uno\nconsole.log(merged.get(2)); // dos\nconsole.log(merged.get(3)); // three</pre> <p>Maps can be merged with Arrays, too:</p> <pre data-language=\"js\">var first = new Map([\n  [1, 'one'],\n  [2, 'two'],\n  [3, 'three'],\n]);\n\nvar second = new Map([\n  [1, 'uno'],\n  [2, 'dos']\n]);\n\n// Merge maps with an array. The last repeated key wins.\nvar merged = new Map([...first, ...second, [1, 'eins']]);\n\nconsole.log(merged.get(1)); // eins\nconsole.log(merged.get(2)); // dos\nconsole.log(merged.get(3)); // three</pre> <h3 id=\"Specifications\">Specifications</h3> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-map-objects\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Map' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-map-objects\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Map' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 38</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 13</td>\n<td class=\"bc-supports-yes\"> 11</td>\n<td class=\"bc-supports-yes\"> 25</td>\n<td class=\"bc-supports-yes\"> 8</td>\n</tr>\n<tr>\n<th scope=\"row\"><code>new Map(iterable)</code></th>\n<td class=\"bc-supports-yes\"> 38</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 13</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 25</td>\n<td class=\"bc-supports-yes\"> 9</td>\n</tr>\n<tr>\n<th scope=\"row\"><code>new Map(null)</code></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 37</td>\n<td class=\"bc-supports-yes\"> 11</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 9</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<code>Map()</code> without <code>new</code> throws</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 42</td>\n<td class=\"bc-supports-yes\"> 11</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 9</td>\n</tr>\n<tr>\n<th scope=\"row\">Key equality for -0 and 0</th>\n<td class=\"bc-supports-yes\"> 38</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 29</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 25</td>\n<td class=\"bc-supports-yes\"> 9</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Map/clear\"><code>clear</code></a></th>\n<td class=\"bc-supports-yes\"> 38</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 19</td>\n<td class=\"bc-supports-yes\"> 11</td>\n<td class=\"bc-supports-yes\"> 25</td>\n<td class=\"bc-supports-yes\"> 8</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Map/delete\"><code>delete</code></a></th>\n<td class=\"bc-supports-yes\"> 38</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 13</td>\n<td class=\"bc-supports-yes\"> 11</td>\n<td class=\"bc-supports-yes\"> 25</td>\n<td class=\"bc-supports-yes\"> 8</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Map/entries\"><code>entries</code></a></th>\n<td class=\"bc-supports-yes\"> 38</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 20</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 25</td>\n<td class=\"bc-supports-yes\"> 8</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Map/forEach\"><code>forEach</code></a></th>\n<td class=\"bc-supports-yes\"> 38</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 25</td>\n<td class=\"bc-supports-yes\"> 11</td>\n<td class=\"bc-supports-yes\"> 25</td>\n<td class=\"bc-supports-yes\"> 8</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Map/get\"><code>get</code></a></th>\n<td class=\"bc-supports-yes\"> 38</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 13</td>\n<td class=\"bc-supports-yes\"> 11</td>\n<td class=\"bc-supports-yes\"> 25</td>\n<td class=\"bc-supports-yes\"> 8</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Map/has\"><code>has</code></a></th>\n<td class=\"bc-supports-yes\"> 38</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 13</td>\n<td class=\"bc-supports-yes\"> 11</td>\n<td class=\"bc-supports-yes\"> 25</td>\n<td class=\"bc-supports-yes\"> 8</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Map/keys\"><code>keys</code></a></th>\n<td class=\"bc-supports-yes\"> 38</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 20</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 25</td>\n<td class=\"bc-supports-yes\"> 8</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Map/prototype\"><code>prototype</code></a></th>\n<td class=\"bc-supports-yes\"> 38</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 13</td>\n<td class=\"bc-supports-yes\"> 11</td>\n<td class=\"bc-supports-yes\"> 25</td>\n<td class=\"bc-supports-yes\"> 8</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Map/set\"><code>set</code></a></th>\n<td class=\"bc-supports-yes\"> 38</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 13</td>\n<td class=\"bc-supports-partial bc-has-history\">11\n<section class=\"bc-history\" id=\"sect4\"><dl>\n<dt class=\"bc-supports-partial bc-supports\">11\n</dt>\n<dd> Returns 'undefined' instead of the 'Map' object.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-yes\"> 25</td>\n<td class=\"bc-supports-yes\"> 8</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Map/size\"><code>size</code></a></th>\n<td class=\"bc-supports-yes\"> 38</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes bc-has-history\"> 19\n<section class=\"bc-history\" id=\"sect5\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 19\n</dt>\n<dd> From Firefox 13 to Firefox 18, the <code>size</code> property was implemented as a <code>Map.prototype.size()</code> method, this has been changed to a property in later versions conform to the ECMAScript 2015 specification.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-yes\"> 11</td>\n<td class=\"bc-supports-yes\"> 25</td>\n<td class=\"bc-supports-yes\"> 8</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Map/values\"><code>values</code></a></th>\n<td class=\"bc-supports-yes\"> 38</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 20</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 25</td>\n<td class=\"bc-supports-yes\"> 8</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Map/@@iterator\"><code>@@iterator</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes bc-has-history\"> 36\n<section class=\"bc-history\" id=\"sect7\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 36\n</dt>\n\n<dt class=\"bc-supports-no bc-supports\">27 — 36\n</dt>\n<dd> A placeholder property named <code>@@iterator</code> is used.</dd>\n<dd> Uses the non-standard name: <code>@@iterator</code>\n</dd>\n<dt class=\"bc-supports-no bc-supports\">17 — 27\n</dt>\n<dd> A placeholder property named <code>iterator</code> is used.</dd>\n<dd> Uses the non-standard name: <code>iterator</code>\n</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Map/@@species\"><code>@@species</code></a></th>\n<td class=\"bc-supports-yes\"> 51</td>\n<td class=\"bc-supports-yes\"> 13</td>\n<td class=\"bc-supports-yes\"> 41</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 38</td>\n<td class=\"bc-supports-yes\"> 10</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Map/@@toStringTag\"><code>@@toStringTag</code></a></th>\n<td class=\"bc-supports-yes\"> 44</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n</tr>\n</tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 38</td>\n<td class=\"bc-supports-yes\"> 38</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 14</td>\n<td class=\"bc-supports-yes\"> 25</td>\n<td class=\"bc-supports-yes\"> 8</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><code>new Map(iterable)</code></th>\n<td class=\"bc-supports-yes\"> 38</td>\n<td class=\"bc-supports-yes\"> 38</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 14</td>\n<td class=\"bc-supports-yes\"> 25</td>\n<td class=\"bc-supports-yes\"> 9</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><code>new Map(null)</code></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 37</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 9</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<code>Map()</code> without <code>new</code> throws</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 42</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 9</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">Key equality for -0 and 0</th>\n<td class=\"bc-supports-yes\"> 38</td>\n<td class=\"bc-supports-yes\"> 38</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 29</td>\n<td class=\"bc-supports-yes\"> 25</td>\n<td class=\"bc-supports-yes\"> 9</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Map/clear\"><code>clear</code></a></th>\n<td class=\"bc-supports-yes\"> 38</td>\n<td class=\"bc-supports-yes\"> 38</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 19</td>\n<td class=\"bc-supports-yes\"> 25</td>\n<td class=\"bc-supports-yes\"> 8</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Map/delete\"><code>delete</code></a></th>\n<td class=\"bc-supports-yes\"> 38</td>\n<td class=\"bc-supports-yes\"> 38</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 14</td>\n<td class=\"bc-supports-yes\"> 25</td>\n<td class=\"bc-supports-yes\"> 8</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Map/entries\"><code>entries</code></a></th>\n<td class=\"bc-supports-yes\"> 38</td>\n<td class=\"bc-supports-yes\"> 38</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 20</td>\n<td class=\"bc-supports-yes\"> 25</td>\n<td class=\"bc-supports-yes\"> 8</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Map/forEach\"><code>forEach</code></a></th>\n<td class=\"bc-supports-yes\"> 38</td>\n<td class=\"bc-supports-yes\"> 38</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 25</td>\n<td class=\"bc-supports-yes\"> 25</td>\n<td class=\"bc-supports-yes\"> 8</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Map/get\"><code>get</code></a></th>\n<td class=\"bc-supports-yes\"> 38</td>\n<td class=\"bc-supports-yes\"> 38</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 14</td>\n<td class=\"bc-supports-yes\"> 25</td>\n<td class=\"bc-supports-yes\"> 8</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Map/has\"><code>has</code></a></th>\n<td class=\"bc-supports-yes\"> 38</td>\n<td class=\"bc-supports-yes\"> 38</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 14</td>\n<td class=\"bc-supports-yes\"> 25</td>\n<td class=\"bc-supports-yes\"> 8</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Map/keys\"><code>keys</code></a></th>\n<td class=\"bc-supports-yes\"> 38</td>\n<td class=\"bc-supports-yes\"> 38</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 20</td>\n<td class=\"bc-supports-yes\"> 25</td>\n<td class=\"bc-supports-yes\"> 8</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Map/prototype\"><code>prototype</code></a></th>\n<td class=\"bc-supports-yes\"> 38</td>\n<td class=\"bc-supports-yes\"> 38</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 14</td>\n<td class=\"bc-supports-yes\"> 25</td>\n<td class=\"bc-supports-yes\"> 8</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Map/set\"><code>set</code></a></th>\n<td class=\"bc-supports-yes\"> 38</td>\n<td class=\"bc-supports-yes\"> 38</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 14</td>\n<td class=\"bc-supports-yes\"> 25</td>\n<td class=\"bc-supports-yes\"> 8</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Map/size\"><code>size</code></a></th>\n<td class=\"bc-supports-yes\"> 38</td>\n<td class=\"bc-supports-yes\"> 38</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes bc-has-history\"> 19\n<section class=\"bc-history\" id=\"sect6\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 19\n</dt>\n<dd> From Firefox 13 to Firefox 18, the <code>size</code> property was implemented as a <code>Map.prototype.size()</code> method, this has been changed to a property in later versions conform to the ECMAScript 2015 specification.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-yes\"> 25</td>\n<td class=\"bc-supports-yes\"> 8</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Map/values\"><code>values</code></a></th>\n<td class=\"bc-supports-yes\"> 38</td>\n<td class=\"bc-supports-yes\"> 38</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 20</td>\n<td class=\"bc-supports-yes\"> 25</td>\n<td class=\"bc-supports-yes\"> 8</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Map/@@iterator\"><code>@@iterator</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes bc-has-history\"> 36\n<section class=\"bc-history\" id=\"sect8\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 36\n</dt>\n\n<dt class=\"bc-supports-no bc-supports\">27 — 36\n</dt>\n<dd> A placeholder property named <code>@@iterator</code> is used.</dd>\n<dd> Uses the non-standard name: <code>@@iterator</code>\n</dd>\n<dt class=\"bc-supports-no bc-supports\">17 — 27\n</dt>\n<dd> A placeholder property named <code>iterator</code> is used.</dd>\n<dd> Uses the non-standard name: <code>iterator</code>\n</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Map/@@species\"><code>@@species</code></a></th>\n<td class=\"bc-supports-yes\"> 51</td>\n<td class=\"bc-supports-yes\"> 51</td>\n<td class=\"bc-supports-yes\"> 13</td>\n<td class=\"bc-supports-yes\"> 41</td>\n<td class=\"bc-supports-yes\"> 38</td>\n<td class=\"bc-supports-yes\"> 10</td>\n<td class=\"bc-supports-yes\"> 5.0</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Map/@@toStringTag\"><code>@@toStringTag</code></a></th>\n<td class=\"bc-supports-yes\"> 44</td>\n<td class=\"bc-supports-yes\"> 44</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 4.0</td>\n</tr>\n</tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes bc-has-history\"> 0.12\n<section class=\"bc-history\" id=\"sect1\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 0.12\n</dt>\n\n<dt class=\"bc-supports-yes bc-supports\"> 0.10<div class=\"bc-icons\">Disabled </div>\n</dt>\n<dd>Disabled From version 0.10: this feature is behind the <code>--harmony</code> runtime flag.</dd>\n</dl></section>\n</td>\n</tr>\n<tr>\n<th scope=\"row\"><code>new Map(iterable)</code></th>\n<td class=\"bc-supports-yes\"> 0.12</td>\n</tr>\n<tr>\n<th scope=\"row\"><code>new Map(null)</code></th>\n<td class=\"bc-supports-yes bc-has-history\"> 0.12\n<section class=\"bc-history\" id=\"sect2\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 0.12\n</dt>\n\n<dt class=\"bc-supports-yes bc-supports\"> 0.10<div class=\"bc-icons\">Disabled </div>\n</dt>\n<dd>Disabled From version 0.10: this feature is behind the <code>--harmony</code> runtime flag.</dd>\n</dl></section>\n</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<code>Map()</code> without <code>new</code> throws</th>\n<td class=\"bc-supports-yes\"> 0.12</td>\n</tr>\n<tr>\n<th scope=\"row\">Key equality for -0 and 0</th>\n<td class=\"bc-supports-yes\"> 4.0.0</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Map/clear\"><code>clear</code></a></th>\n<td class=\"bc-supports-yes\"> 0.12</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Map/delete\"><code>delete</code></a></th>\n<td class=\"bc-supports-yes bc-has-history\"> 0.12\n<section class=\"bc-history\" id=\"sect3\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 0.12\n</dt>\n\n<dt class=\"bc-supports-yes bc-supports\"> 0.10<div class=\"bc-icons\">Disabled </div>\n</dt>\n<dd>Disabled From version 0.10: this feature is behind the <code>--harmony</code> runtime flag.</dd>\n</dl></section>\n</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Map/entries\"><code>entries</code></a></th>\n<td class=\"bc-supports-yes\"> 0.12</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Map/forEach\"><code>forEach</code></a></th>\n<td class=\"bc-supports-yes\"> 0.12</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Map/get\"><code>get</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Map/has\"><code>has</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Map/keys\"><code>keys</code></a></th>\n<td class=\"bc-supports-yes\"> 0.12</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Map/prototype\"><code>prototype</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Map/set\"><code>set</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Map/size\"><code>size</code></a></th>\n<td class=\"bc-supports-yes\"> 0.12</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Map/values\"><code>values</code></a></th>\n<td class=\"bc-supports-yes\"> 0.12</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Map/@@iterator\"><code>@@iterator</code></a></th>\n<td class=\"bc-supports-yes\"> 0.12</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Map/@@species\"><code>@@species</code></a></th>\n<td class=\"bc-supports-yes bc-has-history\"> 6.5.0\n<section class=\"bc-history\" id=\"sect9\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 6.5.0\n</dt>\n\n<dt class=\"bc-supports-yes bc-supports\"> 6.0.0<div class=\"bc-icons\">Disabled </div>\n</dt>\n<dd>Disabled From version 6.0.0: this feature is behind the <code>--harmony</code> runtime flag.</dd>\n</dl></section>\n</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Map/@@toStringTag\"><code>@@toStringTag</code></a></th>\n<td class=\"bc-supports-no\"> No</td>\n</tr>\n</tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"https://bugzilla.mozilla.org/show_bug.cgi?id=697479\" class=\"link-https\">Map and Set bug at Mozilla</a></li> <li><a href=\"http://wiki.ecmascript.org/doku.php?id=harmony:simple_maps_and_sets\">ECMAScript Harmony proposal</a></li> <li><a href=\"set\"><code>Set</code></a></li> <li><a href=\"weakmap\"><code>WeakMap</code></a></li> <li><a href=\"weakset\"><code>WeakSet</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map</a>\n  </p>\n</div>\n","global_objects/proxy":"<h1>Proxy</h1>   <p>The <strong>Proxy</strong> object is used to define custom behavior for fundamental operations (e.g. property lookup, assignment, enumeration, function invocation, etc).</p> <h2 id=\"Terminology\">Terminology</h2> <dl> <dt><a href=\"proxy/handler\">handler</a></dt> <dd>Placeholder object which contains traps.</dd> <dt>traps</dt> <dd>The methods that provide property access. This is analogous to the concept of traps in operating systems.</dd> <dt>target</dt> <dd>Object which the proxy virtualizes. It is often used as storage backend for the proxy. Invariants (semantics that remain unchanged) regarding object non-extensibility or non-configurable properties are verified against the target.</dd> </dl> <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\">var p = new Proxy(target, handler);\n</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><code>target</code></dt> <dd>A target object to wrap with <code>Proxy</code>. It can be any sort of object, including a native array, a function or even another proxy.</dd> <dt><code>handler</code></dt> <dd>An object whose properties are functions which define the behavior of the proxy when an operation is performed on it.</dd> </dl> <h2 id=\"Methods\">Methods</h2> <dl> <dt><a href=\"proxy/revocable\"><code>Proxy.revocable()</code></a></dt> <dd>Creates a revocable <code>Proxy</code> object.</dd> </dl> <h2 id=\"Methods_of_the_handler_object\">Methods of the handler object</h2> <p>The handler object is a placeholder object which contains traps for <code>Proxy</code>.</p> <p>All traps are optional. If a trap has not been defined, the default behavior is to forward the operation to the target.</p> <dl> <dt><a href=\"proxy/handler/getprototypeof\"><code>handler.getPrototypeOf()</code></a></dt> <dd>A trap for <a href=\"object/getprototypeof\"><code>Object.getPrototypeOf</code></a>.</dd> <dt><a href=\"proxy/handler/setprototypeof\"><code>handler.setPrototypeOf()</code></a></dt> <dd>A trap for <a href=\"object/setprototypeof\"><code>Object.setPrototypeOf</code></a>.</dd> <dt><a href=\"proxy/handler/isextensible\"><code>handler.isExtensible()</code></a></dt> <dd>A trap for <a href=\"object/isextensible\"><code>Object.isExtensible</code></a>.</dd> <dt><a href=\"proxy/handler/preventextensions\"><code>handler.preventExtensions()</code></a></dt> <dd>A trap for <a href=\"object/preventextensions\"><code>Object.preventExtensions</code></a>.</dd> <dt><a href=\"proxy/handler/getownpropertydescriptor\"><code>handler.getOwnPropertyDescriptor()</code></a></dt> <dd>A trap for <a href=\"object/getownpropertydescriptor\"><code>Object.getOwnPropertyDescriptor</code></a>.</dd> <dt><a href=\"proxy/handler/defineproperty\"><code>handler.defineProperty()</code></a></dt> <dd>A trap for <a href=\"object/defineproperty\"><code>Object.defineProperty</code></a>.</dd> <dt><a href=\"proxy/handler/has\"><code>handler.has()</code></a></dt> <dd>A trap for the <a href=\"../operators/in\"><code>in</code></a> operator.</dd> <dt><a href=\"proxy/handler/get\"><code>handler.get()</code></a></dt> <dd>A trap for getting property values.</dd> <dt><a href=\"proxy/handler/set\"><code>handler.set()</code></a></dt> <dd>A trap for setting property values.</dd> <dt><a href=\"proxy/handler/deleteproperty\"><code>handler.deleteProperty()</code></a></dt> <dd>A trap for the <a href=\"../operators/delete\"><code>delete</code></a> operator.</dd> <dt><a href=\"proxy/handler/ownkeys\"><code>handler.ownKeys()</code></a></dt> <dd>A trap for <a href=\"object/getownpropertynames\"><code>Object.getOwnPropertyNames</code></a> and <a href=\"object/getownpropertysymbols\"><code>Object.getOwnPropertySymbols</code></a>.</dd> <dt><a href=\"proxy/handler/apply\"><code>handler.apply()</code></a></dt> <dd>A trap for a function call.</dd> <dt><a href=\"proxy/handler/construct\"><code>handler.construct()</code></a></dt> <dd>A trap for the <a href=\"../operators/new\"><code>new</code></a> operator.</dd> </dl> <p>Some non-standard traps are <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Deprecated_and_obsolete_features#Proxy\">obsolete and have been removed</a>.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Basic_example\">Basic example</h3> <p>In this simple example the number <code>37</code> gets returned as the default value when the property name is not in the object. It is using the <a href=\"proxy/handler/get\"><code>get</code></a> handler.</p> <pre data-language=\"js\">var handler = {\n    get: function(obj, prop) {\n        return prop in obj ?\n            obj[prop] :\n            37;\n    }\n};\n\nvar p = new Proxy({}, handler);\np.a = 1;\np.b = undefined;\n\nconsole.log(p.a, p.b); // 1, undefined\nconsole.log('c' in p, p.c); // false, 37\n</pre> <h3 id=\"No-op_forwarding_proxy\">No-op forwarding proxy</h3> <p>In this example, we are using a native JavaScript object to which our proxy will forward all operations that are applied to it.</p> <pre data-language=\"js\">var target = {};\nvar p = new Proxy(target, {});\n\np.a = 37; // operation forwarded to the target\n\nconsole.log(target.a); // 37. The operation has been properly forwarded\n</pre> <p>Note that while this \"no-op\" works for JavaScript objects it does not work for native browser objects like DOM Elements. <a href=\"https://developer.mozilla.org/en-US/docs/\">See this for one solution</a>.</p> <h3 id=\"Validation\">Validation</h3> <p>With a <code>Proxy</code>, you can easily validate the passed value for an object. This example uses the <a href=\"proxy/handler/set\"><code>set</code></a> handler.</p> <pre data-language=\"js\">let validator = {\n  set: function(obj, prop, value) {\n    if (prop === 'age') {\n      if (!Number.isInteger(value)) {\n        throw new TypeError('The age is not an integer');\n      }\n      if (value &gt; 200) {\n        throw new RangeError('The age seems invalid');\n      }\n    }\n\n    // The default behavior to store the value\n    obj[prop] = value;\n\n    // Indicate success\n    return true;\n  }\n};\n\nlet person = new Proxy({}, validator);\n\nperson.age = 100;\nconsole.log(person.age); // 100\nperson.age = 'young'; // Throws an exception\nperson.age = 300; // Throws an exception</pre> <h3 id=\"Extending_constructor\">Extending constructor</h3> <p>A function proxy could easily extend a constructor with a new constructor. This example uses the <a href=\"proxy/handler/construct\"><code>construct</code></a> and <a href=\"proxy/handler/apply\"><code>apply</code></a> handlers.</p> <pre data-language=\"js\">function extend(sup, base) {\n  var descriptor = Object.getOwnPropertyDescriptor(\n    base.prototype, 'constructor'\n  );\n  base.prototype = Object.create(sup.prototype);\n  var handler = {\n    construct: function(target, args) {\n      var obj = Object.create(base.prototype);\n      this.apply(target, obj, args);\n      return obj;\n    },\n    apply: function(target, that, args) {\n      sup.apply(that, args);\n      base.apply(that, args);\n    }\n  };\n  var proxy = new Proxy(base, handler);\n  descriptor.value = proxy;\n  Object.defineProperty(base.prototype, 'constructor', descriptor);\n  return proxy;\n}\n\nvar Person = function(name) {\n  this.name = name;\n};\n\nvar Boy = extend(Person, function(name, age) {\n  this.age = age;\n});\n\nBoy.prototype.sex = 'M';\n\nvar Peter = new Boy('Peter', 13);\nconsole.log(Peter.sex);  // \"M\"\nconsole.log(Peter.name); // \"Peter\"\nconsole.log(Peter.age);  // 13</pre> <h3 id=\"Manipulating_DOM_nodes\">Manipulating DOM nodes</h3> <p>Sometimes you want to toggle the attribute or class name of two different elements. Here's how using the <a href=\"proxy/handler/set\"><code>set</code></a> handler.</p> <pre data-language=\"js\">let view = new Proxy({\n  selected: null\n},\n{\n  set: function(obj, prop, newval) {\n    let oldval = obj[prop];\n\n    if (prop === 'selected') {\n      if (oldval) {\n        oldval.setAttribute('aria-selected', 'false');\n      }\n      if (newval) {\n        newval.setAttribute('aria-selected', 'true');\n      }\n    }\n\n    // The default behavior to store the value\n    obj[prop] = newval;\n\n    // Indicate success\n    return true;\n  }\n});\n\nlet i1 = view.selected = document.getElementById('item-1');\nconsole.log(i1.getAttribute('aria-selected')); // 'true'\n\nlet i2 = view.selected = document.getElementById('item-2');\nconsole.log(i1.getAttribute('aria-selected')); // 'false'\nconsole.log(i2.getAttribute('aria-selected')); // 'true'</pre> <h3 id=\"Value_correction_and_an_extra_property\">Value correction and an extra property</h3> <p>The <code>products</code> proxy object evaluates the passed value and converts it to an array if needed. The object also supports an extra property called <code>latestBrowser</code> both as a getter and a setter.</p> <pre data-language=\"js\">let products = new Proxy({\n  browsers: ['Internet Explorer', 'Netscape']\n},\n{\n  get: function(obj, prop) {\n    // An extra property\n    if (prop === 'latestBrowser') {\n      return obj.browsers[obj.browsers.length - 1];\n    }\n\n    // The default behavior to return the value\n    return obj[prop];\n  },\n  set: function(obj, prop, value) {\n    // An extra property\n    if (prop === 'latestBrowser') {\n      obj.browsers.push(value);\n      return true;\n    }\n\n    // Convert the value if it is not an array\n    if (typeof value === 'string') {\n      value = [value];\n    }\n\n    // The default behavior to store the value\n    obj[prop] = value;\n\n    // Indicate success\n    return true;\n  }\n});\n\nconsole.log(products.browsers); // ['Internet Explorer', 'Netscape']\nproducts.browsers = 'Firefox'; // pass a string (by mistake)\nconsole.log(products.browsers); // ['Firefox'] &lt;- no problem, the value is an array\n\nproducts.latestBrowser = 'Chrome';\nconsole.log(products.browsers); // ['Firefox', 'Chrome']\nconsole.log(products.latestBrowser); // 'Chrome'</pre> <h3 id=\"Finding_an_array_item_object_by_its_property\">Finding an array item object by its property</h3> <p>This proxy extends an array with some utility features. As you see, you can flexibly \"define\" properties without using <a href=\"object/defineproperties\"><code>Object.defineProperties</code></a>. This example can be adapted to find a table row by its cell. In that case, the target will be <a href=\"https://developer.mozilla.org/en-US/docs/DOM/table.rows\"><code>table.rows</code></a>.</p> <pre data-language=\"js\">let products = new Proxy([\n  { name: 'Firefox', type: 'browser' },\n  { name: 'SeaMonkey', type: 'browser' },\n  { name: 'Thunderbird', type: 'mailer' }\n],\n{\n  get: function(obj, prop) {\n    // The default behavior to return the value; prop is usually an integer\n    if (prop in obj) {\n      return obj[prop];\n    }\n\n    // Get the number of products; an alias of products.length\n    if (prop === 'number') {\n      return obj.length;\n    }\n\n    let result, types = {};\n\n    for (let product of obj) {\n      if (product.name === prop) {\n        result = product;\n      }\n      if (types[product.type]) {\n        types[product.type].push(product);\n      } else {\n        types[product.type] = [product];\n      }\n    }\n\n    // Get a product by name\n    if (result) {\n      return result;\n    }\n\n    // Get products by type\n    if (prop in types) {\n      return types[prop];\n    }\n\n    // Get product types\n    if (prop === 'types') {\n      return Object.keys(types);\n    }\n\n    return undefined;\n  }\n});\n\nconsole.log(products[0]); // { name: 'Firefox', type: 'browser' }\nconsole.log(products['Firefox']); // { name: 'Firefox', type: 'browser' }\nconsole.log(products['Chrome']); // undefined\nconsole.log(products.browser); // [{ name: 'Firefox', type: 'browser' }, { name: 'SeaMonkey', type: 'browser' }]\nconsole.log(products.types); // ['browser', 'mailer']\nconsole.log(products.number); // 3\n</pre> <h3 id=\"A_complete_traps_list_example\">A complete <code>traps</code> list example</h3> <p>Now in order to create a complete sample <code>traps</code> list, for didactic purposes, we will try to proxify a <em>non native</em> object that is particularly suited to this type of operation: the <code>docCookies</code> global object created by <a href=\"https://developer.mozilla.org/en-US/docs/Web/API/Document/cookie/Simple_document.cookie_framework\">the \"little framework\" published on the <code>document.cookie</code> page</a>.</p> <pre data-language=\"js\">/*\n  var docCookies = ... get the \"docCookies\" object here:  \n  https://developer.mozilla.org/en-US/docs/DOM/document.cookie#A_little_framework.3A_a_complete_cookies_reader.2Fwriter_with_full_unicode_support\n*/\n\nvar docCookies = new Proxy(docCookies, {\n  get: function (oTarget, sKey) {\n    return oTarget[sKey] || oTarget.getItem(sKey) || undefined;\n  },\n  set: function (oTarget, sKey, vValue) {\n    if (sKey in oTarget) { return false; }\n    return oTarget.setItem(sKey, vValue);\n  },\n  deleteProperty: function (oTarget, sKey) {\n    if (sKey in oTarget) { return false; }\n    return oTarget.removeItem(sKey);\n  },\n  enumerate: function (oTarget, sKey) {\n    return oTarget.keys();\n  },\n  ownKeys: function (oTarget, sKey) {\n    return oTarget.keys();\n  },\n  has: function (oTarget, sKey) {\n    return sKey in oTarget || oTarget.hasItem(sKey);\n  },\n  defineProperty: function (oTarget, sKey, oDesc) {\n    if (oDesc &amp;&amp; 'value' in oDesc) { oTarget.setItem(sKey, oDesc.value); }\n    return oTarget;\n  },\n  getOwnPropertyDescriptor: function (oTarget, sKey) {\n    var vValue = oTarget.getItem(sKey);\n    return vValue ? {\n      value: vValue,\n      writable: true,\n      enumerable: true,\n      configurable: false\n    } : undefined;\n  },\n});\n\n/* Cookies test */\n\nconsole.log(docCookies.my_cookie1 = 'First value');\nconsole.log(docCookies.getItem('my_cookie1'));\n\ndocCookies.setItem('my_cookie1', 'Changed value');\nconsole.log(docCookies.my_cookie1);</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-proxy-objects\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Proxy' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/7.0/#sec-proxy-objects\" hreflang=\"en\">ECMAScript 2016 (ECMA-262)<br><small>The definition of 'Proxy' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/8.0/#sec-proxy-objects\" hreflang=\"en\">ECMAScript 2017 (ECMA-262)<br><small>The definition of 'Proxy' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-proxy-objects\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Proxy' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 49</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 18</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 36</td>\n<td class=\"bc-supports-yes\"> 10</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Proxy/revocable\"><code>revocable</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 34</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 10</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Proxy/handler/apply\"><code>handler.apply</code></a></th>\n<td class=\"bc-supports-yes\"> 49</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 18</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 36</td>\n<td class=\"bc-supports-yes\"> 10</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Proxy/handler/construct\"><code>handler.construct</code></a></th>\n<td class=\"bc-supports-yes\"> 49</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 18</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 36</td>\n<td class=\"bc-supports-yes\"> 10</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Proxy/handler/defineProperty\"><code>handler.defineProperty</code></a></th>\n<td class=\"bc-supports-yes\"> 49</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 18</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 36</td>\n<td class=\"bc-supports-yes\"> 10</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Proxy/handler/deleteProperty\"><code>handler.deleteProperty</code></a></th>\n<td class=\"bc-supports-yes\"> 49</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 18</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 36</td>\n<td class=\"bc-supports-yes\"> 10</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Proxy/handler/enumerate\"><code>handler.enumerate</code></a> \n</th>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\">37 — 47</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Proxy/handler/get\"><code>handler.get</code></a></th>\n<td class=\"bc-supports-yes\"> 49</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 18</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 36</td>\n<td class=\"bc-supports-yes\"> 10</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Proxy/handler/getOwnPropertyDescriptor\"><code>handler.getOwnPropertyDescriptor</code></a></th>\n<td class=\"bc-supports-yes\"> 49</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 18</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 36</td>\n<td class=\"bc-supports-yes\"> 10</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Proxy/handler/getPrototypeOf\"><code>handler.getPrototypeOf</code></a></th>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 49</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Proxy/handler/has\"><code>handler.has</code></a></th>\n<td class=\"bc-supports-yes\"> 49</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 18</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 36</td>\n<td class=\"bc-supports-yes\"> 10</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Proxy/handler/isExtensible\"><code>handler.isExtensible</code></a></th>\n<td> ? </td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 31</td>\n<td class=\"bc-supports-no\"> No</td>\n<td> ? </td>\n<td> ? </td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Proxy/handler/ownKeys\"><code>handler.ownKeys</code></a></th>\n<td class=\"bc-supports-yes\"> 49</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes bc-has-history\"> 18\n<section class=\"bc-history\" id=\"sect1\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 18\n</dt>\n<dd> In Firefox 42, the implementation got updated to reflect the final ES2015 specification: The result is now checked if it is an array and if the array elements are either of type string or of type symbol. Enumerating duplicate own property names is not a failure anymore.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 36</td>\n<td class=\"bc-supports-yes\"> 10</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Proxy/handler/preventExtensions\"><code>handler.preventExtensions</code></a></th>\n<td class=\"bc-supports-yes\"> 49</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 22</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 36</td>\n<td class=\"bc-supports-yes\"> 10</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Proxy/handler/set\"><code>handler.set</code></a></th>\n<td class=\"bc-supports-yes\"> 49</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 18</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 36</td>\n<td class=\"bc-supports-yes\"> 10</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Proxy/handler/setPrototypeOf\"><code>handler.setPrototypeOf</code></a></th>\n<td> ? </td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 49</td>\n<td class=\"bc-supports-no\"> No</td>\n<td> ? </td>\n<td> ? </td>\n</tr>\n</tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 49</td>\n<td class=\"bc-supports-yes\"> 49</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 18</td>\n<td class=\"bc-supports-yes\"> 36</td>\n<td class=\"bc-supports-yes\"> 10</td>\n<td class=\"bc-supports-yes\"> 5.0</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Proxy/revocable\"><code>revocable</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 34</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 10</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Proxy/handler/apply\"><code>handler.apply</code></a></th>\n<td class=\"bc-supports-yes\"> 49</td>\n<td class=\"bc-supports-yes\"> 49</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 18</td>\n<td class=\"bc-supports-yes\"> 36</td>\n<td class=\"bc-supports-yes\"> 10</td>\n<td class=\"bc-supports-yes\"> 5.0</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Proxy/handler/construct\"><code>handler.construct</code></a></th>\n<td class=\"bc-supports-yes\"> 49</td>\n<td class=\"bc-supports-yes\"> 49</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 18</td>\n<td class=\"bc-supports-yes\"> 36</td>\n<td class=\"bc-supports-yes\"> 10</td>\n<td class=\"bc-supports-yes\"> 5.0</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Proxy/handler/defineProperty\"><code>handler.defineProperty</code></a></th>\n<td class=\"bc-supports-yes\"> 49</td>\n<td class=\"bc-supports-yes\"> 49</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 18</td>\n<td class=\"bc-supports-yes\"> 36</td>\n<td class=\"bc-supports-yes\"> 10</td>\n<td class=\"bc-supports-yes\"> 5.0</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Proxy/handler/deleteProperty\"><code>handler.deleteProperty</code></a></th>\n<td class=\"bc-supports-yes\"> 49</td>\n<td class=\"bc-supports-yes\"> 49</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 18</td>\n<td class=\"bc-supports-yes\"> 36</td>\n<td class=\"bc-supports-yes\"> 10</td>\n<td class=\"bc-supports-yes\"> 5.0</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Proxy/handler/enumerate\"><code>handler.enumerate</code></a> \n</th>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\">37 — 47</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Proxy/handler/get\"><code>handler.get</code></a></th>\n<td class=\"bc-supports-yes\"> 49</td>\n<td class=\"bc-supports-yes\"> 49</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 18</td>\n<td class=\"bc-supports-yes\"> 36</td>\n<td class=\"bc-supports-yes\"> 10</td>\n<td class=\"bc-supports-yes\"> 5.0</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Proxy/handler/getOwnPropertyDescriptor\"><code>handler.getOwnPropertyDescriptor</code></a></th>\n<td class=\"bc-supports-yes\"> 49</td>\n<td class=\"bc-supports-yes\"> 49</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 18</td>\n<td class=\"bc-supports-yes\"> 36</td>\n<td class=\"bc-supports-yes\"> 10</td>\n<td class=\"bc-supports-yes\"> 5.0</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Proxy/handler/getPrototypeOf\"><code>handler.getPrototypeOf</code></a></th>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 49</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Proxy/handler/has\"><code>handler.has</code></a></th>\n<td class=\"bc-supports-yes\"> 49</td>\n<td class=\"bc-supports-yes\"> 49</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 18</td>\n<td class=\"bc-supports-yes\"> 36</td>\n<td class=\"bc-supports-yes\"> 10</td>\n<td class=\"bc-supports-yes\"> 5.0</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Proxy/handler/isExtensible\"><code>handler.isExtensible</code></a></th>\n<td> ? </td>\n<td> ? </td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 31</td>\n<td> ? </td>\n<td> ? </td>\n<td> ? </td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Proxy/handler/ownKeys\"><code>handler.ownKeys</code></a></th>\n<td class=\"bc-supports-yes\"> 49</td>\n<td class=\"bc-supports-yes\"> 49</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes bc-has-history\"> 18\n<section class=\"bc-history\" id=\"sect2\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 18\n</dt>\n<dd> In Firefox 42, the implementation got updated to reflect the final ES2015 specification: The result is now checked if it is an array and if the array elements are either of type string or of type symbol. Enumerating duplicate own property names is not a failure anymore.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-yes\"> 36</td>\n<td class=\"bc-supports-yes\"> 10</td>\n<td class=\"bc-supports-yes\"> 5.0</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Proxy/handler/preventExtensions\"><code>handler.preventExtensions</code></a></th>\n<td class=\"bc-supports-yes\"> 49</td>\n<td class=\"bc-supports-yes\"> 49</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 22</td>\n<td class=\"bc-supports-yes\"> 36</td>\n<td class=\"bc-supports-yes\"> 10</td>\n<td class=\"bc-supports-yes\"> 5.0</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Proxy/handler/set\"><code>handler.set</code></a></th>\n<td class=\"bc-supports-yes\"> 49</td>\n<td class=\"bc-supports-yes\"> 49</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 18</td>\n<td class=\"bc-supports-yes\"> 36</td>\n<td class=\"bc-supports-yes\"> 10</td>\n<td class=\"bc-supports-yes\"> 5.0</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Proxy/handler/setPrototypeOf\"><code>handler.setPrototypeOf</code></a></th>\n<td> ? </td>\n<td> ? </td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 49</td>\n<td> ? </td>\n<td> ? </td>\n<td> ? </td>\n</tr>\n</tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 6.0.0</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Proxy/revocable\"><code>revocable</code></a></th>\n<td class=\"bc-supports-yes\"> 6.0.0</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Proxy/handler/apply\"><code>handler.apply</code></a></th>\n<td class=\"bc-supports-yes\"> 6.0.0</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Proxy/handler/construct\"><code>handler.construct</code></a></th>\n<td class=\"bc-supports-yes\"> 6.0.0</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Proxy/handler/defineProperty\"><code>handler.defineProperty</code></a></th>\n<td class=\"bc-supports-yes\"> 6.0.0</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Proxy/handler/deleteProperty\"><code>handler.deleteProperty</code></a></th>\n<td class=\"bc-supports-yes\"> 6.0.0</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Proxy/handler/enumerate\"><code>handler.enumerate</code></a> \n</th>\n<td class=\"bc-supports-no\"> No</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Proxy/handler/get\"><code>handler.get</code></a></th>\n<td class=\"bc-supports-yes\"> 6.0.0</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Proxy/handler/getOwnPropertyDescriptor\"><code>handler.getOwnPropertyDescriptor</code></a></th>\n<td class=\"bc-supports-yes\"> 6.0.0</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Proxy/handler/getPrototypeOf\"><code>handler.getPrototypeOf</code></a></th>\n<td class=\"bc-supports-yes\"> 6.0.0</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Proxy/handler/has\"><code>handler.has</code></a></th>\n<td class=\"bc-supports-yes\"> 6.0.0</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Proxy/handler/isExtensible\"><code>handler.isExtensible</code></a></th>\n<td class=\"bc-supports-yes\"> 6.0.0</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Proxy/handler/ownKeys\"><code>handler.ownKeys</code></a></th>\n<td class=\"bc-supports-yes\"> 6.0.0</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Proxy/handler/preventExtensions\"><code>handler.preventExtensions</code></a></th>\n<td class=\"bc-supports-yes\"> 6.0.0</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Proxy/handler/set\"><code>handler.set</code></a></th>\n<td class=\"bc-supports-yes\"> 6.0.0</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Proxy/handler/setPrototypeOf\"><code>handler.setPrototypeOf</code></a></th>\n<td class=\"bc-supports-yes\"> 6.0.0</td>\n</tr>\n</tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li>\n<a href=\"https://www.youtube.com/watch?v=sClk6aB_CPk\">\"Proxies are awesome\" Brendan Eich presentation at JSConf</a> (<a href=\"http://www.slideshare.net/BrendanEich/metaprog-5303821\">slides</a>)</li> <li>\n<a href=\"http://wiki.ecmascript.org/doku.php?id=harmony:proxies\">ECMAScript Harmony Proxy proposal page</a> and <a href=\"http://wiki.ecmascript.org/doku.php?id=harmony:proxies_semantics\">ECMAScript Harmony proxy semantics page</a>\n</li> <li><a href=\"http://web.archive.org/web/20171007221059/http://soft.vub.ac.be/~tvcutsem/proxies/\">Tutorial on proxies</a></li> <li><a href=\"https://developer.mozilla.org/en-US/docs/JavaScript/Old_Proxy_API\">SpiderMonkey specific Old Proxy API</a></li> <li>\n<a href=\"object/watch\"><code>Object.watch()</code></a> is a non-standard feature but has been supported in Gecko for a long time.</li> </ul> <h2 id=\"Licensing_note\">Licensing note</h2> <p>Some content (text, examples) in this page has been copied or adapted from the <a href=\"http://wiki.ecmascript.org/doku.php\">ECMAScript wiki</a> which content is licensed <a href=\"http://creativecommons.org/licenses/by-nc-sa/2.0/\">CC 2.0 BY-NC-SA</a>.</p><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy</a>\n  </p>\n</div>\n","global_objects/uint16array":"<h1>Uint16Array</h1> <p>The <code>Uint16Array</code> typed array represents an array of 16-bit unsigned integers in the platform byte order. If control over byte order is needed, use <a href=\"dataview\"><code>DataView</code></a> instead. The contents are initialized to <code>0</code>. Once established, you can reference elements in the array using the object's methods, or using standard array index syntax (that is, using bracket notation).</p> <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\">new Uint16Array(); // new in ES2017\nnew Uint16Array(length);\nnew Uint16Array(typedArray);\nnew Uint16Array(object);\nnew Uint16Array(buffer [, byteOffset [, length]]);</pre> <p>For more information about the constructor syntax and the parameters, see <em><a href=\"typedarray#Syntax\">TypedArray</a></em>.</p> <h2 id=\"Properties\">Properties</h2> <dl> <dt><a href=\"typedarray/bytes_per_element\"><code>Uint16Array.BYTES_PER_ELEMENT</code></a></dt> <dd>Returns a number value of the element size. <code>2</code> in the case of an <code>Uint16Array</code>.</dd> <dt>Uint16Array.length</dt> <dd>Static length property whose value is 0. For the actual length (number of elements), see <a href=\"typedarray/length\"><code>Uint16Array.prototype.length</code></a>.</dd> <dt><a href=\"typedarray/name\"><code>Uint16Array.name</code></a></dt> <dd>Returns the string value of the constructor name. In the case of the <code>Uint16Array</code> type: \"Uint16Array\".</dd> <dt><a href=\"typedarray/prototype\"><code>Uint16Array.prototype</code></a></dt> <dd>Prototype for the <em>TypedArray</em> objects.</dd> </dl> <h2 id=\"Methods\">Methods</h2> <dl> <dt><a href=\"typedarray/from\"><code>Uint16Array.from()</code></a></dt> <dd>Creates a new <code>Uint16Array</code> from an array-like or iterable object. See also <a href=\"array/from\"><code>Array.from()</code></a>.</dd> <dt><a href=\"typedarray/of\"><code>Uint16Array.of()</code></a></dt> <dd>Creates a new <code>Uint16Array</code> with a variable number of arguments. See also <a href=\"array/of\"><code>Array.of()</code></a>.</dd> </dl> <h2 id=\"Uint16Array_prototype\">\n<code>Uint16Array</code> prototype</h2> <p>All <code>Uint16Array</code> objects inherit from <a href=\"typedarray/prototype\"><code>%TypedArray%.prototype</code></a>.</p> <h3 id=\"Properties_2\">Properties</h3> <dl> <dt><code>Uint16Array.prototype.constructor</code></dt> <dd>Returns the function that created an instance's prototype. This is the <code>Uint16Array</code> constructor by default.</dd> <dt>\n<a href=\"typedarray/buffer\"><code>Uint16Array.prototype.buffer</code></a> <span class=\"inlineIndicator readOnly readOnlyInline\">Read only </span>\n</dt> <dd>Returns the <a href=\"arraybuffer\"><code>ArrayBuffer</code></a> referenced by the <code>Uint16Array</code> Fixed at construction time and thus <strong>read only</strong>.</dd> <dt>\n<a href=\"typedarray/bytelength\"><code>Uint16Array.prototype.byteLength</code></a> <span class=\"inlineIndicator readOnly readOnlyInline\">Read only </span>\n</dt> <dd>Returns the length (in bytes) of the <code>Uint16Array</code> from the start of its <a href=\"arraybuffer\"><code>ArrayBuffer</code></a>. Fixed at construction time and thus <strong>read only.</strong>\n</dd> <dt>\n<a href=\"typedarray/byteoffset\"><code>Uint16Array.prototype.byteOffset</code></a> <span class=\"inlineIndicator readOnly readOnlyInline\">Read only </span>\n</dt> <dd>Returns the offset (in bytes) of the <code>Uint16Array</code> from the start of its <a href=\"arraybuffer\"><code>ArrayBuffer</code></a>. Fixed at construction time and thus <strong>read only.</strong>\n</dd> <dt>\n<a href=\"typedarray/length\"><code>Uint16Array.prototype.length</code></a> <span class=\"inlineIndicator readOnly readOnlyInline\">Read only </span>\n</dt> <dd>Returns the number of elements hold in the <code>Uint16Array</code>. Fixed at construction time and thus <strong>read only.</strong>\n</dd> </dl> <h3 id=\"Methods_2\">Methods</h3> <dl> <dt><a href=\"typedarray/copywithin\"><code>Uint16Array.prototype.copyWithin()</code></a></dt> <dd>Copies a sequence of array elements within the array. See also <a href=\"array/copywithin\"><code>Array.prototype.copyWithin()</code></a>.</dd> <dt><a href=\"typedarray/entries\"><code>Uint16Array.prototype.entries()</code></a></dt> <dd>Returns a new <code>Array Iterator</code> object that contains the key/value pairs for each index in the array. See also <a href=\"array/entries\"><code>Array.prototype.entries()</code></a>.</dd> <dt><a href=\"typedarray/every\"><code>Uint16Array.prototype.every()</code></a></dt> <dd>Tests whether all elements in the array pass the test provided by a function. See also <a href=\"array/every\"><code>Array.prototype.every()</code></a>.</dd> <dt><a href=\"typedarray/fill\"><code>Uint16Array.prototype.fill()</code></a></dt> <dd>Fills all the elements of an array from a start index to an end index with a static value. See also <a href=\"array/fill\"><code>Array.prototype.fill()</code></a>.</dd> <dt><a href=\"typedarray/filter\"><code>Uint16Array.prototype.filter()</code></a></dt> <dd>Creates a new array with all of the elements of this array for which the provided filtering function returns true. See also <a href=\"array/filter\"><code>Array.prototype.filter()</code></a>.</dd> <dt><a href=\"typedarray/find\"><code>Uint16Array.prototype.find()</code></a></dt> <dd>Returns the found value in the array, if an element in the array satisfies the provided testing function or <code>undefined</code> if not found. See also <a href=\"array/find\"><code>Array.prototype.find()</code></a>.</dd> <dt><a href=\"typedarray/findindex\"><code>Uint16Array.prototype.findIndex()</code></a></dt> <dd>Returns the found index in the array, if an element in the array satisfies the provided testing function or -1 if not found. See also <a href=\"array/findindex\"><code>Array.prototype.findIndex()</code></a>.</dd> <dt><a href=\"typedarray/foreach\"><code>Uint16Array.prototype.forEach()</code></a></dt> <dd>Calls a function for each element in the array. See also <a href=\"array/foreach\"><code>Array.prototype.forEach()</code></a>.</dd> <dt>\n<a href=\"typedarray/includes\"><code>Uint16Array.prototype.includes()</code></a> \n</dt> <dd>Determines whether a typed array includes a certain element, returning <code>true</code> or <code>false</code> as appropriate. See also <a href=\"array/includes\"><code>Array.prototype.includes()</code></a>.</dd> <dt><a href=\"typedarray/indexof\"><code>Uint16Array.prototype.indexOf()</code></a></dt> <dd>Returns the first (least) index of an element within the array equal to the specified value, or -1 if none is found. See also <a href=\"array/indexof\"><code>Array.prototype.indexOf()</code></a>.</dd> <dt><a href=\"typedarray/join\"><code>Uint16Array.prototype.join()</code></a></dt> <dd>Joins all elements of an array into a string. See also <a href=\"array/join\"><code>Array.prototype.join()</code></a>.</dd> <dt><a href=\"typedarray/keys\"><code>Uint16Array.prototype.keys()</code></a></dt> <dd>Returns a new <code>Array Iterator</code> that contains the keys for each index in the array. See also <a href=\"array/keys\"><code>Array.prototype.keys()</code></a>.</dd> <dt><a href=\"typedarray/lastindexof\"><code>Uint16Array.prototype.lastIndexOf()</code></a></dt> <dd>Returns the last (greatest) index of an element within the array equal to the specified value, or -1 if none is found. See also <a href=\"array/lastindexof\"><code>Array.prototype.lastIndexOf()</code></a>.</dd> <dt><a href=\"typedarray/map\"><code>Uint16Array.prototype.map()</code></a></dt> <dd>Creates a new array with the results of calling a provided function on every element in this array. See also <a href=\"array/map\"><code>Array.prototype.map()</code></a>.</dd> <dt>\n<a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/move\"><code>Uint16Array.prototype.move()</code></a>  <span class=\"inlineIndicator unimplemented unimplementedInline\">Unimplemented</span>\n</dt> <dd>Former non-standard version of <a href=\"typedarray/copywithin\"><code>Uint16Array.prototype.copyWithin()</code></a>.</dd> <dt><a href=\"typedarray/reduce\"><code>Uint16Array.prototype.reduce()</code></a></dt> <dd>Apply a function against an accumulator and each value of the array (from left-to-right) as to reduce it to a single value. See also <a href=\"array/reduce\"><code>Array.prototype.reduce()</code></a>.</dd> <dt><a href=\"typedarray/reduceright\"><code>Uint16Array.prototype.reduceRight()</code></a></dt> <dd>Apply a function against an accumulator and each value of the array (from right-to-left) as to reduce it to a single value. See also <a href=\"array/reduceright\"><code>Array.prototype.reduceRight()</code></a>.</dd> <dt><a href=\"typedarray/reverse\"><code>Uint16Array.prototype.reverse()</code></a></dt> <dd>Reverses the order of the elements of an array — the first becomes the last, and the last becomes the first. See also <a href=\"array/reverse\"><code>Array.prototype.reverse()</code></a>.</dd> <dt><a href=\"typedarray/set\"><code>Uint16Array.prototype.set()</code></a></dt> <dd>Stores multiple values in the typed array, reading input values from a specified array.</dd> <dt><a href=\"typedarray/slice\"><code>Uint16Array.prototype.slice()</code></a></dt> <dd>Extracts a section of an array and returns a new array. See also <a href=\"array/slice\"><code>Array.prototype.slice()</code></a>.</dd> <dt><a href=\"typedarray/some\"><code>Uint16Array.prototype.some()</code></a></dt> <dd>Returns true if at least one element in this array satisfies the provided testing function. See also <a href=\"array/some\"><code>Array.prototype.some()</code></a>.</dd> <dt><a href=\"typedarray/sort\"><code>Uint16Array.prototype.sort()</code></a></dt> <dd>Sorts the elements of an array in place and returns the array. See also <a href=\"array/sort\"><code>Array.prototype.sort()</code></a>.</dd> <dt><a href=\"typedarray/subarray\"><code>Uint16Array.prototype.subarray()</code></a></dt> <dd>Returns a new <code>Uint16Array</code> from the given start and end element index.</dd> <dt><a href=\"typedarray/values\"><code>Uint16Array.prototype.values()</code></a></dt> <dd>Returns a new <code>Array Iterator</code> object that contains the values for each index in the array. See also <a href=\"array/values\"><code>Array.prototype.values()</code></a>.</dd> <dt><a href=\"typedarray/tolocalestring\"><code>Uint16Array.prototype.toLocaleString()</code></a></dt> <dd>Returns a localized string representing the array and its elements. See also <a href=\"array/tolocalestring\"><code>Array.prototype.toLocaleString()</code></a>.</dd> <dt><a href=\"typedarray/tostring\"><code>Uint16Array.prototype.toString()</code></a></dt> <dd>Returns a string representing the array and its elements. See also <a href=\"array/tostring\"><code>Array.prototype.toString()</code></a>.</dd> <dt><a href=\"typedarray/@@iterator\"><code>Uint16Array.prototype[@@iterator]()</code></a></dt> <dd>Returns a new <code>Array Iterator</code> object that contains the values for each index in the array.</dd> </dl> <h2 id=\"Examples\">Examples</h2> <p>Different ways to create a <code>Uint16Array</code>:</p> <pre data-language=\"js\">// From a length\nvar uint16 = new Uint16Array(2);\nuint16[0] = 42;\nconsole.log(uint16[0]); // 42\nconsole.log(uint16.length); // 2\nconsole.log(uint16.BYTES_PER_ELEMENT); // 2\n\n// From an array\nvar arr = new Uint16Array([21,31]);\nconsole.log(arr[1]); // 31\n\n// From another TypedArray\nvar x = new Uint16Array([21, 31]);\nvar y = new Uint16Array(x);\nconsole.log(y[0]); // 21\n\n// From an ArrayBuffer\nvar buffer = new ArrayBuffer(8);\nvar z = new Uint16Array(buffer, 0, 4);\n\n// From an iterable\nvar iterable = function*(){ yield* [1,2,3]; }(); \nvar uint16 = new Uint16Array(iterable); \n// Uint16Array[1, 2, 3]\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.khronos.org/registry/typedarray/specs/latest/\" hreflang=\"en\">Typed Array Specification</a></td> <td><span class=\"spec-Obsolete\">Obsolete</span></td> <td>Superseded by ECMAScript 2015.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#table-49\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'TypedArray constructors' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition in an ECMA standard. Specified that <code>new</code> is required.</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#table-49\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'TypedArray constructors' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td>ECMAScript 2017 changed the <code>Uint16Array</code> constructor to use the <code>ToIndex</code> operation and allows constructors with no arguments.</td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility</h2>  <div class=\"bc-old\">\n<div class=\"_table\"><table class=\"compat-table\">\n<thead><tr>\n<th>Feature</th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr></thead>\n<tbody>\n<tr>\n<td><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Uint16Array\">Basic support</a></td>\n<td class=\"full-support\">7</td>\n<td class=\"full-support\"><span> Yes</span></td>\n<td class=\"full-support\">4</td>\n<td class=\"full-support\">10</td>\n<td class=\"full-support\">11.6</td>\n<td class=\"full-support\">5.1</td>\n</tr>\n<tr>\n<td>\n<code>Uint16Array()</code> without <code>new</code> throws</td>\n<td class=\"full-support\"><span> Yes</span></td>\n<td class=\"full-support\"><span> Yes</span></td>\n<td class=\"full-support\">44</td>\n<td class=\"no-support\"><span> No</span></td>\n<td class=\"full-support\"><span> Yes</span></td>\n<td class=\"unknown-support\"><span> ?</span></td>\n</tr>\n<tr>\n<td>Iterable in constructor</td>\n<td class=\"unknown-support\"><span> ?</span></td>\n<td class=\"unknown-support\"><span> ?</span></td>\n<td class=\"full-support\">52</td>\n<td class=\"unknown-support\"><span> ?</span></td>\n<td class=\"unknown-support\"><span> ?</span></td>\n<td class=\"unknown-support\"><span> ?</span></td>\n</tr>\n<tr>\n<td>Constructor without arguments</td>\n<td class=\"unknown-support\"><span> ?</span></td>\n<td class=\"unknown-support\"><span> ?</span></td>\n<td class=\"full-support\">55</td>\n<td class=\"unknown-support\"><span> ?</span></td>\n<td class=\"unknown-support\"><span> ?</span></td>\n<td class=\"unknown-support\"><span> ?</span></td>\n</tr>\n</tbody>\n</table></div>\n<div class=\"_table\"><table class=\"compat-table\">\n<thead><tr>\n<th>Feature</th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge mobile</th>\n<th>Firefox for Android</th>\n<th>Opera Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr></thead>\n<tbody>\n<tr>\n<td><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Uint16Array\">Basic support</a></td>\n<td class=\"full-support\">4</td>\n<td class=\"full-support\"><span> Yes</span></td>\n<td class=\"full-support\"><span> Yes</span></td>\n<td class=\"full-support\">4</td>\n<td class=\"full-support\">11.6</td>\n<td class=\"full-support\">4.2</td>\n<td class=\"full-support\"><span> Yes</span></td>\n</tr>\n<tr>\n<td>\n<code>Uint16Array()</code> without <code>new</code> throws</td>\n<td class=\"unknown-support\"><span> ?</span></td>\n<td class=\"unknown-support\"><span> ?</span></td>\n<td class=\"unknown-support\"><span> ?</span></td>\n<td class=\"full-support\">44</td>\n<td class=\"unknown-support\"><span> ?</span></td>\n<td class=\"unknown-support\"><span> ?</span></td>\n<td class=\"unknown-support\"><span> ?</span></td>\n</tr>\n<tr>\n<td>Iterable in constructor</td>\n<td class=\"unknown-support\"><span> ?</span></td>\n<td class=\"unknown-support\"><span> ?</span></td>\n<td class=\"unknown-support\"><span> ?</span></td>\n<td class=\"full-support\">52</td>\n<td class=\"unknown-support\"><span> ?</span></td>\n<td class=\"unknown-support\"><span> ?</span></td>\n<td class=\"unknown-support\"><span> ?</span></td>\n</tr>\n<tr>\n<td>Constructor without arguments</td>\n<td class=\"unknown-support\"><span> ?</span></td>\n<td class=\"unknown-support\"><span> ?</span></td>\n<td class=\"unknown-support\"><span> ?</span></td>\n<td class=\"full-support\">55</td>\n<td class=\"unknown-support\"><span> ?</span></td>\n<td class=\"unknown-support\"><span> ?</span></td>\n<td class=\"unknown-support\"><span> ?</span></td>\n</tr>\n</tbody>\n</table></div>\n</div> <h2 id=\"Compatibility_notes\">Compatibility notes</h2> <p>Starting with ECMAScript 2015, <code>Uint16Array</code> constructors require to be constructed with a <a href=\"../operators/new\"><code>new</code></a> operator. Calling a <code>Uint16Array</code> constructor as a function without <code>new</code>, will throw a <a href=\"typeerror\"><code>TypeError</code></a> from now on.</p> <pre data-language=\"js\">var dv = Uint16Array([1, 2, 3]);\n// TypeError: calling a builtin Uint16Array constructor\n// without new is forbidden</pre> <pre data-language=\"js\">var dv = new Uint16Array([1, 2, 3]);</pre> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Typed_arrays\">JavaScript typed arrays</a></li> <li><a href=\"arraybuffer\"><code>ArrayBuffer</code></a></li> <li><a href=\"dataview\"><code>DataView</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint16Array$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint16Array\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint16Array</a>\n  </p>\n</div>\n","global_objects/set":"<h1>Set</h1> <p>The <code>Set</code> object lets you store unique values of any type, whether <a href=\"https://developer.mozilla.org/en-US/docs/Glossary/Primitive\">primitive values</a> or object references.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/set-prototype-constructor.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\">new Set([<em>iterable</em>]);</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><code>iterable</code></dt> <dd>If an <a href=\"../statements/for...of\">iterable object </a>is passed, all of its elements will be added to the new <code>Set</code>. If you don't specify this parameter, or its value is <code>null</code>, the new <code>Set</code> is empty.</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p>A new <code>Set</code> object.</p> <h2 id=\"Description\">Description</h2> <p><code>Set</code> objects are collections of values. You can iterate through the elements of a set in insertion order. A value in the <code>Set</code> <strong>may only occur once</strong>; it is unique in the <code>Set</code>'s collection.</p> <h3 id=\"Value_equality\">Value equality</h3> <p>Because each value in the Set has to be unique, the value equality will be checked. In an earlier version of ECMAScript specification, this was not based on the same algorithm as the one used in the === operator. Specifically, for <code>Set</code>s, <code>+0</code> (which is strictly equal to <code>-0</code>) and <code>-0</code> were different values. However, this was changed in the ECMAScript 2015 specification. See \"Value equality for -0 and 0\" in the <a href=\"#Browser_compatibility\">browser compatibility</a> table for details.</p> <p>Also, <code>NaN</code> and <code>undefined</code> can also be stored in a Set. <code>NaN</code> is considered the same as <code>NaN</code> (even though <code>NaN !== NaN</code>).</p> <h2 id=\"Properties\">Properties</h2> <dl> <dt><code>Set.length</code></dt> <dd>The value of the <code>length</code> property is 0.</dd> <dd>To count how many elements are in a <code>Set</code>, use <a href=\"set/size\"><code>Set.prototype.size</code></a>.</dd> <dt><a href=\"set/@@species\"><code>get Set[@@species]</code></a></dt> <dd>The constructor function that is used to create derived objects.</dd> <dt><a href=\"set/prototype\"><code>Set.prototype</code></a></dt> <dd>Represents the prototype for the <code>Set</code> constructor. Allows the addition of properties to all <code>Set</code> objects.</dd> </dl> <h2 id=\"Set_instances\">\n<code>Set</code> instances</h2> <p>All <code>Set</code> instances inherit from <a href=\"set/prototype\"><code>Set.prototype</code></a>.</p> <h3 id=\"Properties_2\">Properties</h3> <dl> <dt><code>Set.prototype.constructor</code></dt> <dd>Returns the function that created an instance's prototype. This is the <a href=\"set\"><code>Set</code></a> function by default.</dd> <dt><a href=\"set/size\"><code>Set.prototype.size</code></a></dt> <dd>Returns the number of values in the <code>Set</code> object.</dd> </dl> <h3 id=\"Methods\">Methods</h3> <dl> <dt><a href=\"set/add\"><code>Set.prototype.add(value)</code></a></dt> <dd>Appends a new element with the given value to the <code>Set</code> object. Returns the <code>Set</code> object.</dd> <dt><a href=\"set/clear\"><code>Set.prototype.clear()</code></a></dt> <dd>Removes all elements from the <code>Set</code> object.</dd> <dt><a href=\"set/delete\"><code>Set.prototype.delete(value)</code></a></dt> <dd>Removes the element associated to the <code>value</code> and returns the value that <code>Set.prototype.has(value)</code> would have previously returned. <code>Set.prototype.has(value)</code> will return <code>false</code> afterwards.</dd> <dt><a href=\"set/entries\"><code>Set.prototype.entries()</code></a></dt> <dd>Returns a new <code>Iterator</code> object that contains<code>[value, value]</code> for each element in the <code>Set</code> object, in insertion order. This is kept similar to the <code>Map</code> object, so that each entry has the same value for its <em>key</em> and <em>value</em> here.</dd> <dt><a href=\"set/foreach\"><code>Set.prototype.forEach(callbackFn[, thisArg])</code></a></dt> <dd>Calls <code>callbackFn</code> once for each value present in the <code>Set</code> object, in insertion order. If a <code>thisArg</code> parameter is provided to <code>forEach</code>, it will be used as the <code>this</code> value for each callback.</dd> <dt><a href=\"set/has\"><code>Set.prototype.has(value)</code></a></dt> <dd>Returns a boolean asserting whether an element is present with the given value in the <code>Set</code> object or not.</dd> <dt><a href=\"set/values\"><code>Set.prototype.keys()</code></a></dt> <dd>Is the same function as the <code>values()</code> function and returns a new <code>Iterator</code> object that contains the values for each element in the <code>Set</code> object in insertion order.</dd> <dt><a href=\"set/values\"><code>Set.prototype.values()</code></a></dt> <dd>Returns a new <code>Iterator</code> object that contains the <strong>values</strong> for each element in the <code>Set</code> object in insertion order.</dd> <dt><a href=\"set/@@iterator\"><code>Set.prototype[@@iterator]()</code></a></dt> <dd>Returns a new <code>Iterator</code> object that contains the <strong>values</strong> for each element in the <code>Set</code> object in insertion order.</dd> </dl> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Using_the_Set_object\">Using the <code>Set</code> object</h3> <pre data-language=\"js\">var mySet = new Set();\n\nmySet.add(1); // Set [ 1 ]\nmySet.add(5); // Set [ 1, 5 ]\nmySet.add(5); // Set [ 1, 5 ]\nmySet.add('some text'); // Set [ 1, 5, 'some text' ]\nvar o = {a: 1, b: 2};\nmySet.add(o);\n\nmySet.add({a: 1, b: 2}); // o is referencing a different object so this is okay\n\nmySet.has(1); // true\nmySet.has(3); // false, 3 has not been added to the set\nmySet.has(5);              // true\nmySet.has(Math.sqrt(25));  // true\nmySet.has('Some Text'.toLowerCase()); // true\nmySet.has(o); // true\n\nmySet.size; // 5\n\nmySet.delete(5); // removes 5 from the set\nmySet.has(5);    // false, 5 has been removed\n\nmySet.size; // 4, we just removed one value\nconsole.log(mySet);// Set [ 1, \"some text\", Object {a: 1, b: 2}, Object {a: 1, b: 2} ]</pre> <h3 id=\"Iterating_Sets\">Iterating Sets</h3> <pre data-language=\"js\">// iterate over items in set\n// logs the items in the order: 1, \"some text\", {\"a\": 1, \"b\": 2}, {\"a\": 1, \"b\": 2} \nfor (let item of mySet) console.log(item);\n\n// logs the items in the order: 1, \"some text\", {\"a\": 1, \"b\": 2}, {\"a\": 1, \"b\": 2} \nfor (let item of mySet.keys()) console.log(item);\n \n// logs the items in the order: 1, \"some text\", {\"a\": 1, \"b\": 2}, {\"a\": 1, \"b\": 2} \nfor (let item of mySet.values()) console.log(item);\n\n// logs the items in the order: 1, \"some text\", {\"a\": 1, \"b\": 2}, {\"a\": 1, \"b\": 2} \n//(key and value are the same here)\nfor (let [key, value] of mySet.entries()) console.log(key);\n\n// convert Set object to an Array object, with <a href=\"array/from\">Array.from</a>\nvar myArr = Array.from(mySet); // [1, \"some text\", {\"a\": 1, \"b\": 2}, {\"a\": 1, \"b\": 2}]\n\n// the following will also work if run in an HTML document\nmySet.add(document.body);\nmySet.has(document.querySelector('body')); // true\n\n// converting between Set and Array\nmySet2 = new Set([1, 2, 3, 4]);\nmySet2.size; // 4\n[...mySet2]; // [1, 2, 3, 4]\n\n// intersect can be simulated via \nvar intersection = new Set([...set1].filter(x =&gt; set2.has(x)));\n\n// difference can be simulated via\nvar difference = new Set([...set1].filter(x =&gt; !set2.has(x)));\n\n// Iterate set entries with forEach\nmySet.forEach(function(value) {\n  console.log(value);\n});\n\n// 1\n// 2\n// 3\n// 4</pre> <h3 id=\"Implementing_basic_set_operations\">Implementing basic set operations</h3> <pre data-language=\"js\">function isSuperset(set, subset) {\n    for (var elem of subset) {\n        if (!set.has(elem)) {\n            return false;\n        }\n    }\n    return true;\n}\n\nfunction union(setA, setB) {\n    var _union = new Set(setA);\n    for (var elem of setB) {\n        _union.add(elem);\n    }\n    return _union;\n}\n\nfunction intersection(setA, setB) {\n    var _intersection = new Set();\n    for (var elem of setB) {\n        if (setA.has(elem)) {\n            _intersection.add(elem);\n        }\n    }\n    return _intersection;\n}\n\nfunction difference(setA, setB) {\n    var _difference = new Set(setA);\n    for (var elem of setB) {\n        _difference.delete(elem);\n    }\n    return _difference;\n}\n\n//Examples\nvar setA = new Set([1, 2, 3, 4]),\n    setB = new Set([2, 3]),\n    setC = new Set([3, 4, 5, 6]);\n\nisSuperset(setA, setB); // =&gt; true\nunion(setA, setC); // =&gt; Set [1, 2, 3, 4, 5, 6]\nintersection(setA, setC); // =&gt; Set [3, 4]\ndifference(setA, setC); // =&gt; Set [1, 2]\n\n</pre> <h3 id=\"Relation_with_Array_objects\">Relation with <code>Array</code> objects</h3> <pre data-language=\"js\">var myArray = ['value1', 'value2', 'value3'];\n\n// Use the regular Set constructor to transform an Array into a Set\nvar mySet = new Set(myArray);\n\nmySet.has('value1'); // returns true\n\n// Use the spread operator to transform a set into an Array.\nconsole.log([...mySet]); // Will show you exactly the same Array as myArray</pre> <h3 id=\"Relation_with_Strings\">Relation with <code>Strings</code>\n</h3> <pre data-language=\"js\">var text = 'India';\n\nvar mySet = new Set(text);  // Set ['I', 'n', 'd', 'i', 'a']\nmySet.size;  // 5\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-set-objects\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Set' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-set-objects\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Set' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 38</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 13</td>\n<td class=\"bc-supports-yes\"> 11</td>\n<td class=\"bc-supports-yes\"> 25</td>\n<td class=\"bc-supports-yes\"> 8</td>\n</tr>\n<tr>\n<th scope=\"row\"><code>new Set(iterable)</code></th>\n<td class=\"bc-supports-yes\"> 38</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 13</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 25</td>\n<td class=\"bc-supports-yes\"> 9</td>\n</tr>\n<tr>\n<th scope=\"row\"><code>new Set(null)</code></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 37</td>\n<td class=\"bc-supports-yes\"> 11</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 9</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<code>Set()</code> without <code>new</code> throws</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 42</td>\n<td class=\"bc-supports-yes\"> 11</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 9</td>\n</tr>\n<tr>\n<th scope=\"row\">Key equality for -0 and 0</th>\n<td class=\"bc-supports-yes\"> 38</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 29</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 25</td>\n<td class=\"bc-supports-yes\"> 9</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Set/add\"><code>add</code></a></th>\n<td class=\"bc-supports-yes\"> 38</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 13</td>\n<td class=\"bc-supports-partial bc-has-history\">11\n<section class=\"bc-history\" id=\"sect3\"><dl>\n<dt class=\"bc-supports-partial bc-supports\">11\n</dt>\n<dd> Returns 'undefined' instead of the 'Set' object.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-yes\"> 25</td>\n<td class=\"bc-supports-yes\"> 8</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Set/clear\"><code>clear</code></a></th>\n<td class=\"bc-supports-yes\"> 38</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 19</td>\n<td class=\"bc-supports-yes\"> 11</td>\n<td class=\"bc-supports-yes\"> 25</td>\n<td class=\"bc-supports-yes\"> 8</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Set/delete\"><code>delete</code></a></th>\n<td class=\"bc-supports-yes\"> 38</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 13</td>\n<td class=\"bc-supports-yes\"> 11</td>\n<td class=\"bc-supports-yes\"> 25</td>\n<td class=\"bc-supports-yes\"> 8</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Set/entries\"><code>entries</code></a></th>\n<td class=\"bc-supports-yes\"> 38</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 24</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 25</td>\n<td class=\"bc-supports-yes\"> 8</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Set/forEach\"><code>forEach</code></a></th>\n<td class=\"bc-supports-yes\"> 38</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 25</td>\n<td class=\"bc-supports-yes\"> 11</td>\n<td class=\"bc-supports-yes\"> 25</td>\n<td class=\"bc-supports-yes\"> 8</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Set/has\"><code>has</code></a></th>\n<td class=\"bc-supports-yes\"> 38</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 13</td>\n<td class=\"bc-supports-yes\"> 11</td>\n<td class=\"bc-supports-yes\"> 25</td>\n<td class=\"bc-supports-yes\"> 8</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Set/prototype\"><code>prototype</code></a></th>\n<td class=\"bc-supports-yes\"> 38</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 13</td>\n<td class=\"bc-supports-yes\"> 11</td>\n<td class=\"bc-supports-yes\"> 25</td>\n<td class=\"bc-supports-yes\"> 8</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Set/size\"><code>size</code></a></th>\n<td class=\"bc-supports-yes\"> 38</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes bc-has-history\"> 19\n<section class=\"bc-history\" id=\"sect5\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 19\n</dt>\n<dd> From Firefox 13 to Firefox 18, the <code>size</code> property was implemented as a <code>Set.prototype.size()</code> method, this has been changed to a property in later versions conform to the ECMAScript 2015 specification.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-yes\"> 11</td>\n<td class=\"bc-supports-yes\"> 25</td>\n<td class=\"bc-supports-yes\"> 8</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Set/values\"><code>values</code></a></th>\n<td class=\"bc-supports-yes\"> 38</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 24</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 25</td>\n<td class=\"bc-supports-yes\"> 8</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Set/@@iterator\"><code>@@iterator</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes bc-has-history\"> 36\n<section class=\"bc-history\" id=\"sect7\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 36\n</dt>\n\n<dt class=\"bc-supports-no bc-supports\">27 — 36\n</dt>\n<dd> A placeholder property named <code>@@iterator</code> is used.</dd>\n<dd> Uses the non-standard name: <code>@@iterator</code>\n</dd>\n<dt class=\"bc-supports-no bc-supports\">17 — 27\n</dt>\n<dd> A placeholder property named <code>iterator</code> is used.</dd>\n<dd> Uses the non-standard name: <code>iterator</code>\n</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Set/@@species\"><code>@@species</code></a></th>\n<td class=\"bc-supports-yes\"> 51</td>\n<td class=\"bc-supports-yes\"> 13</td>\n<td class=\"bc-supports-yes\"> 41</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 38</td>\n<td class=\"bc-supports-yes\"> 10</td>\n</tr>\n</tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 38</td>\n<td class=\"bc-supports-yes\"> 38</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 14</td>\n<td class=\"bc-supports-yes\"> 25</td>\n<td class=\"bc-supports-yes\"> 8</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><code>new Set(iterable)</code></th>\n<td class=\"bc-supports-yes\"> 38</td>\n<td class=\"bc-supports-yes\"> 38</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 14</td>\n<td class=\"bc-supports-yes\"> 25</td>\n<td class=\"bc-supports-yes\"> 9</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><code>new Set(null)</code></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 37</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 9</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<code>Set()</code> without <code>new</code> throws</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 42</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 9</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">Key equality for -0 and 0</th>\n<td class=\"bc-supports-yes\"> 38</td>\n<td class=\"bc-supports-yes\"> 38</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 29</td>\n<td class=\"bc-supports-yes\"> 25</td>\n<td class=\"bc-supports-yes\"> 9</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Set/add\"><code>add</code></a></th>\n<td class=\"bc-supports-yes\"> 38</td>\n<td class=\"bc-supports-yes\"> 38</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 14</td>\n<td class=\"bc-supports-yes\"> 25</td>\n<td class=\"bc-supports-yes\"> 8</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Set/clear\"><code>clear</code></a></th>\n<td class=\"bc-supports-yes\"> 38</td>\n<td class=\"bc-supports-yes\"> 38</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 19</td>\n<td class=\"bc-supports-yes\"> 25</td>\n<td class=\"bc-supports-yes\"> 8</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Set/delete\"><code>delete</code></a></th>\n<td class=\"bc-supports-yes\"> 38</td>\n<td class=\"bc-supports-yes\"> 38</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 14</td>\n<td class=\"bc-supports-yes\"> 25</td>\n<td class=\"bc-supports-yes\"> 8</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Set/entries\"><code>entries</code></a></th>\n<td class=\"bc-supports-yes\"> 38</td>\n<td class=\"bc-supports-yes\"> 38</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 24</td>\n<td class=\"bc-supports-yes\"> 25</td>\n<td class=\"bc-supports-yes\"> 8</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Set/forEach\"><code>forEach</code></a></th>\n<td class=\"bc-supports-yes\"> 38</td>\n<td class=\"bc-supports-yes\"> 38</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 25</td>\n<td class=\"bc-supports-yes\"> 25</td>\n<td class=\"bc-supports-yes\"> 8</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Set/has\"><code>has</code></a></th>\n<td class=\"bc-supports-yes\"> 38</td>\n<td class=\"bc-supports-yes\"> 38</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 14</td>\n<td class=\"bc-supports-yes\"> 25</td>\n<td class=\"bc-supports-yes\"> 8</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Set/prototype\"><code>prototype</code></a></th>\n<td class=\"bc-supports-yes\"> 38</td>\n<td class=\"bc-supports-yes\"> 38</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 14</td>\n<td class=\"bc-supports-yes\"> 25</td>\n<td class=\"bc-supports-yes\"> 8</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Set/size\"><code>size</code></a></th>\n<td class=\"bc-supports-yes\"> 38</td>\n<td class=\"bc-supports-yes\"> 38</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes bc-has-history\"> 19\n<section class=\"bc-history\" id=\"sect6\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 19\n</dt>\n<dd> From Firefox 13 to Firefox 18, the <code>size</code> property was implemented as a <code>Set.prototype.size()</code> method, this has been changed to a property in later versions conform to the ECMAScript 2015 specification.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-yes\"> 25</td>\n<td class=\"bc-supports-yes\"> 8</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Set/values\"><code>values</code></a></th>\n<td class=\"bc-supports-yes\"> 38</td>\n<td class=\"bc-supports-yes\"> 38</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 24</td>\n<td class=\"bc-supports-yes\"> 25</td>\n<td class=\"bc-supports-yes\"> 8</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Set/@@iterator\"><code>@@iterator</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes bc-has-history\"> 36\n<section class=\"bc-history\" id=\"sect8\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 36\n</dt>\n\n<dt class=\"bc-supports-no bc-supports\">27 — 36\n</dt>\n<dd> A placeholder property named <code>@@iterator</code> is used.</dd>\n<dd> Uses the non-standard name: <code>@@iterator</code>\n</dd>\n<dt class=\"bc-supports-no bc-supports\">17 — 27\n</dt>\n<dd> A placeholder property named <code>iterator</code> is used.</dd>\n<dd> Uses the non-standard name: <code>iterator</code>\n</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Set/@@species\"><code>@@species</code></a></th>\n<td class=\"bc-supports-yes\"> 51</td>\n<td class=\"bc-supports-yes\"> 51</td>\n<td class=\"bc-supports-yes\"> 13</td>\n<td class=\"bc-supports-yes\"> 41</td>\n<td class=\"bc-supports-yes\"> 38</td>\n<td class=\"bc-supports-yes\"> 10</td>\n<td class=\"bc-supports-yes\"> 5.0</td>\n</tr>\n</tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes bc-has-history\"> 0.12\n<section class=\"bc-history\" id=\"sect1\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 0.12\n</dt>\n\n<dt class=\"bc-supports-yes bc-supports\"> 0.10<div class=\"bc-icons\">Disabled </div>\n</dt>\n<dd>Disabled From version 0.10: this feature is behind the <code>--harmony</code> runtime flag.</dd>\n</dl></section>\n</td>\n</tr>\n<tr>\n<th scope=\"row\"><code>new Set(iterable)</code></th>\n<td class=\"bc-supports-yes\"> 0.12</td>\n</tr>\n<tr>\n<th scope=\"row\"><code>new Set(null)</code></th>\n<td class=\"bc-supports-yes bc-has-history\"> 0.12\n<section class=\"bc-history\" id=\"sect2\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 0.12\n</dt>\n\n<dt class=\"bc-supports-yes bc-supports\"> 0.10<div class=\"bc-icons\">Disabled </div>\n</dt>\n<dd>Disabled From version 0.10: this feature is behind the <code>--harmony</code> runtime flag.</dd>\n</dl></section>\n</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<code>Set()</code> without <code>new</code> throws</th>\n<td class=\"bc-supports-yes\"> 0.12</td>\n</tr>\n<tr>\n<th scope=\"row\">Key equality for -0 and 0</th>\n<td class=\"bc-supports-yes\"> 4.0.0</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Set/add\"><code>add</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Set/clear\"><code>clear</code></a></th>\n<td class=\"bc-supports-yes\"> 0.12</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Set/delete\"><code>delete</code></a></th>\n<td class=\"bc-supports-yes bc-has-history\"> 0.12\n<section class=\"bc-history\" id=\"sect4\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 0.12\n</dt>\n\n<dt class=\"bc-supports-yes bc-supports\"> 0.10<div class=\"bc-icons\">Disabled </div>\n</dt>\n<dd>Disabled From version 0.10: this feature is behind the <code>--harmony</code> runtime flag.</dd>\n</dl></section>\n</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Set/entries\"><code>entries</code></a></th>\n<td class=\"bc-supports-yes\"> 0.12</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Set/forEach\"><code>forEach</code></a></th>\n<td class=\"bc-supports-yes\"> 0.12</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Set/has\"><code>has</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Set/prototype\"><code>prototype</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Set/size\"><code>size</code></a></th>\n<td class=\"bc-supports-yes\"> 0.12</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Set/values\"><code>values</code></a></th>\n<td class=\"bc-supports-yes\"> 0.12</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Set/@@iterator\"><code>@@iterator</code></a></th>\n<td class=\"bc-supports-yes\"> 0.12</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Set/@@species\"><code>@@species</code></a></th>\n<td class=\"bc-supports-yes bc-has-history\"> 6.5.0\n<section class=\"bc-history\" id=\"sect9\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 6.5.0\n</dt>\n\n<dt class=\"bc-supports-yes bc-supports\"> 6.0.0<div class=\"bc-icons\">Disabled </div>\n</dt>\n<dd>Disabled From version 6.0.0: this feature is behind the <code>--harmony</code> runtime flag.</dd>\n</dl></section>\n</td>\n</tr>\n</tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"map\"><code>Map</code></a></li> <li><a href=\"weakmap\"><code>WeakMap</code></a></li> <li><a href=\"weakset\"><code>WeakSet</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set</a>\n  </p>\n</div>\n","global_objects/sharedarraybuffer":"<h1>SharedArrayBuffer</h1> <p>The <code>SharedArrayBuffer</code> object is used to represent a generic, fixed-length raw binary data buffer, similar to the <a href=\"arraybuffer\"><code>ArrayBuffer</code></a> object, but in a way that they can be used to create views on shared memory. Unlike an <code>ArrayBuffer</code>, a <code>SharedArrayBuffer</code> cannot become detached.</p> <div class=\"note\"> <p>Note that <code>SharedArrayBuffer</code> was disabled by default in all major browsers on 5 January, 2018 in response to <a href=\"https://meltdownattack.com/\">Spectre</a>. Chrome <a href=\"https://bugs.chromium.org/p/chromium/issues/detail?id=821270\">re-enabled it in v67</a> on platforms where its site-isolation feature is enabled to protect against Spectre-style vulnerabilities.</p> </div> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/sharedarraybuffer-constructor.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\">new SharedArrayBuffer(length)\n</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><code>length</code></dt> <dd>The size, in bytes, of the array buffer to create.</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p>A new <code>SharedArrayBuffer</code> object of the specified size. Its contents are initialized to 0.</p> <h2 id=\"Description\">Description</h2> <h3 id=\"Allocating_and_sharing_memory\">Allocating and sharing memory</h3> <p>To share memory using <a href=\"sharedarraybuffer\"><code>SharedArrayBuffer</code></a> objects from one agent in the cluster to another (an agent is either the web page’s main program or one of its web workers), <code><a href=\"https://developer.mozilla.org/en-US/docs/Web/API/Worker/postMessage\">postMessage</a></code> and <a href=\"https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Structured_clone_algorithm\">structured cloning</a> is used.</p> <p>The structured clone algorithm accepts <code>SharedArrayBuffers</code> and <code>TypedArrays</code> mapped onto <code>SharedArrayBuffers</code>. In both cases, the <code>SharedArrayBuffer</code> object is transmitted to the receiver resulting in a new, private SharedArrayBuffer object in the receiving agent (just as for <a href=\"arraybuffer\"><code>ArrayBuffer</code></a>). However, the shared data block referenced by the two <code>SharedArrayBuffer</code> objects is the same data block, and a side effect to the block in one agent will eventually become visible in the other agent.</p> <pre data-language=\"js\">var sab = new SharedArrayBuffer(1024);\nworker.postMessage(sab);\n</pre> <h3 id=\"Updating_and_synchronizing_shared_memory_with_Atomic_operations\">Updating and synchronizing shared memory with Atomic operations</h3> <p>Shared memory can be created and updated simultaneously in workers or the main thread. Depending on the system (the CPU, the OS, the Browser) it can take a while until the change is propagated to all contexts. To synchronize, <a href=\"atomics\">atomic</a> operations are needed.</p> <h3 id=\"APIs_accepting_SharedArrayBuffer_objects\">APIs accepting <code>SharedArrayBuffer</code> objects</h3> <ul> <li><a href=\"https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/bufferData\"><code>WebGLRenderingContext.bufferData()</code></a></li> <li><a href=\"https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/bufferSubData\"><code>WebGLRenderingContext.bufferSubData()</code></a></li> <li><a href=\"https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/getBufferSubData\"><code>WebGL2RenderingContext.getBufferSubData()</code></a></li> </ul> <h3 id=\"Constructing_is_required_with_new_operator\">Constructing is required with <code>new</code> operator</h3> <p><code>SharedArrayBuffer</code> constructors are required to be constructed with a <a href=\"../operators/new\"><code>new</code></a> operator. Calling a <code>SharedArrayBuffer</code> constructor as a function without <code>new</code> will throw a <a href=\"typeerror\"><code>TypeError</code></a>.</p> <pre data-language=\"js\">var sab = SharedArrayBuffer(1024);\n// TypeError: calling a builtin SharedArrayBuffer constructor \n// without new is forbidden</pre> <pre data-language=\"js\">var sab = new SharedArrayBuffer(1024);</pre> <h2 id=\"Properties\">Properties</h2> <dl> <dt><code>SharedArrayBuffer.length</code></dt> <dd>The <code>SharedArrayBuffer</code> constructor's length property whose value is 1.</dd> <dt><a href=\"sharedarraybuffer/prototype\"><code>SharedArrayBuffer.prototype</code></a></dt> <dd>Allows the addition of properties to all <code>SharedArrayBuffer</code> objects.</dd> </dl> <h2 id=\"SharedArrayBuffer_prototype_object\">\n<code>SharedArrayBuffer</code> prototype object</h2> <p>All <code>SharedArrayBuffer</code> instances inherit from <a href=\"sharedarraybuffer/prototype\"><code>SharedArrayBuffer.prototype</code></a>.</p> <h3 id=\"Properties_2\">Properties</h3> <dl> <dt>SharedArrayBuffer.prototype.constructor</dt> <dd>Specifies the function that creates an object's prototype. The initial value is the standard built-in <code>SharedArrayBuffer</code> constructor.</dd> <dt>\n<a href=\"sharedarraybuffer/bytelength\"><code>SharedArrayBuffer.prototype.byteLength</code></a> <span class=\"inlineIndicator readOnly readOnlyInline\">Read only </span>\n</dt> <dd>The size, in bytes, of the array. This is established when the array is constructed and cannot be changed. <strong>Read only.</strong>\n</dd> </dl> <h3 id=\"Methods\">Methods</h3> <dl> <dt><a href=\"sharedarraybuffer/slice\"><code>SharedArrayBuffer.prototype.slice(begin, end)</code></a></dt> <dd>Returns a new <code>SharedArrayBuffer</code> whose contents are a copy of this <code>SharedArrayBuffer</code>'s bytes from <code>begin</code>, inclusive, up to <code>end</code>, exclusive. If either <code>begin</code> or <code>end</code> is negative, it refers to an index from the end of the array, as opposed to from the beginning.</dd> </dl> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-sharedarraybuffer-objects\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'SharedArrayBuffer' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td>Initial definition in ES2017.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/8.0/#sec-sharedarraybuffer-objects\" hreflang=\"en\">ECMAScript 2017 (ECMA-262)<br><small>The definition of 'SharedArrayBuffer' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes bc-has-history\"> 68\n<section class=\"bc-history\" id=\"sect1\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 68\n</dt>\n\n<dt class=\"bc-supports-no bc-supports\">60 — 63\n</dt>\n<dd> Chrome disabled SharedArrayBuffer on January 5, 2018 to help reduce the efficacy of <a href=\"https://www.chromium.org/Home/chromium-security/ssca\">speculative side-channel attacks</a>. This was a temporary removal while mitigations were put in place.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-no bc-has-history\"> No\n<section class=\"bc-history\" id=\"sect2\"><dl>\n<dt class=\"bc-supports-no bc-supports\"> No\n</dt>\n<dd> Support was removed to mitigate <a href=\"https://blogs.windows.com/msedgedev/2018/01/03/speculative-execution-mitigations-microsoft-edge-internet-explorer\">speculative execution side-channel attacks (Windows blog)</a>.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-yes bc-has-history\"> 57<div class=\"bc-icons\"> Disabled </div>\n<section class=\"bc-history\" id=\"sect3\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 57<div class=\"bc-icons\"> Disabled </div>\n</dt>\n<dd> Support was disabled by default to mitigate <a href=\"https://blog.mozilla.org/security/2018/01/03/mitigations-landing-new-class-timing-attack/\">speculative execution side-channel attacks (Mozilla Security Blog)</a>.</dd>\n<dd>Disabled From version 57: this feature is behind the <code>javascript.options.shared_memory</code> preference (needs to be set to <code>true</code>). To change preferences in Firefox, visit about:config.</dd>\n<dt class=\"bc-supports-no bc-supports\">55 — 57\n</dt>\n\n<dt class=\"bc-supports-no bc-supports\">46 — 55<div class=\"bc-icons\">Disabled </div>\n</dt>\n<dd>Disabled From version 46 until version 55 (exclusive): this feature is behind the <code>javascript.options.shared_memory</code> preference (needs to be set to <code>true</code>). To change preferences in Firefox, visit about:config.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\">10.1 — ?</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<code>SharedArrayBuffer</code> in <code>DataView</code>\n</th>\n<td class=\"bc-supports-yes bc-has-history\"> 68\n<section class=\"bc-history\" id=\"sect7\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 68\n</dt>\n\n<dt class=\"bc-supports-no bc-supports\">60 — 63\n</dt>\n<dd> Chrome disabled SharedArrayBuffer on January 5, 2018 to help reduce the efficacy of <a href=\"https://www.chromium.org/Home/chromium-security/ssca\">speculative side-channel attacks</a>. This was a temporary removal while mitigations were put in place.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-no bc-has-history\"> No\n<section class=\"bc-history\" id=\"sect8\"><dl>\n<dt class=\"bc-supports-no bc-supports\"> No\n</dt>\n<dd> Support was removed to mitigate <a href=\"https://blogs.windows.com/msedgedev/2018/01/03/speculative-execution-mitigations-microsoft-edge-internet-explorer\">speculative execution side-channel attacks (Windows blog)</a>.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-yes bc-has-history\"> 57<div class=\"bc-icons\"> Disabled </div>\n<section class=\"bc-history\" id=\"sect9\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 57<div class=\"bc-icons\"> Disabled </div>\n</dt>\n<dd> Support was disabled by default to mitigate <a href=\"https://blog.mozilla.org/security/2018/01/03/mitigations-landing-new-class-timing-attack/\">speculative execution side-channel attacks (Mozilla Security Blog)</a>.</dd>\n<dd>Disabled From version 57: this feature is behind the <code>javascript.options.shared_memory</code> preference (needs to be set to <code>true</code>). To change preferences in Firefox, visit about:config.</dd>\n<dt class=\"bc-supports-no bc-supports\">55 — 57\n</dt>\n\n<dt class=\"bc-supports-no bc-supports\">46 — 55<div class=\"bc-icons\">Disabled </div>\n</dt>\n<dd>Disabled From version 46 until version 55 (exclusive): this feature is behind the <code>javascript.options.shared_memory</code> preference (needs to be set to <code>true</code>). To change preferences in Firefox, visit about:config.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\">10.1 — ?</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/SharedArrayBuffer/prototype\"><code>prototype</code></a></th>\n<td class=\"bc-supports-yes bc-has-history\"> 68\n<section class=\"bc-history\" id=\"sect13\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 68\n</dt>\n\n<dt class=\"bc-supports-no bc-supports\">60 — 63\n</dt>\n<dd> Chrome disabled SharedArrayBuffer on January 5, 2018 to help reduce the efficacy of <a href=\"https://www.chromium.org/Home/chromium-security/ssca\">speculative side-channel attacks</a>. This was a temporary removal while mitigations were put in place.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-no bc-has-history\"> No\n<section class=\"bc-history\" id=\"sect14\"><dl>\n<dt class=\"bc-supports-no bc-supports\"> No\n</dt>\n<dd> Support was removed to mitigate <a href=\"https://blogs.windows.com/msedgedev/2018/01/03/speculative-execution-mitigations-microsoft-edge-internet-explorer\">speculative execution side-channel attacks (Windows blog)</a>.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-yes bc-has-history\"> 57<div class=\"bc-icons\"> Disabled </div>\n<section class=\"bc-history\" id=\"sect15\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 57<div class=\"bc-icons\"> Disabled </div>\n</dt>\n<dd> Support was disabled by default to mitigate <a href=\"https://blog.mozilla.org/security/2018/01/03/mitigations-landing-new-class-timing-attack/\">speculative execution side-channel attacks (Mozilla Security Blog)</a>.</dd>\n<dd>Disabled From version 57: this feature is behind the <code>javascript.options.shared_memory</code> preference (needs to be set to <code>true</code>). To change preferences in Firefox, visit about:config.</dd>\n<dt class=\"bc-supports-no bc-supports\">55 — 57\n</dt>\n\n<dt class=\"bc-supports-no bc-supports\">46 — 55<div class=\"bc-icons\">Disabled </div>\n</dt>\n<dd>Disabled From version 46 until version 55 (exclusive): this feature is behind the <code>javascript.options.shared_memory</code> preference (needs to be set to <code>true</code>). To change preferences in Firefox, visit about:config.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\">10.1 — ?</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/SharedArrayBuffer/byteLength\"><code>byteLength</code></a></th>\n<td class=\"bc-supports-yes bc-has-history\"> 68\n<section class=\"bc-history\" id=\"sect19\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 68\n</dt>\n\n<dt class=\"bc-supports-no bc-supports\">60 — 63\n</dt>\n<dd> Chrome disabled SharedArrayBuffer on January 5, 2018 to help reduce the efficacy of <a href=\"https://www.chromium.org/Home/chromium-security/ssca\">speculative side-channel attacks</a>. This was a temporary removal while mitigations were put in place.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-yes bc-has-history\"> 16\n<section class=\"bc-history\" id=\"sect20\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 16\n</dt>\n<dd> Support was removed to mitigate <a href=\"https://blogs.windows.com/msedgedev/2018/01/03/speculative-execution-mitigations-microsoft-edge-internet-explorer\">speculative execution side-channel attacks (Windows blog)</a>.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-yes bc-has-history\"> 57<div class=\"bc-icons\"> Disabled </div>\n<section class=\"bc-history\" id=\"sect21\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 57<div class=\"bc-icons\"> Disabled </div>\n</dt>\n<dd> Support was disabled by default to mitigate <a href=\"https://blog.mozilla.org/security/2018/01/03/mitigations-landing-new-class-timing-attack/\">speculative execution side-channel attacks (Mozilla Security Blog)</a>.</dd>\n<dd>Disabled From version 57: this feature is behind the <code>javascript.options.shared_memory</code> preference (needs to be set to <code>true</code>). To change preferences in Firefox, visit about:config.</dd>\n<dt class=\"bc-supports-no bc-supports\">55 — 57\n</dt>\n\n<dt class=\"bc-supports-no bc-supports\">46 — 55<div class=\"bc-icons\">Disabled </div>\n</dt>\n<dd>Disabled From version 46 until version 55 (exclusive): this feature is behind the <code>javascript.options.shared_memory</code> preference (needs to be set to <code>true</code>). To change preferences in Firefox, visit about:config.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\">10.1 — ?</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/SharedArrayBuffer/slice\"><code>slice</code></a></th>\n<td class=\"bc-supports-yes bc-has-history\"> 68\n<section class=\"bc-history\" id=\"sect25\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 68\n</dt>\n\n<dt class=\"bc-supports-no bc-supports\">60 — 63\n</dt>\n<dd> Chrome disabled SharedArrayBuffer on January 5, 2018 to help reduce the efficacy of <a href=\"https://www.chromium.org/Home/chromium-security/ssca\">speculative side-channel attacks</a>. This was a temporary removal while mitigations were put in place.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-yes bc-has-history\"> 16\n<section class=\"bc-history\" id=\"sect26\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 16\n</dt>\n<dd> Support was removed to mitigate <a href=\"https://blogs.windows.com/msedgedev/2018/01/03/speculative-execution-mitigations-microsoft-edge-internet-explorer\">speculative execution side-channel attacks (Windows blog)</a>.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-yes bc-has-history\"> 57<div class=\"bc-icons\"> Disabled </div>\n<section class=\"bc-history\" id=\"sect27\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 57<div class=\"bc-icons\"> Disabled </div>\n</dt>\n<dd> Support was disabled by default to mitigate <a href=\"https://blog.mozilla.org/security/2018/01/03/mitigations-landing-new-class-timing-attack/\">speculative execution side-channel attacks (Mozilla Security Blog)</a>.</dd>\n<dd>Disabled From version 57: this feature is behind the <code>javascript.options.shared_memory</code> preference (needs to be set to <code>true</code>). To change preferences in Firefox, visit about:config.</dd>\n<dt class=\"bc-supports-no bc-supports\">55 — 57\n</dt>\n\n<dt class=\"bc-supports-no bc-supports\">46 — 55<div class=\"bc-icons\">Disabled </div>\n</dt>\n<dd>Disabled From version 46 until version 55 (exclusive): this feature is behind the <code>javascript.options.shared_memory</code> preference (needs to be set to <code>true</code>). To change preferences in Firefox, visit about:config.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\">10.1 — ?</td>\n</tr>\n</tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-no bc-has-history\">60 — 63\n<section class=\"bc-history\" id=\"sect4\"><dl>\n<dt class=\"bc-supports-no bc-supports\">60 — 63\n</dt>\n<dd> Chrome disabled SharedArrayBuffer on January 5, 2018 to help reduce the efficacy of <a href=\"https://www.chromium.org/Home/chromium-security/ssca\">speculative side-channel attacks</a>. This is intended as a temporary measure until other mitigations are in place.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-no bc-has-history\">60 — 63\n<section class=\"bc-history\" id=\"sect5\"><dl>\n<dt class=\"bc-supports-no bc-supports\">60 — 63\n</dt>\n<dd> Chrome disabled SharedArrayBuffer on January 5, 2018 to help reduce the efficacy of <a href=\"https://www.chromium.org/Home/chromium-security/ssca\">speculative side-channel attacks</a>. This is intended as a temporary measure until other mitigations are in place.</dd>\n</dl></section>\n</td>\n<td> ? </td>\n<td class=\"bc-supports-yes bc-has-history\"> 57<div class=\"bc-icons\"> Disabled </div>\n<section class=\"bc-history\" id=\"sect6\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 57<div class=\"bc-icons\"> Disabled </div>\n</dt>\n<dd> Support was disabled by default to mitigate <a href=\"https://blog.mozilla.org/security/2018/01/03/mitigations-landing-new-class-timing-attack/\">speculative execution side-channel attacks (Mozilla Security Blog)</a>.</dd>\n<dd>Disabled From version 57: this feature is behind the <code>javascript.options.shared_memory</code> preference (needs to be set to <code>true</code>). To change preferences in Firefox, visit about:config.</dd>\n<dt class=\"bc-supports-no bc-supports\">55 — 57\n</dt>\n\n<dt class=\"bc-supports-no bc-supports\">46 — 55<div class=\"bc-icons\">Disabled </div>\n</dt>\n<dd>Disabled From version 46 until version 55 (exclusive): this feature is behind the <code>javascript.options.shared_memory</code> preference (needs to be set to <code>true</code>). To change preferences in Firefox, visit about:config.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<code>SharedArrayBuffer</code> in <code>DataView</code>\n</th>\n<td class=\"bc-supports-no bc-has-history\">60 — 63\n<section class=\"bc-history\" id=\"sect10\"><dl>\n<dt class=\"bc-supports-no bc-supports\">60 — 63\n</dt>\n<dd> Chrome disabled SharedArrayBuffer on January 5, 2018 to help reduce the efficacy of <a href=\"https://www.chromium.org/Home/chromium-security/ssca\">speculative side-channel attacks</a>. This is intended as a temporary measure until other mitigations are in place.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-no bc-has-history\">60 — 63\n<section class=\"bc-history\" id=\"sect11\"><dl>\n<dt class=\"bc-supports-no bc-supports\">60 — 63\n</dt>\n<dd> Chrome disabled SharedArrayBuffer on January 5, 2018 to help reduce the efficacy of <a href=\"https://www.chromium.org/Home/chromium-security/ssca\">speculative side-channel attacks</a>. This is intended as a temporary measure until other mitigations are in place.</dd>\n</dl></section>\n</td>\n<td> ? </td>\n<td class=\"bc-supports-yes bc-has-history\"> 57<div class=\"bc-icons\"> Disabled </div>\n<section class=\"bc-history\" id=\"sect12\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 57<div class=\"bc-icons\"> Disabled </div>\n</dt>\n<dd> Support was disabled by default to mitigate <a href=\"https://blog.mozilla.org/security/2018/01/03/mitigations-landing-new-class-timing-attack/\">speculative execution side-channel attacks (Mozilla Security Blog)</a>.</dd>\n<dd>Disabled From version 57: this feature is behind the <code>javascript.options.shared_memory</code> preference (needs to be set to <code>true</code>). To change preferences in Firefox, visit about:config.</dd>\n<dt class=\"bc-supports-no bc-supports\">55 — 57\n</dt>\n\n<dt class=\"bc-supports-no bc-supports\">46 — 55<div class=\"bc-icons\">Disabled </div>\n</dt>\n<dd>Disabled From version 46 until version 55 (exclusive): this feature is behind the <code>javascript.options.shared_memory</code> preference (needs to be set to <code>true</code>). To change preferences in Firefox, visit about:config.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/SharedArrayBuffer/prototype\"><code>prototype</code></a></th>\n<td class=\"bc-supports-no bc-has-history\">60 — 63\n<section class=\"bc-history\" id=\"sect16\"><dl>\n<dt class=\"bc-supports-no bc-supports\">60 — 63\n</dt>\n<dd> Chrome disabled SharedArrayBuffer on January 5, 2018 to help reduce the efficacy of <a href=\"https://www.chromium.org/Home/chromium-security/ssca\">speculative side-channel attacks</a>. This is intended as a temporary measure until other mitigations are in place.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-no bc-has-history\">60 — 63\n<section class=\"bc-history\" id=\"sect17\"><dl>\n<dt class=\"bc-supports-no bc-supports\">60 — 63\n</dt>\n<dd> Chrome disabled SharedArrayBuffer on January 5, 2018 to help reduce the efficacy of <a href=\"https://www.chromium.org/Home/chromium-security/ssca\">speculative side-channel attacks</a>. This is intended as a temporary measure until other mitigations are in place.</dd>\n</dl></section>\n</td>\n<td> ? </td>\n<td class=\"bc-supports-yes bc-has-history\"> 57<div class=\"bc-icons\"> Disabled </div>\n<section class=\"bc-history\" id=\"sect18\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 57<div class=\"bc-icons\"> Disabled </div>\n</dt>\n<dd> Support was disabled by default to mitigate <a href=\"https://blog.mozilla.org/security/2018/01/03/mitigations-landing-new-class-timing-attack/\">speculative execution side-channel attacks (Mozilla Security Blog)</a>.</dd>\n<dd>Disabled From version 57: this feature is behind the <code>javascript.options.shared_memory</code> preference (needs to be set to <code>true</code>). To change preferences in Firefox, visit about:config.</dd>\n<dt class=\"bc-supports-no bc-supports\">55 — 57\n</dt>\n\n<dt class=\"bc-supports-no bc-supports\">46 — 55<div class=\"bc-icons\">Disabled </div>\n</dt>\n<dd>Disabled From version 46 until version 55 (exclusive): this feature is behind the <code>javascript.options.shared_memory</code> preference (needs to be set to <code>true</code>). To change preferences in Firefox, visit about:config.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/SharedArrayBuffer/byteLength\"><code>byteLength</code></a></th>\n<td class=\"bc-supports-no bc-has-history\">60 — 63\n<section class=\"bc-history\" id=\"sect22\"><dl>\n<dt class=\"bc-supports-no bc-supports\">60 — 63\n</dt>\n<dd> Chrome disabled SharedArrayBuffer on January 5, 2018 to help reduce the efficacy of <a href=\"https://www.chromium.org/Home/chromium-security/ssca\">speculative side-channel attacks</a>. This is intended as a temporary measure until other mitigations are in place.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-no bc-has-history\">60 — 63\n<section class=\"bc-history\" id=\"sect23\"><dl>\n<dt class=\"bc-supports-no bc-supports\">60 — 63\n</dt>\n<dd> Chrome disabled SharedArrayBuffer on January 5, 2018 to help reduce the efficacy of <a href=\"https://www.chromium.org/Home/chromium-security/ssca\">speculative side-channel attacks</a>. This is intended as a temporary measure until other mitigations are in place.</dd>\n</dl></section>\n</td>\n<td> ? </td>\n<td class=\"bc-supports-yes bc-has-history\"> 57<div class=\"bc-icons\"> Disabled </div>\n<section class=\"bc-history\" id=\"sect24\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 57<div class=\"bc-icons\"> Disabled </div>\n</dt>\n<dd> Support was disabled by default to mitigate <a href=\"https://blog.mozilla.org/security/2018/01/03/mitigations-landing-new-class-timing-attack/\">speculative execution side-channel attacks (Mozilla Security Blog)</a>.</dd>\n<dd>Disabled From version 57: this feature is behind the <code>javascript.options.shared_memory</code> preference (needs to be set to <code>true</code>). To change preferences in Firefox, visit about:config.</dd>\n<dt class=\"bc-supports-no bc-supports\">55 — 57\n</dt>\n\n<dt class=\"bc-supports-no bc-supports\">46 — 55<div class=\"bc-icons\">Disabled </div>\n</dt>\n<dd>Disabled From version 46 until version 55 (exclusive): this feature is behind the <code>javascript.options.shared_memory</code> preference (needs to be set to <code>true</code>). To change preferences in Firefox, visit about:config.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/SharedArrayBuffer/slice\"><code>slice</code></a></th>\n<td class=\"bc-supports-no bc-has-history\">60 — 63\n<section class=\"bc-history\" id=\"sect28\"><dl>\n<dt class=\"bc-supports-no bc-supports\">60 — 63\n</dt>\n<dd> Chrome disabled SharedArrayBuffer on January 5, 2018 to help reduce the efficacy of <a href=\"https://www.chromium.org/Home/chromium-security/ssca\">speculative side-channel attacks</a>. This is intended as a temporary measure until other mitigations are in place.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-no bc-has-history\">60 — 63\n<section class=\"bc-history\" id=\"sect29\"><dl>\n<dt class=\"bc-supports-no bc-supports\">60 — 63\n</dt>\n<dd> Chrome disabled SharedArrayBuffer on January 5, 2018 to help reduce the efficacy of <a href=\"https://www.chromium.org/Home/chromium-security/ssca\">speculative side-channel attacks</a>. This is intended as a temporary measure until other mitigations are in place.</dd>\n</dl></section>\n</td>\n<td> ? </td>\n<td class=\"bc-supports-yes bc-has-history\"> 57<div class=\"bc-icons\"> Disabled </div>\n<section class=\"bc-history\" id=\"sect30\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 57<div class=\"bc-icons\"> Disabled </div>\n</dt>\n<dd> Support was disabled by default to mitigate <a href=\"https://blog.mozilla.org/security/2018/01/03/mitigations-landing-new-class-timing-attack/\">speculative execution side-channel attacks (Mozilla Security Blog)</a>.</dd>\n<dd>Disabled From version 57: this feature is behind the <code>javascript.options.shared_memory</code> preference (needs to be set to <code>true</code>). To change preferences in Firefox, visit about:config.</dd>\n<dt class=\"bc-supports-no bc-supports\">55 — 57\n</dt>\n\n<dt class=\"bc-supports-no bc-supports\">46 — 55<div class=\"bc-icons\">Disabled </div>\n</dt>\n<dd>Disabled From version 46 until version 55 (exclusive): this feature is behind the <code>javascript.options.shared_memory</code> preference (needs to be set to <code>true</code>). To change preferences in Firefox, visit about:config.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n</tr>\n</tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 8.10.0</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<code>SharedArrayBuffer</code> in <code>DataView</code>\n</th>\n<td class=\"bc-supports-no\"> No</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/SharedArrayBuffer/prototype\"><code>prototype</code></a></th>\n<td class=\"bc-supports-no\"> No</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/SharedArrayBuffer/byteLength\"><code>byteLength</code></a></th>\n<td class=\"bc-supports-yes\"> 8.10.0</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/SharedArrayBuffer/slice\"><code>slice</code></a></th>\n<td class=\"bc-supports-yes\"> 8.10.0</td>\n</tr>\n</tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"atomics\"><code>Atomics</code></a></li> <li><a href=\"arraybuffer\"><code>ArrayBuffer</code></a></li> <li><a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Typed_arrays\">JavaScript typed arrays</a></li> <li><a href=\"https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API\">Web Workers</a></li> <li>\n<a href=\"https://github.com/lars-t-hansen/parlib-simple\">parlib-simple </a>– a simple library providing synchronization and work distribution abstractions.</li> <li><a href=\"https://github.com/tc39/ecmascript_sharedmem/blob/master/TUTORIAL.md\">Shared Memory – a brief tutorial</a></li> <li> <p><a href=\"https://hacks.mozilla.org/2016/05/a-taste-of-javascripts-new-parallel-primitives/\">A Taste of JavaScript’s New Parallel Primitives – Mozilla Hacks</a></p> </li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SharedArrayBuffer$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SharedArrayBuffer\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SharedArrayBuffer</a>\n  </p>\n</div>\n","global_objects/uint32array":"<h1>Uint32Array</h1> <p>The <code>Uint32Array</code> typed array represents an array of 32-bit unsigned integers in the platform byte order. If control over byte order is needed, use <a href=\"dataview\"><code>DataView</code></a> instead. The contents are initialized to <code>0</code>. Once established, you can reference elements in the array using the object's methods, or using standard array index syntax (that is, using bracket notation).</p> <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\">new Uint32Array(); // new in ES2017\nnew Uint32Array(length);\nnew Uint32Array(typedArray);\nnew Uint32Array(object);\nnew Uint32Array(buffer [, byteOffset [, length]]);</pre> <p>For more information about the constructor syntax and the parameters, see <em><a href=\"typedarray#Syntax\">TypedArray</a></em>.</p> <h2 id=\"Properties\">Properties</h2> <dl> <dt><a href=\"typedarray/bytes_per_element\"><code>Uint32Array.BYTES_PER_ELEMENT</code></a></dt> <dd>Returns a number value of the element size. <code>4</code> in the case of an <code>Uint32Array</code>.</dd> <dt>Uint32Array.length</dt> <dd>Static length property whose value is 0. For the actual length (number of elements), see <a href=\"typedarray/length\"><code>Uint32Array.prototype.length</code></a>.</dd> <dt><a href=\"typedarray/name\"><code>Uint32Array.name</code></a></dt> <dd>Returns the string value of the constructor name. In the case of the <code>Uint32Array</code> type: \"Uint32Array\".</dd> <dt><a href=\"typedarray/prototype\"><code>Uint32Array.prototype</code></a></dt> <dd>Prototype for the <em>TypedArray</em> objects.</dd> </dl> <h2 id=\"Methods\">Methods</h2> <dl> <dt><a href=\"typedarray/from\"><code>Uint32Array.from()</code></a></dt> <dd>Creates a new <code>Uint32Array</code> from an array-like or iterable object. See also <a href=\"array/from\"><code>Array.from()</code></a>.</dd> <dt><a href=\"typedarray/of\"><code>Uint32Array.of()</code></a></dt> <dd>Creates a new <code>Uint32Array</code> with a variable number of arguments. See also <a href=\"array/of\"><code>Array.of()</code></a>.</dd> </dl> <h2 id=\"Uint32Array_prototype\">\n<code>Uint32Array</code> prototype</h2> <p>All <code>Uint32Array</code> objects inherit from <a href=\"typedarray/prototype\"><code>%TypedArray%.prototype</code></a>.</p> <h3 id=\"Properties_2\">Properties</h3> <dl> <dt><code>Uint32Array.prototype.constructor</code></dt> <dd>Returns the function that created an instance's prototype. This is the <code>Uint32Array</code> constructor by default.</dd> <dt>\n<a href=\"typedarray/buffer\"><code>Uint32Array.prototype.buffer</code></a> <span class=\"inlineIndicator readOnly readOnlyInline\">Read only </span>\n</dt> <dd>Returns the <a href=\"arraybuffer\"><code>ArrayBuffer</code></a> referenced by the <code>Uint32Array</code> Fixed at construction time and thus <strong>read only</strong>.</dd> <dt>\n<a href=\"typedarray/bytelength\"><code>Uint32Array.prototype.byteLength</code></a> <span class=\"inlineIndicator readOnly readOnlyInline\">Read only </span>\n</dt> <dd>Returns the length (in bytes) of the <code>Uint32Array</code> from the start of its <a href=\"arraybuffer\"><code>ArrayBuffer</code></a>. Fixed at construction time and thus <strong>read only.</strong>\n</dd> <dt>\n<a href=\"typedarray/byteoffset\"><code>Uint32Array.prototype.byteOffset</code></a> <span class=\"inlineIndicator readOnly readOnlyInline\">Read only </span>\n</dt> <dd>Returns the offset (in bytes) of the <code>Uint32Array</code> from the start of its <a href=\"arraybuffer\"><code>ArrayBuffer</code></a>. Fixed at construction time and thus <strong>read only.</strong>\n</dd> <dt>\n<a href=\"typedarray/length\"><code>Uint32Array.prototype.length</code></a> <span class=\"inlineIndicator readOnly readOnlyInline\">Read only </span>\n</dt> <dd>Returns the number of elements hold in the <code>Uint32Array</code>. Fixed at construction time and thus <strong>read only.</strong>\n</dd> </dl> <h3 id=\"Methods_2\">Methods</h3> <dl> <dt><a href=\"typedarray/copywithin\"><code>Uint32Array.prototype.copyWithin()</code></a></dt> <dd>Copies a sequence of array elements within the array. See also <a href=\"array/copywithin\"><code>Array.prototype.copyWithin()</code></a>.</dd> <dt><a href=\"typedarray/entries\"><code>Uint32Array.prototype.entries()</code></a></dt> <dd>Returns a new <code>Array Iterator</code> object that contains the key/value pairs for each index in the array. See also <a href=\"array/entries\"><code>Array.prototype.entries()</code></a>.</dd> <dt><a href=\"typedarray/every\"><code>Uint32Array.prototype.every()</code></a></dt> <dd>Tests whether all elements in the array pass the test provided by a function. See also <a href=\"array/every\"><code>Array.prototype.every()</code></a>.</dd> <dt><a href=\"typedarray/fill\"><code>Uint32Array.prototype.fill()</code></a></dt> <dd>Fills all the elements of an array from a start index to an end index with a static value. See also <a href=\"array/fill\"><code>Array.prototype.fill()</code></a>.</dd> <dt><a href=\"typedarray/filter\"><code>Uint32Array.prototype.filter()</code></a></dt> <dd>Creates a new array with all of the elements of this array for which the provided filtering function returns true. See also <a href=\"array/filter\"><code>Array.prototype.filter()</code></a>.</dd> <dt><a href=\"typedarray/find\"><code>Uint32Array.prototype.find()</code></a></dt> <dd>Returns the found value in the array, if an element in the array satisfies the provided testing function or <code>undefined</code> if not found. See also <a href=\"array/find\"><code>Array.prototype.find()</code></a>.</dd> <dt><a href=\"typedarray/findindex\"><code>Uint32Array.prototype.findIndex()</code></a></dt> <dd>Returns the found index in the array, if an element in the array satisfies the provided testing function or -1 if not found. See also <a href=\"array/findindex\"><code>Array.prototype.findIndex()</code></a>.</dd> <dt><a href=\"typedarray/foreach\"><code>Uint32Array.prototype.forEach()</code></a></dt> <dd>Calls a function for each element in the array. See also <a href=\"array/foreach\"><code>Array.prototype.forEach()</code></a>.</dd> <dt>\n<a href=\"typedarray/includes\"><code>Uint32Array.prototype.includes()</code></a> \n</dt> <dd>Determines whether a typed array includes a certain element, returning <code>true</code> or <code>false</code> as appropriate. See also <a href=\"array/includes\"><code>Array.prototype.includes()</code></a>.</dd> <dt><a href=\"typedarray/indexof\"><code>Uint32Array.prototype.indexOf()</code></a></dt> <dd>Returns the first (least) index of an element within the array equal to the specified value, or -1 if none is found. See also <a href=\"array/indexof\"><code>Array.prototype.indexOf()</code></a>.</dd> <dt><a href=\"typedarray/join\"><code>Uint32Array.prototype.join()</code></a></dt> <dd>Joins all elements of an array into a string. See also <a href=\"array/join\"><code>Array.prototype.join()</code></a>.</dd> <dt><a href=\"typedarray/keys\"><code>Uint32Array.prototype.keys()</code></a></dt> <dd>Returns a new <code>Array Iterator</code> that contains the keys for each index in the array. See also <a href=\"array/keys\"><code>Array.prototype.keys()</code></a>.</dd> <dt><a href=\"typedarray/lastindexof\"><code>Uint32Array.prototype.lastIndexOf()</code></a></dt> <dd>Returns the last (greatest) index of an element within the array equal to the specified value, or -1 if none is found. See also <a href=\"array/lastindexof\"><code>Array.prototype.lastIndexOf()</code></a>.</dd> <dt><a href=\"typedarray/map\"><code>Uint32Array.prototype.map()</code></a></dt> <dd>Creates a new array with the results of calling a provided function on every element in this array. See also <a href=\"array/map\"><code>Array.prototype.map()</code></a>.</dd> <dt>\n<a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/move\"><code>Uint32Array.prototype.move()</code></a>  <span class=\"inlineIndicator unimplemented unimplementedInline\">Unimplemented</span>\n</dt> <dd>Former non-standard version of <a href=\"typedarray/copywithin\"><code>Uint32Array.prototype.copyWithin()</code></a>.</dd> <dt><a href=\"typedarray/reduce\"><code>Uint32Array.prototype.reduce()</code></a></dt> <dd>Apply a function against an accumulator and each value of the array (from left-to-right) as to reduce it to a single value. See also <a href=\"array/reduce\"><code>Array.prototype.reduce()</code></a>.</dd> <dt><a href=\"typedarray/reduceright\"><code>Uint32Array.prototype.reduceRight()</code></a></dt> <dd>Apply a function against an accumulator and each value of the array (from right-to-left) as to reduce it to a single value. See also <a href=\"array/reduceright\"><code>Array.prototype.reduceRight()</code></a>.</dd> <dt><a href=\"typedarray/reverse\"><code>Uint32Array.prototype.reverse()</code></a></dt> <dd>Reverses the order of the elements of an array — the first becomes the last, and the last becomes the first. See also <a href=\"array/reverse\"><code>Array.prototype.reverse()</code></a>.</dd> <dt><a href=\"typedarray/set\"><code>Uint32Array.prototype.set()</code></a></dt> <dd>Stores multiple values in the typed array, reading input values from a specified array.</dd> <dt><a href=\"typedarray/slice\"><code>Uint32Array.prototype.slice()</code></a></dt> <dd>Extracts a section of an array and returns a new array. See also <a href=\"array/slice\"><code>Array.prototype.slice()</code></a>.</dd> <dt><a href=\"typedarray/some\"><code>Uint32Array.prototype.some()</code></a></dt> <dd>Returns true if at least one element in this array satisfies the provided testing function. See also <a href=\"array/some\"><code>Array.prototype.some()</code></a>.</dd> <dt><a href=\"typedarray/sort\"><code>Uint32Array.prototype.sort()</code></a></dt> <dd>Sorts the elements of an array in place and returns the array. See also <a href=\"array/sort\"><code>Array.prototype.sort()</code></a>.</dd> <dt><a href=\"typedarray/subarray\"><code>Uint32Array.prototype.subarray()</code></a></dt> <dd>Returns a new <code>Uint32Array</code> from the given start and end element index.</dd> <dt><a href=\"typedarray/values\"><code>Uint32Array.prototype.values()</code></a></dt> <dd>Returns a new <code>Array Iterator</code> object that contains the values for each index in the array. See also <a href=\"array/values\"><code>Array.prototype.values()</code></a>.</dd> <dt><a href=\"typedarray/tolocalestring\"><code>Uint32Array.prototype.toLocaleString()</code></a></dt> <dd>Returns a localized string representing the array and its elements. See also <a href=\"array/tolocalestring\"><code>Array.prototype.toLocaleString()</code></a>.</dd> <dt><a href=\"typedarray/tostring\"><code>Uint32Array.prototype.toString()</code></a></dt> <dd>Returns a string representing the array and its elements. See also <a href=\"array/tostring\"><code>Array.prototype.toString()</code></a>.</dd> <dt><a href=\"typedarray/@@iterator\"><code>Uint32Array.prototype[@@iterator]()</code></a></dt> <dd>Returns a new <code>Array Iterator</code> object that contains the values for each index in the array.</dd> </dl> <h2 id=\"Examples\">Examples</h2> <p>Different ways to create a <code>Uint32Array</code>:</p> <pre data-language=\"js\">// From a length\nvar uint32 = new Uint32Array(2);\nuint32[0] = 42;\nconsole.log(uint32[0]); // 42\nconsole.log(uint32.length); // 2\nconsole.log(uint32.BYTES_PER_ELEMENT); // 4\n\n// From an array\nvar arr = new Uint32Array([21,31]);\nconsole.log(arr[1]); // 31\n\n// From another TypedArray\nvar x = new Uint32Array([21, 31]);\nvar y = new Uint32Array(x);\nconsole.log(y[0]); // 21\n\n// From an ArrayBuffer\nvar buffer = new ArrayBuffer(16);\nvar z = new Uint32Array(buffer, 0, 4);\n\n// From an iterable \nvar iterable = function*(){ yield* [1,2,3]; }(); \nvar uint32 = new Uint32Array(iterable);\n// Uint32Array[1, 2, 3]\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.khronos.org/registry/typedarray/specs/latest/\" hreflang=\"en\">Typed Array Specification</a></td> <td><span class=\"spec-Obsolete\">Obsolete</span></td> <td>Superseded by ECMAScript 2015.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#table-49\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'TypedArray constructors' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition in an ECMA standard. Specified that <code>new</code> is required.</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#table-49\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'TypedArray constructors' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td>ECMAScript 2017 changed the <code>Uint32Array</code> constructor to use the <code>ToIndex</code> operation and allows constructors with no arguments.</td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 7</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> 10</td>\n<td class=\"bc-supports-yes\"> 11.6</td>\n<td class=\"bc-supports-yes\"> 5.1</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<code>Uint32Array()</code> without <code>new</code> throws</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 44</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td> ? </td>\n</tr>\n<tr>\n<th scope=\"row\">Iterable in constructor</th>\n<td> ? </td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 52</td>\n<td> ? </td>\n<td> ? </td>\n<td> ? </td>\n</tr>\n<tr>\n<th scope=\"row\">Constructor without arguments</th>\n<td> ? </td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 55</td>\n<td> ? </td>\n<td> ? </td>\n<td> ? </td>\n</tr>\n</tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> 11.6</td>\n<td class=\"bc-supports-yes\"> 4.2</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<code>Uint32Array()</code> without <code>new</code> throws</th>\n<td> ? </td>\n<td> ? </td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 44</td>\n<td> ? </td>\n<td> ? </td>\n<td> ? </td>\n</tr>\n<tr>\n<th scope=\"row\">Iterable in constructor</th>\n<td> ? </td>\n<td> ? </td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 52</td>\n<td> ? </td>\n<td> ? </td>\n<td> ? </td>\n</tr>\n<tr>\n<th scope=\"row\">Constructor without arguments</th>\n<td> ? </td>\n<td> ? </td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 55</td>\n<td> ? </td>\n<td> ? </td>\n<td> ? </td>\n</tr>\n</tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 0.10</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<code>Uint32Array()</code> without <code>new</code> throws</th>\n<td class=\"bc-supports-yes\"> 0.12</td>\n</tr>\n<tr>\n<th scope=\"row\">Iterable in constructor</th>\n<td class=\"bc-supports-yes\"> 4.0.0</td>\n</tr>\n<tr>\n<th scope=\"row\">Constructor without arguments</th>\n<td> ? </td>\n</tr>\n</tbody>\n</table>\n</div> <h2 id=\"Compatibility_notes\">Compatibility notes</h2> <p>Starting with ECMAScript 2015, <code>Uint32Array</code> constructors require to be constructed with a <a href=\"../operators/new\"><code>new</code></a> operator. Calling a <code>Uint32Array</code> constructor as a function without <code>new</code>, will throw a <a href=\"typeerror\"><code>TypeError</code></a> from now on.</p> <pre data-language=\"js\">var dv = Uint32Array([1, 2, 3]);\n// TypeError: calling a builtin Uint32Array constructor \n// without new is forbidden</pre> <pre data-language=\"js\">var dv = new Uint32Array([1, 2, 3]);</pre> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Typed_arrays\">JavaScript typed arrays</a></li> <li><a href=\"arraybuffer\"><code>ArrayBuffer</code></a></li> <li><a href=\"dataview\"><code>DataView</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint32Array$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint32Array\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint32Array</a>\n  </p>\n</div>\n","global_objects/uint8array":"<h1>Uint8Array</h1> <p>The <code>Uint8Array</code> typed array represents an array of 8-bit unsigned integers. The contents are initialized to <code>0</code>. Once established, you can reference elements in the array using the object's methods, or using standard array index syntax (that is, using bracket notation).</p> <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\">new Uint8Array(); // new in ES2017\nnew Uint8Array(length);\nnew Uint8Array(typedArray);\nnew Uint8Array(object);\nnew Uint8Array(buffer [, byteOffset [, length]]);</pre> <p>For more information about the constructor syntax and the parameters, see <em><a href=\"typedarray#Syntax\">TypedArray</a></em>.</p> <h2 id=\"Properties\">Properties</h2> <dl> <dt><a href=\"typedarray/bytes_per_element\"><code>Uint8Array.BYTES_PER_ELEMENT</code></a></dt> <dd>Returns a number value of the element size. <code>1</code> in the case of an <code>Uint8Array</code>.</dd> <dt>Uint8Array.length</dt> <dd>Static length property whose value is 0. For the actual length (number of elements), see <a href=\"typedarray/length\"><code>Uint8Array.prototype.length</code></a>.</dd> <dt><a href=\"typedarray/name\"><code>Uint8Array.name</code></a></dt> <dd>Returns the string value of the constructor name. In the case of the <code>Uint8Array</code> type: \"Uint8Array\".</dd> <dt><a href=\"typedarray/prototype\"><code>Uint8Array.prototype</code></a></dt> <dd>Prototype for the <em>TypedArray</em> objects.</dd> </dl> <h2 id=\"Methods\">Methods</h2> <dl> <dt><a href=\"typedarray/from\"><code>Uint8Array.from()</code></a></dt> <dd>Creates a new <code>Uint8Array</code> from an array-like or iterable object. See also <a href=\"array/from\"><code>Array.from()</code></a>.</dd> <dt><a href=\"typedarray/of\"><code>Uint8Array.of()</code></a></dt> <dd>Creates a new <code>Uint8Array</code> with a variable number of arguments. See also <a href=\"array/of\"><code>Array.of()</code></a>.</dd> </dl> <h2 id=\"Uint8Array_prototype\">\n<code>Uint8Array</code> prototype</h2> <p>All <code>Uint8Array</code> objects inherit from <a href=\"typedarray/prototype\"><code>%TypedArray%.prototype</code></a>.</p> <h3 id=\"Properties_2\">Properties</h3> <dl> <dt><code>Uint8Array.prototype.constructor</code></dt> <dd>Returns the function that created an instance's prototype. This is the <code>Uint8Array</code> constructor by default.</dd> <dt>\n<a href=\"typedarray/buffer\"><code>Uint8Array.prototype.buffer</code></a> <span class=\"inlineIndicator readOnly readOnlyInline\">Read only </span>\n</dt> <dd>Returns the <a href=\"arraybuffer\"><code>ArrayBuffer</code></a> referenced by the <code>Uint8Array</code> Fixed at construction time and thus <strong>read only</strong>.</dd> <dt>\n<a href=\"typedarray/bytelength\"><code>Uint8Array.prototype.byteLength</code></a> <span class=\"inlineIndicator readOnly readOnlyInline\">Read only </span>\n</dt> <dd>Returns the length (in bytes) of the <code>Uint8Array</code>. Fixed at construction time and thus <strong>read only.</strong>\n</dd> <dt>\n<a href=\"typedarray/byteoffset\"><code>Uint8Array.prototype.byteOffset</code></a> <span class=\"inlineIndicator readOnly readOnlyInline\">Read only </span>\n</dt> <dd>Returns the offset (in bytes) of the <code>Uint8Array</code> from the start of its <a href=\"arraybuffer\"><code>ArrayBuffer</code></a>. Fixed at construction time and thus <strong>read only.</strong>\n</dd> <dt>\n<a href=\"typedarray/length\"><code>Uint8Array.prototype.length</code></a> <span class=\"inlineIndicator readOnly readOnlyInline\">Read only </span>\n</dt> <dd>Returns the number of elements held in the <code>Uint8Array</code>. Fixed at construction time and thus <strong>read only.</strong>\n</dd> </dl> <h3 id=\"Methods_2\">Methods</h3> <dl> <dt><a href=\"typedarray/copywithin\"><code>Uint8Array.prototype.copyWithin()</code></a></dt> <dd>Copies a sequence of array elements within the array. See also <a href=\"array/copywithin\"><code>Array.prototype.copyWithin()</code></a>.</dd> <dt><a href=\"typedarray/entries\"><code>Uint8Array.prototype.entries()</code></a></dt> <dd>Returns a new <code>Array Iterator</code> object that contains the key/value pairs for each index in the array. See also <a href=\"array/entries\"><code>Array.prototype.entries()</code></a>.</dd> <dt><a href=\"typedarray/every\"><code>Uint8Array.prototype.every()</code></a></dt> <dd>Tests whether all elements in the array pass the test provided by a function. See also <a href=\"array/every\"><code>Array.prototype.every()</code></a>.</dd> <dt><a href=\"typedarray/fill\"><code>Uint8Array.prototype.fill()</code></a></dt> <dd>Fills all the elements of an array from a start index to an end index with a static value. See also <a href=\"array/fill\"><code>Array.prototype.fill()</code></a>.</dd> <dt><a href=\"typedarray/filter\"><code>Uint8Array.prototype.filter()</code></a></dt> <dd>Creates a new array with all of the elements of this array for which the provided filtering function returns true. See also <a href=\"array/filter\"><code>Array.prototype.filter()</code></a>.</dd> <dt><a href=\"typedarray/find\"><code>Uint8Array.prototype.find()</code></a></dt> <dd>Returns the found value in the array, if an element in the array satisfies the provided testing function or <code>undefined</code> if not found. See also <a href=\"array/find\"><code>Array.prototype.find()</code></a>.</dd> <dt><a href=\"typedarray/findindex\"><code>Uint8Array.prototype.findIndex()</code></a></dt> <dd>Returns the found index in the array, if an element in the array satisfies the provided testing function or -1 if not found. See also <a href=\"array/findindex\"><code>Array.prototype.findIndex()</code></a>.</dd> <dt><a href=\"typedarray/foreach\"><code>Uint8Array.prototype.forEach()</code></a></dt> <dd>Calls a function for each element in the array. See also <a href=\"array/foreach\"><code>Array.prototype.forEach()</code></a>.</dd> <dt>\n<a href=\"typedarray/includes\"><code>Uint8Array.prototype.includes()</code></a> \n</dt> <dd>Determines whether a typed array includes a certain element, returning <code>true</code> or <code>false</code> as appropriate. See also <a href=\"array/includes\"><code>Array.prototype.includes()</code></a>.</dd> <dt><a href=\"typedarray/indexof\"><code>Uint8Array.prototype.indexOf()</code></a></dt> <dd>Returns the first (least) index of an element within the array equal to the specified value, or -1 if none is found. See also <a href=\"array/indexof\"><code>Array.prototype.indexOf()</code></a>.</dd> <dt><a href=\"typedarray/join\"><code>Uint8Array.prototype.join()</code></a></dt> <dd>Joins all elements of an array into a string. See also <a href=\"array/join\"><code>Array.prototype.join()</code></a>.</dd> <dt><a href=\"typedarray/keys\"><code>Uint8Array.prototype.keys()</code></a></dt> <dd>Returns a new <code>Array Iterator</code> that contains the keys for each index in the array. See also <a href=\"array/keys\"><code>Array.prototype.keys()</code></a>.</dd> <dt><a href=\"typedarray/lastindexof\"><code>Uint8Array.prototype.lastIndexOf()</code></a></dt> <dd>Returns the last (greatest) index of an element within the array equal to the specified value, or -1 if none is found. See also <a href=\"array/lastindexof\"><code>Array.prototype.lastIndexOf()</code></a>.</dd> <dt><a href=\"typedarray/map\"><code>Uint8Array.prototype.map()</code></a></dt> <dd>Creates a new array with the results of calling a provided function on every element in this array. See also <a href=\"array/map\"><code>Array.prototype.map()</code></a>.</dd> <dt>\n<a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/move\"><code>Uint8Array.prototype.move()</code></a>  <span class=\"inlineIndicator unimplemented unimplementedInline\">Unimplemented</span>\n</dt> <dd>Former non-standard version of <a href=\"typedarray/copywithin\"><code>Uint8Array.prototype.copyWithin()</code></a>.</dd> <dt><a href=\"typedarray/reduce\"><code>Uint8Array.prototype.reduce()</code></a></dt> <dd>Apply a function against an accumulator and each value of the array (from left-to-right) as to reduce it to a single value. See also <a href=\"array/reduce\"><code>Array.prototype.reduce()</code></a>.</dd> <dt><a href=\"typedarray/reduceright\"><code>Uint8Array.prototype.reduceRight()</code></a></dt> <dd>Apply a function against an accumulator and each value of the array (from right-to-left) as to reduce it to a single value. See also <a href=\"array/reduceright\"><code>Array.prototype.reduceRight()</code></a>.</dd> <dt><a href=\"typedarray/reverse\"><code>Uint8Array.prototype.reverse()</code></a></dt> <dd>Reverses the order of the elements of an array — the first becomes the last, and the last becomes the first. See also <a href=\"array/reverse\"><code>Array.prototype.reverse()</code></a>.</dd> <dt><a href=\"typedarray/set\"><code>Uint8Array.prototype.set()</code></a></dt> <dd>Stores multiple values in the typed array, reading input values from a specified array.</dd> <dt><a href=\"typedarray/slice\"><code>Uint8Array.prototype.slice()</code></a></dt> <dd>Extracts a section of an array and returns a new array. See also <a href=\"array/slice\"><code>Array.prototype.slice()</code></a>.</dd> <dt><a href=\"typedarray/some\"><code>Uint8Array.prototype.some()</code></a></dt> <dd>Returns true if at least one element in this array satisfies the provided testing function. See also <a href=\"array/some\"><code>Array.prototype.some()</code></a>.</dd> <dt><a href=\"typedarray/sort\"><code>Uint8Array.prototype.sort()</code></a></dt> <dd>Sorts the elements of an array in place and returns the array. See also <a href=\"array/sort\"><code>Array.prototype.sort()</code></a>.</dd> <dt><a href=\"typedarray/subarray\"><code>Uint8Array.prototype.subarray()</code></a></dt> <dd>Returns a new <code>Uint8Array</code> from the given start and end element index.</dd> <dt><a href=\"typedarray/values\"><code>Uint8Array.prototype.values()</code></a></dt> <dd>Returns a new <code>Array Iterator</code> object that contains the values for each index in the array. See also <a href=\"array/values\"><code>Array.prototype.values()</code></a>.</dd> <dt><a href=\"typedarray/tolocalestring\"><code>Uint8Array.prototype.toLocaleString()</code></a></dt> <dd>Returns a localized string representing the array and its elements. See also <a href=\"array/tolocalestring\"><code>Array.prototype.toLocaleString()</code></a>.</dd> <dt><a href=\"typedarray/tostring\"><code>Uint8Array.prototype.toString()</code></a></dt> <dd>Returns a string representing the array and its elements. See also <a href=\"array/tostring\"><code>Array.prototype.toString()</code></a>.</dd> <dt><a href=\"typedarray/@@iterator\"><code>Uint8Array.prototype[@@iterator]()</code></a></dt> <dd>Returns a new <code>Array Iterator</code> object that contains the values for each index in the array.</dd> </dl> <h2 id=\"Examples\">Examples</h2> <p>Different ways to create a <code>Uint8Array</code>:</p> <pre data-language=\"js\">// From a length\nvar uint8 = new Uint8Array(2);\nuint8[0] = 42;\nconsole.log(uint8[0]); // 42\nconsole.log(uint8.length); // 2\nconsole.log(uint8.BYTES_PER_ELEMENT); // 1\n\n// From an array\nvar arr = new Uint8Array([21,31]);\nconsole.log(arr[1]); // 31\n\n// From another TypedArray\nvar x = new Uint8Array([21, 31]);\nvar y = new Uint8Array(x);\nconsole.log(y[0]); // 21\n\n// From an ArrayBuffer\nvar buffer = new ArrayBuffer(8);\nvar z = new Uint8Array(buffer, 1, 4);\n\n// From an iterable \nvar iterable = function*(){ yield* [1,2,3]; }(); \nvar uint8 = new Uint8Array(iterable); \n// Uint8Array[1, 2, 3]\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.khronos.org/registry/typedarray/specs/latest/\" hreflang=\"en\">Typed Array Specification</a></td> <td><span class=\"spec-Obsolete\">Obsolete</span></td> <td>Superseded by ECMAScript 6.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#table-49\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'TypedArray constructors' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition in an ECMA standard. Specified that <code>new</code> is required.</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#table-49\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'TypedArray constructors' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td>ECMAScript 2017 changed the <code>Uint8Array</code> constructor to use the <code>ToIndex</code> operation and allows constructors with no arguments.</td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 7</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> 10</td>\n<td class=\"bc-supports-yes\"> 11.6</td>\n<td class=\"bc-supports-yes\"> 5.1</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<code>Uint8Array()</code> without <code>new</code> throws</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 44</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td> ? </td>\n</tr>\n<tr>\n<th scope=\"row\">Iterable in constructor</th>\n<td> ? </td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 52</td>\n<td> ? </td>\n<td> ? </td>\n<td> ? </td>\n</tr>\n<tr>\n<th scope=\"row\">Constructor without arguments</th>\n<td> ? </td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 55</td>\n<td> ? </td>\n<td> ? </td>\n<td> ? </td>\n</tr>\n</tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> 11.6</td>\n<td class=\"bc-supports-yes\"> 4.2</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<code>Uint8Array()</code> without <code>new</code> throws</th>\n<td> ? </td>\n<td> ? </td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 44</td>\n<td> ? </td>\n<td> ? </td>\n<td> ? </td>\n</tr>\n<tr>\n<th scope=\"row\">Iterable in constructor</th>\n<td> ? </td>\n<td> ? </td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 52</td>\n<td> ? </td>\n<td> ? </td>\n<td> ? </td>\n</tr>\n<tr>\n<th scope=\"row\">Constructor without arguments</th>\n<td> ? </td>\n<td> ? </td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 55</td>\n<td> ? </td>\n<td> ? </td>\n<td> ? </td>\n</tr>\n</tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 0.10</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<code>Uint8Array()</code> without <code>new</code> throws</th>\n<td class=\"bc-supports-yes\"> 0.12</td>\n</tr>\n<tr>\n<th scope=\"row\">Iterable in constructor</th>\n<td class=\"bc-supports-yes\"> 4.0.0</td>\n</tr>\n<tr>\n<th scope=\"row\">Constructor without arguments</th>\n<td> ? </td>\n</tr>\n</tbody>\n</table>\n</div> <h2 id=\"Compatibility_notes\">Compatibility notes</h2> <p>Starting with ECMAScript 2015, <code>Uint8Array</code> constructors require to be constructed with a <a href=\"../operators/new\"><code>new</code></a> operator. Calling a <code>Uint8Array</code> constructor as a function without <code>new</code>, will throw a <a href=\"typeerror\"><code>TypeError</code></a> from now on.</p> <pre data-language=\"js\">var dv = Uint8Array([1, 2, 3]);\n// TypeError: calling a builtin Uint8Array constructor\n// without new is forbidden</pre> <pre data-language=\"js\">var dv = new Uint8Array([1, 2, 3]);</pre> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Typed_arrays\">JavaScript typed arrays</a></li> <li><a href=\"arraybuffer\"><code>ArrayBuffer</code></a></li> <li><a href=\"dataview\"><code>DataView</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array</a>\n  </p>\n</div>\n","global_objects/promise":"<h1>Promise</h1> <p>The <code>Promise</code> object represents the eventual completion (or failure) of an asynchronous operation, and its resulting value.</p> <div class=\"note\"> <p><strong>Note:</strong> This article describes the <code>Promise</code> constructor and the methods and properties of such objects. To learn about the way promises work and how you can use them, we advise you to read <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Using_promises\">Using promises</a> first. The constructor is primarily used to wrap functions that do not already support promises.</p> </div> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/promise-constructor.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre data-language=\"js\">new Promise( /* executor */ function(resolve, reject) { ... } );</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt>executor</dt> <dd>A function that is passed with the arguments <code>resolve</code> and <code>reject</code>. The <code>executor</code> function is executed immediately by the Promise implementation, passing <code>resolve</code> and <code>reject</code> functions (the executor is called before the <code>Promise</code> constructor even returns the created object). The <code>resolve</code> and <code>reject</code> functions, when called, resolve or reject the promise, respectively. The executor normally initiates some asynchronous work, and then, once that completes, either calls the <code>resolve</code> function to resolve the promise or else rejects it if an error occurred. If an error is thrown in the executor function, the promise is rejected. The return value of the executor is ignored.</dd> </dl> <h2 id=\"Description\">Description</h2> <p>A <code><strong>Promise</strong></code> is a proxy for a value not necessarily known when the promise is created. It allows you to associate handlers with an asynchronous action's eventual success value or failure reason. This lets asynchronous methods return values like synchronous methods: instead of immediately returning the final value, the asynchronous method returns a <em>promise</em> to supply the value at some point in the future.</p> <p>A <code>Promise</code> is in one of these states:</p> <ul> <li>\n<em>pending</em>: initial state, neither fulfilled nor rejected.</li> <li>\n<em>fulfilled</em>: meaning that the operation completed successfully.</li> <li>\n<em>rejected</em>: meaning that the operation failed.</li> </ul> <p>A pending promise can either be <em>fulfilled</em> with a value, or <em>rejected</em> with a reason (error). When either of these options happens, the associated handlers queued up by a promise's <code>then</code> method are called. (If the promise has already been fulfilled or rejected when a corresponding handler is attached, the handler will be called, so there is no race condition between an asynchronous operation completing and its handlers being attached.)</p> <p>As the <code><a href=\"promise/then\"><code>Promise.prototype.then()</code></a></code> and <code><a href=\"promise/catch\"><code>Promise.prototype.catch()</code></a></code> methods return promises, they can be chained.</p> <p><img src=\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAyEAAAEpCAMAAACz/N2FAAAACXBIWXMAAAsTAAALEwEAmpwYAAADAFBMVEX///8DAwX///4aGhkQEBAqJ3QICAgAAAD40nvO9/8gICDx8fH///vw/v/X+P79/f3b+v/3z3eCgoIMDAyHh4fS+P////b8//8sKiqurq4UFBTz8/PNzc07Ojp7e3siLYX/8LOzs7NQUFD5//92dnb29/cmJXPV09YmJiYyMTJmZmb7+/vIyMj2yWwoDgP5+flVVVW4uLgBAxJCQkKr7f+np6ekpKSXl5fn5+nglTS88//96Kj1//+cnJzsqUDd3d1FEj7s6tX/88IuLi5GRkZMTEz/++rr6+sXVLlycnLDw8P3zHFdXVzm5uYRL4wjKHqMjIz//fJgYGG+vr5tbWzv7++Pj4/r/v9aWlrYhzA+Pj7X19fu7e3/+Nbf3+AjE1H/8bugoKD0xGUuXZg1Nzn/+t/I9f/314wuidnj4OEFETbR0dHm/f+Ev+H/9MwjAxJKSUn84ps8HQl7NQxtyvZcFx0PRKg4GVSc5P3k5OSqqKyA1fmUlJSk6f628P+f2fb84JPCYBqHNgvB5vomeNDLbyIgQ3ew7f4QRLFTGTc6lN8VNGSTNR+oZCcpKXoPOZMSAgJavO89gMLb29sgDzsCDEMbYcEQJXVMJw4bExMvDzouIWav4vkDE1IsNIDBfjI+Ey1EETeiURqL2vjKiE/bpWgEDym7u7twsNno8+XQdyHpvn/O9/TvtlHt3cLQ+PmnfktzuOltIywuDSxMsexjqtYebMjr27a2TBOfv+S41OdTmNnu6cPis3WQRBU7n+VZEAQOMn8IGmqCUCqzeDTRm11HEyNOfq1giIrc7tqZbztJH1EUHV15KAz34rnC5epvwfBRj8iCLB7z1q7rs2N8PlilunO2dCjjyJLApqpLQossZ7Dn9PwoQaKQdks+DA8dMlWAi72wtNNqWpHBl250t9vhuqjMkliLpHdXeHV+mdRFZldUQhbYsppSVGDw/PKYrsowRVtiRSqm5+u5p42pvZZ1jmGmkamPpbnblk7I07lWOm1cSxjB7/55lNBtIynSaF4eAAAaf0lEQVR42uyde1QTVx7HLyEQggmEV0AEBKNVUUHQ1SIRBJUiVhSrRYSsiEQQARdRoIiA4AMVCqigR8W31je24qsq6tpWra9Wt2pbd3Xbau1293C67e4fe/Z1ZyYBAiRgoIHE7+fEc3KHOzNmZj75/X73wrmEAAAAAAAAAAAAAAAAAAAAAAAAAAAYGoGBwRUHRmaISZ8OABgCAAwBAIYAAENgCIAhMATAEBgCYAgMAQCGAABDAIAhAMAQAGAIADAEgFfKEM9xI4f1tYEhAIZoNST9GzEMAa+KIVHf+wjWFxBFWYX/hoazyTLp4Wq7HSd8Ut53lu5f7D/PpqkL275RJKh50NeGeb+6mFhxPdmdo2EIMEVDkramhZSFy4M2f/ho17KgconiXqXVog2HdkZKrLamnclMljV24dpclpV08mDInqxUVU9uZxgCTNGQsNdlyocl4qBb5+Rx4sBxOUnbxljNySd2FrWHq+W8++dk6i4NXJszJCZcTAq3Lud6CrmdYQgwRUOUJ1wS/1oiDvtuy4FrNsrSuphqsZWFkFhZHD3LxI+mLg1cmzWkdtVKGYlfu5frKeR2hiHABA0RBVwpJkEl4uPFvDuZ62wDyu9VEpUhq6rlJOkvcnWXBq6tGUM4Q7idnWEIMEVDym3uZGZFx1y5e+b2Ouckn5oxKkOEdpvSLhTRuKHuwrU9d+ewdcgztg5he9aqdoYhwASzrPhM/6cvnlwKvVrBDFwpbtPgoDIk6mMf/3lOTV24tqK+qtlYFtdTtTMMASZoSIuqpLSy/aPw1G+cO3s6AIzLkLCLc/INKSQARmUI79iB8zIYAmCINkN4Bk7qADCyOgSGABgCQwCAIQDAEABgCAAwBAAYAgAMgSEAhsAQAENgCIAhMAQAGALAyz2yWE8dAAAAAAAAAAAAAAAAXhl87S1Vo7WWC3E1AGjNQBcHVhAvXAoA2mJBIiOIPS4EAG0Q19/BmwoyHFcCgNb0ceTP2kgEluN9cS0AaFWm55lPZOpzgesbuBgAtMB2lLV7BPvOAcNYALTEa/x49fAVhrGAMeI5biR9TZ7q1GxbRvaYrjl4hLv1KFtcYwBD2sTtd+ajUZsD44NbrFx0ZIvZ6u2KIsGBxYKaB1OduDaJ2udz4Ic5XWDIxll8xwG42MD44HGLlQd+ciqkrFzSGENU7YRNaWcyazptyBRvh/4zca2BUcItVh6QFU0Cd+eoDanl2j+vOC0nCZ2NIcwE4RRcaGCkcIuVHzbj8/kpexsNUbXPXnImhZ2rQ7gJQgCMNctiFytPDggXk7CB4qYYwrYbOh1D1BOEABgpIm6x8oxdB0M+ipR40kRrdw6tQ1RtWoccL9K/DmmaIATAWOEWKxddXGy2voAo6qt+rq9ixrK4NjOWdf2mvoY0myAEwGSCSlctx4kJQgC0gwlCALSDCUIAtIMJQgC0gwlCALSDCUIAtIMJQgC0gwlCAHSACUIAtIMJQgC0gwlCALSDCUJgpGBdQQB0GmLCZwMAhgAAQwCAIQDAEBgCYAgMATAEhgAYAkMAgCEAwBAAYAgAMAQAGAIADAEAhsAQAENgCIAhMATAkJ5+NtHz7bhNAIZoRVn64+DP4sTM26jHuGGgWwzxHDfSykLYxo+l+z7T3BB6mflzc/WiU5OnOinLUl70taFvNNdY14Ae/g/nZXoaEvjk2i9/Nz9wTUJIQl8J7hjoUYZkfNXimQxdWhkXF9fLudGQ+LV7078Rt2tI+hdr9DTkWKTNzs8f38lcKT+yJUuClAvoTZRYX0MURYKaB9v+5JPyvrPoyBaz1duJ1Y4TbCtmnbN0/2L/1cXqLaFLlzB7MN/m9N/kqTfqBVWNMcTK4tOK9f/Y4v91qsZhmMNvp0fSyxDpquT0L950efrvckno7Z+elVYS6d+KcbPBy+sRtqeuUzFk0YZDOyMlgZ+cCikrl6haytJlJOnkwZA9WamqLS0NoTFk+bBGQxadv1BUU3DkZI7mYejhybA/pupliOLektBvU0XHf/mvPPDmGvoioR/sRfUOXtKPQ3vqRAEl0Z0xZE4+sXu3NiArmgTuzmFbFkLPm/mimHAxKdy6XLWFrUP8L2kxZNt86arT8vQPlrU4DDUkkFl0XQ9Dwr60CSu7FvvdV/8hx8pT6YvQfJCt3g1oSUb2GPoh8ZwZKdLnd/fUUT0ystd0sg6xerf2sBmfz0/Zy7YshIXMI79SRmixodoSuvRUcHDwYy2GWAhpd8YQzcMwhtB+TYZ4DJ6e91bHFqGypa/QT62fHpRLVyTTl0wUUy2n1XvEjdIf3X8qcDaUIbTYwqNmnNkV79itgkfnqB7K0rrOGxJAI0bYQHGTIY0xRG2IKsuy4QVFajdE8zCtDPFdOGrSBFfriR65sbYdsoTH4xFlUXLDinLh/ct1tHqXkMAn5xt2bhZ24bXkBc27WrG+gGjWYsx62D/MYWKIesPHPinXt83Hs2cU0OKDF1QSLQo5VErTrHCdX3NDhvq2aUjYl8WeNCFiDXHK2HUw5KNIifrRvplP65BnbB2iYYjVprQLmToMaXGY3TltZVlT/BxnufATvfMienXks4oefTs//urgHzfl0Opdxlpi91rXGuL/+Y2Hm500i6iETWlnMmtYQ7gNdsyG38MQ40hdmeIjY9f1u6V1VI/C7Hydnf34g+0jfFsZEn+5TlFf9YAzRHRxsRn9GlU92kylrh7L0jBEWVZR82KHdkM0D0MPv1xbpe7rNnfSCFfrfh69N7YbTnjMSu7puam0eidM9icKqJZ3qSGbnUj80iUaRdTRFaflJIGLIdwGWmnxjsGQnp26Sp/PbzzNmp0VX9sEhCdl5ytLK3Xv5mdmxrfUtER37Sxix2gpbaX7L1UCiHSP9r7DhhN379EdCSe2tHpnxriIfsN3OgyhaijuVWoUUUfPXnImhezXnXoD/SSTkWX16NSVKT3Yb/JciZLLrgqz75ZWsiWDbkUcBAKBmaXrxg4a0nrGUF86MmM4wG3sjNk0nNj3Dubp/vy27BgX8Vyb07U3UxVDmhdRzWNI0wbEkJ6dunKlx2OS/r9lnB5jaPigegT+Wed47xte/QdZCgSW5rEdjSGtf+tE3/9xx3/rZIGX4/BBfPcZo4f2aW+MS5Gb2tU3M+ThZqFmEUVv5vGimiZDhMPoBtQhPTx1ZUuPSjYXL2SzKxo+zujUI3iut4trv2nTHASWiXGkw4Z0MR0+24ChNJzwBw239/qtbku69mZe4RICjSKKSQiu32xmSNT3PlX/7NIhAtM2pDtSVylXeoiZQVdWj2pd4WOI29vDzQdNH8tEDm+Bw3Rf0vMNUWntZU/DyewZY90GGOZmlojb1453/xw3kAZ6cOoqUo1cBe5aJtKZXfV5z34EP3FS79dVbWvB2516Zg1rCPcRho6e4U7DiaPXAoMY0i4Jt7Yr6lfK8fD36NSVLT3qRPt9kmVa9ZjSe9Jg/gT7t5ql83F8P2JshnDXObi3fT9r1xGTfs1w0kFDwvb5+M9DktXDU1cmtwqyNJ/3rw/bHnONHTt9kPnwPLchmpvdYolxGsLRK2K0dyLfZZaj3zvdedOx5LURpK5M6SE6flfWxo98h06b6OriPSrYEM+sYQ3hns+NuR5sOJnrhtWnjcWQbkhd286tZvp5zOa79/eKM+gzS7rhbDMj8mg4Gf+m43tT8BSagCGGSF0X/GbGeNeJjhG+3fTMdsPZhsTmeky0Np/Qf9TCtj5165wS9Fh+3dTVdmHeLOv/s3f+sWmcZxw/cxdIzo7TAHEAAwsEajA04FCwo9rJEhsTPKxhbIhnO06JSWOLJmFKNgWPaVq6Nuu2qkndpFXVTWv+KNI2VdOqqU0UNYqqKsvUdGo3ad1aZdVaaevWKNn6xzrtn91xB8aYw/w47gc8X8m+O/uOl3vf98N77/M+PA8e6I1v4rvP8lHazHgkZFVYA8G0r+Afq+wSSDioQ6V1zRgvxV0pM3R4Ack8ovRigxPupID6LA+l2abdpgSKJkzu+LJ1YpVtewAN5Azf9XqqSHqceA8bdcWtGpMOn8Gkw6b0Pa1C7LN8lDaTzgwnoch4ZiZWuD46oeri5DbteET4dcVnaZyIdiOxO6AdCoeTuMc0hKJe02JqpY/NgCrM0X0mUQMQwqPy3UigHZjG13QwgK/w0/RpuJu5j+MOaBl+VOhGAu3ArAJff2U3h2UnPE3UMoKxfxRxIwFCSgBS8H0xXZrDwqPO5mkZYdg/GNxIgBBmQAq/cyzl0gi7ZGmaluHf/lGZGwkQQk/WVtkwpFzeqUPRLC3Ds/2jcjcSIKRBblUkb5dP+0d1biSV1kzzrEsBIfUojSf7Rw1uJCAghMvSeLB/1OhGAgJCuCyNB/uHvjY3EhAQwikh4rJ/gJqQkFIJxKggTPV8u7D0D4SIlpCv//k+KpAfEAJqYkJKJhDLhZUFQkBNPYYwJRCjUn8BIaBmJ4QhgRhCJaUAQkAwDymaQAyhEhsBISBWajeTo/Hld4uH5qg0GQwfhKxKIAaEgFgl5BvnZ/a+deJU0X9WmgyGG0IkayQQg6csEKuEEHAcvHVt809+e/8vspm3shniiTHk4FPndj5zgDYYsd2W6XBVL7BGAjGYqYNYJqTt5yfObz4xdyWXRT6bIZ4gZPdzV97/6bdogxHbbRnHQl3sdgaw9oLqMQ9p+eDRzYfO5jIA5zLEk4S8fbl/ZiNtMGK9LeUyacywic3OACuGILbHkF/vmf0QITPs5mWRp3OXEoQMf/L8yzfaaYMR621ps8hkCjQYZq8zCMPrRFj2D1DN8xAkQ0heFvllQl55TPLOyXnaYFRmacoKvjzTQv7SdAnnw3lsYbY/+9Mg9g8QS4TkZZFfJuRr13/32q0f0AYj9tvSSRAiNS4I6PHl6I4LZ7M/4rR/gErJVwshy1nklwnZ9+a5nXPttMGI9bZcksoUg/aaOsO2Lz9I7WQ9Gct/zqovIbzZP0ClZMDQWEDptvdVXbtbayi94tKcMo1bgrBLSPlz9TrPQ3izf4BKqUdKNI0Ca9HERWB1WVLIzVW8ADnWzbWP/W2H7IffIb18X8wcr6d9fcu399aREF7tH6DSiJBBF3NhSYVNSM9CVS+w/oVjr52cP/rCsb1P7e8n/U8yx5V799aTEPbtH6DiGlvY+0noWNmZvBwjclVLXmjrRvRc7PjZxX7J7y8P920/8sfvbyQIoY4pX98tFfidcEIIH/aP2htSJNGAOhb2/ufqk4nf3H72dDmnb9IGE9iU3C/NS4/QiISMvT5PTsSP/FIV+4wk5HPqmPbTqsB3kRtCuLd/CKAh61ra4Q8OjC1sRB763yMPP/nvuZtnvrd9+Efn17xqOmXUWE09nQhizU+x05BjyOMX+5Gj/9h1/TFkd2YMoY6FRAi/9o9GJ2T9oS+uEg2871enj5y5uHHsu/PbOx6fL2m9XBgIoKoJNfVk5VuRpq3hCCEdezc/e+zqmfldT7e/c/KbB7a9dJo6pgkRxFOWiLuroG9w+E7vvfuOXNp54+Z7p8js8QQdW9t27e+X7N7POJ3rW+y24CHPcnLcdBfSyISQjr1jb+3YObfl4ZM7P/r7X64dfOPC55ljmhBBzNSBEPafHIgpx81LH018dn3DwfdOjb1+bWsHMXgQdCCHiancV4p78rQa/IPo5MCexmlLFt6uIKy9QqjVwlgwuYUjcd4gOeV4/91X/nT73HkCj7ZdF/uHL+3fSNLx0MdbkI7VMf7MaX1M443EJQ31acfG2xXCiqEQavX4Xw80ECEScsqx/tV/ffrFlQ9JPB549dM3//mldpIOZDUDthG5C3Mp7bYGaUt2326NXifiJoR0BHuEjo+0bgPt+JVZYb15RvbjBysr0lu0bE9grYtlshZcXfTNr3rFgLvcGySnHPs+fhQ5fus8cvjte3fv6C/fJQYOySo8JPGgF9Ppxx1ib0sxv10BE3Ji7ko2PtK6Ddm9zIpq5WOIrFjZM5bw2hc7DGh5txK2zJR5g+SEvO2/T+iff7odOX77BsM8c7rXqbH6DZ0N1+WAELYIOXS2LRsfad0Geo9aUa2YEHIpTxa1tKiR5JBiagmRKXFiX64vdkHSpXAl6TNIQtxo9iJ6mxySqrSZV1xxLqKXl3uD5JSj44783gGmE5LRAG7pXvRVVrucxmA2K4AQvgm5f0NHLj5SNlIStaJa3RhiCqtbEKfb7HYhMr2Z2LfGi11g1LeajPQZ5Cq5Kp29iN4a/Z2LKmpUyj8XiVvLvUFyyiFhmnb7MibdaBW5IyCPYdMR0paLj0RHSrpLrahWR4iZ3GBEn1cgslZyv3iPwsJIGKPPkCGtCWJ6QV9EbxUzuee2/HMzn6pl3iATHp0GvxV19i5VV7uQC7fpCEGW4yPRe9SK6raXTldBSGaD+bJ/lCEKJkJmFPQZxG8f7stdRG2xcD4huXMrIaToY8u4XoetbdItIU7ziQ15gBABELIcH4neo1ZYD75x4dsVEuKj+7HXZO7V0fvWoikcvcST09AyIUgwkruI2hKPVm4V9Yr55yLTg1VXp82udGEuub22VNk+TZyzluzBHUCIcN5m8ewR5RcpQxJSemfWJbV20ftyJZI3wGTNXbNTUt1sHiEOY+4iakvM161a6hXzz0WU+qpuUBKPeDUxfZqFSQTPeY0bkxAx2D8kf/jqlnrUzIylwJRa8illsaV0QZ14soov3g1MooN+A1tJ6/yqLk4a0o5HkKYhRAT2jwdOPNNfl5qJFqwYmkr2PnXpggIDFbbDqCdUhUm3tDxoQN1X30aUJD1GvAdpGkJEZv9gsWYkm5htSnVvhxn1hAoNRBdYv91wcAqV1vU7YlLclTIjzUOIyOwfdawZCSLhprTOHpNV40xNI00ukXz7kw/7hx4ddDm79ZGowb4UFuxnR11Kc4zIdVgiqN2EgMQi7u0fEvOCNu1OyScmEzFc0YKqdMaQKTigHpnuszUyITatcgibko84oNOJSzzbPxyj8RH1gNIf8uosGhlmiXkDfnnv4ng8aWavzw7b+CakK2XUxExpM/Q3EUpA9g+Jb3rEEA3qu41TKlSqwK1DkxPyiKfHPluWPdSWGhXiGLJnYBJVTRjC0NXEKqHaP1pn7T2eiH5icsiKK6SoasrYrQ9GDSPTPqY5dRyTm4VFSJ87hOPd7j7oZaA6y5yMjy/2yv0Bb8yCyTQWnTfkVxKTl67R/Od6eUFsWF4JCZMm3cmBWWg8ENey9U0Tk5egKWTUqdAWBR5LEE9jKXdau8eyMr44b4SY06aYxpjqgrYCCeApccluiEb03U7XICpdmaOCN0L0Q0qtDZoGJDg5V+Y5gjR0IFC+lqQrc+UBISDQiiGkIN8qEAIC5Q8hilAXr30WCAEJWl3hMvqst+BfBVGzKo6RldNWIAQkPsmY/0LtFEbNqjhGFhACEj8hmRhXiF2nQKOkIzR1SEXQIqNm1RQjCwgBiZuQMQlCx7hSqR1aDdmL6ZBXmQhaZNSsmmJkASEgcRNyhCCEinHlkxvxTHgGOuSVORs1q6YYWTBTB4n/KYuKcaXrTS9lCMmFvKKjZtUUIwsIAYmfECrGlULbNykjI13RIa+QbNSsmmJkASEgsRMio2NcpTA0komdRR0uR82qKUYWEAIS/xhSQquiZuWprBhZQAiooQlZFTUrT2XFyAJCQI1NiHhLA4GAEBAICAGBgBAQCAgBQkBACBACAkKAEBAQAoSAQEAICLRmnxVHlgoQSFwyGyYslglDJ9QECMSkpVQCcwXjUBEgEJMc46ZBtFs9AzUBAjEpOeDU6OR2SKwGAjHJZtfH0EnPKNQECMQknyeAWvUjENAdBGKSRKuc0jghZQ4IxKywuhu3+HsgZScIxKjpyBCWSE1DRYBATCJXFPFuNawogkCMmu01Yi6lVgI1AQIxyDFusqIhN6wogkCMGo1mVhTBDAwCMclml+v+3969hjQVBQAcP3PTufC1TFcmhmmGlksNTXMGYqhlmGallaX5BMtMBSuotHz0EBV6QPjqZWGlZUj2gJKiQir6EtS3iiAs6HOfu3dus9kW+KXs9v/BBc8RvHDhz7lnB1xA1E5OFAGn8mM3qMNDc5bxJAAnXAKzlmsWruBEEXBqvnyiuDGYE0XAqW0H92pWb+ZEEXBqUfQa+URx6nfzcnYC2OxIigrYan+imBPIYwEmLVkbFK7Oi0uzjvM1JALYv1bFx+WpS4IsJ4qz3EgEmMrbfKKYdECICK0viQAObJoXoU4Jne1LIoAzu7JS3LQkAjgT7Sv/Y0YSARwHotJqVb4at4DTPAvgF8Eadcm6ObFL43kUgANpPAIAAAAAAADMEFq+Eg74XSGKvh1AIQCFABQCUAiFgEIoBBRCIaAQCgEoBKAQgEIACgEoBKAQQKmFuLvqHP+iet/KjPV+kQu8KAQU4rSQPZ88KQQKL8TjxjlVS7fQ974IeytdA1dqYloazcMyqZCu98aK24bscaO2tV649w6ZR33Gq18LLGuIde6ZsWKsq4xCoLhCEp/fSW7r8NFXFT+Qr/Lh/uRLdbvlH01SIVWnrp3P9CnvrExuSzdZRkVnKu/W9lgLmZjTy3NPKASKK8QjoS5XJF7cry84JqTLY0u6p2joPCQP5besgsNC3+6XGh9S+u64p3nkOnBkxCSKbGvIxFzziMllkEKgvEL8r6s0Gk3FZX2YTkiXf3NTiCg8YR5a9iHu7X6lQ3NLvkmFyCPXgXujBtFg3alb504aRAZvWVDiGiItGqmLPS2F2NaQnwu5lfC4UayyFWK/hkzOsYZAifuQ6gv9yU+ljcREIaJ8+LN5H2JfSIfX69q63IkadNI+5ObRHrtCdJHSHPsQKLEQj4c1qtZ6YS3E3/JZlt1bVmFtzMcvH0YtNcifZY29tC8ke9x49nuYjkKguEIcMkzzr7q8uR8iBjN9KAT/RyHTVvSqe/ujJhOFgEIcSu0zxhTrBIWAQhzyNvzR2wH/WCEz5HYAhQAUAlAIQCEUAgqhEFAIhYBCKASgEIBCAAoBKAT4C4XwfeoAAAAAAAAAAAAAAAAAAEz1A5kWsPR/EkLjAAAAAElFTkSuQmCC\" alt=\"\" style=\"height: 297px; width: 801px;\"></p> <div class=\"note\"> <p><strong>Not to be confused with:</strong> Several other languages have mechanisms for lazy evaluation and deferring a computation, which they also call \"promises\", e.g. Scheme. Promises in JavaScript represent processes which are already happening, which can be chained with callback functions. If you are looking to lazily evaluate an expression, consider the <a href=\"../functions/arrow_functions\">arrow function</a> with no arguments: <code>f = () =&gt; <em>expression</em></code> to create the lazily-evaluated expression, and <code>f()</code> to evaluate.</p> </div> <div class=\"note\"> <p><strong>Note</strong>: A promise is said to be <em>settled</em> if it is either fulfilled or rejected, but not pending. You will also hear the term <em>resolved</em> used with promises — this means that the promise is settled or “locked in” to match the state of another promise. <a href=\"https://github.com/domenic/promises-unwrapping/blob/master/docs/states-and-fates.md\">States and fates</a> contains more details about promise terminology.</p> </div> <h2 id=\"Properties\">Properties</h2> <dl> <dt><code>Promise.length</code></dt> <dd>Length property whose value is always 1 (number of constructor arguments).</dd> <dt><a href=\"promise/prototype\"><code>Promise.prototype</code></a></dt> <dd>Represents the prototype for the <code>Promise</code> constructor.</dd> </dl> <h2 id=\"Methods\">Methods</h2> <dl> <dt><a href=\"promise/all\"><code>Promise.all(iterable)</code></a></dt> <dd>Returns a promise that either fulfills when all of the promises in the iterable argument have fulfilled or rejects as soon as one of the promises in the iterable argument rejects. If the returned promise fulfills, it is fulfilled with an array of the values from the fulfilled promises in the same order as defined in the iterable. If the returned promise rejects, it is rejected with the reason from the first promise in the iterable that rejected. This method can be useful for aggregating results of multiple promises.</dd> <dt><a href=\"promise/race\"><code>Promise.race(iterable)</code></a></dt> <dd>Returns a promise that fulfills or rejects as soon as one of the promises in the iterable fulfills or rejects, with the value or reason from that promise.</dd> <dt><a href=\"promise/reject\"><code>Promise.reject(reason)</code></a></dt> <dd>Returns a <code>Promise</code> object that is rejected with the given reason.</dd> <dt><a href=\"promise/resolve\"><code>Promise.resolve(value)</code></a></dt> <dd>Returns a <code>Promise</code> object that is resolved with the given value. If the value is a thenable (i.e. has a <code>then</code> method), the returned promise will \"follow\" that thenable, adopting its eventual state; otherwise the returned promise will be fulfilled with the value. Generally, if you don't know if a value is a promise or not, <a href=\"promise/resolve\"><code>Promise.resolve(value)</code></a> it instead and work with the return value as a promise.</dd> </dl> <h2 id=\"Promise_prototype\">Promise prototype</h2> <h3 id=\"Properties_2\">Properties</h3> <dl> <dt><code>Promise.prototype.constructor</code></dt> <dd>Returns the function that created an instance's prototype. This is the <a href=\"promise\"><code>Promise</code></a> function by default.</dd> </dl> <h3 id=\"Methods_2\">Methods</h3> <dl> <dt><a href=\"promise/catch\"><code>Promise.prototype.catch(onRejected)</code></a></dt> <dd>Appends a rejection handler callback to the promise, and returns a new promise resolving to the return value of the callback if it is called, or to its original fulfillment value if the promise is instead fulfilled.</dd> <dt><a href=\"promise/then\"><code>Promise.prototype.then(onFulfilled, onRejected)</code></a></dt> <dd>Appends fulfillment and rejection handlers to the promise, and returns a new promise resolving to the return value of the called handler, or to its original settled value if the promise was not handled (i.e. if the relevant handler <code>onFulfilled</code> or <code>onRejected</code> is not a function).</dd> <dt><a href=\"promise/finally\"><code>Promise.prototype.finally(onFinally)</code></a></dt> <dd>Appends a handler to the promise, and returns a new promise which is resolved when the original promise is resolved. The handler is called when the promise is settled, whether fulfilled or rejected.</dd> </dl> <h2 id=\"Creating_a_Promise\">Creating a Promise</h2> <p>A <code>Promise</code> object is created using the <code>new </code>keyword and its constructor. This constructor takes as its argument a function, called the \"executor function\". This function should take two functions as parameters. The first of these functions (<code>resolve</code>) is called when the asynchronous task completes successfully and returns the results of the task as a value. The second (<code>reject</code>) is called when the task fails, and returns the reason for failure, which is typically an error object.</p> <pre data-language=\"js\">const myFirstPromise = new Promise((resolve, reject) =&gt; {\n  // do something asynchronous which eventually calls either:\n  //\n  //   resolve(someValue); // fulfilled\n  // or\n  //   reject(\"failure reason\"); // rejected\n});\n</pre> <p>To provide a function with promise functionality, simply have it return a promise:</p> <pre data-language=\"js\">function myAsyncFunction(url) {\n  return new Promise((resolve, reject) =&gt; {\n    const xhr = new XMLHttpRequest();\n    xhr.open(\"GET\", url);\n    xhr.onload = () =&gt; resolve(xhr.responseText);\n    xhr.onerror = () =&gt; reject(xhr.statusText);\n    xhr.send();\n  });\n}</pre> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Basic_Example\">Basic Example</h3> <pre data-language=\"js\">let myFirstPromise = new Promise((resolve, reject) =&gt; {\n  // We call resolve(...) when what we were doing asynchronously was successful, and reject(...) when it failed.\n  // In this example, we use setTimeout(...) to simulate async code. \n  // In reality, you will probably be using something like XHR or an HTML5 API.\n  setTimeout(function(){\n    resolve(\"Success!\"); // Yay! Everything went well!\n  }, 250);\n});\n\nmyFirstPromise.then((successMessage) =&gt; {\n  // successMessage is whatever we passed in the resolve(...) function above.\n  // It doesn't have to be a string, but if it is only a succeed message, it probably will be.\n  console.log(\"Yay! \" + successMessage);\n});\n</pre> <h3 id=\"Advanced_Example\">Advanced Example</h3>  <p>This small example shows the mechanism of a <code>Promise</code>. The <code>testPromise()</code> method is called each time the <a href=\"https://developer.mozilla.org/en-US/docs/Web/HTML/Element/button\"><code>&lt;button&gt;</code></a> is clicked. It creates a promise that will be fulfilled, using <a href=\"https://developer.mozilla.org/en-US/docs/Web/API/Window/setTimeout\"><code>window.setTimeout()</code></a>, to the promise count (number starting from 1) every 1-3 seconds, at random. The <code>Promise()</code> constructor is used to create the promise.</p> <p>The fulfillment of the promise is simply logged, via a fulfill callback set using <a href=\"promise/then\"><code>p1.then()</code></a>. A few logs show how the synchronous part of the method is decoupled from the asynchronous completion of the promise.</p> <pre data-language=\"js\">'use strict';\nvar promiseCount = 0;\n\nfunction testPromise() {\n    let thisPromiseCount = ++promiseCount;\n\n    let log = document.getElementById('log');\n    log.insertAdjacentHTML('beforeend', thisPromiseCount +\n        ') Started (&lt;small&gt;Sync code started&lt;/small&gt;)&lt;br/&gt;');\n\n    // We make a new promise: we promise a numeric count of this promise, starting from 1 (after waiting 3s)\n    let p1 = new Promise(\n        // The executor function is called with the ability to resolve or\n        // reject the promise\n       (resolve, reject) =&gt; {\n            log.insertAdjacentHTML('beforeend', thisPromiseCount +\n                ') Promise started (&lt;small&gt;Async code started&lt;/small&gt;)&lt;br/&gt;');\n            // This is only an example to create asynchronism\n            window.setTimeout(\n                function() {\n                    // We fulfill the promise !\n                    resolve(thisPromiseCount);\n                }, Math.random() * 2000 + 1000);\n        }\n    );\n\n    // We define what to do when the promise is resolved with the then() call,\n    // and what to do when the promise is rejected with the catch() call\n    p1.then(\n        // Log the fulfillment value\n        function(val) {\n            log.insertAdjacentHTML('beforeend', val +\n                ') Promise fulfilled (&lt;small&gt;Async code terminated&lt;/small&gt;)&lt;br/&gt;');\n        }).catch(\n        // Log the rejection reason\n       (reason) =&gt; {\n            console.log('Handle rejected promise ('+reason+') here.');\n        });\n\n    log.insertAdjacentHTML('beforeend', thisPromiseCount +\n        ') Promise made (&lt;small&gt;Sync code terminated&lt;/small&gt;)&lt;br/&gt;');\n}</pre>  <p>This example is started by clicking the button. You need a browser that supports <code>Promise</code>. By clicking the button several times in a short amount of time, you'll even see the different promises being fulfilled one after another.</p> <p><iframe src=\"https://mdn.mozillademos.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise%24samples/Advanced_Example?revision=1435646\" height=\"200\" id=\"frame_Advanced_Example\" width=\"500\" frameborder=\"0\" class=\"live-sample-frame sample-code-frame\"></iframe></p> <h2 id=\"Loading_an_image_with_XHR\">Loading an image with XHR</h2> <p>Another simple example using <code>Promise</code> and <a href=\"https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest\"><code>XMLHttpRequest</code></a> to load an image is available at the MDN GitHub <a href=\"https://github.com/mdn/js-examples/tree/master/promises-test\">js-examples</a> repository. You can also <a href=\"https://mdn.github.io/js-examples/promises-test/\">see it in action</a>. Each step is commented and allows you to follow the Promise and XHR architecture closely.</p> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-promise-objects\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Promise' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition in an ECMA standard.</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-promise-objects\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Promise' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 32</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 29</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 19</td>\n<td class=\"bc-supports-yes\"> 8</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<code>Promise()</code> constructor</th>\n<td class=\"bc-supports-yes\"> 32</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes bc-has-history\"> 29\n<section class=\"bc-history\" id=\"sect1\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 29\n</dt>\n<dd> Constructor requires a new operator since version 37.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 19</td>\n<td class=\"bc-supports-yes bc-has-history\"> 8\n<section class=\"bc-history\" id=\"sect2\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 8\n</dt>\n<dd> Constructor requires a new operator since version 10.</dd>\n</dl></section>\n</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise/all\"><code>all</code></a></th>\n<td class=\"bc-supports-yes\"> 32</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 29</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 19</td>\n<td class=\"bc-supports-yes\"> 8</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise/prototype\"><code>prototype</code></a></th>\n<td class=\"bc-supports-yes\"> 32</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 29</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 19</td>\n<td class=\"bc-supports-yes\"> 8</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise/catch\"><code>catch</code></a></th>\n<td class=\"bc-supports-yes\"> 32</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 29</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 19</td>\n<td class=\"bc-supports-yes\"> 8</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise/finally\"><code>finally</code></a></th>\n<td class=\"bc-supports-yes\"> 63</td>\n<td class=\"bc-supports-yes\"> 18</td>\n<td class=\"bc-supports-yes\"> 58</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 50</td>\n<td class=\"bc-supports-yes\"> 11.1</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise/then\"><code>then</code></a></th>\n<td class=\"bc-supports-yes\"> 32</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 29</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 19</td>\n<td class=\"bc-supports-yes\"> 8</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise/race\"><code>race</code></a></th>\n<td class=\"bc-supports-yes\"> 32</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 29</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 19</td>\n<td class=\"bc-supports-yes\"> 8</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise/reject\"><code>reject</code></a></th>\n<td class=\"bc-supports-yes\"> 32</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 29</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 19</td>\n<td class=\"bc-supports-yes\"> 8</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise/resolve\"><code>resolve</code></a></th>\n<td class=\"bc-supports-yes\"> 32</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 29</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 19</td>\n<td class=\"bc-supports-yes\"> 8</td>\n</tr>\n</tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 4.4.3</td>\n<td class=\"bc-supports-yes\"> 32</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 29</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 8</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<code>Promise()</code> constructor</th>\n<td class=\"bc-supports-yes\"> 4.4.3</td>\n<td class=\"bc-supports-yes\"> 32</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes bc-has-history\"> 29\n<section class=\"bc-history\" id=\"sect3\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 29\n</dt>\n<dd> Constructor requires a new operator since version 37.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes bc-has-history\"> 8\n<section class=\"bc-history\" id=\"sect4\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 8\n</dt>\n<dd> Constructor requires a new operator since version 10.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise/all\"><code>all</code></a></th>\n<td class=\"bc-supports-yes\"> 4.4.3</td>\n<td class=\"bc-supports-yes\"> 32</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 29</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 8</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise/prototype\"><code>prototype</code></a></th>\n<td class=\"bc-supports-yes\"> 4.4.3</td>\n<td class=\"bc-supports-yes\"> 32</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 29</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 8</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise/catch\"><code>catch</code></a></th>\n<td class=\"bc-supports-yes\"> 4.4.3</td>\n<td class=\"bc-supports-yes\"> 32</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 29</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 8</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise/finally\"><code>finally</code></a></th>\n<td class=\"bc-supports-yes\"> 63</td>\n<td class=\"bc-supports-yes\"> 63</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 58</td>\n<td class=\"bc-supports-yes\"> 50</td>\n<td class=\"bc-supports-yes\"> 11.1</td>\n<td class=\"bc-supports-no\"> No</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise/then\"><code>then</code></a></th>\n<td class=\"bc-supports-yes\"> 4.4.3</td>\n<td class=\"bc-supports-yes\"> 32</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 29</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 8</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise/race\"><code>race</code></a></th>\n<td class=\"bc-supports-yes\"> 4.4.3</td>\n<td class=\"bc-supports-yes\"> 32</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 29</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 8</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise/reject\"><code>reject</code></a></th>\n<td class=\"bc-supports-yes\"> 4.4.3</td>\n<td class=\"bc-supports-yes\"> 32</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 29</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 8</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise/resolve\"><code>resolve</code></a></th>\n<td class=\"bc-supports-yes\"> 4.4.3</td>\n<td class=\"bc-supports-yes\"> 32</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 29</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 8</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n</tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 0.12</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<code>Promise()</code> constructor</th>\n<td class=\"bc-supports-yes bc-has-history\"> 0.12\n<section class=\"bc-history\" id=\"sect5\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 0.12\n</dt>\n<dd> Constructor requires a new operator since version 4.</dd>\n</dl></section>\n</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise/all\"><code>all</code></a></th>\n<td class=\"bc-supports-yes\"> 0.12</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise/prototype\"><code>prototype</code></a></th>\n<td class=\"bc-supports-yes\"> 0.12</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise/catch\"><code>catch</code></a></th>\n<td class=\"bc-supports-yes\"> 0.12</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise/finally\"><code>finally</code></a></th>\n<td class=\"bc-supports-yes\"> 10.0.0</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise/then\"><code>then</code></a></th>\n<td class=\"bc-supports-yes\"> 0.12</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise/race\"><code>race</code></a></th>\n<td class=\"bc-supports-yes\"> 0.12</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise/reject\"><code>reject</code></a></th>\n<td class=\"bc-supports-yes\"> 0.12</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise/resolve\"><code>resolve</code></a></th>\n<td class=\"bc-supports-yes\"> 0.12</td>\n</tr>\n</tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Using_promises\">Using promises</a></li> <li><a href=\"http://promisesaplus.com/\">Promises/A+ specification</a></li> <li><a href=\"https://medium.com/@ramsunvtech/promises-of-promise-part-1-53f769245a53\">Venkatraman.R - JS Promise (Part 1, Basics)</a></li> <li><a href=\"https://medium.com/@ramsunvtech/js-promise-part-2-q-js-when-js-and-rsvp-js-af596232525c#.dzlqh6ski\">Venkatraman.R - JS Promise (Part 2 - Using Q.js, When.js and RSVP.js)</a></li> <li><a href=\"https://tech.io/playgrounds/11107/tools-for-promises-unittesting/introduction\">Venkatraman.R - Tools for Promises Unit Testing</a></li> <li><a href=\"http://www.html5rocks.com/en/tutorials/es6/promises/\">Jake Archibald: JavaScript Promises: There and Back Again</a></li> <li><a href=\"http://de.slideshare.net/domenicdenicola/callbacks-promises-and-coroutines-oh-my-the-evolution-of-asynchronicity-in-javascript\">Domenic Denicola: Callbacks, Promises, and Coroutines – Asynchronous Programming Patterns in JavaScript</a></li> <li><a href=\"http://www.mattgreer.org/articles/promises-in-wicked-detail/\">Matt Greer: JavaScript Promises ... In Wicked Detail</a></li> <li><a href=\"https://www.promisejs.org/\">Forbes Lindesay: promisejs.org</a></li> <li><a href=\"https://github.com/jakearchibald/es6-promise/\">Promise polyfill</a></li> <li><a href=\"https://www.udacity.com/course/javascript-promises--ud898\">Udacity: JavaScript Promises</a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise</a>\n  </p>\n</div>\n","global_objects/number":"<h1>Number</h1> <p>The <code>Number</code> JavaScript object is a wrapper object allowing you to work with numerical values. A <code>Number</code> object is created using the <code>Number()</code> constructor.</p> <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\">new Number(value);</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><code>value</code></dt> <dd>The numeric value of the object being created.</dd> </dl> <h2 id=\"Description\">Description</h2> <p>The primary uses of the <code>Number</code> object are:</p> <ul> <li>If the argument cannot be converted into a number, it returns <a href=\"nan\"><code>NaN</code></a>.</li> <li>In a non-constructor context (i.e., without the <a href=\"../operators/new\"><code>new</code></a> operator), <code>Number</code> can be used to perform a type conversion.</li> </ul> <h2 id=\"Properties\">Properties</h2> <dl> <dt><a href=\"number/epsilon\"><code>Number.EPSILON</code></a></dt> <dd>The smallest interval between two representable numbers.</dd> <dt><a href=\"number/max_safe_integer\"><code>Number.MAX_SAFE_INTEGER</code></a></dt> <dd>The maximum safe integer in JavaScript (<code>2<sup>53</sup> - 1</code>).</dd> <dt><a href=\"number/max_value\"><code>Number.MAX_VALUE</code></a></dt> <dd>The largest positive representable number.</dd> <dt><a href=\"number/min_safe_integer\"><code>Number.MIN_SAFE_INTEGER</code></a></dt> <dd>The minimum safe integer in JavaScript (<code>-(2<sup>53</sup> - 1)</code>).</dd> <dt><a href=\"number/min_value\"><code>Number.MIN_VALUE</code></a></dt> <dd>The smallest positive representable number - that is, the positive number closest to zero (without actually being zero).</dd> <dt><a href=\"number/nan\"><code>Number.NaN</code></a></dt> <dd>Special \"not a number\" value.</dd> <dt><a href=\"number/negative_infinity\"><code>Number.NEGATIVE_INFINITY</code></a></dt> <dd>Special value representing negative infinity; returned on overflow.</dd> <dt><a href=\"number/positive_infinity\"><code>Number.POSITIVE_INFINITY</code></a></dt> <dd>Special value representing infinity; returned on overflow.</dd> <dt><a href=\"number/prototype\"><code>Number.prototype</code></a></dt> <dd>Allows the addition of properties to a <code>Number</code> object.</dd> </dl> <h2 id=\"Methods\">Methods</h2> <dl> <dt><a href=\"number/isnan\"><code>Number.isNaN()</code></a></dt> <dd>Determine whether the passed value is NaN.</dd> <dt><a href=\"number/isfinite\"><code>Number.isFinite()</code></a></dt> <dd>Determine whether the passed value is a finite number.</dd> <dt><a href=\"number/isinteger\"><code>Number.isInteger()</code></a></dt> <dd>Determine whether the passed value is an integer.</dd> <dt><a href=\"number/issafeinteger\"><code>Number.isSafeInteger()</code></a></dt> <dd>Determine whether the passed value is a safe integer (number between <code>-(2<sup>53</sup> - 1)</code> and <code>2<sup>53</sup> - 1</code>).</dd> <dt><s class=\"obsoleteElement\"><a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toInteger\"><code>Number.toInteger()</code></a> </s></dt> <dd><s class=\"obsoleteElement\">Used to evaluate the passed value and convert it to an integer (or <a href=\"infinity\"><code>Infinity</code></a>), but has been removed.</s></dd> <dt><a href=\"number/parsefloat\"><code>Number.parseFloat()</code></a></dt> <dd>The value is the same as <a href=\"parsefloat\"><code>parseFloat()</code></a> of the global object.</dd> <dt><a href=\"number/parseint\"><code>Number.parseInt()</code></a></dt> <dd>The value is the same as <a href=\"parseint\"><code>parseInt()</code></a> of the global object.</dd> </dl> <h2 id=\"Number_instances\">\n<code>Number</code> instances</h2> <p>All <code>Number</code> instances inherit from <a href=\"number/prototype\"><code>Number.prototype</code></a>. The prototype object of the <code>Number</code> constructor can be modified to affect all <code>Number</code> instances.</p> <h3 id=\"Methods_2\">Methods</h3> <dl> <dt><a href=\"number/toexponential\"><code>Number.prototype.toExponential()</code></a></dt> <dd>Returns a string representing the number in exponential notation.</dd> <dt><a href=\"number/tofixed\"><code>Number.prototype.toFixed()</code></a></dt> <dd>Returns a string representing the number in fixed-point notation.</dd> <dt><a href=\"number/tolocalestring\"><code>Number.prototype.toLocaleString()</code></a></dt> <dd>Returns a string with a language sensitive representation of this number. Overrides the <a href=\"object/tolocalestring\"><code>Object.prototype.toLocaleString()</code></a> method.</dd> <dt><a href=\"number/toprecision\"><code>Number.prototype.toPrecision()</code></a></dt> <dd>Returns a string representing the number to a specified precision in fixed-point or exponential notation.</dd> <dt>\n<a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toSource\"><code>Number.prototype.toSource()</code></a> \n</dt> <dd>Returns an object literal representing the specified <a href=\"number\"><code>Number</code></a> object; you can use this value to create a new object. Overrides the <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/toSource\"><code>Object.prototype.toSource()</code></a> method.</dd> <dt><a href=\"number/tostring\"><code>Number.prototype.toString()</code></a></dt> <dd>Returns a string representing the specified object in the specified radix (base). Overrides the <a href=\"object/tostring\"><code>Object.prototype.toString()</code></a> method.</dd> <dt><a href=\"number/valueof\"><code>Number.prototype.valueOf()</code></a></dt> <dd>Returns the primitive value of the specified object. Overrides the <a href=\"object/valueof\"><code>Object.prototype.valueOf()</code></a> method.</dd> </dl> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Using_the_Number_object_to_assign_values_to_numeric_variables\">Using the <code>Number</code> object to assign values to numeric variables</h3> <p>The following example uses the <code>Number</code> object's properties to assign values to several numeric variables:</p> <pre data-language=\"js\">var biggestNum = Number.MAX_VALUE;\nvar smallestNum = Number.MIN_VALUE;\nvar infiniteNum = Number.POSITIVE_INFINITY;\nvar negInfiniteNum = Number.NEGATIVE_INFINITY;\nvar notANum = Number.NaN;\n</pre> <h3 id=\"Integer_range_for_Number\">Integer range for <code>Number</code>\n</h3> <p>The following example shows the minimum and maximum integer values that can be represented as <code>Number</code> object (for details, refer to ECMAScript standard, chapter <em><a href=\"https://tc39.github.io/ecma262/#sec-ecmascript-language-types-number-type\">6.1.6 The Number Type</a></em>):</p> <pre data-language=\"js\">var biggestInt = 9007199254740991;\nvar smallestInt = -9007199254740991;\n</pre> <p>When parsing data that has been serialized to JSON, integer values falling out of this range can be expected to become corrupted when JSON parser coerces them to <code>Number</code> type. Using <a href=\"string\"><code>String</code></a> instead is a possible workaround.</p> <h3 id=\"Using_Number_to_convert_a_Date_object\">Using <code>Number</code> to convert a <code>Date</code> object</h3> <p>The following example converts the <a href=\"date\"><code>Date</code></a> object to a numerical value using <code>Number</code> as a function:</p> <pre data-language=\"js\">var d = new Date('December 17, 1995 03:24:00');\nconsole.log(Number(d));\n</pre> <p>This logs \"819199440000\".</p> <h3 id=\"Convert_numeric_strings_and_null_to_numbers\">Convert numeric strings and null to numbers</h3> <pre data-language=\"js\">Number('123')     // 123\nNumber('12.3')    // 12.3\nNumber('123e-1')  // 12.3\nNumber('')        // 0\nNumber(null)      // 0 \nNumber('0x11')    // 17\nNumber('0b11')    // 3\nNumber('0o11')    // 9\nNumber('foo')     // NaN\nNumber('100a')    // NaN\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/publications/files/ECMA-ST-ARCH/ECMA-262,%201st%20edition,%20June%201997.pdf\" hreflang=\"en\">ECMAScript 1st Edition (ECMA-262)</a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition. Implemented in JavaScript 1.1.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/5.1/#sec-15.7\" hreflang=\"en\">ECMAScript 5.1 (ECMA-262)<br><small>The definition of 'Number' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-number-objects\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Number' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>New methods and properties added: <a href=\"number/epsilon\"><code>EPSILON</code></a>, <a href=\"number/isfinite\"><code>isFinite</code></a>, <a href=\"number/isinteger\"><code>isInteger</code></a>, <a href=\"number/isnan\"><code>isNaN</code></a>, <a href=\"number/parsefloat\"><code>parseFloat</code></a>, <a href=\"number/parseint\"><code>parseInt</code></a>\n</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-number-objects\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Number' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number/EPSILON\"><code>EPSILON</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 25</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 9</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number/MAX_SAFE_INTEGER\"><code>MAX_SAFE_INTEGER</code></a></th>\n<td class=\"bc-supports-yes\"> 34</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 31</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 9</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number/MAX_VALUE\"><code>MAX_VALUE</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number/MIN_SAFE_INTEGER\"><code>MIN_SAFE_INTEGER</code></a></th>\n<td class=\"bc-supports-yes\"> 34</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 31</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 9</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number/MIN_VALUE\"><code>MIN_VALUE</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number/NEGATIVE_INFINITY\"><code>NEGATIVE_INFINITY</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number/NaN\"><code>NaN</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number/POSITIVE_INFINITY\"><code>POSITIVE_INFINITY</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number/isFinite\"><code>isFinite</code></a></th>\n<td class=\"bc-supports-yes\"> 19</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 16</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 15</td>\n<td class=\"bc-supports-yes\"> 9</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number/isInteger\"><code>isInteger</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 16</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number/isNaN\"><code>isNaN</code></a></th>\n<td class=\"bc-supports-yes\"> 25</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 15</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 9</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number/isSafeInteger\"><code>isSafeInteger</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 32</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 10</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number/parseFloat\"><code>parseFloat</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 25</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 9</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number/parseInt\"><code>parseInt</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 25</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 9</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number/prototype\"><code>prototype</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number/toExponential\"><code>toExponential</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number/toFixed\"><code>toFixed</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number/toInteger\"><code>toInteger</code></a> \n</th>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\">16 — 32</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number/toLocaleString\"><code>toLocaleString</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number/toPrecision\"><code>toPrecision</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number/toSource\"><code>toSource</code></a> \n</th>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number/toString\"><code>toString</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number/valueOf\"><code>valueOf</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n</tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number/EPSILON\"><code>EPSILON</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 25</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 9</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number/MAX_SAFE_INTEGER\"><code>MAX_SAFE_INTEGER</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 31</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 9</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number/MAX_VALUE\"><code>MAX_VALUE</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number/MIN_SAFE_INTEGER\"><code>MIN_SAFE_INTEGER</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 31</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 9</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number/MIN_VALUE\"><code>MIN_VALUE</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number/NEGATIVE_INFINITY\"><code>NEGATIVE_INFINITY</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number/NaN\"><code>NaN</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number/POSITIVE_INFINITY\"><code>POSITIVE_INFINITY</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number/isFinite\"><code>isFinite</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 16</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number/isInteger\"><code>isInteger</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 16</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number/isNaN\"><code>isNaN</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 15</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 9</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number/isSafeInteger\"><code>isSafeInteger</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 32</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number/parseFloat\"><code>parseFloat</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 25</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 9</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number/parseInt\"><code>parseInt</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 25</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 9</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number/prototype\"><code>prototype</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number/toExponential\"><code>toExponential</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number/toFixed\"><code>toFixed</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number/toInteger\"><code>toInteger</code></a> \n</th>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\">16 — 32</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number/toLocaleString\"><code>toLocaleString</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number/toPrecision\"><code>toPrecision</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number/toSource\"><code>toSource</code></a> \n</th>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number/toString\"><code>toString</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number/valueOf\"><code>valueOf</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n</tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number/EPSILON\"><code>EPSILON</code></a></th>\n<td class=\"bc-supports-yes\"> 0.12</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number/MAX_SAFE_INTEGER\"><code>MAX_SAFE_INTEGER</code></a></th>\n<td class=\"bc-supports-yes\"> 0.12</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number/MAX_VALUE\"><code>MAX_VALUE</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number/MIN_SAFE_INTEGER\"><code>MIN_SAFE_INTEGER</code></a></th>\n<td class=\"bc-supports-yes\"> 0.12</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number/MIN_VALUE\"><code>MIN_VALUE</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number/NEGATIVE_INFINITY\"><code>NEGATIVE_INFINITY</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number/NaN\"><code>NaN</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number/POSITIVE_INFINITY\"><code>POSITIVE_INFINITY</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number/isFinite\"><code>isFinite</code></a></th>\n<td class=\"bc-supports-yes\"> 0.10</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number/isInteger\"><code>isInteger</code></a></th>\n<td class=\"bc-supports-yes\"> 0.12</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number/isNaN\"><code>isNaN</code></a></th>\n<td class=\"bc-supports-yes\"> 0.10</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number/isSafeInteger\"><code>isSafeInteger</code></a></th>\n<td class=\"bc-supports-yes\"> 0.12</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number/parseFloat\"><code>parseFloat</code></a></th>\n<td class=\"bc-supports-yes\"> 0.12</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number/parseInt\"><code>parseInt</code></a></th>\n<td class=\"bc-supports-yes\"> 0.12</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number/prototype\"><code>prototype</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number/toExponential\"><code>toExponential</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number/toFixed\"><code>toFixed</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number/toInteger\"><code>toInteger</code></a> \n</th>\n<td class=\"bc-supports-no\"> No</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number/toLocaleString\"><code>toLocaleString</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number/toPrecision\"><code>toPrecision</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number/toSource\"><code>toSource</code></a> \n</th>\n<td class=\"bc-supports-no\"> No</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number/toString\"><code>toString</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number/valueOf\"><code>valueOf</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n</tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"nan\"><code>NaN</code></a></li> <li>The <a href=\"math\"><code>Math</code></a> global object</li> <li><a href=\"https://medium.com/@maximus.koretskyi/javascripts-number-type-8d59199db1b6#.9whwe88tz\">Number type in details</a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number</a>\n  </p>\n</div>\n","global_objects/uint8clampedarray":"<h1>Uint8ClampedArray</h1> <p>The <code>Uint8ClampedArray</code> typed array represents an array of 8-bit unsigned integers clamped to 0-255; if you specified a value that is out of the range of [0,255], 0 or 255 will be set instead; if you specify a non-integer, the nearest integer will be set. The contents are initialized to <code>0</code>. Once established, you can reference elements in the array using the object's methods, or using standard array index syntax (that is, using bracket notation).</p> <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\">new Uint8ClampedArray(); // new in ES2017\nnew Uint8ClampedArray(length);\nnew Uint8ClampedArray(typedArray);\nnew Uint8ClampedArray(object);\nnew Uint8ClampedArray(buffer [, byteOffset [, length]]);</pre> <p>For more information about the constructor syntax and the parameters, see <em><a href=\"typedarray#Syntax\">TypedArray</a></em>.</p> <h2 id=\"Properties\">Properties</h2> <dl> <dt><a href=\"typedarray/bytes_per_element\"><code>Uint8ClampedArray.BYTES_PER_ELEMENT</code></a></dt> <dd>Returns a number value of the element size. <code>1</code> in the case of an <code>Uint8ClampedArray</code>.</dd> <dt>Uint8ClampedArray.length</dt> <dd>Static length property whose value is 0. For the actual length (number of elements), see <a href=\"typedarray/length\"><code>Uint8ClampedArray.prototype.length</code></a>.</dd> <dt><a href=\"typedarray/name\"><code>Uint8ClampedArray.name</code></a></dt> <dd>Returns the string value of the constructor name. In the case of the <code>Uint8ClampedArray</code> type: \"Uint8ClampedArray\".</dd> <dt><a href=\"typedarray/prototype\"><code>Uint8ClampedArray.prototype</code></a></dt> <dd>Prototype for the <em>TypedArray</em> objects.</dd> </dl> <h2 id=\"Methods\">Methods</h2> <dl> <dt><a href=\"typedarray/from\"><code>Uint8ClampedArray.from()</code></a></dt> <dd>Creates a new <code>Uint8ClampedArray</code> from an array-like or iterable object. See also <a href=\"array/from\"><code>Array.from()</code></a>.</dd> <dt><a href=\"typedarray/of\"><code>Uint8ClampedArray.of()</code></a></dt> <dd>Creates a new <code>Uint8ClampedArray</code> with a variable number of arguments. See also <a href=\"array/of\"><code>Array.of()</code></a>.</dd> </dl> <h2 id=\"Uint8ClampedArray_prototype\">\n<code>Uint8ClampedArray</code> prototype</h2> <p>All <code>Uint8ClampedArray</code> objects inherit from <a href=\"typedarray/prototype\"><code>%TypedArray%.prototype</code></a>.</p> <h3 id=\"Properties_2\">Properties</h3> <dl> <dt><code>Uint8ClampedArray.prototype.constructor</code></dt> <dd>Returns the function that created an instance's prototype. This is the <code>Uint8ClampedArray</code> constructor by default.</dd> <dt>\n<a href=\"typedarray/buffer\"><code>Uint8ClampedArray.prototype.buffer</code></a> <span class=\"inlineIndicator readOnly readOnlyInline\">Read only </span>\n</dt> <dd>Returns the <a href=\"arraybuffer\"><code>ArrayBuffer</code></a> referenced by the <code>Uint8ClampedArray</code> Fixed at construction time and thus <strong>read only</strong>.</dd> <dt>\n<a href=\"typedarray/bytelength\"><code>Uint8ClampedArray.prototype.byteLength</code></a> <span class=\"inlineIndicator readOnly readOnlyInline\">Read only </span>\n</dt> <dd>Returns the length (in bytes) of the <code>Uint8ClampedArray</code> from the start of its <a href=\"arraybuffer\"><code>ArrayBuffer</code></a>. Fixed at construction time and thus <strong>read only.</strong>\n</dd> <dt>\n<a href=\"typedarray/byteoffset\"><code>Uint8ClampedArray.prototype.byteOffset</code></a> <span class=\"inlineIndicator readOnly readOnlyInline\">Read only </span>\n</dt> <dd>Returns the offset (in bytes) of the <code>Uint8ClampedArray</code> from the start of its <a href=\"arraybuffer\"><code>ArrayBuffer</code></a>. Fixed at construction time and thus <strong>read only.</strong>\n</dd> <dt>\n<a href=\"typedarray/length\"><code>Uint8ClampedArray.prototype.length</code></a> <span class=\"inlineIndicator readOnly readOnlyInline\">Read only </span>\n</dt> <dd>Returns the number of elements hold in the <code>UintClamped8Array</code>. Fixed at construction time and thus <strong>read only.</strong>\n</dd> </dl> <h3 id=\"Methods_2\">Methods</h3> <dl> <dt><a href=\"typedarray/copywithin\"><code>Uint8ClampedArray.prototype.copyWithin()</code></a></dt> <dd>Copies a sequence of array elements within the array. See also <a href=\"array/copywithin\"><code>Array.prototype.copyWithin()</code></a>.</dd> <dt><a href=\"typedarray/entries\"><code>Uint8ClampedArray.prototype.entries()</code></a></dt> <dd>Returns a new <code>Array Iterator</code> object that contains the key/value pairs for each index in the array. See also <a href=\"array/entries\"><code>Array.prototype.entries()</code></a>.</dd> <dt><a href=\"typedarray/every\"><code>Uint8ClampedArray.prototype.every()</code></a></dt> <dd>Tests whether all elements in the array pass the test provided by a function. See also <a href=\"array/every\"><code>Array.prototype.every()</code></a>.</dd> <dt><a href=\"typedarray/fill\"><code>Uint8ClampedArray.prototype.fill()</code></a></dt> <dd>Fills all the elements of an array from a start index to an end index with a static value. See also <a href=\"array/fill\"><code>Array.prototype.fill()</code></a>.</dd> <dt><a href=\"typedarray/filter\"><code>Uint8ClampedArray.prototype.filter()</code></a></dt> <dd>Creates a new array with all of the elements of this array for which the provided filtering function returns true. See also <a href=\"array/filter\"><code>Array.prototype.filter()</code></a>.</dd> <dt><a href=\"typedarray/find\"><code>Uint8ClampedArray.prototype.find()</code></a></dt> <dd>Returns the found value in the array, if an element in the array satisfies the provided testing function or <code>undefined</code> if not found. See also <a href=\"array/find\"><code>Array.prototype.find()</code></a>.</dd> <dt><a href=\"typedarray/findindex\"><code>Uint8ClampedArray.prototype.findIndex()</code></a></dt> <dd>Returns the found index in the array, if an element in the array satisfies the provided testing function or -1 if not found. See also <a href=\"array/findindex\"><code>Array.prototype.findIndex()</code></a>.</dd> <dt><a href=\"typedarray/foreach\"><code>Uint8ClampedArray.prototype.forEach()</code></a></dt> <dd>Calls a function for each element in the array. See also <a href=\"array/foreach\"><code>Array.prototype.forEach()</code></a>.</dd> <dt>\n<a href=\"typedarray/includes\"><code>Uint8ClampedArray.prototype.includes()</code></a> \n</dt> <dd>Determines whether a typed array includes a certain element, returning <code>true</code> or <code>false</code> as appropriate. See also <a href=\"array/includes\"><code>Array.prototype.includes()</code></a>.</dd> <dt><a href=\"typedarray/indexof\"><code>Uint8ClampedArray.prototype.indexOf()</code></a></dt> <dd>Returns the first (least) index of an element within the array equal to the specified value, or -1 if none is found. See also <a href=\"array/indexof\"><code>Array.prototype.indexOf()</code></a>.</dd> <dt><a href=\"typedarray/join\"><code>Uint8ClampedArray.prototype.join()</code></a></dt> <dd>Joins all elements of an array into a string. See also <a href=\"array/join\"><code>Array.prototype.join()</code></a>.</dd> <dt><a href=\"typedarray/keys\"><code>Uint8ClampedArray.prototype.keys()</code></a></dt> <dd>Returns a new <code>Array Iterator</code> that contains the keys for each index in the array. See also <a href=\"array/keys\"><code>Array.prototype.keys()</code></a>.</dd> <dt><a href=\"typedarray/lastindexof\"><code>Uint8ClampedArray.prototype.lastIndexOf()</code></a></dt> <dd>Returns the last (greatest) index of an element within the array equal to the specified value, or -1 if none is found. See also <a href=\"array/lastindexof\"><code>Array.prototype.lastIndexOf()</code></a>.</dd> <dt><a href=\"typedarray/map\"><code>Uint8ClampedArray.prototype.map()</code></a></dt> <dd>Creates a new array with the results of calling a provided function on every element in this array. See also <a href=\"array/map\"><code>Array.prototype.map()</code></a>.</dd> <dt>\n<a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/move\"><code>Uint8ClampedArray.prototype.move()</code></a>  <span class=\"inlineIndicator unimplemented unimplementedInline\">Unimplemented</span>\n</dt> <dd>Former non-standard version of <a href=\"typedarray/copywithin\"><code>Uint8ClampedArray.prototype.copyWithin()</code></a>.</dd> <dt><a href=\"typedarray/reduce\"><code>Uint8ClampedArray.prototype.reduce()</code></a></dt> <dd>Apply a function against an accumulator and each value of the array (from left-to-right) as to reduce it to a single value. See also <a href=\"array/reduce\"><code>Array.prototype.reduce()</code></a>.</dd> <dt><a href=\"typedarray/reduceright\"><code>Uint8ClampedArray.prototype.reduceRight()</code></a></dt> <dd>Apply a function against an accumulator and each value of the array (from right-to-left) as to reduce it to a single value. See also <a href=\"array/reduceright\"><code>Array.prototype.reduceRight()</code></a>.</dd> <dt><a href=\"typedarray/reverse\"><code>Uint8ClampedArray.prototype.reverse()</code></a></dt> <dd>Reverses the order of the elements of an array — the first becomes the last, and the last becomes the first. See also <a href=\"array/reverse\"><code>Array.prototype.reverse()</code></a>.</dd> <dt><a href=\"typedarray/set\"><code>Uint8ClampedArray.prototype.set()</code></a></dt> <dd>Stores multiple values in the typed array, reading input values from a specified array.</dd> <dt><a href=\"typedarray/slice\"><code>Uint8ClampedArray.prototype.slice()</code></a></dt> <dd>Extracts a section of an array and returns a new array. See also <a href=\"array/slice\"><code>Array.prototype.slice()</code></a>.</dd> <dt><a href=\"typedarray/some\"><code>Uint8ClampedArray.prototype.some()</code></a></dt> <dd>Returns true if at least one element in this array satisfies the provided testing function. See also <a href=\"array/some\"><code>Array.prototype.some()</code></a>.</dd> <dt><a href=\"typedarray/sort\"><code>Uint8ClampedArray.prototype.sort()</code></a></dt> <dd>Sorts the elements of an array in place and returns the array. See also <a href=\"array/sort\"><code>Array.prototype.sort()</code></a>.</dd> <dt><a href=\"typedarray/subarray\"><code>Uint8ClampedArray.prototype.subarray()</code></a></dt> <dd>Returns a new <code>Uint8ClampedArray</code> from the given start and end element index.</dd> <dt><a href=\"typedarray/values\"><code>Uint8ClampedArray.prototype.values()</code></a></dt> <dd>Returns a new <code>Array Iterator</code> object that contains the values for each index in the array. See also <a href=\"array/values\"><code>Array.prototype.values()</code></a>.</dd> <dt><a href=\"typedarray/tolocalestring\"><code>Uint8ClampedArray.prototype.toLocaleString()</code></a></dt> <dd>Returns a localized string representing the array and its elements. See also <a href=\"array/tolocalestring\"><code>Array.prototype.toLocaleString()</code></a>.</dd> <dt><a href=\"typedarray/tostring\"><code>Uint8ClampedArray.prototype.toString()</code></a></dt> <dd>Returns a string representing the array and its elements. See also <a href=\"array/tostring\"><code>Array.prototype.toString()</code></a>.</dd> <dt><a href=\"typedarray/@@iterator\"><code>Uint8ClampedArray.prototype[@@iterator]()</code></a></dt> <dd>Returns a new <code>Array Iterator</code> object that contains the values for each index in the array.</dd> </dl> <h2 id=\"Examples\">Examples</h2> <p>Different ways to create a <code>Uint8ClampedArray</code>:</p> <pre data-language=\"js\">// From a length\nvar uintc8 = new Uint8ClampedArray(2);\nuintc8[0] = 42;\nuintc8[1] = 1337;\nconsole.log(uintc8[0]); // 42\nconsole.log(uintc8[1]); // 255 (clamped)\nconsole.log(uintc8.length); // 2\nconsole.log(uintc8.BYTES_PER_ELEMENT); // 1\n\n// From an array\nvar arr = new Uint8ClampedArray([21,31]);\nconsole.log(arr[1]); // 31\n\n// From another TypedArray\nvar x = new Uint8ClampedArray([21, 31]);\nvar y = new Uint8ClampedArray(x);\nconsole.log(y[0]); // 21\n\n// From an ArrayBuffer\nvar buffer = new ArrayBuffer(8);\nvar z = new Uint8ClampedArray(buffer, 1, 4);\n\n// From an iterable \nvar iterable = function*(){ yield* [1,2,3]; }(); \nvar uintc8 = new Uint8ClampedArray(iterable); \n// Uint8ClampedArray[1, 2, 3]\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.khronos.org/registry/typedarray/specs/latest/\" hreflang=\"en\">Typed Array Specification</a></td> <td><span class=\"spec-Obsolete\">Obsolete</span></td> <td>Superseded by ECMAScript 2015.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#table-49\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'TypedArray constructors' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition in an ECMA standard. Specified that <code>new</code> is required.</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#table-49\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'TypedArray constructors' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td>ECMAScript 2017 changed the <code>Uint8ClampedArray</code> constructor to use the <code>ToIndex</code> operation and allows constructors with no arguments.</td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 7</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> 10</td>\n<td class=\"bc-supports-yes\"> 11.6</td>\n<td class=\"bc-supports-yes\"> 5.1</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<code>Uint8ClampedArray()</code> without <code>new</code> throws</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 44</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td> ? </td>\n</tr>\n<tr>\n<th scope=\"row\">Iterable in constructor</th>\n<td> ? </td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 52</td>\n<td> ? </td>\n<td> ? </td>\n<td> ? </td>\n</tr>\n<tr>\n<th scope=\"row\">Constructor without arguments</th>\n<td> ? </td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 55</td>\n<td> ? </td>\n<td> ? </td>\n<td> ? </td>\n</tr>\n</tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> 11.6</td>\n<td class=\"bc-supports-yes\"> 4.2</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<code>Uint8ClampedArray()</code> without <code>new</code> throws</th>\n<td> ? </td>\n<td> ? </td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 44</td>\n<td> ? </td>\n<td> ? </td>\n<td> ? </td>\n</tr>\n<tr>\n<th scope=\"row\">Iterable in constructor</th>\n<td> ? </td>\n<td> ? </td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 52</td>\n<td> ? </td>\n<td> ? </td>\n<td> ? </td>\n</tr>\n<tr>\n<th scope=\"row\">Constructor without arguments</th>\n<td> ? </td>\n<td> ? </td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 55</td>\n<td> ? </td>\n<td> ? </td>\n<td> ? </td>\n</tr>\n</tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 0.10</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<code>Uint8ClampedArray()</code> without <code>new</code> throws</th>\n<td class=\"bc-supports-yes\"> 0.12</td>\n</tr>\n<tr>\n<th scope=\"row\">Iterable in constructor</th>\n<td class=\"bc-supports-yes\"> 4.0.0</td>\n</tr>\n<tr>\n<th scope=\"row\">Constructor without arguments</th>\n<td> ? </td>\n</tr>\n</tbody>\n</table>\n</div> <h2 id=\"Compatibility_notes\">Compatibility notes</h2> <p>Starting with ECMAScript 2015, <code>Uint8ClampedArray</code> constructors require to be constructed with a <a href=\"../operators/new\"><code>new</code></a> operator. Calling a <code>Uint8ClampedArray</code> constructor as a function without <code>new</code>, will throw a <a href=\"typeerror\"><code>TypeError</code></a> from now on.</p> <pre data-language=\"js\">var dv = Uint8ClampedArray([1, 2, 3]);\n// TypeError: calling a builtin Uint8ClampedArray constructor\n// without new is forbidden</pre> <pre data-language=\"js\">var dv = new Uint8ClampedArray([1, 2, 3]);</pre> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Typed_arrays\">JavaScript typed arrays</a></li> <li><a href=\"arraybuffer\"><code>ArrayBuffer</code></a></li> <li><a href=\"dataview\"><code>DataView</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint8ClampedArray$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint8ClampedArray\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint8ClampedArray</a>\n  </p>\n</div>\n","global_objects/dataview":"<h1>DataView</h1> <p>The <code>DataView</code> view provides a low-level interface for reading and writing multiple number types in a binary <a href=\"arraybuffer\"><code>ArrayBuffer</code></a>, without having to care about the platform's <a href=\"https://developer.mozilla.org/en-US/docs/Glossary/Endianness\">endianness</a>.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/dataview-constructor.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\">new DataView(buffer [, byteOffset [, byteLength]])</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><code>buffer</code></dt> <dd>An existing <a href=\"arraybuffer\"><code>ArrayBuffer</code></a> or <a href=\"sharedarraybuffer\"><code>SharedArrayBuffer</code></a>  to use as the storage backing the new <code>DataView</code> object.</dd> <dt>\n<code>byteOffset</code> <span class=\"inlineIndicator optional optionalInline\">Optional</span>\n</dt> <dd>The offset, in bytes, to the first byte in the above buffer for the new view to reference. If unspecified, the buffer view starts with the first byte.</dd> <dt>\n<code>byteLength</code> <span class=\"inlineIndicator optional optionalInline\">Optional</span>\n</dt> <dd>The number of elements in the byte array. If unspecified, the view's length will match the buffer's length.</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p>A new <code>DataView</code> object representing the specified data buffer. (That probably wasn't a very helpful description.)</p> <p>You can think of the returned object as an \"interpreter\" of the array buffer of bytes — it knows how to convert numbers to fit within the buffer correctly, both when reading and writing to it. This means handling integer and float conversion, endianness, and other details of representing numbers in binary form.</p> <h3 id=\"Exceptions\">Exceptions</h3> <dl> <dt><code><a href=\"rangeerror\"><code>RangeError</code></a></code></dt> <dd> <p>Thrown if the <code>byteOffset</code> or <code>byteLength</code> parameter values result in the view extending past the end of the buffer.</p> <p>For example, if the buffer is 16 bytes long, the <code>byteOffset</code> is 8, and the <code>byteLength</code> is 10, this error is thrown because the resulting view tries to extend 2 bytes past the total length of the buffer.</p> </dd> </dl> <h2 id=\"Description\">Description</h2> <h3 id=\"Endianness\">Endianness</h3> <p>Multi-byte number formats are represented in memory differently depending on machine architecture — see <a href=\"https://developer.mozilla.org/en-US/docs/Glossary/Endianness\">Endianness</a> for an explanation. <code>DataView</code> accessors provide explicit control of how data is accessed, regardless of the executing computer's endianness.</p> <pre data-language=\"js\">var littleEndian = (function() {\n  var buffer = new ArrayBuffer(2);\n  new DataView(buffer).setInt16(0, 256, true /* littleEndian */);\n  // Int16Array uses the platform's endianness.\n  return new Int16Array(buffer)[0] === 256;\n})();\nconsole.log(littleEndian); // true or false\n</pre> <h3 id=\"64-bit_Integer_Values\">64-bit Integer Values</h3> <p>Because JavaScript does not currently include standard support for 64-bit integer values, <code>DataView</code> does not offer native 64-bit operations. As a workaround, you could implement your own getUint64() method to obtain a value with precision up to <a href=\"number/max_safe_integer\"><code>Number.MAX_SAFE_INTEGER</code></a>, which could suffice for certain cases.</p> <pre data-language=\"js\">DataView.prototype.getUint64 = function(byteOffset, littleEndian) {\n  // split 64-bit number into two 32-bit (4-byte) parts\n  const left =  this.getUint32(byteOffset, littleEndian);\n  const right = this.getUint32(byteOffset+4, littleEndian);\n\n  // combine the two 32-bit values\n  const combined = littleEndian? left + 2**32*right : 2**32*left + right;\n\n  if (!Number.isSafeInteger(combined))\n    console.warn(combined, 'exceeds MAX_SAFE_INTEGER. Precision may be lost');\n\n  return combined;\n}\n</pre>  <h2 id=\"Properties\">Properties</h2> <p>All <code>DataView</code> instances inherit from <a href=\"dataview/prototype\"><code>DataView.prototype</code></a> and allows the addition of properties to all DataView objects.</p> <dl> <dt><code>DataView.prototype.constructor</code></dt> <dd>Specifies the function that creates an object's prototype. The initial value is the standard built-in <code>DataView</code> constructor.</dd> <dt>\n<a href=\"dataview/buffer\"><code>DataView.prototype.buffer</code></a> <span class=\"inlineIndicator readOnly readOnlyInline\">Read only </span>\n</dt> <dd>The <a href=\"arraybuffer\"><code>ArrayBuffer</code></a> referenced by this view. Fixed at construction time and thus <strong>read only.</strong>\n</dd> <dt>\n<a href=\"dataview/bytelength\"><code>DataView.prototype.byteLength</code></a> <span class=\"inlineIndicator readOnly readOnlyInline\">Read only </span>\n</dt> <dd>The length (in bytes) of this view from the start of its <a href=\"arraybuffer\"><code>ArrayBuffer</code></a>. Fixed at construction time and thus <strong>read only.</strong>\n</dd> <dt>\n<a href=\"dataview/byteoffset\"><code>DataView.prototype.byteOffset</code></a> <span class=\"inlineIndicator readOnly readOnlyInline\">Read only </span>\n</dt> <dd>The offset (in bytes) of this view from the start of its <a href=\"arraybuffer\"><code>ArrayBuffer</code></a>. Fixed at construction time and thus <strong>read only.</strong>\n</dd> </dl> <h2 id=\"Methods\">Methods</h2> <h3 id=\"Read\">Read</h3> <dl> <dt><a href=\"dataview/getint8\"><code>DataView.prototype.getInt8()</code></a></dt> <dd>Gets a signed 8-bit integer (byte) at the specified byte offset from the start of the view.</dd> <dt><a href=\"dataview/getuint8\"><code>DataView.prototype.getUint8()</code></a></dt> <dd>Gets an unsigned 8-bit integer (unsigned byte) at the specified byte offset from the start of the view.</dd> <dt><a href=\"dataview/getint16\"><code>DataView.prototype.getInt16()</code></a></dt> <dd>Gets a signed 16-bit integer (short) at the specified byte offset from the start of the view.</dd> <dt><a href=\"dataview/getuint16\"><code>DataView.prototype.getUint16()</code></a></dt> <dd>Gets an unsigned 16-bit integer (unsigned short) at the specified byte offset from the start of the view.</dd> <dt><a href=\"dataview/getint32\"><code>DataView.prototype.getInt32()</code></a></dt> <dd>Gets a signed 32-bit integer (long) at the specified byte offset from the start of the view.</dd> <dt><a href=\"dataview/getuint32\"><code>DataView.prototype.getUint32()</code></a></dt> <dd>Gets an unsigned 32-bit integer (unsigned long) at the specified byte offset from the start of the view.</dd> <dt><a href=\"dataview/getfloat32\"><code>DataView.prototype.getFloat32()</code></a></dt> <dd>Gets a signed 32-bit float (float) at the specified byte offset from the start of the view.</dd> <dt><a href=\"dataview/getfloat64\"><code>DataView.prototype.getFloat64()</code></a></dt> <dd>Gets a signed 64-bit float (double) at the specified byte offset from the start of the view.</dd> </dl> <h3 id=\"Write\">Write</h3> <dl> <dt><a href=\"dataview/setint8\"><code>DataView.prototype.setInt8()</code></a></dt> <dd>Stores a signed 8-bit integer (byte) value at the specified byte offset from the start of the view.</dd> <dt><a href=\"dataview/setuint8\"><code>DataView.prototype.setUint8()</code></a></dt> <dd>Stores an unsigned 8-bit integer (unsigned byte) value at the specified byte offset from the start of the view.</dd> <dt><a href=\"dataview/setint16\"><code>DataView.prototype.setInt16()</code></a></dt> <dd>Stores a signed 16-bit integer (short) value at the specified byte offset from the start of the view.</dd> <dt><a href=\"dataview/setuint16\"><code>DataView.prototype.setUint16()</code></a></dt> <dd>Stores an unsigned 16-bit integer (unsigned short) value at the specified byte offset from the start of the view.</dd> <dt><a href=\"dataview/setint32\"><code>DataView.prototype.setInt32()</code></a></dt> <dd>Stores a signed 32-bit integer (long) value at the specified byte offset from the start of the view.</dd> <dt><a href=\"dataview/setuint32\"><code>DataView.prototype.setUint32()</code></a></dt> <dd>Stores an unsigned 32-bit integer (unsigned long) value at the specified byte offset from the start of the view.</dd> <dt><a href=\"dataview/setfloat32\"><code>DataView.prototype.setFloat32()</code></a></dt> <dd>Stores a signed 32-bit float (float) value at the specified byte offset from the start of the view.</dd> <dt><a href=\"dataview/setfloat64\"><code>DataView.prototype.setFloat64()</code></a></dt> <dd>Stores a signed 64-bit float (double) value at the specified byte offset from the start of the view.</dd> </dl> <h2 id=\"Example\">Example</h2> <pre data-language=\"js\">var buffer = new ArrayBuffer(16);\nvar view = new DataView(buffer, 0);\n\nview.setInt16(1, 42);\nview.getInt16(1); // 42\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.khronos.org/registry/typedarray/specs/latest/\" hreflang=\"en\">Typed Array Specification</a></td> <td><span class=\"spec-Obsolete\">Obsolete</span></td> <td>Superseded by ECMAScript 6</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-dataview-constructor\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'DataView' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition in an ECMA standard</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-dataview-constructor\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'DataView' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 9</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 15</td>\n<td class=\"bc-supports-yes\"> 10</td>\n<td class=\"bc-supports-yes\"> 12.1</td>\n<td class=\"bc-supports-yes\"> 5.1</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<code>DataView()</code> without <code>new</code> throws</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 40</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td> ? </td>\n</tr>\n<tr>\n<th scope=\"row\">\n<code>SharedArrayBuffer</code> accepted as buffer</th>\n<td class=\"bc-supports-yes\"> 60</td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 55</td>\n<td> ? </td>\n<td> ? </td>\n<td> ? </td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/DataView/buffer\"><code>buffer</code></a></th>\n<td class=\"bc-supports-yes\"> 9</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 15</td>\n<td class=\"bc-supports-yes\"> 10</td>\n<td class=\"bc-supports-yes\"> 12.1</td>\n<td class=\"bc-supports-yes\"> 5.1</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/DataView/byteLength\"><code>byteLength</code></a></th>\n<td class=\"bc-supports-yes\"> 9</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 15</td>\n<td class=\"bc-supports-yes\"> 10</td>\n<td class=\"bc-supports-yes\"> 12.1</td>\n<td class=\"bc-supports-yes\"> 5.1</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/DataView/byteOffset\"><code>byteOffset</code></a></th>\n<td class=\"bc-supports-yes\"> 9</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 15</td>\n<td class=\"bc-supports-yes\"> 10</td>\n<td class=\"bc-supports-yes\"> 12.1</td>\n<td class=\"bc-supports-yes\"> 5.1</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/DataView/getFloat32\"><code>getFloat32</code></a></th>\n<td class=\"bc-supports-yes\"> 9</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 15</td>\n<td class=\"bc-supports-yes\"> 10</td>\n<td class=\"bc-supports-yes\"> 12.1</td>\n<td class=\"bc-supports-yes\"> 5.1</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/DataView/getFloat64\"><code>getFloat64</code></a></th>\n<td class=\"bc-supports-yes\"> 9</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 15</td>\n<td class=\"bc-supports-yes\"> 10</td>\n<td class=\"bc-supports-yes\"> 12.1</td>\n<td class=\"bc-supports-yes\"> 5.1</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/DataView/getInt16\"><code>getInt16</code></a></th>\n<td class=\"bc-supports-yes\"> 9</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 15</td>\n<td class=\"bc-supports-yes\"> 10</td>\n<td class=\"bc-supports-yes\"> 12.1</td>\n<td class=\"bc-supports-yes\"> 5.1</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/DataView/getInt32\"><code>getInt32</code></a></th>\n<td class=\"bc-supports-yes\"> 9</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 15</td>\n<td class=\"bc-supports-yes\"> 10</td>\n<td class=\"bc-supports-yes\"> 12.1</td>\n<td class=\"bc-supports-yes\"> 5.1</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/DataView/getInt8\"><code>getInt8</code></a></th>\n<td class=\"bc-supports-yes\"> 9</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 15</td>\n<td class=\"bc-supports-yes\"> 10</td>\n<td class=\"bc-supports-yes\"> 12.1</td>\n<td class=\"bc-supports-yes\"> 5.1</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/DataView/getUint16\"><code>getUint16</code></a></th>\n<td class=\"bc-supports-yes\"> 9</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 15</td>\n<td class=\"bc-supports-yes\"> 10</td>\n<td class=\"bc-supports-yes\"> 12.1</td>\n<td class=\"bc-supports-yes\"> 5.1</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/DataView/getUint32\"><code>getUint32</code></a></th>\n<td class=\"bc-supports-yes\"> 9</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 15</td>\n<td class=\"bc-supports-yes\"> 10</td>\n<td class=\"bc-supports-yes\"> 12.1</td>\n<td class=\"bc-supports-yes\"> 5.1</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/DataView/getUint8\"><code>getUint8</code></a></th>\n<td class=\"bc-supports-yes\"> 9</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 15</td>\n<td class=\"bc-supports-yes\"> 10</td>\n<td class=\"bc-supports-yes\"> 12.1</td>\n<td class=\"bc-supports-yes\"> 5.1</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/DataView/setFloat32\"><code>setFloat32</code></a></th>\n<td class=\"bc-supports-yes\"> 9</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 15</td>\n<td class=\"bc-supports-yes\"> 10</td>\n<td class=\"bc-supports-yes\"> 12.1</td>\n<td class=\"bc-supports-yes\"> 5.1</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/DataView/setFloat64\"><code>setFloat64</code></a></th>\n<td class=\"bc-supports-yes\"> 9</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 15</td>\n<td class=\"bc-supports-yes\"> 10</td>\n<td class=\"bc-supports-yes\"> 12.1</td>\n<td class=\"bc-supports-yes\"> 5.1</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/DataView/setInt16\"><code>setInt16</code></a></th>\n<td class=\"bc-supports-yes\"> 9</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 15</td>\n<td class=\"bc-supports-yes\"> 10</td>\n<td class=\"bc-supports-yes\"> 12.1</td>\n<td class=\"bc-supports-yes\"> 5.1</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/DataView/setInt32\"><code>setInt32</code></a></th>\n<td class=\"bc-supports-yes\"> 9</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 15</td>\n<td class=\"bc-supports-yes\"> 10</td>\n<td class=\"bc-supports-yes\"> 12.1</td>\n<td class=\"bc-supports-yes\"> 5.1</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/DataView/setInt8\"><code>setInt8</code></a></th>\n<td class=\"bc-supports-yes\"> 9</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 15</td>\n<td class=\"bc-supports-yes\"> 10</td>\n<td class=\"bc-supports-yes\"> 12.1</td>\n<td class=\"bc-supports-yes\"> 5.1</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/DataView/setUint16\"><code>setUint16</code></a></th>\n<td class=\"bc-supports-yes\"> 9</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 15</td>\n<td class=\"bc-supports-yes\"> 10</td>\n<td class=\"bc-supports-yes\"> 12.1</td>\n<td class=\"bc-supports-yes\"> 5.1</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/DataView/setUint32\"><code>setUint32</code></a></th>\n<td class=\"bc-supports-yes\"> 9</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 15</td>\n<td class=\"bc-supports-yes\"> 10</td>\n<td class=\"bc-supports-yes\"> 12.1</td>\n<td class=\"bc-supports-yes\"> 5.1</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/DataView/setUint8\"><code>setUint8</code></a></th>\n<td class=\"bc-supports-yes\"> 9</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 15</td>\n<td class=\"bc-supports-yes\"> 10</td>\n<td class=\"bc-supports-yes\"> 12.1</td>\n<td class=\"bc-supports-yes\"> 5.1</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/DataView/prototype\"><code>prototype</code></a></th>\n<td class=\"bc-supports-yes\"> 9</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 15</td>\n<td class=\"bc-supports-yes\"> 10</td>\n<td class=\"bc-supports-yes\"> 12.1</td>\n<td class=\"bc-supports-yes\"> 5.1</td>\n</tr>\n</tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 15</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 4.2</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<code>DataView()</code> without <code>new</code> throws</th>\n<td> ? </td>\n<td> ? </td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 40</td>\n<td> ? </td>\n<td> ? </td>\n<td> ? </td>\n</tr>\n<tr>\n<th scope=\"row\">\n<code>SharedArrayBuffer</code> accepted as buffer</th>\n<td> ? </td>\n<td> ? </td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 55</td>\n<td> ? </td>\n<td> ? </td>\n<td> ? </td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/DataView/buffer\"><code>buffer</code></a></th>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 15</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 4.2</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/DataView/byteLength\"><code>byteLength</code></a></th>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 15</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 4.2</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/DataView/byteOffset\"><code>byteOffset</code></a></th>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 15</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 4.2</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/DataView/getFloat32\"><code>getFloat32</code></a></th>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 15</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 4.2</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/DataView/getFloat64\"><code>getFloat64</code></a></th>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 15</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 4.2</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/DataView/getInt16\"><code>getInt16</code></a></th>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 15</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 4.2</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/DataView/getInt32\"><code>getInt32</code></a></th>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 15</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 4.2</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/DataView/getInt8\"><code>getInt8</code></a></th>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 15</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 4.2</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/DataView/getUint16\"><code>getUint16</code></a></th>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 15</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 4.2</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/DataView/getUint32\"><code>getUint32</code></a></th>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 15</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 4.2</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/DataView/getUint8\"><code>getUint8</code></a></th>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 15</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 4.2</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/DataView/setFloat32\"><code>setFloat32</code></a></th>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 15</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 4.2</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/DataView/setFloat64\"><code>setFloat64</code></a></th>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 15</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 4.2</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/DataView/setInt16\"><code>setInt16</code></a></th>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 15</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 4.2</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/DataView/setInt32\"><code>setInt32</code></a></th>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 15</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 4.2</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/DataView/setInt8\"><code>setInt8</code></a></th>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 15</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 4.2</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/DataView/setUint16\"><code>setUint16</code></a></th>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 15</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 4.2</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/DataView/setUint32\"><code>setUint32</code></a></th>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 15</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 4.2</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/DataView/setUint8\"><code>setUint8</code></a></th>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 15</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 4.2</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/DataView/prototype\"><code>prototype</code></a></th>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 15</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 4.2</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n</tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<code>DataView()</code> without <code>new</code> throws</th>\n<td class=\"bc-supports-yes\"> 0.12</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<code>SharedArrayBuffer</code> accepted as buffer</th>\n<td> ? </td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/DataView/buffer\"><code>buffer</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/DataView/byteLength\"><code>byteLength</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/DataView/byteOffset\"><code>byteOffset</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/DataView/getFloat32\"><code>getFloat32</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/DataView/getFloat64\"><code>getFloat64</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/DataView/getInt16\"><code>getInt16</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/DataView/getInt32\"><code>getInt32</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/DataView/getInt8\"><code>getInt8</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/DataView/getUint16\"><code>getUint16</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/DataView/getUint32\"><code>getUint32</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/DataView/getUint8\"><code>getUint8</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/DataView/setFloat32\"><code>setFloat32</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/DataView/setFloat64\"><code>setFloat64</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/DataView/setInt16\"><code>setInt16</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/DataView/setInt32\"><code>setInt32</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/DataView/setInt8\"><code>setInt8</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/DataView/setUint16\"><code>setUint16</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/DataView/setUint32\"><code>setUint32</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/DataView/setUint8\"><code>setUint8</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/DataView/prototype\"><code>prototype</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n</tbody>\n</table>\n</div> <h2 id=\"Compatibility_notes\">Compatibility notes</h2> <p>Starting with Firefox 40, <code>DataView</code> must be constructed with the <a href=\"../operators/new\"><code>new</code></a> operator. Calling <code>DataView()</code> as a function without <code>new</code> will throw a <a href=\"typeerror\"><code>TypeError</code></a>.</p> <pre data-language=\"js\">var view = DataView(buffer, 0); \n// TypeError: calling a builtin DataView constructor without new is forbidden</pre> <pre data-language=\"js\">var view = new DataView(buffer, 0);</pre> <h2 id=\"See_also\">See also</h2> <ul> <li>\n<a href=\"https://github.com/jDataView/jDataView\" class=\"link-https\">jDataView</a>: JavaScript library that polyfills and extends the <code>DataView</code> API to all browsers and Node.js.</li> <li><a href=\"arraybuffer\"><code>ArrayBuffer</code></a></li> <li><a href=\"sharedarraybuffer\"><code>SharedArrayBuffer</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView</a>\n  </p>\n</div>\n","global_objects/weakmap":"<h1>WeakMap</h1> <p>The <code>WeakMap</code> object is a collection of key/value pairs in which the keys are weakly referenced. The keys must be objects and the values can be arbitrary values.</p> <p>You can learn more about <code>WeakMap</code>s in the section <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Keyed_collections#WeakMap_object\">WeakMap object</a> in <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Keyed_collections\">Keyed collections</a>.</p> <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\">new WeakMap([iterable])\n</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><code>iterable</code></dt> <dd>Iterable is an Array or other iterable object whose elements are key-value pairs (2-element Arrays). Each key-value pair will be added to the new WeakMap. null is treated as undefined.</dd> </dl> <h2 id=\"Description\">Description</h2> <p>Keys of WeakMaps are of the type <code>Object</code> only. <a href=\"https://developer.mozilla.org/en-US/docs/Glossary/Primitive\">Primitive data types</a> as keys are not allowed (e.g. a <a href=\"symbol\"><code>Symbol</code></a> can't be a <code>WeakMap</code> key).</p> <h3 id=\"Why_WeakMap\">Why <em>Weak</em>Map?</h3> <p>A map API could be implemented in JavaScript with two arrays (one for keys, one for values) shared by the four API methods. Setting elements on this map would involve pushing a key and value onto the end of each of those arrays simultaneously. As a result, the indices of the key and value would correspond to both arrays. Getting values from the map would involve iterating through all keys to find a match, then using the index of this match to retrieve the corresponding value from the array of values. </p> <p>Such an implementation would have two main inconveniences. The first one is an O(n) set and search (n being the number of keys in the map) since both operations must iterate through the list of keys to find a matching value. The second inconvenience is a memory leak because the arrays ensure that references to each key and each value are maintained indefinitely. These references prevent the keys from being garbage collected, even if there are no other references to the object. This would also prevent the corresponding values from being garbage collected.</p> <p>By contrast, native WeakMaps hold \"weak\" references to key objects, which means that they do not prevent garbage collection in case there would be no other reference to the key object. This also avoids preventing garbage collection of values in the map. Native WeakMaps can be particularly useful constructs when mapping keys to information about the key that is valuable only if the key has not been garbage collected.</p> <p>Because of references being weak, <code>WeakMap</code> keys are not enumerable (i.e. there is no method giving you a list of the keys). If they were, the list would depend on the state of garbage collection, introducing non-determinism. If you want to have a list of keys, you should use a <a href=\"map\"><code>Map</code></a>.</p> <h2 id=\"Properties\">Properties</h2> <dl> <dt><code>WeakMap.length</code></dt> <dd>The value of the <code>length</code> property is 0.</dd> <dt><a href=\"weakmap/prototype\"><code>WeakMap.prototype</code></a></dt> <dd>Represents the prototype for the <code>WeakMap</code> constructor. Allows the addition of properties to all <code>WeakMap</code> objects.</dd> </dl> <h2 id=\"WeakMap_instances\">\n<code>WeakMap</code> instances</h2> <p>All <code>WeakMap</code> instances inherit from <a href=\"weakmap/prototype\"><code>WeakMap.prototype</code></a>.</p> <h3 id=\"Properties_2\">Properties</h3> <dl> <dt><code>WeakMap.prototype.constructor</code></dt> <dd>Returns the function that created an instance's prototype. This is the <a href=\"weakmap\"><code>WeakMap</code></a> function by default.</dd> </dl> <h3 id=\"Methods\">Methods</h3> <dl> <dt><a href=\"weakmap/delete\"><code>WeakMap.prototype.delete(key)</code></a></dt> <dd>Removes any value associated to the <code>key</code>. <code>WeakMap.prototype.has(key)</code> will return <code>false</code> afterwards.</dd> <dt><a href=\"weakmap/get\"><code>WeakMap.prototype.get(key)</code></a></dt> <dd>Returns the value associated to the <code>key</code>, or <code>undefined</code> if there is none.</dd> <dt><a href=\"weakmap/has\"><code>WeakMap.prototype.has(key)</code></a></dt> <dd>Returns a Boolean asserting whether a value has been associated to the <code>key</code> in the <code>WeakMap</code> object or not.</dd> <dt><a href=\"weakmap/set\"><code>WeakMap.prototype.set(key, value)</code></a></dt> <dd>Sets the value for the <code>key</code> in the <code>WeakMap</code> object. Returns the <code>WeakMap</code> object.</dd> <dt><s class=\"obsoleteElement\"><a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WeakMap/clear\"><code>WeakMap.prototype.clear()</code></a> </s></dt> <dd><s class=\"obsoleteElement\">Removes all key/value pairs from the <code>WeakMap</code> object. Note that it is possible to implement a <code>WeakMap</code>-like object that has a <code>.clear()</code> method by encapsulating a <code>WeakMap</code> object that hasn't it (see example on page <a href=\"weakmap\"><code>WeakMap</code></a>)</s></dd> </dl> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Using_WeakMap\">Using <code>WeakMap</code>\n</h3> <pre data-language=\"js\">var wm1 = new WeakMap(),\n    wm2 = new WeakMap(),\n    wm3 = new WeakMap();\nvar o1 = {},\n    o2 = function() {},\n    o3 = window;\n\nwm1.set(o1, 37);\nwm1.set(o2, 'azerty');\nwm2.set(o1, o2); // a value can be anything, including an object or a function\nwm2.set(o3, undefined);\nwm2.set(wm1, wm2); // keys and values can be any objects. Even WeakMaps!\n\nwm1.get(o2); // \"azerty\"\nwm2.get(o2); // undefined, because there is no key for o2 on wm2\nwm2.get(o3); // undefined, because that is the set value\n\nwm1.has(o2); // true\nwm2.has(o2); // false\nwm2.has(o3); // true (even if the value itself is 'undefined')\n\nwm3.set(o1, 37);\nwm3.get(o1); // 37\n\nwm1.has(o1); // true\nwm1.delete(o1);\nwm1.has(o1); // false\n</pre> <h3 id=\"Implementing_a_WeakMap-like_class_with_a_.clear()_method\">Implementing a <code>WeakMap</code>-like class with a .clear() method</h3> <pre data-language=\"js\">class ClearableWeakMap {\n  constructor(init) {\n    this._wm = new WeakMap(init)\n  }\n  clear() {\n    this._wm = new WeakMap()\n  }\n  delete(k) {\n    return this._wm.delete(k)\n  }\n  get(k) {\n    return this._wm.get(k)\n  }\n  has(k) {\n    return this._wm.has(k)\n  }\n  set(k, v) {\n    this._wm.set(k, v)\n    return this\n  }\n}\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <thead> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> </thead> <tbody> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-weakmap-objects\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'WeakMap' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-weakmap-objects\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'WeakMap' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 36</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 6</td>\n<td class=\"bc-supports-yes\"> 11</td>\n<td class=\"bc-supports-yes\"> 23</td>\n<td class=\"bc-supports-yes\"> 8</td>\n</tr>\n<tr>\n<th scope=\"row\"><code>new WeakMap(iterable)</code></th>\n<td class=\"bc-supports-yes\"> 38</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 36</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 25</td>\n<td class=\"bc-supports-yes\"> 9</td>\n</tr>\n<tr>\n<th scope=\"row\"><code>new WeakMap(null)</code></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 37</td>\n<td class=\"bc-supports-yes\"> 11</td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 8</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<code>WeakMap()</code> without <code>new</code> throws</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 42</td>\n<td class=\"bc-supports-yes\"> 11</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 9</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/WeakMap/clear\"><code>clear</code></a> \n</th>\n<td class=\"bc-supports-no\">36 — 43</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\">20 — 46</td>\n<td class=\"bc-supports-yes\"> 11</td>\n<td class=\"bc-supports-no\">25 — 30</td>\n<td class=\"bc-supports-no\">8 — 9</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/WeakMap/delete\"><code>delete</code></a></th>\n<td class=\"bc-supports-yes\"> 36</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes bc-has-history\"> 6\n<section class=\"bc-history\" id=\"sect3\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 6\n</dt>\n<dd> Prior to Firefox 38, this method threw a <code>TypeError</code> when the key parameter was not an object. This has been fixed in version 38 and later to return <code>false</code> as per the ES2015 standard.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-yes\"> 11</td>\n<td class=\"bc-supports-yes\"> 23</td>\n<td class=\"bc-supports-yes\"> 8</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/WeakMap/get\"><code>get</code></a></th>\n<td class=\"bc-supports-yes\"> 36</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes bc-has-history\"> 6\n<section class=\"bc-history\" id=\"sect6\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 6\n</dt>\n<dd> Prior to Firefox 38, this method threw a <code>TypeError</code> when the key parameter was not an object. However, the ES2015 specification specifies to return <code>undefined</code> instead. Furthermore, <code>WeakMap.prototype.get</code> accepted an optional second argument as a fallback value, which is not part of the standard. Both non-standard behaviors are removed in version 38 and higher.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-yes\"> 11</td>\n<td class=\"bc-supports-yes\"> 23</td>\n<td class=\"bc-supports-yes\"> 8</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/WeakMap/has\"><code>has</code></a></th>\n<td class=\"bc-supports-yes\"> 36</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes bc-has-history\"> 6\n<section class=\"bc-history\" id=\"sect9\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 6\n</dt>\n<dd> Prior to Firefox 38, this method threw a <code>TypeError</code> when the key parameter was not an object. This has been fixed in version 38 and later to return <code>false</code> as per the ES2015 standard.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-yes\"> 11</td>\n<td class=\"bc-supports-yes\"> 23</td>\n<td class=\"bc-supports-yes\"> 8</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/WeakMap/prototype\"><code>prototype</code></a></th>\n<td class=\"bc-supports-yes\"> 36</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 6</td>\n<td class=\"bc-supports-yes\"> 11</td>\n<td class=\"bc-supports-yes\"> 23</td>\n<td class=\"bc-supports-yes\"> 8</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/WeakMap/set\"><code>set</code></a></th>\n<td class=\"bc-supports-yes\"> 36</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes bc-has-history\"> 6\n<section class=\"bc-history\" id=\"sect13\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 6\n</dt>\n<dd> Prior to Firefox 38, this method threw a <code>TypeError</code> when the key parameter was not an object. This has been fixed in version 38 and later to return <code>false</code> as per the ES2015 standard.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-partial bc-has-history\">11\n<section class=\"bc-history\" id=\"sect14\"><dl>\n<dt class=\"bc-supports-partial bc-supports\">11\n</dt>\n<dd> Returns 'undefined' instead of the 'Map' object.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-yes\"> 23</td>\n<td class=\"bc-supports-yes\"> 8</td>\n</tr>\n</tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 37</td>\n<td class=\"bc-supports-yes\"> 36</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 6</td>\n<td class=\"bc-supports-yes\"> 23</td>\n<td class=\"bc-supports-yes\"> 8</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><code>new WeakMap(iterable)</code></th>\n<td class=\"bc-supports-yes\"> 38</td>\n<td class=\"bc-supports-yes\"> 38</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 36</td>\n<td class=\"bc-supports-yes\"> 25</td>\n<td class=\"bc-supports-yes\"> 9</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><code>new WeakMap(null)</code></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 37</td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 8</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<code>WeakMap()</code> without <code>new</code> throws</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 42</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 9</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/WeakMap/clear\"><code>clear</code></a> \n</th>\n<td class=\"bc-supports-no\">37 — 43</td>\n<td class=\"bc-supports-no\">36 — 43</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\">20 — 46</td>\n<td class=\"bc-supports-no\">25 — 30</td>\n<td class=\"bc-supports-no\">8 — 9</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/WeakMap/delete\"><code>delete</code></a></th>\n<td class=\"bc-supports-yes\"> 37</td>\n<td class=\"bc-supports-yes\"> 36</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes bc-has-history\"> 6\n<section class=\"bc-history\" id=\"sect4\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 6\n</dt>\n<dd> Prior to Firefox 38, this method threw a <code>TypeError</code> when the key parameter was not an object. This has been fixed in version 38 and later to return <code>false</code> as per the ES2015 standard.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-yes\"> 23</td>\n<td class=\"bc-supports-yes\"> 8</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/WeakMap/get\"><code>get</code></a></th>\n<td class=\"bc-supports-yes\"> 37</td>\n<td class=\"bc-supports-yes\"> 36</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes bc-has-history\"> 6\n<section class=\"bc-history\" id=\"sect7\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 6\n</dt>\n<dd> Prior to Firefox 38, this method threw a <code>TypeError</code> when the key parameter was not an object. However, the ES2015 specification specifies to return <code>undefined</code> instead. Furthermore, <code>WeakMap.prototype.get</code> accepted an optional second argument as a fallback value, which is not part of the standard. Both non-standard behaviors are removed in version 38 and higher.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-yes\"> 23</td>\n<td class=\"bc-supports-yes\"> 8</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/WeakMap/has\"><code>has</code></a></th>\n<td class=\"bc-supports-yes\"> 37</td>\n<td class=\"bc-supports-yes\"> 36</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes bc-has-history\"> 6\n<section class=\"bc-history\" id=\"sect10\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 6\n</dt>\n<dd> Prior to Firefox 38, this method threw a <code>TypeError</code> when the key parameter was not an object. This has been fixed in version 38 and later to return <code>false</code> as per the ES2015 standard.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-yes\"> 23</td>\n<td class=\"bc-supports-yes\"> 8</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/WeakMap/prototype\"><code>prototype</code></a></th>\n<td class=\"bc-supports-yes\"> 37</td>\n<td class=\"bc-supports-yes\"> 36</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 6</td>\n<td class=\"bc-supports-yes\"> 23</td>\n<td class=\"bc-supports-yes\"> 8</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/WeakMap/set\"><code>set</code></a></th>\n<td class=\"bc-supports-yes\"> 37</td>\n<td class=\"bc-supports-yes\"> 36</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes bc-has-history\"> 6\n<section class=\"bc-history\" id=\"sect15\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 6\n</dt>\n<dd> Prior to Firefox 38, this method threw a <code>TypeError</code> when the key parameter was not an object. This has been fixed in version 38 and later to return <code>false</code> as per the ES2015 standard.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-yes\"> 23</td>\n<td class=\"bc-supports-yes\"> 8</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n</tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes bc-has-history\"> 0.12\n<section class=\"bc-history\" id=\"sect1\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 0.12\n</dt>\n\n<dt class=\"bc-supports-yes bc-supports\"> 0.10<div class=\"bc-icons\">Disabled </div>\n</dt>\n<dd>Disabled From version 0.10: this feature is behind the <code>--harmony</code> runtime flag.</dd>\n</dl></section>\n</td>\n</tr>\n<tr>\n<th scope=\"row\"><code>new WeakMap(iterable)</code></th>\n<td class=\"bc-supports-yes\"> 0.12</td>\n</tr>\n<tr>\n<th scope=\"row\"><code>new WeakMap(null)</code></th>\n<td class=\"bc-supports-yes bc-has-history\"> 0.12\n<section class=\"bc-history\" id=\"sect2\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 0.12\n</dt>\n\n<dt class=\"bc-supports-yes bc-supports\"> 0.10<div class=\"bc-icons\">Disabled </div>\n</dt>\n<dd>Disabled From version 0.10: this feature is behind the <code>--harmony</code> runtime flag.</dd>\n</dl></section>\n</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<code>WeakMap()</code> without <code>new</code> throws</th>\n<td class=\"bc-supports-yes\"> 0.12</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/WeakMap/clear\"><code>clear</code></a> \n</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/WeakMap/delete\"><code>delete</code></a></th>\n<td class=\"bc-supports-yes bc-has-history\"> 0.12\n<section class=\"bc-history\" id=\"sect5\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 0.12\n</dt>\n\n<dt class=\"bc-supports-yes bc-supports\"> 0.10<div class=\"bc-icons\">Disabled </div>\n</dt>\n<dd>Disabled From version 0.10: this feature is behind the <code>--harmony</code> runtime flag.</dd>\n</dl></section>\n</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/WeakMap/get\"><code>get</code></a></th>\n<td class=\"bc-supports-yes bc-has-history\"> 0.12\n<section class=\"bc-history\" id=\"sect8\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 0.12\n</dt>\n\n<dt class=\"bc-supports-yes bc-supports\"> 0.10<div class=\"bc-icons\">Disabled </div>\n</dt>\n<dd>Disabled From version 0.10: this feature is behind the <code>--harmony</code> runtime flag.</dd>\n</dl></section>\n</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/WeakMap/has\"><code>has</code></a></th>\n<td class=\"bc-supports-yes bc-has-history\"> 0.12\n<section class=\"bc-history\" id=\"sect11\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 0.12\n</dt>\n\n<dt class=\"bc-supports-yes bc-supports\"> 0.10<div class=\"bc-icons\">Disabled </div>\n</dt>\n<dd>Disabled From version 0.10: this feature is behind the <code>--harmony</code> runtime flag.</dd>\n</dl></section>\n</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/WeakMap/prototype\"><code>prototype</code></a></th>\n<td class=\"bc-supports-yes bc-has-history\"> 0.12\n<section class=\"bc-history\" id=\"sect12\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 0.12\n</dt>\n\n<dt class=\"bc-supports-yes bc-supports\"> 0.10<div class=\"bc-icons\">Disabled </div>\n</dt>\n<dd>Disabled From version 0.10: this feature is behind the <code>--harmony</code> runtime flag.</dd>\n</dl></section>\n</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/WeakMap/set\"><code>set</code></a></th>\n<td class=\"bc-supports-yes bc-has-history\"> 0.12\n<section class=\"bc-history\" id=\"sect16\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 0.12\n</dt>\n\n<dt class=\"bc-supports-yes bc-supports\"> 0.10<div class=\"bc-icons\">Disabled </div>\n</dt>\n<dd>Disabled From version 0.10: this feature is behind the <code>--harmony</code> runtime flag.</dd>\n</dl></section>\n</td>\n</tr>\n</tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Keyed_collections#WeakMap_object\"><code>WeakMap</code> in the JavaScript guide</a></li> <li><a href=\"http://fitzgeraldnick.com/weblog/53/\">Hiding Implementation Details with ECMAScript 6 WeakMaps</a></li> <li><a href=\"map\"><code>Map</code></a></li> <li><a href=\"set\"><code>Set</code></a></li> <li><a href=\"weakset\"><code>WeakSet</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WeakMap$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WeakMap\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WeakMap</a>\n  </p>\n</div>\n","global_objects/decodeuricomponent":"<h1>decodeURIComponent</h1> <p>The <code><strong>decodeURIComponent()</strong></code> function decodes a Uniform Resource Identifier (URI) component previously created by <a href=\"encodeuricomponent\"><code>encodeURIComponent</code></a> or by a similar routine.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/globalprops-decodeuricomponent.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\">decodeURIComponent(<em>encodedURI</em>)</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><code>encodedURI</code></dt> <dd>An encoded component of a Uniform Resource Identifier.</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p>A new string representing the decoded version of the given encoded Uniform Resource Identifier (URI) component.</p> <h3 id=\"Exceptions\">Exceptions</h3> <p>Throws an <a href=\"urierror\"><code>URIError</code></a> (\"malformed URI sequence\") exception when used wrongly.</p> <h2 id=\"Description\">Description</h2> <p>Replaces each escape sequence in the encoded URI component with the character that it represents.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Decoding_a_Cyrillic_URL_component\">Decoding a Cyrillic URL component</h3> <pre data-language=\"js\">decodeURIComponent('JavaScript_%D1%88%D0%B5%D0%BB%D0%BB%D1%8B');\n// \"JavaScript_шеллы\"\n</pre> <h3 id=\"Catching_errors\">Catching errors</h3> <pre data-language=\"js\">try { \n  var a = decodeURIComponent('%E0%A4%A'); \n} catch(e) { \n  console.error(e); \n}\n\n// URIError: malformed URI sequence</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/publications/files/ECMA-ST-ARCH/ECMA-262,%203rd%20edition,%20December%201999.pdf\" hreflang=\"en\">ECMAScript 3rd Edition (ECMA-262)</a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/5.1/#sec-15.1.3.2\" hreflang=\"en\">ECMAScript 5.1 (ECMA-262)<br><small>The definition of 'decodeURIComponent' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-decodeuricomponent-encodeduricomponent\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'decodeURIComponent' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-decodeuricomponent-encodeduricomponent\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'decodeURIComponent' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"decodeuri\"><code>decodeURI</code></a></li> <li><a href=\"encodeuri\"><code>encodeURI</code></a></li> <li><a href=\"encodeuricomponent\"><code>encodeURIComponent</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/decodeURIComponent$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/decodeURIComponent\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/decodeURIComponent</a>\n  </p>\n</div>\n","global_objects/weakset":"<h1>WeakSet</h1> <p>The <code>WeakSet</code> object lets you store weakly held <em>objects</em> in a collection.</p> <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\"> new WeakSet([iterable]);</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt>iterable</dt> <dd>If an <a href=\"../statements/for...of\">iterable object </a>is passed, all of its elements will be added to the new <code>WeakSet</code>. null is treated as undefined.</dd> </dl> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Using_the_WeakSet_object\">Using the WeakSet object</h3> <pre data-language=\"js\">var ws = new WeakSet();\nvar foo = {};\nvar bar = {};\n\nws.add(foo);\nws.add(bar);\n\nws.has(foo);    // true\nws.has(bar);    // true\n\nws.delete(foo); // removes foo from the set\nws.has(foo);    // false, foo has been removed\n</pre> <p>Note that <code>foo !== bar</code>. While they are similar objects, <em>they are not <strong>the same object</strong></em>. And so they are both added to the set.</p> <h2 id=\"Description\">Description</h2> <p><code>WeakSet</code> objects are collections of objects. An object in the <code>WeakSet</code> may occur only once; it is unique in the <code>WeakSet</code>'s collection.</p> <p>The main differences to the <a href=\"set\"><code>Set</code></a> object are:</p> <ul> <li>In contrast to <code>Sets</code>, <code>WeakSets</code> are <strong>collections of objects only</strong> and not of arbitrary values of any type.</li> <li>The <code>WeakSet</code> is <em>weak</em>: References to objects in the collection are held weakly. If there is no other reference to an object stored in the <code>WeakSet</code>, they can be garbage collected. That also means that there is no list of current objects stored in the collection. <code>WeakSets</code> are not enumerable.</li> </ul> <p>TODO describe usecases.</p> <h2 id=\"Properties\">Properties</h2> <dl> <dt><code>WeakSet.length</code></dt> <dd>The value of the <code>length</code> property is 0.</dd> <dt><a href=\"weakset/prototype\"><code>WeakSet.prototype</code></a></dt> <dd>Represents the prototype for the <code>WeakSet</code> constructor. Allows the addition of properties to all <code>WeakSet</code> objects.</dd> </dl> <h2 id=\"WeakSet_instances\">\n<code>WeakSet</code> instances</h2> <p>All <code>WeakSet</code> instances inherit from <a href=\"weakset/prototype\"><code>WeakSet.prototype</code></a>.</p> <h3 id=\"Properties_2\">Properties</h3> <dl> <dt><code>WeakSet.prototype.constructor</code></dt> <dd>Returns the function that created an instance's prototype. This is the <a href=\"weakset\"><code>WeakSet</code></a> function by default.</dd> </dl> <h3 id=\"Methods\">Methods</h3> <dl> <dt><a href=\"weakset/add\"><code>WeakSet.prototype.add(value)</code></a></dt> <dd>Appends a new object with the given value to the <code>WeakSet</code> object.</dd> <dt><a href=\"weakset/delete\"><code>WeakSet.prototype.delete(value)</code></a></dt> <dd>Removes the element associated to the <code>value</code>. <code>WeakSet.prototype.has(value)</code> will return <code>false</code> afterwards.</dd> <dt><a href=\"weakset/has\"><code>WeakSet.prototype.has(value)</code></a></dt> <dd>Returns a boolean asserting whether an element is present with the given value in the <code>WeakSet</code> object or not.</dd> <dt><s class=\"obsoleteElement\"><a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WeakSet/clear\"><code>WeakSet.prototype.clear()</code></a> </s></dt> <dd><s class=\"obsoleteElement\">Removes all elements from the <code>WeakSet</code> object.</s></dd> </dl> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-weakset-objects\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'WeakSet' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-weakset-objects\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'WeakSet' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 36</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 34</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 23</td>\n<td class=\"bc-supports-yes\"> 9</td>\n</tr>\n<tr>\n<th scope=\"row\"><code>new WeakSet(iterable)</code></th>\n<td class=\"bc-supports-yes\"> 38</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 34</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 25</td>\n<td class=\"bc-supports-yes\"> 9</td>\n</tr>\n<tr>\n<th scope=\"row\"><code>new WeakSet(null)</code></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 37</td>\n<td class=\"bc-supports-no\"> No</td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 9</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/WeakSet/add\"><code>add</code></a></th>\n<td class=\"bc-supports-yes\"> 36</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 34</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 23</td>\n<td class=\"bc-supports-yes\"> 9</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/WeakSet/clear\"><code>clear</code></a> \n</th>\n<td class=\"bc-supports-no\">36 — 43</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\">34 — 46</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\">25 — 30</td>\n<td class=\"bc-supports-no\"> No</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/WeakSet/delete\"><code>delete</code></a></th>\n<td class=\"bc-supports-yes\"> 36</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 34</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 23</td>\n<td class=\"bc-supports-yes\"> 9</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/WeakSet/has\"><code>has</code></a></th>\n<td class=\"bc-supports-yes\"> 36</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 34</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 23</td>\n<td class=\"bc-supports-yes\"> 9</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/WeakSet/prototype\"><code>prototype</code></a></th>\n<td class=\"bc-supports-yes\"> 36</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 34</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 23</td>\n<td class=\"bc-supports-yes\"> 9</td>\n</tr>\n</tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 37</td>\n<td class=\"bc-supports-yes\"> 36</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 34</td>\n<td class=\"bc-supports-yes\"> 23</td>\n<td class=\"bc-supports-yes\"> 9</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><code>new WeakSet(iterable)</code></th>\n<td class=\"bc-supports-yes\"> 38</td>\n<td class=\"bc-supports-yes\"> 38</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 34</td>\n<td class=\"bc-supports-yes\"> 25</td>\n<td class=\"bc-supports-yes\"> 9</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><code>new WeakSet(null)</code></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 37</td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 9</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/WeakSet/add\"><code>add</code></a></th>\n<td class=\"bc-supports-yes\"> 37</td>\n<td class=\"bc-supports-yes\"> 36</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 34</td>\n<td class=\"bc-supports-yes\"> 23</td>\n<td class=\"bc-supports-yes\"> 9</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/WeakSet/clear\"><code>clear</code></a> \n</th>\n<td class=\"bc-supports-no\">37 — 43</td>\n<td class=\"bc-supports-no\">36 — 43</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\">34 — 46</td>\n<td class=\"bc-supports-no\">25 — 30</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/WeakSet/delete\"><code>delete</code></a></th>\n<td class=\"bc-supports-yes\"> 37</td>\n<td class=\"bc-supports-yes\"> 36</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 34</td>\n<td class=\"bc-supports-yes\"> 23</td>\n<td class=\"bc-supports-yes\"> 9</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/WeakSet/has\"><code>has</code></a></th>\n<td class=\"bc-supports-yes\"> 37</td>\n<td class=\"bc-supports-yes\"> 36</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 34</td>\n<td class=\"bc-supports-yes\"> 23</td>\n<td class=\"bc-supports-yes\"> 9</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/WeakSet/prototype\"><code>prototype</code></a></th>\n<td class=\"bc-supports-yes\"> 37</td>\n<td class=\"bc-supports-yes\"> 36</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 34</td>\n<td class=\"bc-supports-yes\"> 23</td>\n<td class=\"bc-supports-yes\"> 9</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n</tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 0.12</td>\n</tr>\n<tr>\n<th scope=\"row\"><code>new WeakSet(iterable)</code></th>\n<td class=\"bc-supports-yes\"> 0.12</td>\n</tr>\n<tr>\n<th scope=\"row\"><code>new WeakSet(null)</code></th>\n<td class=\"bc-supports-yes\"> 0.12</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/WeakSet/add\"><code>add</code></a></th>\n<td class=\"bc-supports-yes\"> 0.12</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/WeakSet/clear\"><code>clear</code></a> \n</th>\n<td class=\"bc-supports-no\"> No</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/WeakSet/delete\"><code>delete</code></a></th>\n<td class=\"bc-supports-yes\"> 0.12</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/WeakSet/has\"><code>has</code></a></th>\n<td class=\"bc-supports-yes\"> 0.12</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/WeakSet/prototype\"><code>prototype</code></a></th>\n<td class=\"bc-supports-yes\"> 0.12</td>\n</tr>\n</tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"map\"><code>Map</code></a></li> <li><a href=\"set\"><code>Set</code></a></li> <li><a href=\"weakmap\"><code>WeakMap</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WeakSet$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WeakSet\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WeakSet</a>\n  </p>\n</div>\n","global_objects/null":"<h1>null</h1> <p>The value <code>null</code> represents the intentional absence of any object value. It is one of JavaScript's <a href=\"https://developer.mozilla.org/en-US/docs/Glossary/Primitive\">primitive values</a>.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/globalprops-null.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\">null</pre> <h2 id=\"Description\">Description</h2> <p>The value <code>null</code> is written with a literal: <code>null</code>. <code>null</code> is not an identifier for a property of the global object, like <a href=\"undefined\"><code>undefined</code></a> can be. Instead, <code>null</code> expresses a lack of identification, indicating that a variable points to no object. In APIs, <code>null</code> is often retrieved in a place where an object can be expected but no object is relevant. </p> <pre data-language=\"js\">// foo does not exist. It is not defined and has never been initialized:\nfoo;\n\"ReferenceError: foo is not defined\"\n\n// foo is known to exist now but it has no type or value:\nvar foo = null; \nfoo;\n\"null\"\n</pre> <h3 id=\"Difference_between_null_and_undefined\">Difference between <code>null</code> and <code>undefined</code>\n</h3> <p>When checking for <code>null</code> or <code>undefined</code>, beware of the <a href=\"../operators/comparison_operators\">differences between equality (==) and identity (===) operators</a>, as the former performs type-conversion.</p> <pre data-language=\"js\">typeof null          // \"object\" (not \"null\" for legacy reasons)\ntypeof undefined     // \"undefined\"\nnull === undefined   // false\nnull  == undefined   // true\nnull === null        // true\nnull == null         // true\n!null                // true\nisNaN(1 + null)      // false\nisNaN(1 + undefined) // true</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/publications/files/ECMA-ST-ARCH/ECMA-262,%201st%20edition,%20June%201997.pdf\" hreflang=\"en\">ECMAScript 1st Edition (ECMA-262)</a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/5.1/#sec-4.3.11\" hreflang=\"en\">ECMAScript 5.1 (ECMA-262)<br><small>The definition of 'null value' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-null-value\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'null value' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-null-value\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'null value' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"undefined\"><code>undefined</code></a></li> <li><a href=\"nan\"><code>NaN</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/null$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/null\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/null</a>\n  </p>\n</div>\n","global_objects/symbol":"<h1>Symbol</h1> <p>The <code>Symbol()</code> function returns a value of type <strong>symbol</strong>, has static properties that expose several members of built-in objects, has static methods that expose the global symbol registry, and resembles a built-in object class but is incomplete as a constructor because it does not support the syntax \"<code>new Symbol()</code>\". </p> <p>Every symbol value returned from <code>Symbol()</code> is unique. A symbol value may be used as an identifier for object properties; this is the data type's only purpose. Some further explanation about purpose and usage can be found in the <a href=\"https://developer.mozilla.org/en-US/docs/Glossary/Symbol\">glossary entry for Symbol</a>.</p> <p>The data type <strong>symbol</strong> is a <a href=\"https://developer.mozilla.org/en-US/docs/Glossary/Primitive\">primitive data type</a>.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/symbol-constructor.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\">Symbol(<em>[description]</em>)</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt>\n<code>description</code> <span class=\"inlineIndicator optional optionalInline\">Optional</span>\n</dt> <dd>Optional, string. A description of the symbol which can be used for debugging but not to access the symbol itself.</dd> </dl> <h2 id=\"Description\">Description</h2> <p>To create a new primitive symbol, you write <code>Symbol()</code> with an optional string as its description:</p> <pre data-language=\"js\">var sym1 = Symbol();\nvar sym2 = Symbol('foo');\nvar sym3 = Symbol('foo');\n</pre> <p>The above code creates three new symbols. Note that <code>Symbol(\"foo\")</code> does not coerce the string \"foo\" into a symbol. It creates a new symbol each time:</p> <pre data-language=\"js\">Symbol('foo') === Symbol('foo'); // false</pre> <p>The following syntax with the <a href=\"../operators/new\"><code>new</code></a> operator will throw a <a href=\"typeerror\"><code>TypeError</code></a>:</p> <pre data-language=\"js\">var sym = new Symbol(); // TypeError</pre> <p>This prevents authors from creating an explicit <code>Symbol</code> wrapper object instead of a new symbol value and might be surprising as creating explicit wrapper objects around primitive data types is generally possible (for example, <code>new Boolean</code>, <code>new String</code> and <code>new Number</code>).</p> <p>If you really want to create a <code>Symbol</code> wrapper object, you can use the <code>Object()</code> function:</p> <pre data-language=\"js\">var sym = Symbol('foo');\ntypeof sym;     // \"symbol\" \nvar symObj = Object(sym);\ntypeof symObj;  // \"object\"\n</pre> <h3 id=\"Shared_symbols_in_the_global_symbol_registry\">Shared symbols in the global symbol registry</h3> <p>The above syntax using the <code>Symbol()</code> function will not create a global symbol that is available in your whole codebase. To create symbols available across files and even across realms (each of which has its own global scope), use the methods <a href=\"symbol/for\"><code>Symbol.for()</code></a> and <a href=\"symbol/keyfor\"><code>Symbol.keyFor()</code></a> to set and retrieve symbols from the global symbol registry.</p> <h3 id=\"Finding_symbol_properties_on_objects\">Finding symbol properties on objects</h3> <p>The method <a href=\"object/getownpropertysymbols\"><code>Object.getOwnPropertySymbols()</code></a> returns an array of symbols and lets you find symbol properties on a given object. Note that every object is initialized with no own symbol properties, so that this array will be empty unless you've set symbol properties on the object.</p> <h2 id=\"Properties\">Properties</h2> <dl> <dt><code>Symbol.length</code></dt> <dd>Length property whose value is 0.</dd> <dt><a href=\"symbol/prototype\"><code>Symbol.prototype</code></a></dt> <dd>Represents the prototype for the <code>Symbol</code> constructor.</dd> </dl> <h3 id=\"Well-known_symbols\">Well-known symbols</h3> <p>In addition to your own symbols, JavaScript has some built-in symbols which represent internal language behaviors which were not exposed to developers in ECMAScript 5 and before. These symbols can be accessed using the following properties:</p> <h4 id=\"Iteration_symbols\">Iteration symbols</h4> <dl> <dt><a href=\"symbol/iterator\"><code>Symbol.iterator</code></a></dt> <dd>A method returning the default iterator for an object. Used by <a href=\"../statements/for...of\"><code>for...of</code></a>.</dd> <dt>\n<a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/asyncIterator\"><code>Symbol.asyncIterator</code></a> \n</dt> <dd>A method that returns the default AsyncIterator for an object. Used by <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/for-await-of\"><code>for await of</code></a>.</dd> </dl> <h4 id=\"Regular_expression_symbols\">Regular expression symbols</h4> <dl> <dt><a href=\"symbol/match\"><code>Symbol.match</code></a></dt> <dd>A method that matches against a string, also used to determine if an object may be used as a regular expression. Used by <a href=\"string/match\"><code>String.prototype.match()</code></a>.</dd> <dt><a href=\"symbol/replace\"><code>Symbol.replace</code></a></dt> <dd>A method that replaces matched substrings of a string. Used by <a href=\"string/replace\"><code>String.prototype.replace()</code></a>.</dd> <dt><a href=\"symbol/search\"><code>Symbol.search</code></a></dt> <dd>A method that returns the index within a string that matches the regular expression. Used by <a href=\"string/search\"><code>String.prototype.search()</code></a>.</dd> <dt><a href=\"symbol/split\"><code>Symbol.split</code></a></dt> <dd>A method that splits a string at the indices that match a regular expression. Used by <a href=\"string/split\"><code>String.prototype.split()</code></a>.</dd> </dl> <h4 id=\"Other_symbols\">Other symbols</h4> <dl> <dt><a href=\"symbol/hasinstance\"><code>Symbol.hasInstance</code></a></dt> <dd>A method determining if a constructor object recognizes an object as its instance. Used by <a href=\"../operators/instanceof\"><code>instanceof</code></a>.</dd> <dt><a href=\"symbol/isconcatspreadable\"><code>Symbol.isConcatSpreadable</code></a></dt> <dd>A Boolean value indicating if an object should be flattened to its array elements. Used by <a href=\"array/concat\"><code>Array.prototype.concat()</code></a>.</dd> <dt><a href=\"symbol/unscopables\"><code>Symbol.unscopables</code></a></dt> <dd>An object value of whose own and inherited property names are excluded from the <code><a href=\"../statements/with\">with</a></code> environment bindings of the associated object.</dd> <dt><a href=\"symbol/species\"><code>Symbol.species</code></a></dt> <dd>A constructor function that is used to create derived objects.</dd> <dt><a href=\"symbol/toprimitive\"><code>Symbol.toPrimitive</code></a></dt> <dd>A method converting an object to a primitive value.</dd> <dt><a href=\"symbol/tostringtag\"><code>Symbol.toStringTag</code></a></dt> <dd>A string value used for the default description of an object. Used by <a href=\"object/tostring\"><code>Object.prototype.toString()</code></a>.</dd> </dl> <h2 id=\"Methods\">Methods</h2> <dl> <dt><a href=\"symbol/for\"><code>Symbol.for(key)</code></a></dt> <dd>Searches for existing symbols with the given key and returns it if found. Otherwise a new symbol gets created in the global symbol registry with this key.</dd> <dt><a href=\"symbol/keyfor\"><code>Symbol.keyFor(sym)</code></a></dt> <dd>Retrieves a shared symbol key from the global symbol registry for the given symbol.</dd> </dl> <h2 id=\"Symbol_prototype\">\n<code>Symbol</code> prototype</h2> <p>All Symbols inherit from <a href=\"symbol/prototype\"><code>Symbol.prototype</code></a>.</p> <h3 id=\"Properties_2\">Properties</h3> <dl> <dt><code>Symbol.prototype.constructor</code></dt> <dd>Returns the function that created an instance's prototype. This is the <a href=\"symbol\"><code>Symbol</code></a> function by default.</dd> <dt><a href=\"symbol/description\"><code>Symbol.prototype.description</code></a></dt> <dd>A read-only string containing the description of the symbol.</dd> </dl> <h3 id=\"Methods_2\">Methods</h3> <dl> <dt>\n<a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/toSource\"><code>Symbol.prototype.toSource()</code></a> \n</dt> <dd>Returns a string containing the source of the <a href=\"symbol\"><code>Symbol</code></a> object. Overrides the <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/toSource\"><code>Object.prototype.toSource()</code></a> method.</dd> <dt><a href=\"symbol/tostring\"><code>Symbol.prototype.toString()</code></a></dt> <dd>Returns a string containing the description of the Symbol. Overrides the <a href=\"object/tostring\"><code>Object.prototype.toString()</code></a> method.</dd> <dt><a href=\"symbol/valueof\"><code>Symbol.prototype.valueOf()</code></a></dt> <dd>Returns the primitive value of the <a href=\"symbol\"><code>Symbol</code></a> object. Overrides the <a href=\"object/valueof\"><code>Object.prototype.valueOf()</code></a> method.</dd> <dt><a href=\"symbol/@@toprimitive\"><code>Symbol.prototype[@@toPrimitive]</code></a></dt> <dd>Returns the primitive value of the <a href=\"symbol\"><code>Symbol</code></a> object.</dd> </dl> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Using_the_typeof_operator_with_symbols\">Using the <code>typeof</code> operator with symbols</h3> <p>The <a href=\"../operators/typeof\"><code>typeof</code></a> operator can help you to identify symbols.</p> <pre data-language=\"js\">typeof Symbol() === 'symbol'\ntypeof Symbol('foo') === 'symbol'\ntypeof Symbol.iterator === 'symbol'\n</pre> <h3 id=\"Symbol_type_conversions\">Symbol type conversions</h3> <p>Some things to note when working with type conversion of symbols.</p> <ul> <li>When trying to convert a symbol to a number, a <a href=\"typeerror\"><code>TypeError</code></a> will be thrown<br> (e.g. <code>+sym</code> or <code>sym | 0</code>).</li> <li>When using loose equality, <code>Object(sym) == sym</code> returns <code>true.</code>\n</li> <li>\n<code>Symbol(\"foo\") + \"bar\" </code>throws a <a href=\"typeerror\"><code>TypeError</code></a> (can't convert symbol to string). This prevents you from silently creating a new string property name from a symbol, for example.</li> <li>The <a href=\"string#String_conversion\">\"safer\" <code>String(sym)</code> conversion</a> works like a call to <a href=\"symbol/tostring\"><code>Symbol.prototype.toString()</code></a> with symbols, but note that <code>new String(sym)</code> will throw.</li> </ul> <h3 id=\"Symbols_and_for...in_iteration\">Symbols and <code>for...in</code> iteration</h3> <p>Symbols are not enumerable in <a href=\"../statements/for...in\"><code>for...in</code></a> iterations. In addition, <a href=\"object/getownpropertynames\"><code>Object.getOwnPropertyNames()</code></a> will not return symbol object properties, however, you can use <a href=\"object/getownpropertysymbols\"><code>Object.getOwnPropertySymbols()</code></a> to get these.</p> <pre data-language=\"js\">var obj = {};\n\nobj[Symbol('a')] = 'a';\nobj[Symbol.for('b')] = 'b';\nobj['c'] = 'c';\nobj.d = 'd';\n\nfor (var i in obj) {\n   console.log(i); // logs \"c\" and \"d\"\n}</pre> <h3 id=\"Symbols_and_JSON.stringify()\">Symbols and <code>JSON.stringify()</code>\n</h3> <p>Symbol-keyed properties will be completely ignored when using <code>JSON.stringify()</code>:</p> <pre data-language=\"js\">JSON.stringify({[Symbol('foo')]: 'foo'});                 \n// '{}'</pre> <p>For more details, see <a href=\"json/stringify\"><code>JSON.stringify()</code></a>.</p> <h3 id=\"Symbol_wrapper_objects_as_property_keys\">Symbol wrapper objects as property keys</h3> <p>When a Symbol wrapper object is used as a property key, this object will be coerced to its wrapped symbol:</p> <pre data-language=\"js\">var sym = Symbol('foo');\nvar obj = {[sym]: 1};\nobj[sym];            // 1\nobj[Object(sym)];    // still 1\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-symbol-objects\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Symbol' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-symbol-objects\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Symbol' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 38</td>\n<td class=\"bc-supports-yes bc-has-history\"> 12\n<section class=\"bc-history\" id=\"sect1\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 12\n</dt>\n<dd> Edge 12 included Symbol properties in <code>JSON.stringify()</code> output.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-yes\"> 36</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 25</td>\n<td class=\"bc-supports-yes\"> 9</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<code>asyncIterator</code> \n</th>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no bc-has-history\"> No\n<section class=\"bc-history\" id=\"sect2\"><dl>\n<dt class=\"bc-supports-no bc-supports\"> No\n</dt>\n<dd> Available in Firefox Nightly.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Symbol/description\"><code>description</code></a></th>\n<td class=\"bc-supports-yes\"> 70</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 63</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 57</td>\n<td class=\"bc-supports-no\"> No</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Symbol/for\"><code>for</code></a></th>\n<td class=\"bc-supports-yes\"> 40</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 36</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 9</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Symbol/hasInstance\"><code>hasInstance</code></a></th>\n<td class=\"bc-supports-yes\"> 51</td>\n<td class=\"bc-supports-yes\"> 15</td>\n<td class=\"bc-supports-yes\"> 50</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Symbol/isConcatSpreadable\"><code>isConcatSpreadable</code></a></th>\n<td class=\"bc-supports-yes\"> 48</td>\n<td class=\"bc-supports-yes\"> 15</td>\n<td class=\"bc-supports-yes\"> 48</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Symbol/iterator\"><code>iterator</code></a></th>\n<td class=\"bc-supports-yes\"> 43</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 36</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 30</td>\n<td class=\"bc-supports-yes\"> 10</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Symbol/keyFor\"><code>keyFor</code></a></th>\n<td class=\"bc-supports-yes\"> 40</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 36</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 9</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Symbol/match\"><code>match</code></a></th>\n<td class=\"bc-supports-yes\"> 50</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 40</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Symbol/prototype\"><code>prototype</code></a></th>\n<td class=\"bc-supports-yes\"> 38</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 36</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 25</td>\n<td class=\"bc-supports-yes\"> 9</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Symbol/replace\"><code>replace</code></a></th>\n<td class=\"bc-supports-yes\"> 50</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 49</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Symbol/search\"><code>search</code></a></th>\n<td class=\"bc-supports-yes\"> 50</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 49</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Symbol/species\"><code>species</code></a></th>\n<td class=\"bc-supports-yes\"> 51</td>\n<td class=\"bc-supports-yes\"> 14</td>\n<td class=\"bc-supports-yes\"> 41</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 38</td>\n<td class=\"bc-supports-yes\"> 10</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Symbol/split\"><code>split</code></a></th>\n<td class=\"bc-supports-yes\"> 50</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 49</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Symbol/toPrimitive\"><code>toPrimitive</code></a></th>\n<td class=\"bc-supports-yes\"> 48</td>\n<td class=\"bc-supports-yes\"> 15</td>\n<td class=\"bc-supports-yes\"> 44</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Symbol/toSource\"><code>toSource</code></a> \n</th>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 36</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Symbol/toString\"><code>toString</code></a></th>\n<td class=\"bc-supports-yes\"> 38</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 36</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 25</td>\n<td class=\"bc-supports-yes\"> 9</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Symbol/toStringTag\"><code>toStringTag</code></a></th>\n<td class=\"bc-supports-yes\"> 49</td>\n<td class=\"bc-supports-yes\"> 15</td>\n<td class=\"bc-supports-yes\"> 51</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Symbol/unscopables\"><code>unscopables</code></a></th>\n<td class=\"bc-supports-yes\"> 38</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 48</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 9</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Symbol/valueOf\"><code>valueOf</code></a></th>\n<td class=\"bc-supports-yes\"> 38</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 36</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 25</td>\n<td class=\"bc-supports-yes\"> 9</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Symbol/@@toPrimitive\"><code>@@toPrimitive</code></a></th>\n<td> ? </td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 44</td>\n<td class=\"bc-supports-no\"> No</td>\n<td> ? </td>\n<td> ? </td>\n</tr>\n</tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 38</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 36</td>\n<td class=\"bc-supports-yes\"> 25</td>\n<td class=\"bc-supports-yes\"> 9</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<code>asyncIterator</code> \n</th>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Symbol/description\"><code>description</code></a></th>\n<td class=\"bc-supports-yes\"> 70</td>\n<td class=\"bc-supports-yes\"> 70</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 63</td>\n<td class=\"bc-supports-yes\"> 57</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Symbol/for\"><code>for</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 36</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 9</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Symbol/hasInstance\"><code>hasInstance</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 50</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Symbol/isConcatSpreadable\"><code>isConcatSpreadable</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 48</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Symbol/iterator\"><code>iterator</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 36</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 10</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Symbol/keyFor\"><code>keyFor</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 36</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 9</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Symbol/match\"><code>match</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 40</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Symbol/prototype\"><code>prototype</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 38</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 36</td>\n<td class=\"bc-supports-yes\"> 25</td>\n<td class=\"bc-supports-yes\"> 9</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Symbol/replace\"><code>replace</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 49</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Symbol/search\"><code>search</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 49</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Symbol/species\"><code>species</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 14</td>\n<td class=\"bc-supports-yes\"> 41</td>\n<td class=\"bc-supports-yes\"> 38</td>\n<td class=\"bc-supports-yes\"> 10</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Symbol/split\"><code>split</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 49</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Symbol/toPrimitive\"><code>toPrimitive</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 44</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Symbol/toSource\"><code>toSource</code></a> \n</th>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 36</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Symbol/toString\"><code>toString</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 38</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 36</td>\n<td class=\"bc-supports-yes\"> 25</td>\n<td class=\"bc-supports-yes\"> 9</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Symbol/toStringTag\"><code>toStringTag</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 51</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Symbol/unscopables\"><code>unscopables</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 48</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 9</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Symbol/valueOf\"><code>valueOf</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 38</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 36</td>\n<td class=\"bc-supports-yes\"> 25</td>\n<td class=\"bc-supports-yes\"> 9</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Symbol/@@toPrimitive\"><code>@@toPrimitive</code></a></th>\n<td> ? </td>\n<td> ? </td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 44</td>\n<td> ? </td>\n<td> ? </td>\n<td> ? </td>\n</tr>\n</tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<code>asyncIterator</code> \n</th>\n<td class=\"bc-supports-no\"> No</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Symbol/description\"><code>description</code></a></th>\n<td class=\"bc-supports-no\"> No</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Symbol/for\"><code>for</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Symbol/hasInstance\"><code>hasInstance</code></a></th>\n<td class=\"bc-supports-yes bc-has-history\"> 6.5.0\n<section class=\"bc-history\" id=\"sect3\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 6.5.0\n</dt>\n\n<dt class=\"bc-supports-yes bc-supports\"> 6.0.0<div class=\"bc-icons\">Disabled </div>\n</dt>\n<dd>Disabled From version 6.0.0: this feature is behind the <code>--harmony</code> runtime flag.</dd>\n</dl></section>\n</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Symbol/isConcatSpreadable\"><code>isConcatSpreadable</code></a></th>\n<td class=\"bc-supports-yes\"> 6.0.0</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Symbol/iterator\"><code>iterator</code></a></th>\n<td class=\"bc-supports-yes\"> 0.12</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Symbol/keyFor\"><code>keyFor</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Symbol/match\"><code>match</code></a></th>\n<td class=\"bc-supports-yes\"> 6.0.0</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Symbol/prototype\"><code>prototype</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Symbol/replace\"><code>replace</code></a></th>\n<td class=\"bc-supports-yes\"> 6.0.0</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Symbol/search\"><code>search</code></a></th>\n<td class=\"bc-supports-yes\"> 6.0.0</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Symbol/species\"><code>species</code></a></th>\n<td class=\"bc-supports-yes bc-has-history\"> 6.5.0\n<section class=\"bc-history\" id=\"sect4\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 6.5.0\n</dt>\n\n<dt class=\"bc-supports-yes bc-supports\"> 6.0.0<div class=\"bc-icons\">Disabled </div>\n</dt>\n<dd>Disabled From version 6.0.0: this feature is behind the <code>--harmony</code> runtime flag.</dd>\n</dl></section>\n</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Symbol/split\"><code>split</code></a></th>\n<td class=\"bc-supports-yes\"> 6.0.0</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Symbol/toPrimitive\"><code>toPrimitive</code></a></th>\n<td class=\"bc-supports-yes\"> 6.0.0</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Symbol/toSource\"><code>toSource</code></a> \n</th>\n<td class=\"bc-supports-no\"> No</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Symbol/toString\"><code>toString</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Symbol/toStringTag\"><code>toStringTag</code></a></th>\n<td class=\"bc-supports-yes bc-has-history\"> 6.0.0\n<section class=\"bc-history\" id=\"sect5\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 6.0.0\n</dt>\n\n<dt class=\"bc-supports-yes bc-supports\"> 4.0.0<div class=\"bc-icons\">Disabled </div>\n</dt>\n<dd>Disabled From version 4.0.0: this feature is behind the <code>--harmony</code> runtime flag.</dd>\n</dl></section>\n</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Symbol/unscopables\"><code>unscopables</code></a></th>\n<td class=\"bc-supports-yes\"> 0.12</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Symbol/valueOf\"><code>valueOf</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Symbol/@@toPrimitive\"><code>@@toPrimitive</code></a></th>\n<td> ? </td>\n</tr>\n</tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"https://developer.mozilla.org/en-US/docs/Glossary/Symbol\">Glossary: Symbol data type</a></li> <li><a href=\"../operators/typeof\"><code>typeof</code></a></li> <li><a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures\">Data types and data structures</a></li> <li><a href=\"https://hacks.mozilla.org/2015/06/es6-in-depth-symbols/\">\"ES6 In Depth: Symbols\" on hacks.mozilla.org</a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol</a>\n  </p>\n</div>\n","global_objects/decodeuri":"<h1>decodeURI</h1> <p>The <code><strong>decodeURI()</strong></code> function decodes a Uniform Resource Identifier (URI) previously created by <a href=\"encodeuri\"><code>encodeURI()</code></a> or by a similar routine.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/globalprops-decodeuri.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\">decodeURI(<em>encodedURI</em>)</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><code>encodedURI</code></dt> <dd>A complete, encoded Uniform Resource Identifier.</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p>A new string representing the unencoded version of the given encoded Uniform Resource Identifier (URI).</p> <h3 id=\"Exceptions\">Exceptions</h3> <p>Throws an <a href=\"urierror\"><code>URIError</code></a> (\"malformed URI sequence\") exception when <code><em>encodedURI</em></code> contains invalid character sequences.</p> <h2 id=\"Description\">Description</h2> <p>Replaces each escape sequence in the encoded URI with the character that it represents, but does not decode escape sequences that could not have been introduced by <a href=\"encodeuri\"><code>encodeURI</code></a>. The character “<code>#</code>” is not decoded from escape sequences.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Decoding_a_Cyrillic_URL\">Decoding a Cyrillic URL</h3> <pre data-language=\"js\">decodeURI('https://developer.mozilla.org/ru/docs/JavaScript_%D1%88%D0%B5%D0%BB%D0%BB%D1%8B');\n// \"https://developer.mozilla.org/ru/docs/JavaScript_шеллы\"\n</pre> <h3 id=\"Catching_errors\">Catching errors</h3> <pre>try { \n  var a = decodeURI('%E0%A4%A'); \n} catch(e) { \n  console.error(e); \n}\n\n// URIError: malformed URI sequence</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/publications/files/ECMA-ST-ARCH/ECMA-262,%203rd%20edition,%20December%201999.pdf\" hreflang=\"en\">ECMAScript 3rd Edition (ECMA-262)</a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/5.1/#sec-15.1.3.1\" hreflang=\"en\">ECMAScript 5.1 (ECMA-262)<br><small>The definition of 'decodeURI' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-decodeuri-encodeduri\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'decodeURI' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-decodeuri-encodeduri\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'decodeURI' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"decodeuricomponent\"><code>decodeURIComponent()</code></a></li> <li><a href=\"encodeuri\"><code>encodeURI()</code></a></li> <li><a href=\"encodeuricomponent\"><code>encodeURIComponent()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/decodeURI$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/decodeURI\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/decodeURI</a>\n  </p>\n</div>\n","global_objects/atomics":"<h1>Atomics</h1> <p>The <code>Atomics</code> object provides atomic operations as static methods. They are used with <a href=\"sharedarraybuffer\"><code>SharedArrayBuffer</code></a> objects.</p> <p>The Atomic operations are installed on an <code>Atomics</code> module. Unlike the other global objects, <code>Atomics</code> is not a constructor. You cannot use it with a <a href=\"../operators/new\"><code>new</code> operator</a> or invoke the <code>Atomics</code> object as a function. All properties and methods of <code>Atomics</code> are static (as is the case with the <a href=\"math\"><code>Math</code></a> object, for example).</p> <h2 id=\"Properties\">Properties</h2> <dl> <dt><code>Atomics[Symbol.toStringTag]</code></dt> <dd>The value of this property is \"Atomics\".</dd> </dl> <h2 id=\"Methods\">Methods</h2> <h3 id=\"Atomic_operations\">Atomic operations</h3> <p>When memory is shared, multiple threads can read and write the same data in memory. Atomic operations make sure that predictable values are written and read, that operations are finished before the next operation starts and that operations are not interrupted.</p> <dl> <dt><a href=\"atomics/add\"><code>Atomics.add()</code></a></dt> <dd>Adds the provided value to the existing value at the specified index of the array. Returns the old value at that index.</dd> <dt><a href=\"atomics/and\"><code>Atomics.and()</code></a></dt> <dd>Computes a bitwise AND on the value at the specified index of the array with the provided value. Returns the old value at that index.</dd> <dt><a href=\"atomics/compareexchange\"><code>Atomics.compareExchange()</code></a></dt> <dd>Stores a value at the specified index of the array, if it equals a value. Returns the old value.</dd> <dt><a href=\"atomics/exchange\"><code>Atomics.exchange()</code></a></dt> <dd>Stores a value at the specified index of the array. Returns the old value.</dd> </dl> <dl> <dt><a href=\"atomics/load\"><code>Atomics.load()</code></a></dt> <dd>Returns the value at the specified index of the array.</dd> <dt><a href=\"atomics/or\"><code>Atomics.or()</code></a></dt> <dd>Computes a bitwise OR on the value at the specified index of the array with the provided value. Returns the old value at that index.</dd> <dt><a href=\"atomics/store\"><code>Atomics.store()</code></a></dt> <dd>Stores a value at the specified index of the array. Returns the value.</dd> <dt><a href=\"atomics/sub\"><code>Atomics.sub()</code></a></dt> <dd>Subtracts a value at the specified index of the array. Returns the old value at that index.</dd> <dt><a href=\"atomics/xor\"><code>Atomics.xor()</code></a></dt> <dd>Computes a bitwise XOR on the value at the specified index of the array with the provided value. Returns the old value at that index.</dd> </dl> <h3 id=\"Wait_and_notify\">Wait and notify</h3> <p>The <code>wait()</code> and <code>notify()</code> methods are modeled on Linux futexes (\"fast user-space mutex\") and provide ways for waiting until a certain condition becomes true and are typically used as blocking constructs.</p> <dl> <dt><a href=\"atomics/wait\"><code>Atomics.wait()</code></a></dt> <dd> <p>Verifies that the specified index of the array still contains a value and sleeps awaiting or times out. Returns either <code>\"ok\"</code>, <code>\"not-equal\"</code>, or <code>\"timed-out\"</code>. If waiting is not allowed in the calling agent then it throws an Error exception (most browsers will not allow <code>wait()</code> on the browser's main thread).</p> </dd> <dt><a href=\"atomics/notify\"><code>Atomics.notify()</code></a></dt> <dd>Notifies agents that are waiting on the specified index of the array. Returns the number of agents that were notified.</dd> <dt><a href=\"atomics/islockfree\"><code>Atomics.isLockFree(size)</code></a></dt> <dd> <p>An optimization primitive that can be used to determine whether to use locks or atomic operations. Returns <code>true</code>, if an atomic operation on arrays of the given element size will be implemented using a hardware atomic operation (as opposed to a lock). Experts only.</p> </dd> </dl> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-atomics-object\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Atomics' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td>Initial definition in ES2017.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/8.0/#sec-atomics-object\" hreflang=\"en\">ECMAScript 2017 (ECMA-262)<br><small>The definition of 'Atomics' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes bc-has-history\"> 68\n<section class=\"bc-history\" id=\"sect1\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 68\n</dt>\n\n<dt class=\"bc-supports-no bc-supports\">60 — 63\n</dt>\n<dd> Chrome disabled <code>SharedArrayBuffer</code> on January 5, 2018 to help reduce the efficacy of <a href=\"https://www.chromium.org/Home/chromium-security/ssca\">speculative side-channel attacks</a>. This was a temporary removal while mitigations were put in place.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-no bc-has-history\"> No\n<section class=\"bc-history\" id=\"sect2\"><dl>\n<dt class=\"bc-supports-no bc-supports\"> No\n</dt>\n<dd> Support was removed to mitigate <a href=\"https://blogs.windows.com/msedgedev/2018/01/03/speculative-execution-mitigations-microsoft-edge-internet-explorer\">speculative execution side-channel attacks (Windows blog)</a>.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-yes bc-has-history\"> 57<div class=\"bc-icons\"> Disabled </div>\n<section class=\"bc-history\" id=\"sect3\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 57<div class=\"bc-icons\"> Disabled </div>\n</dt>\n<dd> Support was disabled by default to mitigate <a href=\"https://blog.mozilla.org/security/2018/01/03/mitigations-landing-new-class-timing-attack/\">speculative execution side-channel attacks (Mozilla Security Blog)</a>.</dd>\n<dd>Disabled From version 57: this feature is behind the <code>javascript.options.shared_memory</code> preference (needs to be set to <code>true</code>). To change preferences in Firefox, visit about:config.</dd>\n<dt class=\"bc-supports-no bc-supports\">55 — 57\n</dt>\n\n<dt class=\"bc-supports-no bc-supports\">46 — 55<div class=\"bc-icons\">Disabled </div>\n</dt>\n<dd>Disabled From version 46 until version 55 (exclusive): this feature is behind the <code>javascript.options.shared_memory</code> preference (needs to be set to <code>true</code>). To change preferences in Firefox, visit about:config.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\">10.1 — ?</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Atomics/add\"><code>add</code></a></th>\n<td class=\"bc-supports-yes bc-has-history\"> 68\n<section class=\"bc-history\" id=\"sect7\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 68\n</dt>\n\n<dt class=\"bc-supports-no bc-supports\">60 — 63\n</dt>\n<dd> Chrome disabled <code>SharedArrayBuffer</code> on January 5, 2018 to help reduce the efficacy of <a href=\"https://www.chromium.org/Home/chromium-security/ssca\">speculative side-channel attacks</a>. This was a temporary removal while mitigations were put in place.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-yes bc-has-history\"> 16\n<section class=\"bc-history\" id=\"sect8\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 16\n</dt>\n<dd> Support was removed to mitigate <a href=\"https://blogs.windows.com/msedgedev/2018/01/03/speculative-execution-mitigations-microsoft-edge-internet-explorer\">speculative execution side-channel attacks (Windows blog)</a>.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-yes bc-has-history\"> 57<div class=\"bc-icons\"> Disabled </div>\n<section class=\"bc-history\" id=\"sect9\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 57<div class=\"bc-icons\"> Disabled </div>\n</dt>\n<dd> Support was disabled by default to mitigate <a href=\"https://blog.mozilla.org/security/2018/01/03/mitigations-landing-new-class-timing-attack/\">speculative execution side-channel attacks (Mozilla Security Blog)</a>.</dd>\n<dd>Disabled From version 57: this feature is behind the <code>javascript.options.shared_memory</code> preference (needs to be set to <code>true</code>). To change preferences in Firefox, visit about:config.</dd>\n<dt class=\"bc-supports-no bc-supports\">55 — 57\n</dt>\n\n<dt class=\"bc-supports-no bc-supports\">46 — 55<div class=\"bc-icons\">Disabled </div>\n</dt>\n<dd>Disabled From version 46 until version 55 (exclusive): this feature is behind the <code>javascript.options.shared_memory</code> preference (needs to be set to <code>true</code>). To change preferences in Firefox, visit about:config.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\">10.1 — ?</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Atomics/and\"><code>and</code></a></th>\n<td class=\"bc-supports-yes bc-has-history\"> 68\n<section class=\"bc-history\" id=\"sect13\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 68\n</dt>\n\n<dt class=\"bc-supports-no bc-supports\">60 — 63\n</dt>\n<dd> Chrome disabled <code>SharedArrayBuffer</code> on January 5, 2018 to help reduce the efficacy of <a href=\"https://www.chromium.org/Home/chromium-security/ssca\">speculative side-channel attacks</a>. This was a temporary removal while mitigations were put in place.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-yes bc-has-history\"> 16\n<section class=\"bc-history\" id=\"sect14\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 16\n</dt>\n<dd> Support was removed to mitigate <a href=\"https://blogs.windows.com/msedgedev/2018/01/03/speculative-execution-mitigations-microsoft-edge-internet-explorer\">speculative execution side-channel attacks (Windows blog)</a>.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-yes bc-has-history\"> 57<div class=\"bc-icons\"> Disabled </div>\n<section class=\"bc-history\" id=\"sect15\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 57<div class=\"bc-icons\"> Disabled </div>\n</dt>\n<dd> Support was disabled by default to mitigate <a href=\"https://blog.mozilla.org/security/2018/01/03/mitigations-landing-new-class-timing-attack/\">speculative execution side-channel attacks (Mozilla Security Blog)</a>.</dd>\n<dd>Disabled From version 57: this feature is behind the <code>javascript.options.shared_memory</code> preference (needs to be set to <code>true</code>). To change preferences in Firefox, visit about:config.</dd>\n<dt class=\"bc-supports-no bc-supports\">55 — 57\n</dt>\n\n<dt class=\"bc-supports-no bc-supports\">46 — 55<div class=\"bc-icons\">Disabled </div>\n</dt>\n<dd>Disabled From version 46 until version 55 (exclusive): this feature is behind the <code>javascript.options.shared_memory</code> preference (needs to be set to <code>true</code>). To change preferences in Firefox, visit about:config.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\">10.1 — ?</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Atomics/compareExchange\"><code>compareExchange</code></a></th>\n<td class=\"bc-supports-yes bc-has-history\"> 68\n<section class=\"bc-history\" id=\"sect19\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 68\n</dt>\n\n<dt class=\"bc-supports-no bc-supports\">60 — 63\n</dt>\n<dd> Chrome disabled <code>SharedArrayBuffer</code> on January 5, 2018 to help reduce the efficacy of <a href=\"https://www.chromium.org/Home/chromium-security/ssca\">speculative side-channel attacks</a>. This was a temporary removal while mitigations were put in place.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-yes bc-has-history\"> 16\n<section class=\"bc-history\" id=\"sect20\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 16\n</dt>\n<dd> Support was removed to mitigate <a href=\"https://blogs.windows.com/msedgedev/2018/01/03/speculative-execution-mitigations-microsoft-edge-internet-explorer\">speculative execution side-channel attacks (Windows blog)</a>.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-yes bc-has-history\"> 57<div class=\"bc-icons\"> Disabled </div>\n<section class=\"bc-history\" id=\"sect21\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 57<div class=\"bc-icons\"> Disabled </div>\n</dt>\n<dd> Support was disabled by default to mitigate <a href=\"https://blog.mozilla.org/security/2018/01/03/mitigations-landing-new-class-timing-attack/\">speculative execution side-channel attacks (Mozilla Security Blog)</a>.</dd>\n<dd>Disabled From version 57: this feature is behind the <code>javascript.options.shared_memory</code> preference (needs to be set to <code>true</code>). To change preferences in Firefox, visit about:config.</dd>\n<dt class=\"bc-supports-no bc-supports\">55 — 57\n</dt>\n\n<dt class=\"bc-supports-no bc-supports\">46 — 55<div class=\"bc-icons\">Disabled </div>\n</dt>\n<dd>Disabled From version 46 until version 55 (exclusive): this feature is behind the <code>javascript.options.shared_memory</code> preference (needs to be set to <code>true</code>). To change preferences in Firefox, visit about:config.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\">10.1 — ?</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Atomics/exchange\"><code>exchange</code></a></th>\n<td class=\"bc-supports-yes bc-has-history\"> 68\n<section class=\"bc-history\" id=\"sect25\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 68\n</dt>\n\n<dt class=\"bc-supports-no bc-supports\">60 — 63\n</dt>\n<dd> Chrome disabled <code>SharedArrayBuffer</code> on January 5, 2018 to help reduce the efficacy of <a href=\"https://www.chromium.org/Home/chromium-security/ssca\">speculative side-channel attacks</a>. This was a temporary removal while mitigations were put in place.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-yes bc-has-history\"> 16\n<section class=\"bc-history\" id=\"sect26\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 16\n</dt>\n<dd> Support was removed to mitigate <a href=\"https://blogs.windows.com/msedgedev/2018/01/03/speculative-execution-mitigations-microsoft-edge-internet-explorer\">speculative execution side-channel attacks (Windows blog)</a>.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-yes bc-has-history\"> 57<div class=\"bc-icons\"> Disabled </div>\n<section class=\"bc-history\" id=\"sect27\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 57<div class=\"bc-icons\"> Disabled </div>\n</dt>\n<dd> Support was disabled by default to mitigate <a href=\"https://blog.mozilla.org/security/2018/01/03/mitigations-landing-new-class-timing-attack/\">speculative execution side-channel attacks (Mozilla Security Blog)</a>.</dd>\n<dd>Disabled From version 57: this feature is behind the <code>javascript.options.shared_memory</code> preference (needs to be set to <code>true</code>). To change preferences in Firefox, visit about:config.</dd>\n<dt class=\"bc-supports-no bc-supports\">55 — 57\n</dt>\n\n<dt class=\"bc-supports-no bc-supports\">46 — 55<div class=\"bc-icons\">Disabled </div>\n</dt>\n<dd>Disabled From version 46 until version 55 (exclusive): this feature is behind the <code>javascript.options.shared_memory</code> preference (needs to be set to <code>true</code>). To change preferences in Firefox, visit about:config.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\">10.1 — ?</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Atomics/isLockFree\"><code>isLockFree</code></a></th>\n<td class=\"bc-supports-yes bc-has-history\"> 68\n<section class=\"bc-history\" id=\"sect31\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 68\n</dt>\n\n<dt class=\"bc-supports-no bc-supports\">60 — 63\n</dt>\n<dd> Chrome disabled <code>SharedArrayBuffer</code> on January 5, 2018 to help reduce the efficacy of <a href=\"https://www.chromium.org/Home/chromium-security/ssca\">speculative side-channel attacks</a>. This was a temporary removal while mitigations were put in place.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-yes bc-has-history\"> 16\n<section class=\"bc-history\" id=\"sect32\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 16\n</dt>\n<dd> Support was removed to mitigate <a href=\"https://blogs.windows.com/msedgedev/2018/01/03/speculative-execution-mitigations-microsoft-edge-internet-explorer\">speculative execution side-channel attacks (Windows blog)</a>.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-yes bc-has-history\"> 57<div class=\"bc-icons\"> Disabled </div>\n<section class=\"bc-history\" id=\"sect33\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 57<div class=\"bc-icons\"> Disabled </div>\n</dt>\n<dd> Support was disabled by default to mitigate <a href=\"https://blog.mozilla.org/security/2018/01/03/mitigations-landing-new-class-timing-attack/\">speculative execution side-channel attacks (Mozilla Security Blog)</a>.</dd>\n<dd>Disabled From version 57: this feature is behind the <code>javascript.options.shared_memory</code> preference (needs to be set to <code>true</code>). To change preferences in Firefox, visit about:config.</dd>\n<dt class=\"bc-supports-no bc-supports\">55 — 57\n</dt>\n\n<dt class=\"bc-supports-no bc-supports\">46 — 55<div class=\"bc-icons\">Disabled </div>\n</dt>\n<dd>Disabled From version 46 until version 55 (exclusive): this feature is behind the <code>javascript.options.shared_memory</code> preference (needs to be set to <code>true</code>). To change preferences in Firefox, visit about:config.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\">10.1 — ?</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Atomics/load\"><code>load</code></a></th>\n<td class=\"bc-supports-yes bc-has-history\"> 68\n<section class=\"bc-history\" id=\"sect37\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 68\n</dt>\n\n<dt class=\"bc-supports-no bc-supports\">60 — 63\n</dt>\n<dd> Chrome disabled <code>SharedArrayBuffer</code> on January 5, 2018 to help reduce the efficacy of <a href=\"https://www.chromium.org/Home/chromium-security/ssca\">speculative side-channel attacks</a>. This was a temporary removal while mitigations were put in place.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-yes bc-has-history\"> 16\n<section class=\"bc-history\" id=\"sect38\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 16\n</dt>\n<dd> Support was removed to mitigate <a href=\"https://blogs.windows.com/msedgedev/2018/01/03/speculative-execution-mitigations-microsoft-edge-internet-explorer\">speculative execution side-channel attacks (Windows blog)</a>.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-yes bc-has-history\"> 57<div class=\"bc-icons\"> Disabled </div>\n<section class=\"bc-history\" id=\"sect39\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 57<div class=\"bc-icons\"> Disabled </div>\n</dt>\n<dd> Support was disabled by default to mitigate <a href=\"https://blog.mozilla.org/security/2018/01/03/mitigations-landing-new-class-timing-attack/\">speculative execution side-channel attacks (Mozilla Security Blog)</a>.</dd>\n<dd>Disabled From version 57: this feature is behind the <code>javascript.options.shared_memory</code> preference (needs to be set to <code>true</code>). To change preferences in Firefox, visit about:config.</dd>\n<dt class=\"bc-supports-no bc-supports\">55 — 57\n</dt>\n\n<dt class=\"bc-supports-no bc-supports\">46 — 55<div class=\"bc-icons\">Disabled </div>\n</dt>\n<dd>Disabled From version 46 until version 55 (exclusive): this feature is behind the <code>javascript.options.shared_memory</code> preference (needs to be set to <code>true</code>). To change preferences in Firefox, visit about:config.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\">10.1 — ?</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Atomics/notify\"><code>notify</code></a></th>\n<td class=\"bc-supports-yes bc-has-history\"> 68\n<section class=\"bc-history\" id=\"sect43\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 68\n</dt>\n\n<dt class=\"bc-supports-no bc-supports\">60 — 63\n</dt>\n<dd> Chrome disabled <code>SharedArrayBuffer</code> on January 5, 2018 to help reduce the efficacy of <a href=\"https://www.chromium.org/Home/chromium-security/ssca\">speculative side-channel attacks</a>. This was a temporary removal while mitigations were put in place.</dd>\n<dd> Uses the non-standard name: <code>wake</code>\n</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-yes bc-has-history\"> 16\n<section class=\"bc-history\" id=\"sect44\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 16\n</dt>\n<dd> Support was removed to mitigate <a href=\"https://blogs.windows.com/msedgedev/2018/01/03/speculative-execution-mitigations-microsoft-edge-internet-explorer\">speculative execution side-channel attacks (Windows blog)</a>.</dd>\n<dd> Uses the non-standard name: <code>wake</code>\n</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-yes bc-has-history\"> 63<div class=\"bc-icons\"> Disabled </div>\n<section class=\"bc-history\" id=\"sect45\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 63<div class=\"bc-icons\"> Disabled </div>\n</dt>\n<dd> Support was disabled by default to mitigate <a href=\"https://blog.mozilla.org/security/2018/01/03/mitigations-landing-new-class-timing-attack/\">speculative execution side-channel attacks (Mozilla Security Blog)</a>.</dd>\n<dd>Disabled From version 63: this feature is behind the <code>javascript.options.shared_memory</code> preference (needs to be set to <code>true</code>). To change preferences in Firefox, visit about:config.</dd>\n<dt class=\"bc-supports-yes bc-supports\"> 57<div class=\"bc-icons\">  Disabled </div>\n</dt>\n<dd> Support was disabled by default to mitigate <a href=\"https://blog.mozilla.org/security/2018/01/03/mitigations-landing-new-class-timing-attack/\">speculative execution side-channel attacks (Mozilla Security Blog)</a>.</dd>\n<dd> Uses the non-standard name: <code>wake</code>\n</dd>\n<dd>Disabled From version 57: this feature is behind the <code>javascript.options.shared_memory</code> preference (needs to be set to <code>true</code>). To change preferences in Firefox, visit about:config.</dd>\n<dt class=\"bc-supports-no bc-supports\">55 — 57\n</dt>\n\n<dt class=\"bc-supports-no bc-supports\">48 — 55<div class=\"bc-icons\">Disabled </div>\n</dt>\n<dd>Disabled From version 48 until version 55 (exclusive): this feature is behind the <code>javascript.options.shared_memory</code> preference (needs to be set to <code>true</code>). To change preferences in Firefox, visit about:config.</dd>\n<dt class=\"bc-supports-no bc-supports\">46 — 48<div class=\"bc-icons\">  Disabled </div>\n</dt>\n<dd> The <code>count</code> parameter defaults to <code>0</code> instead of the later-specified <code>+Infinity</code>.</dd>\n<dd> Uses the non-standard name: <code>futexWake</code>\n</dd>\n<dd>Disabled From version 46 until version 48 (exclusive): this feature is behind the <code>javascript.options.shared_memory</code> preference (needs to be set to <code>true</code>). To change preferences in Firefox, visit about:config.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no bc-has-history\">10.1 — ?\n<section class=\"bc-history\" id=\"sect46\"><dl>\n<dt class=\"bc-supports-no bc-supports\">10.1 — ?\n</dt>\n<dd> Uses the non-standard name: <code>wake</code>\n</dd>\n</dl></section>\n</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Atomics/or\"><code>or</code></a></th>\n<td class=\"bc-supports-yes bc-has-history\"> 68\n<section class=\"bc-history\" id=\"sect51\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 68\n</dt>\n\n<dt class=\"bc-supports-no bc-supports\">60 — 63\n</dt>\n<dd> Chrome disabled <code>SharedArrayBuffer</code> on January 5, 2018 to help reduce the efficacy of <a href=\"https://www.chromium.org/Home/chromium-security/ssca\">speculative side-channel attacks</a>. This was a temporary removal while mitigations were put in place.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-yes bc-has-history\"> 16\n<section class=\"bc-history\" id=\"sect52\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 16\n</dt>\n<dd> Support was removed to mitigate <a href=\"https://blogs.windows.com/msedgedev/2018/01/03/speculative-execution-mitigations-microsoft-edge-internet-explorer\">speculative execution side-channel attacks (Windows blog)</a>.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-yes bc-has-history\"> 57<div class=\"bc-icons\"> Disabled </div>\n<section class=\"bc-history\" id=\"sect53\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 57<div class=\"bc-icons\"> Disabled </div>\n</dt>\n<dd> Support was disabled by default to mitigate <a href=\"https://blog.mozilla.org/security/2018/01/03/mitigations-landing-new-class-timing-attack/\">speculative execution side-channel attacks (Mozilla Security Blog)</a>.</dd>\n<dd>Disabled From version 57: this feature is behind the <code>javascript.options.shared_memory</code> preference (needs to be set to <code>true</code>). To change preferences in Firefox, visit about:config.</dd>\n<dt class=\"bc-supports-no bc-supports\">55 — 57\n</dt>\n\n<dt class=\"bc-supports-no bc-supports\">46 — 55<div class=\"bc-icons\">Disabled </div>\n</dt>\n<dd>Disabled From version 46 until version 55 (exclusive): this feature is behind the <code>javascript.options.shared_memory</code> preference (needs to be set to <code>true</code>). To change preferences in Firefox, visit about:config.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\">10.1 — ?</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Atomics/store\"><code>store</code></a></th>\n<td class=\"bc-supports-yes bc-has-history\"> 68\n<section class=\"bc-history\" id=\"sect57\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 68\n</dt>\n\n<dt class=\"bc-supports-no bc-supports\">60 — 63\n</dt>\n<dd> Chrome disabled <code>SharedArrayBuffer</code> on January 5, 2018 to help reduce the efficacy of <a href=\"https://www.chromium.org/Home/chromium-security/ssca\">speculative side-channel attacks</a>. This was a temporary removal while mitigations were put in place.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-yes bc-has-history\"> 16\n<section class=\"bc-history\" id=\"sect58\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 16\n</dt>\n<dd> Support was removed to mitigate <a href=\"https://blogs.windows.com/msedgedev/2018/01/03/speculative-execution-mitigations-microsoft-edge-internet-explorer\">speculative execution side-channel attacks (Windows blog)</a>.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-yes bc-has-history\"> 57<div class=\"bc-icons\"> Disabled </div>\n<section class=\"bc-history\" id=\"sect59\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 57<div class=\"bc-icons\"> Disabled </div>\n</dt>\n<dd> Support was disabled by default to mitigate <a href=\"https://blog.mozilla.org/security/2018/01/03/mitigations-landing-new-class-timing-attack/\">speculative execution side-channel attacks (Mozilla Security Blog)</a>.</dd>\n<dd>Disabled From version 57: this feature is behind the <code>javascript.options.shared_memory</code> preference (needs to be set to <code>true</code>). To change preferences in Firefox, visit about:config.</dd>\n<dt class=\"bc-supports-no bc-supports\">55 — 57\n</dt>\n\n<dt class=\"bc-supports-no bc-supports\">46 — 55<div class=\"bc-icons\">Disabled </div>\n</dt>\n<dd>Disabled From version 46 until version 55 (exclusive): this feature is behind the <code>javascript.options.shared_memory</code> preference (needs to be set to <code>true</code>). To change preferences in Firefox, visit about:config.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\">10.1 — ?</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Atomics/sub\"><code>sub</code></a></th>\n<td class=\"bc-supports-yes bc-has-history\"> 68\n<section class=\"bc-history\" id=\"sect63\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 68\n</dt>\n\n<dt class=\"bc-supports-no bc-supports\">60 — 63\n</dt>\n<dd> Chrome disabled <code>SharedArrayBuffer</code> on January 5, 2018 to help reduce the efficacy of <a href=\"https://www.chromium.org/Home/chromium-security/ssca\">speculative side-channel attacks</a>. This was a temporary removal while mitigations were put in place.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-yes bc-has-history\"> 16\n<section class=\"bc-history\" id=\"sect64\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 16\n</dt>\n<dd> Support was removed to mitigate <a href=\"https://blogs.windows.com/msedgedev/2018/01/03/speculative-execution-mitigations-microsoft-edge-internet-explorer\">speculative execution side-channel attacks (Windows blog)</a>.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-yes bc-has-history\"> 57<div class=\"bc-icons\"> Disabled </div>\n<section class=\"bc-history\" id=\"sect65\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 57<div class=\"bc-icons\"> Disabled </div>\n</dt>\n<dd> Support was disabled by default to mitigate <a href=\"https://blog.mozilla.org/security/2018/01/03/mitigations-landing-new-class-timing-attack/\">speculative execution side-channel attacks (Mozilla Security Blog)</a>.</dd>\n<dd>Disabled From version 57: this feature is behind the <code>javascript.options.shared_memory</code> preference (needs to be set to <code>true</code>). To change preferences in Firefox, visit about:config.</dd>\n<dt class=\"bc-supports-no bc-supports\">55 — 57\n</dt>\n\n<dt class=\"bc-supports-no bc-supports\">46 — 55<div class=\"bc-icons\">Disabled </div>\n</dt>\n<dd>Disabled From version 46 until version 55 (exclusive): this feature is behind the <code>javascript.options.shared_memory</code> preference (needs to be set to <code>true</code>). To change preferences in Firefox, visit about:config.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\">10.1 — ?</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Atomics/wait\"><code>wait</code></a></th>\n<td class=\"bc-supports-yes bc-has-history\"> 68\n<section class=\"bc-history\" id=\"sect69\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 68\n</dt>\n\n<dt class=\"bc-supports-no bc-supports\">60 — 63\n</dt>\n<dd> Chrome disabled <code>SharedArrayBuffer</code> on January 5, 2018 to help reduce the efficacy of <a href=\"https://www.chromium.org/Home/chromium-security/ssca\">speculative side-channel attacks</a>. This was a temporary removal while mitigations were put in place.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-yes bc-has-history\"> 16\n<section class=\"bc-history\" id=\"sect70\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 16\n</dt>\n<dd> Support was removed to mitigate <a href=\"https://blogs.windows.com/msedgedev/2018/01/03/speculative-execution-mitigations-microsoft-edge-internet-explorer\">speculative execution side-channel attacks (Windows blog)</a>.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-yes bc-has-history\"> 57<div class=\"bc-icons\"> Disabled </div>\n<section class=\"bc-history\" id=\"sect71\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 57<div class=\"bc-icons\"> Disabled </div>\n</dt>\n<dd> Support was disabled by default to mitigate <a href=\"https://blog.mozilla.org/security/2018/01/03/mitigations-landing-new-class-timing-attack/\">speculative execution side-channel attacks (Mozilla Security Blog)</a>.</dd>\n<dd>Disabled From version 57: this feature is behind the <code>javascript.options.shared_memory</code> preference (needs to be set to <code>true</code>). To change preferences in Firefox, visit about:config.</dd>\n<dt class=\"bc-supports-no bc-supports\">55 — 57\n</dt>\n\n<dt class=\"bc-supports-no bc-supports\">48 — 55<div class=\"bc-icons\">Disabled </div>\n</dt>\n<dd>Disabled From version 48 until version 55 (exclusive): this feature is behind the <code>javascript.options.shared_memory</code> preference (needs to be set to <code>true</code>). To change preferences in Firefox, visit about:config.</dd>\n<dt class=\"bc-supports-no bc-supports\">46 — 48<div class=\"bc-icons\">  Disabled </div>\n</dt>\n<dd> The method returns values <code>Atomics.OK</code>, <code>Atomics.TIMEDOUT</code>, and <code>Atomics.NOTEQUAL</code>, instead of the later-specified strings.</dd>\n<dd> Uses the non-standard name: <code>futexWait</code>\n</dd>\n<dd>Disabled From version 46 until version 48 (exclusive): this feature is behind the <code>javascript.options.shared_memory</code> preference (needs to be set to <code>true</code>). To change preferences in Firefox, visit about:config.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\">10.1 — ?</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Atomics/xor\"><code>xor</code></a></th>\n<td class=\"bc-supports-yes bc-has-history\"> 68\n<section class=\"bc-history\" id=\"sect75\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 68\n</dt>\n\n<dt class=\"bc-supports-no bc-supports\">60 — 63\n</dt>\n<dd> Chrome disabled <code>SharedArrayBuffer</code> on January 5, 2018 to help reduce the efficacy of <a href=\"https://www.chromium.org/Home/chromium-security/ssca\">speculative side-channel attacks</a>. This was a temporary removal while mitigations were put in place.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-yes bc-has-history\"> 16\n<section class=\"bc-history\" id=\"sect76\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 16\n</dt>\n<dd> Support was removed to mitigate <a href=\"https://blogs.windows.com/msedgedev/2018/01/03/speculative-execution-mitigations-microsoft-edge-internet-explorer\">speculative execution side-channel attacks (Windows blog)</a>.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-yes bc-has-history\"> 57<div class=\"bc-icons\"> Disabled </div>\n<section class=\"bc-history\" id=\"sect77\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 57<div class=\"bc-icons\"> Disabled </div>\n</dt>\n<dd> Support was disabled by default to mitigate <a href=\"https://blog.mozilla.org/security/2018/01/03/mitigations-landing-new-class-timing-attack/\">speculative execution side-channel attacks (Mozilla Security Blog)</a>.</dd>\n<dd>Disabled From version 57: this feature is behind the <code>javascript.options.shared_memory</code> preference (needs to be set to <code>true</code>). To change preferences in Firefox, visit about:config.</dd>\n<dt class=\"bc-supports-no bc-supports\">55 — 57\n</dt>\n\n<dt class=\"bc-supports-no bc-supports\">46 — 55<div class=\"bc-icons\">Disabled </div>\n</dt>\n<dd>Disabled From version 46 until version 55 (exclusive): this feature is behind the <code>javascript.options.shared_memory</code> preference (needs to be set to <code>true</code>). To change preferences in Firefox, visit about:config.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\">10.1 — ?</td>\n</tr>\n</tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-no bc-has-history\">60 — 63\n<section class=\"bc-history\" id=\"sect4\"><dl>\n<dt class=\"bc-supports-no bc-supports\">60 — 63\n</dt>\n<dd> Chrome disabled <code>SharedArrayBuffer</code> on January 5, 2018 to help reduce the efficacy of <a href=\"https://www.chromium.org/Home/chromium-security/ssca\">speculative side-channel attacks</a>. This is intended as a temporary measure until other mitigations are in place.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-no bc-has-history\">60 — 63\n<section class=\"bc-history\" id=\"sect5\"><dl>\n<dt class=\"bc-supports-no bc-supports\">60 — 63\n</dt>\n<dd> Chrome disabled <code>SharedArrayBuffer</code> on January 5, 2018 to help reduce the efficacy of <a href=\"https://www.chromium.org/Home/chromium-security/ssca\">speculative side-channel attacks</a>. This is intended as a temporary measure until other mitigations are in place.</dd>\n</dl></section>\n</td>\n<td> ? </td>\n<td class=\"bc-supports-yes bc-has-history\"> 57<div class=\"bc-icons\"> Disabled </div>\n<section class=\"bc-history\" id=\"sect6\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 57<div class=\"bc-icons\"> Disabled </div>\n</dt>\n<dd> Support was disabled by default to mitigate <a href=\"https://blog.mozilla.org/security/2018/01/03/mitigations-landing-new-class-timing-attack/\">speculative execution side-channel attacks (Mozilla Security Blog)</a>.</dd>\n<dd>Disabled From version 57: this feature is behind the <code>javascript.options.shared_memory</code> preference (needs to be set to <code>true</code>). To change preferences in Firefox, visit about:config.</dd>\n<dt class=\"bc-supports-no bc-supports\">55 — 57\n</dt>\n\n<dt class=\"bc-supports-no bc-supports\">46 — 55<div class=\"bc-icons\">Disabled </div>\n</dt>\n<dd>Disabled From version 46 until version 55 (exclusive): this feature is behind the <code>javascript.options.shared_memory</code> preference (needs to be set to <code>true</code>). To change preferences in Firefox, visit about:config.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Atomics/add\"><code>add</code></a></th>\n<td class=\"bc-supports-no bc-has-history\">60 — 63\n<section class=\"bc-history\" id=\"sect10\"><dl>\n<dt class=\"bc-supports-no bc-supports\">60 — 63\n</dt>\n<dd> Chrome disabled <code>SharedArrayBuffer</code> on January 5, 2018 to help reduce the efficacy of <a href=\"https://www.chromium.org/Home/chromium-security/ssca\">speculative side-channel attacks</a>. This is intended as a temporary measure until other mitigations are in place.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-no bc-has-history\">60 — 63\n<section class=\"bc-history\" id=\"sect11\"><dl>\n<dt class=\"bc-supports-no bc-supports\">60 — 63\n</dt>\n<dd> Chrome disabled <code>SharedArrayBuffer</code> on January 5, 2018 to help reduce the efficacy of <a href=\"https://www.chromium.org/Home/chromium-security/ssca\">speculative side-channel attacks</a>. This is intended as a temporary measure until other mitigations are in place.</dd>\n</dl></section>\n</td>\n<td> ? </td>\n<td class=\"bc-supports-yes bc-has-history\"> 57<div class=\"bc-icons\"> Disabled </div>\n<section class=\"bc-history\" id=\"sect12\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 57<div class=\"bc-icons\"> Disabled </div>\n</dt>\n<dd> Support was disabled by default to mitigate <a href=\"https://blog.mozilla.org/security/2018/01/03/mitigations-landing-new-class-timing-attack/\">speculative execution side-channel attacks (Mozilla Security Blog)</a>.</dd>\n<dd>Disabled From version 57: this feature is behind the <code>javascript.options.shared_memory</code> preference (needs to be set to <code>true</code>). To change preferences in Firefox, visit about:config.</dd>\n<dt class=\"bc-supports-no bc-supports\">55 — 57\n</dt>\n\n<dt class=\"bc-supports-no bc-supports\">46 — 55<div class=\"bc-icons\">Disabled </div>\n</dt>\n<dd>Disabled From version 46 until version 55 (exclusive): this feature is behind the <code>javascript.options.shared_memory</code> preference (needs to be set to <code>true</code>). To change preferences in Firefox, visit about:config.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Atomics/and\"><code>and</code></a></th>\n<td class=\"bc-supports-no bc-has-history\">60 — 63\n<section class=\"bc-history\" id=\"sect16\"><dl>\n<dt class=\"bc-supports-no bc-supports\">60 — 63\n</dt>\n<dd> Chrome disabled <code>SharedArrayBuffer</code> on January 5, 2018 to help reduce the efficacy of <a href=\"https://www.chromium.org/Home/chromium-security/ssca\">speculative side-channel attacks</a>. This is intended as a temporary measure until other mitigations are in place.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-no bc-has-history\">60 — 63\n<section class=\"bc-history\" id=\"sect17\"><dl>\n<dt class=\"bc-supports-no bc-supports\">60 — 63\n</dt>\n<dd> Chrome disabled <code>SharedArrayBuffer</code> on January 5, 2018 to help reduce the efficacy of <a href=\"https://www.chromium.org/Home/chromium-security/ssca\">speculative side-channel attacks</a>. This is intended as a temporary measure until other mitigations are in place.</dd>\n</dl></section>\n</td>\n<td> ? </td>\n<td class=\"bc-supports-yes bc-has-history\"> 57<div class=\"bc-icons\"> Disabled </div>\n<section class=\"bc-history\" id=\"sect18\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 57<div class=\"bc-icons\"> Disabled </div>\n</dt>\n<dd> Support was disabled by default to mitigate <a href=\"https://blog.mozilla.org/security/2018/01/03/mitigations-landing-new-class-timing-attack/\">speculative execution side-channel attacks (Mozilla Security Blog)</a>.</dd>\n<dd>Disabled From version 57: this feature is behind the <code>javascript.options.shared_memory</code> preference (needs to be set to <code>true</code>). To change preferences in Firefox, visit about:config.</dd>\n<dt class=\"bc-supports-no bc-supports\">55 — 57\n</dt>\n\n<dt class=\"bc-supports-no bc-supports\">46 — 55<div class=\"bc-icons\">Disabled </div>\n</dt>\n<dd>Disabled From version 46 until version 55 (exclusive): this feature is behind the <code>javascript.options.shared_memory</code> preference (needs to be set to <code>true</code>). To change preferences in Firefox, visit about:config.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Atomics/compareExchange\"><code>compareExchange</code></a></th>\n<td class=\"bc-supports-no bc-has-history\">60 — 63\n<section class=\"bc-history\" id=\"sect22\"><dl>\n<dt class=\"bc-supports-no bc-supports\">60 — 63\n</dt>\n<dd> Chrome disabled <code>SharedArrayBuffer</code> on January 5, 2018 to help reduce the efficacy of <a href=\"https://www.chromium.org/Home/chromium-security/ssca\">speculative side-channel attacks</a>. This is intended as a temporary measure until other mitigations are in place.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-no bc-has-history\">60 — 63\n<section class=\"bc-history\" id=\"sect23\"><dl>\n<dt class=\"bc-supports-no bc-supports\">60 — 63\n</dt>\n<dd> Chrome disabled <code>SharedArrayBuffer</code> on January 5, 2018 to help reduce the efficacy of <a href=\"https://www.chromium.org/Home/chromium-security/ssca\">speculative side-channel attacks</a>. This is intended as a temporary measure until other mitigations are in place.</dd>\n</dl></section>\n</td>\n<td> ? </td>\n<td class=\"bc-supports-yes bc-has-history\"> 57<div class=\"bc-icons\"> Disabled </div>\n<section class=\"bc-history\" id=\"sect24\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 57<div class=\"bc-icons\"> Disabled </div>\n</dt>\n<dd> Support was disabled by default to mitigate <a href=\"https://blog.mozilla.org/security/2018/01/03/mitigations-landing-new-class-timing-attack/\">speculative execution side-channel attacks (Mozilla Security Blog)</a>.</dd>\n<dd>Disabled From version 57: this feature is behind the <code>javascript.options.shared_memory</code> preference (needs to be set to <code>true</code>). To change preferences in Firefox, visit about:config.</dd>\n<dt class=\"bc-supports-no bc-supports\">55 — 57\n</dt>\n\n<dt class=\"bc-supports-no bc-supports\">46 — 55<div class=\"bc-icons\">Disabled </div>\n</dt>\n<dd>Disabled From version 46 until version 55 (exclusive): this feature is behind the <code>javascript.options.shared_memory</code> preference (needs to be set to <code>true</code>). To change preferences in Firefox, visit about:config.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Atomics/exchange\"><code>exchange</code></a></th>\n<td class=\"bc-supports-no bc-has-history\">60 — 63\n<section class=\"bc-history\" id=\"sect28\"><dl>\n<dt class=\"bc-supports-no bc-supports\">60 — 63\n</dt>\n<dd> Chrome disabled <code>SharedArrayBuffer</code> on January 5, 2018 to help reduce the efficacy of <a href=\"https://www.chromium.org/Home/chromium-security/ssca\">speculative side-channel attacks</a>. This is intended as a temporary measure until other mitigations are in place.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-no bc-has-history\">60 — 63\n<section class=\"bc-history\" id=\"sect29\"><dl>\n<dt class=\"bc-supports-no bc-supports\">60 — 63\n</dt>\n<dd> Chrome disabled <code>SharedArrayBuffer</code> on January 5, 2018 to help reduce the efficacy of <a href=\"https://www.chromium.org/Home/chromium-security/ssca\">speculative side-channel attacks</a>. This is intended as a temporary measure until other mitigations are in place.</dd>\n</dl></section>\n</td>\n<td> ? </td>\n<td class=\"bc-supports-yes bc-has-history\"> 57<div class=\"bc-icons\"> Disabled </div>\n<section class=\"bc-history\" id=\"sect30\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 57<div class=\"bc-icons\"> Disabled </div>\n</dt>\n<dd> Support was disabled by default to mitigate <a href=\"https://blog.mozilla.org/security/2018/01/03/mitigations-landing-new-class-timing-attack/\">speculative execution side-channel attacks (Mozilla Security Blog)</a>.</dd>\n<dd>Disabled From version 57: this feature is behind the <code>javascript.options.shared_memory</code> preference (needs to be set to <code>true</code>). To change preferences in Firefox, visit about:config.</dd>\n<dt class=\"bc-supports-no bc-supports\">55 — 57\n</dt>\n\n<dt class=\"bc-supports-no bc-supports\">46 — 55<div class=\"bc-icons\">Disabled </div>\n</dt>\n<dd>Disabled From version 46 until version 55 (exclusive): this feature is behind the <code>javascript.options.shared_memory</code> preference (needs to be set to <code>true</code>). To change preferences in Firefox, visit about:config.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Atomics/isLockFree\"><code>isLockFree</code></a></th>\n<td class=\"bc-supports-no bc-has-history\">60 — 63\n<section class=\"bc-history\" id=\"sect34\"><dl>\n<dt class=\"bc-supports-no bc-supports\">60 — 63\n</dt>\n<dd> Chrome disabled <code>SharedArrayBuffer</code> on January 5, 2018 to help reduce the efficacy of <a href=\"https://www.chromium.org/Home/chromium-security/ssca\">speculative side-channel attacks</a>. This is intended as a temporary measure until other mitigations are in place.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-no bc-has-history\">60 — 63\n<section class=\"bc-history\" id=\"sect35\"><dl>\n<dt class=\"bc-supports-no bc-supports\">60 — 63\n</dt>\n<dd> Chrome disabled <code>SharedArrayBuffer</code> on January 5, 2018 to help reduce the efficacy of <a href=\"https://www.chromium.org/Home/chromium-security/ssca\">speculative side-channel attacks</a>. This is intended as a temporary measure until other mitigations are in place.</dd>\n</dl></section>\n</td>\n<td> ? </td>\n<td class=\"bc-supports-yes bc-has-history\"> 57<div class=\"bc-icons\"> Disabled </div>\n<section class=\"bc-history\" id=\"sect36\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 57<div class=\"bc-icons\"> Disabled </div>\n</dt>\n<dd> Support was disabled by default to mitigate <a href=\"https://blog.mozilla.org/security/2018/01/03/mitigations-landing-new-class-timing-attack/\">speculative execution side-channel attacks (Mozilla Security Blog)</a>.</dd>\n<dd>Disabled From version 57: this feature is behind the <code>javascript.options.shared_memory</code> preference (needs to be set to <code>true</code>). To change preferences in Firefox, visit about:config.</dd>\n<dt class=\"bc-supports-no bc-supports\">55 — 57\n</dt>\n\n<dt class=\"bc-supports-no bc-supports\">46 — 55<div class=\"bc-icons\">Disabled </div>\n</dt>\n<dd>Disabled From version 46 until version 55 (exclusive): this feature is behind the <code>javascript.options.shared_memory</code> preference (needs to be set to <code>true</code>). To change preferences in Firefox, visit about:config.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Atomics/load\"><code>load</code></a></th>\n<td class=\"bc-supports-no bc-has-history\">60 — 63\n<section class=\"bc-history\" id=\"sect40\"><dl>\n<dt class=\"bc-supports-no bc-supports\">60 — 63\n</dt>\n<dd> Chrome disabled <code>SharedArrayBuffer</code> on January 5, 2018 to help reduce the efficacy of <a href=\"https://www.chromium.org/Home/chromium-security/ssca\">speculative side-channel attacks</a>. This is intended as a temporary measure until other mitigations are in place.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-no bc-has-history\">60 — 63\n<section class=\"bc-history\" id=\"sect41\"><dl>\n<dt class=\"bc-supports-no bc-supports\">60 — 63\n</dt>\n<dd> Chrome disabled SharedArrayBuffer on January 5, 2018 to help reduce the efficacy of <a href=\"https://www.chromium.org/Home/chromium-security/ssca\">speculative side-channel attacks</a>. This is intended as a temporary measure until other mitigations are in place.</dd>\n</dl></section>\n</td>\n<td> ? </td>\n<td class=\"bc-supports-yes bc-has-history\"> 57<div class=\"bc-icons\"> Disabled </div>\n<section class=\"bc-history\" id=\"sect42\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 57<div class=\"bc-icons\"> Disabled </div>\n</dt>\n<dd> Support was disabled by default to mitigate <a href=\"https://blog.mozilla.org/security/2018/01/03/mitigations-landing-new-class-timing-attack/\">speculative execution side-channel attacks (Mozilla Security Blog)</a>.</dd>\n<dd>Disabled From version 57: this feature is behind the <code>javascript.options.shared_memory</code> preference (needs to be set to <code>true</code>). To change preferences in Firefox, visit about:config.</dd>\n<dt class=\"bc-supports-no bc-supports\">55 — 57\n</dt>\n\n<dt class=\"bc-supports-no bc-supports\">46 — 55<div class=\"bc-icons\">Disabled </div>\n</dt>\n<dd>Disabled From version 46 until version 55 (exclusive): this feature is behind the <code>javascript.options.shared_memory</code> preference (needs to be set to <code>true</code>). To change preferences in Firefox, visit about:config.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Atomics/notify\"><code>notify</code></a></th>\n<td class=\"bc-supports-no bc-has-history\">60 — 63\n<section class=\"bc-history\" id=\"sect47\"><dl>\n<dt class=\"bc-supports-no bc-supports\">60 — 63\n</dt>\n<dd> Chrome disabled <code>SharedArrayBuffer</code> on January 5, 2018 to help reduce the efficacy of <a href=\"https://www.chromium.org/Home/chromium-security/ssca\">speculative side-channel attacks</a>. This is intended as a temporary measure until other mitigations are in place.</dd>\n<dd> Uses the non-standard name: <code>wake</code>\n</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-no bc-has-history\">60 — 63\n<section class=\"bc-history\" id=\"sect48\"><dl>\n<dt class=\"bc-supports-no bc-supports\">60 — 63\n</dt>\n<dd> Chrome disabled <code>SharedArrayBuffer</code> on January 5, 2018 to help reduce the efficacy of <a href=\"https://www.chromium.org/Home/chromium-security/ssca\">speculative side-channel attacks</a>. This is intended as a temporary measure until other mitigations are in place.</dd>\n<dd> Uses the non-standard name: <code>wake</code>\n</dd>\n</dl></section>\n</td>\n<td> ? </td>\n<td class=\"bc-supports-yes bc-has-history\"> 63<div class=\"bc-icons\"> Disabled </div>\n<section class=\"bc-history\" id=\"sect49\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 63<div class=\"bc-icons\"> Disabled </div>\n</dt>\n<dd> Support was disabled by default to mitigate <a href=\"https://blog.mozilla.org/security/2018/01/03/mitigations-landing-new-class-timing-attack/\">speculative execution side-channel attacks (Mozilla Security Blog)</a>.</dd>\n<dd>Disabled From version 63: this feature is behind the <code>javascript.options.shared_memory</code> preference (needs to be set to <code>true</code>). To change preferences in Firefox, visit about:config.</dd>\n<dt class=\"bc-supports-yes bc-supports\"> 57<div class=\"bc-icons\">  Disabled </div>\n</dt>\n<dd> Support was disabled by default to mitigate <a href=\"https://blog.mozilla.org/security/2018/01/03/mitigations-landing-new-class-timing-attack/\">speculative execution side-channel attacks (Mozilla Security Blog)</a>.</dd>\n<dd> Uses the non-standard name: <code>wake</code>\n</dd>\n<dd>Disabled From version 57: this feature is behind the <code>javascript.options.shared_memory</code> preference (needs to be set to <code>true</code>). To change preferences in Firefox, visit about:config.</dd>\n<dt class=\"bc-supports-no bc-supports\">55 — 57\n</dt>\n\n<dt class=\"bc-supports-no bc-supports\">48 — 55<div class=\"bc-icons\">Disabled </div>\n</dt>\n<dd>Disabled From version 48 until version 55 (exclusive): this feature is behind the <code>javascript.options.shared_memory</code> preference (needs to be set to <code>true</code>). To change preferences in Firefox, visit about:config.</dd>\n<dt class=\"bc-supports-no bc-supports\">46 — 48<div class=\"bc-icons\">  Disabled </div>\n</dt>\n<dd> The <code>count</code> parameter defaults to <code>0</code> instead of the later-specified <code>+Infinity</code>.</dd>\n<dd> Uses the non-standard name: <code>futexWake</code>\n</dd>\n<dd>Disabled From version 46 until version 48 (exclusive): this feature is behind the <code>javascript.options.shared_memory</code> preference (needs to be set to <code>true</code>). To change preferences in Firefox, visit about:config.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Atomics/or\"><code>or</code></a></th>\n<td class=\"bc-supports-no bc-has-history\">60 — 63\n<section class=\"bc-history\" id=\"sect54\"><dl>\n<dt class=\"bc-supports-no bc-supports\">60 — 63\n</dt>\n<dd> Chrome disabled <code>SharedArrayBuffer</code> on January 5, 2018 to help reduce the efficacy of <a href=\"https://www.chromium.org/Home/chromium-security/ssca\">speculative side-channel attacks</a>. This is intended as a temporary measure until other mitigations are in place.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-no bc-has-history\">60 — 63\n<section class=\"bc-history\" id=\"sect55\"><dl>\n<dt class=\"bc-supports-no bc-supports\">60 — 63\n</dt>\n<dd> Chrome disabled <code>SharedArrayBuffer</code> on January 5, 2018 to help reduce the efficacy of <a href=\"https://www.chromium.org/Home/chromium-security/ssca\">speculative side-channel attacks</a>. This is intended as a temporary measure until other mitigations are in place.</dd>\n</dl></section>\n</td>\n<td> ? </td>\n<td class=\"bc-supports-yes bc-has-history\"> 57<div class=\"bc-icons\"> Disabled </div>\n<section class=\"bc-history\" id=\"sect56\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 57<div class=\"bc-icons\"> Disabled </div>\n</dt>\n<dd> Support was disabled by default to mitigate <a href=\"https://blog.mozilla.org/security/2018/01/03/mitigations-landing-new-class-timing-attack/\">speculative execution side-channel attacks (Mozilla Security Blog)</a>.</dd>\n<dd>Disabled From version 57: this feature is behind the <code>javascript.options.shared_memory</code> preference (needs to be set to <code>true</code>). To change preferences in Firefox, visit about:config.</dd>\n<dt class=\"bc-supports-no bc-supports\">55 — 57\n</dt>\n\n<dt class=\"bc-supports-no bc-supports\">46 — 55<div class=\"bc-icons\">Disabled </div>\n</dt>\n<dd>Disabled From version 46 until version 55 (exclusive): this feature is behind the <code>javascript.options.shared_memory</code> preference (needs to be set to <code>true</code>). To change preferences in Firefox, visit about:config.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Atomics/store\"><code>store</code></a></th>\n<td class=\"bc-supports-no bc-has-history\">60 — 63\n<section class=\"bc-history\" id=\"sect60\"><dl>\n<dt class=\"bc-supports-no bc-supports\">60 — 63\n</dt>\n<dd> Chrome disabled <code>SharedArrayBuffer</code> on January 5, 2018 to help reduce the efficacy of <a href=\"https://www.chromium.org/Home/chromium-security/ssca\">speculative side-channel attacks</a>. This is intended as a temporary measure until other mitigations are in place.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-no bc-has-history\">60 — 63\n<section class=\"bc-history\" id=\"sect61\"><dl>\n<dt class=\"bc-supports-no bc-supports\">60 — 63\n</dt>\n<dd> Chrome disabled <code>SharedArrayBuffer</code> on January 5, 2018 to help reduce the efficacy of <a href=\"https://www.chromium.org/Home/chromium-security/ssca\">speculative side-channel attacks</a>. This is intended as a temporary measure until other mitigations are in place.</dd>\n</dl></section>\n</td>\n<td> ? </td>\n<td class=\"bc-supports-yes bc-has-history\"> 57<div class=\"bc-icons\"> Disabled </div>\n<section class=\"bc-history\" id=\"sect62\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 57<div class=\"bc-icons\"> Disabled </div>\n</dt>\n<dd> Support was disabled by default to mitigate <a href=\"https://blog.mozilla.org/security/2018/01/03/mitigations-landing-new-class-timing-attack/\">speculative execution side-channel attacks (Mozilla Security Blog)</a>.</dd>\n<dd>Disabled From version 57: this feature is behind the <code>javascript.options.shared_memory</code> preference (needs to be set to <code>true</code>). To change preferences in Firefox, visit about:config.</dd>\n<dt class=\"bc-supports-no bc-supports\">55 — 57\n</dt>\n\n<dt class=\"bc-supports-no bc-supports\">46 — 55<div class=\"bc-icons\">Disabled </div>\n</dt>\n<dd>Disabled From version 46 until version 55 (exclusive): this feature is behind the <code>javascript.options.shared_memory</code> preference (needs to be set to <code>true</code>). To change preferences in Firefox, visit about:config.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Atomics/sub\"><code>sub</code></a></th>\n<td class=\"bc-supports-no bc-has-history\">60 — 63\n<section class=\"bc-history\" id=\"sect66\"><dl>\n<dt class=\"bc-supports-no bc-supports\">60 — 63\n</dt>\n<dd> Chrome disabled <code>SharedArrayBuffer</code> on January 5, 2018 to help reduce the efficacy of <a href=\"https://www.chromium.org/Home/chromium-security/ssca\">speculative side-channel attacks</a>. This is intended as a temporary measure until other mitigations are in place.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-no bc-has-history\">60 — 63\n<section class=\"bc-history\" id=\"sect67\"><dl>\n<dt class=\"bc-supports-no bc-supports\">60 — 63\n</dt>\n<dd> Chrome disabled SharedArrayBuffer on January 5, 2018 to help reduce the efficacy of <a href=\"https://www.chromium.org/Home/chromium-security/ssca\">speculative side-channel attacks</a>. This is intended as a temporary measure until other mitigations are in place.</dd>\n</dl></section>\n</td>\n<td> ? </td>\n<td class=\"bc-supports-yes bc-has-history\"> 57<div class=\"bc-icons\"> Disabled </div>\n<section class=\"bc-history\" id=\"sect68\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 57<div class=\"bc-icons\"> Disabled </div>\n</dt>\n<dd> Support was disabled by default to mitigate <a href=\"https://blog.mozilla.org/security/2018/01/03/mitigations-landing-new-class-timing-attack/\">speculative execution side-channel attacks (Mozilla Security Blog)</a>.</dd>\n<dd>Disabled From version 57: this feature is behind the <code>javascript.options.shared_memory</code> preference (needs to be set to <code>true</code>). To change preferences in Firefox, visit about:config.</dd>\n<dt class=\"bc-supports-no bc-supports\">55 — 57\n</dt>\n\n<dt class=\"bc-supports-no bc-supports\">46 — 55<div class=\"bc-icons\">Disabled </div>\n</dt>\n<dd>Disabled From version 46 until version 55 (exclusive): this feature is behind the <code>javascript.options.shared_memory</code> preference (needs to be set to <code>true</code>). To change preferences in Firefox, visit about:config.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Atomics/wait\"><code>wait</code></a></th>\n<td class=\"bc-supports-no bc-has-history\">60 — 63\n<section class=\"bc-history\" id=\"sect72\"><dl>\n<dt class=\"bc-supports-no bc-supports\">60 — 63\n</dt>\n<dd> Chrome disabled <code>SharedArrayBuffer</code> on January 5, 2018 to help reduce the efficacy of <a href=\"https://www.chromium.org/Home/chromium-security/ssca\">speculative side-channel attacks</a>. This is intended as a temporary measure until other mitigations are in place.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-no bc-has-history\">60 — 63\n<section class=\"bc-history\" id=\"sect73\"><dl>\n<dt class=\"bc-supports-no bc-supports\">60 — 63\n</dt>\n<dd> Chrome disabled <code>SharedArrayBuffer</code> on January 5, 2018 to help reduce the efficacy of <a href=\"https://www.chromium.org/Home/chromium-security/ssca\">speculative side-channel attacks</a>. This is intended as a temporary measure until other mitigations are in place.</dd>\n</dl></section>\n</td>\n<td> ? </td>\n<td class=\"bc-supports-yes bc-has-history\"> 57<div class=\"bc-icons\"> Disabled </div>\n<section class=\"bc-history\" id=\"sect74\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 57<div class=\"bc-icons\"> Disabled </div>\n</dt>\n<dd> Support was disabled by default to mitigate <a href=\"https://blog.mozilla.org/security/2018/01/03/mitigations-landing-new-class-timing-attack/\">speculative execution side-channel attacks (Mozilla Security Blog)</a>.</dd>\n<dd>Disabled From version 57: this feature is behind the <code>javascript.options.shared_memory</code> preference (needs to be set to <code>true</code>). To change preferences in Firefox, visit about:config.</dd>\n<dt class=\"bc-supports-no bc-supports\">55 — 57\n</dt>\n\n<dt class=\"bc-supports-no bc-supports\">48 — 55<div class=\"bc-icons\">Disabled </div>\n</dt>\n<dd>Disabled From version 48 until version 55 (exclusive): this feature is behind the <code>javascript.options.shared_memory</code> preference (needs to be set to <code>true</code>). To change preferences in Firefox, visit about:config.</dd>\n<dt class=\"bc-supports-no bc-supports\">46 — 48<div class=\"bc-icons\">  Disabled </div>\n</dt>\n<dd> The method returns values <code>Atomics.OK</code>, <code>Atomics.TIMEDOUT</code>, and <code>Atomics.NOTEQUAL</code>, instead of the later-specified strings.</dd>\n<dd> Uses the non-standard name: <code>futexWait</code>\n</dd>\n<dd>Disabled From version 46 until version 48 (exclusive): this feature is behind the <code>javascript.options.shared_memory</code> preference (needs to be set to <code>true</code>). To change preferences in Firefox, visit about:config.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Atomics/xor\"><code>xor</code></a></th>\n<td class=\"bc-supports-no bc-has-history\">60 — 63\n<section class=\"bc-history\" id=\"sect78\"><dl>\n<dt class=\"bc-supports-no bc-supports\">60 — 63\n</dt>\n<dd> Chrome disabled <code>SharedArrayBuffer</code> on January 5, 2018 to help reduce the efficacy of <a href=\"https://www.chromium.org/Home/chromium-security/ssca\">speculative side-channel attacks</a>. This is intended as a temporary measure until other mitigations are in place.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-no bc-has-history\">60 — 63\n<section class=\"bc-history\" id=\"sect79\"><dl>\n<dt class=\"bc-supports-no bc-supports\">60 — 63\n</dt>\n<dd> Chrome disabled <code>SharedArrayBuffer</code> on January 5, 2018 to help reduce the efficacy of <a href=\"https://www.chromium.org/Home/chromium-security/ssca\">speculative side-channel attacks</a>. This is intended as a temporary measure until other mitigations are in place.</dd>\n</dl></section>\n</td>\n<td> ? </td>\n<td class=\"bc-supports-yes bc-has-history\"> 57<div class=\"bc-icons\"> Disabled </div>\n<section class=\"bc-history\" id=\"sect80\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 57<div class=\"bc-icons\"> Disabled </div>\n</dt>\n<dd> Support was disabled by default to mitigate <a href=\"https://blog.mozilla.org/security/2018/01/03/mitigations-landing-new-class-timing-attack/\">speculative execution side-channel attacks (Mozilla Security Blog)</a>.</dd>\n<dd>Disabled From version 57: this feature is behind the <code>javascript.options.shared_memory</code> preference (needs to be set to <code>true</code>). To change preferences in Firefox, visit about:config.</dd>\n<dt class=\"bc-supports-no bc-supports\">55 — 57\n</dt>\n\n<dt class=\"bc-supports-no bc-supports\">46 — 55<div class=\"bc-icons\">Disabled </div>\n</dt>\n<dd>Disabled From version 46 until version 55 (exclusive): this feature is behind the <code>javascript.options.shared_memory</code> preference (needs to be set to <code>true</code>). To change preferences in Firefox, visit about:config.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n</tr>\n</tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-no\"> No</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Atomics/add\"><code>add</code></a></th>\n<td class=\"bc-supports-yes\"> 8.10.0</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Atomics/and\"><code>and</code></a></th>\n<td class=\"bc-supports-yes\"> 8.10.0</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Atomics/compareExchange\"><code>compareExchange</code></a></th>\n<td class=\"bc-supports-yes\"> 8.10.0</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Atomics/exchange\"><code>exchange</code></a></th>\n<td class=\"bc-supports-yes\"> 8.10.0</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Atomics/isLockFree\"><code>isLockFree</code></a></th>\n<td class=\"bc-supports-yes\"> 8.10.0</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Atomics/load\"><code>load</code></a></th>\n<td class=\"bc-supports-yes\"> 8.10.0</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Atomics/notify\"><code>notify</code></a></th>\n<td class=\"bc-supports-yes bc-has-history\"> 8.10.0\n<section class=\"bc-history\" id=\"sect50\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 8.10.0\n</dt>\n<dd> Uses the non-standard name: <code>wake</code>\n</dd>\n</dl></section>\n</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Atomics/or\"><code>or</code></a></th>\n<td class=\"bc-supports-yes\"> 8.10.0</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Atomics/store\"><code>store</code></a></th>\n<td class=\"bc-supports-yes\"> 8.10.0</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Atomics/sub\"><code>sub</code></a></th>\n<td class=\"bc-supports-yes\"> 8.10.0</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Atomics/wait\"><code>wait</code></a></th>\n<td class=\"bc-supports-yes\"> 8.10.0</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Atomics/xor\"><code>xor</code></a></th>\n<td class=\"bc-supports-yes\"> 8.10.0</td>\n</tr>\n</tbody>\n</table>\n</div> <h2 id=\"Compatibility_notes\">Compatibility notes</h2> <p>Prior to Firefox 48, the latest API names and semantics weren't implemented yet. The changes between Firefox version 46 and version 48 are:</p> <ul> <li>The methods <code>Atomics.futexWakeOrRequeue()</code> and <code>Atomics.fence()</code> are now removed entirely (<a href=\"https://bugzilla.mozilla.org/show_bug.cgi?id=1259544\">bug 1259544</a> and <a href=\"https://bugzilla.mozilla.org/show_bug.cgi?id=1225028\">bug 1225028</a>).</li> <li>The methods <a href=\"atomics/wait\"><code>Atomics.wait()</code></a> and <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics/wake\"><code>Atomics.wake()</code></a> were named <code>Atomics.futexWait()</code> and <code>Atomics.futexWake()</code> (<a href=\"https://bugzilla.mozilla.org/show_bug.cgi?id=1260910\">bug 1260910</a>). Note: The old names have been removed in version 49 and later (<a href=\"https://bugzilla.mozilla.org/show_bug.cgi?id=1262062\">bug 1262062</a>). <code>Atomics.wake()</code> has then been renamed to <code>Atomics.notify()</code> in version 63.</li> <li>The properties <code>Atomics.OK</code>, <code>Atomics.TIMEDOUT</code>, <code>Atomics.NOTEQUAL</code> have been removed. The <a href=\"atomics/wait\"><code>Atomics.wait()</code></a> method now returns the strings \"ok\", \"timed-out\" and \"not-equal\" (<a href=\"https://bugzilla.mozilla.org/show_bug.cgi?id=1260835\">bug 1260835</a>).</li> <li> <p>The <code>count</code> parameter of the <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics/wake\"><code>Atomics.wake()</code></a> method has been changed: it now defaults to <code>+Infinity</code>, not <code>0</code> (<a href=\"https://bugzilla.mozilla.org/show_bug.cgi?id=1253350\">bug 1253350</a>).</p> </li> </ul> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"arraybuffer\"><code>ArrayBuffer</code></a></li> <li><a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Typed_arrays\">JavaScript typed arrays</a></li> <li><a href=\"https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API\">Web Workers</a></li> <li>\n<a href=\"https://github.com/lars-t-hansen/parlib-simple\">parlib-simple </a>– a simple library providing synchronization and work distribution abstractions.</li> <li><a href=\"https://github.com/tc39/ecmascript_sharedmem/blob/master/TUTORIAL.md\">Shared Memory – a brief tutorial</a></li> <li><a href=\"https://hacks.mozilla.org/2016/05/a-taste-of-javascripts-new-parallel-primitives/\">A Taste of JavaScript’s New Parallel Primitives – Mozilla Hacks</a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics</a>\n  </p>\n</div>\n","global_objects/regexp":"<h1>RegExp</h1> <p>The <code>RegExp</code> constructor creates a regular expression object for matching text with a pattern.</p> <p>For an introduction to regular expressions, read the <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions\">Regular Expressions chapter</a> in the <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions\">JavaScript Guide</a>.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/regexp-constructor.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <p>Literal, constructor, and factory notations are possible:</p> <pre class=\"syntaxbox\">/<var>pattern</var>/<var>flags</var>\nnew RegExp(<var>pattern</var>[, <var>flags</var>])\nRegExp(<var>pattern</var>[, <var>flags</var>])\n</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><code>pattern</code></dt> <dd>The text of the regular expression or, as of ES5, another RegExp object (or literal) to copy (the latter for the two RegExp constructor notations only).</dd> <dt><code>flags</code></dt> <dd> <p>If specified, <code>flags</code> indicates the flags to add, or if an object is supplied for the pattern, the <code>flags</code> value will replace any of that object's flags (and <code>lastIndex</code> will be reset to 0) (as of ES2015). If <code>flags</code> is not specified and a regular expressions object is supplied, that object's flags (and <code>lastIndex</code> value) will be copied over. The value is a string containing any combination of the following values:</p> <dl> <dt><code>g</code></dt> <dd>global match; find all matches rather than stopping after the first match</dd> <dt><code>i</code></dt> <dd>ignore case; if <code>u</code> flag is also enabled, use Unicode case folding</dd> <dt><code>m</code></dt> <dd>multiline; treat beginning and end characters (^ and $) as working over multiple lines (i.e., match the beginning or end of <em>each</em> line (delimited by \\n or \\r), not only the very beginning or end of the whole input string)</dd> <dt><code>u</code></dt> <dd>Unicode; treat pattern as a sequence of Unicode code points</dd> <dt><code>y</code></dt> <dd>sticky; matches only from the index indicated by the <code>lastIndex</code> property of this regular expression in the target string (and does not attempt to match from any later indexes).</dd> </dl> </dd> </dl> <h2 id=\"Description\">Description</h2> <p>There are 2 ways to create a <code>RegExp</code> object: a literal notation and a constructor. To indicate strings, the parameters to the literal notation do not use quotation marks while the parameters to the constructor function do use quotation marks. So the following expressions create the same regular expression:</p> <pre data-language=\"js\">/ab+c/i;\nnew RegExp('ab+c', 'i');\nnew RegExp(/ab+c/, 'i');\n</pre> <p>The literal notation provides a compilation of the regular expression when the expression is evaluated. Use literal notation when the regular expression will remain constant. For example, if you use literal notation to construct a regular expression used in a loop, the regular expression won't be recompiled on each iteration.</p> <p>The constructor of the regular expression object, for example, <code>new RegExp('ab+c')</code>, provides runtime compilation of the regular expression. Use the constructor function when you know the regular expression pattern will be changing, or you don't know the pattern and are getting it from another source, such as user input.</p> <p>Starting with ECMAScript 6, <code>new RegExp(/ab+c/, 'i')</code> no longer throws a <a href=\"typeerror\"><code>TypeError</code></a> (\"can't supply flags when constructing one RegExp from another\") when the first argument is a <code>RegExp</code> and the second <code>flags</code> argument is present. A new <code>RegExp</code> from the arguments is created instead.</p> <p>When using the constructor function, the normal string escape rules (preceding special characters with \\ when included in a string) are necessary. For example, the following are equivalent:</p> <pre data-language=\"js\">var re = /\\w+/;\nvar re = new RegExp('\\\\w+');\n</pre> <h2 id=\"Special_characters_meaning_in_regular_expressions\">Special characters meaning in regular expressions</h2> <ul> <li><a href=\"#character-classes\">Character Classes</a></li> <li><a href=\"#character-sets\">Character Sets</a></li> <li><a href=\"#boundaries\">Boundaries</a></li> <li><a href=\"#alternation\">Alternation</a></li> <li><a href=\"#grouping-back-references\">Grouping and back references</a></li> <li><a href=\"#quantifiers\">Quantifiers</a></li> <li><a href=\"#assertions\">Assertions</a></li> </ul> <div class=\"_table\"><table class=\"fullwidth-table\"> <tbody> <tr id=\"character-classes\"> <th colspan=\"2\">Character Classes</th> </tr> <tr> <th>Character</th> <th>Meaning</th> </tr> <tr> <td><code>.</code></td> <td> <p>(The dot, the decimal point) matches any single character <em>except</em> line terminators: <code>\\n</code>, <code>\\r</code>, <code>\\u2028</code> or <code>\\u2029</code>.</p> <p>Inside a character set, the dot loses its special meaning and matches a literal dot.</p> <p>Note that the <code>m</code> multiline flag doesn't change the dot behavior. So to match a pattern across multiple lines, the character set <code>[^]</code> can be used (if you don't mean an old version of IE, of course), it will match any character including newlines.</p> <p>For example, <code>/.y/</code> matches \"my\" and \"ay\", but not \"yes\", in \"yes make my day\".</p> </td> </tr> <tr> <td><code>\\d</code></td> <td> <p>Matches any digit (Arabic numeral). Equivalent to <code>[0-9]</code>.</p> <p>For example, <code>/\\d/</code> or <code>/[0-9]/</code> matches \"2\" in \"B2 is the suite number\".</p> </td> </tr> <tr> <td><code>\\D</code></td> <td> <p>Matches any character that is not a digit (Arabic numeral). Equivalent to <code>[^0-9]</code>.</p> <p>For example, <code>/\\D/</code> or <code>/[^0-9]/</code> matches \"B\" in \"B2 is the suite number\".</p> </td> </tr> <tr> <td><code>\\w</code></td> <td> <p>Matches any alphanumeric character from the basic Latin alphabet, including the underscore. Equivalent to <code>[A-Za-z0-9_]</code>.</p> <p>For example, <code>/\\w/</code> matches \"a\" in \"apple\", \"5\" in \"$5.28\", and \"3\" in \"3D\".</p> </td> </tr> <tr> <td><code>\\W</code></td> <td> <p>Matches any character that is not a word character from the basic Latin alphabet. Equivalent to <code>[^A-Za-z0-9_]</code>.</p> <p>For example, <code>/\\W/</code> or <code>/[^A-Za-z0-9_]/</code> matches \"%\" in \"50%\".</p> </td> </tr> <tr> <td><code>\\s</code></td> <td> <p>Matches a single white space character, including space, tab, form feed, line feed and other Unicode spaces. Equivalent to <code>[ \\f\\n\\r\\t\\v\\u00a0\\u1680\\u2000-\\u200a\\u2028\\u2029\\u202f\\u205f\\u3000\\ufeff]</code>.</p> <p>For example, <code>/\\s\\w*/</code> matches \" bar\" in \"foo bar\".</p> </td> </tr> <tr> <td><code>\\S</code></td> <td> <p>Matches a single character other than white space. Equivalent to <code>[^ \\f\\n\\r\\t\\v\\u00a0\\u1680\\u2000-\\u200a\\u2028\\u2029\\u202f\\u205f\\u3000\\ufeff]</code>.</p> <p>For example, <code>/\\S\\w*/</code> matches \"foo\" in \"foo bar\".</p> </td> </tr> <tr> <td><code>\\t</code></td> <td>Matches a horizontal tab.</td> </tr> <tr> <td><code>\\r</code></td> <td>Matches a carriage return.</td> </tr> <tr> <td><code>\\n</code></td> <td>Matches a linefeed.</td> </tr> <tr> <td><code>\\v</code></td> <td>Matches a vertical tab.</td> </tr> <tr> <td><code>\\f</code></td> <td>Matches a form-feed.</td> </tr> <tr> <td><code>[\\b]</code></td> <td>Matches a backspace. (Not to be confused with <code>\\b</code>)</td> </tr> <tr> <td><code>\\0</code></td> <td>Matches a NUL character. Do not follow this with another digit.</td> </tr> <tr> <td><code>\\c<em>X</em></code></td> <td> <p>Where <code><em>X</em></code> is a letter from A - Z. Matches a control character in a string.</p> <p>For example, <code>/\\cM/</code> matches control-M in a string.</p> </td> </tr> <tr> <td><code>\\x<em>hh</em></code></td> <td>Matches the character with the code <code><em>hh</em></code> (two hexadecimal digits).</td> </tr> <tr> <td><code>\\u<em>hhhh</em></code></td> <td>Matches a UTF-16 code-unit with the value <code><em>hhhh</em></code> (four hexadecimal digits).</td> </tr> <tr> <td><code>\\u<em>{hhhh} </em>or <em>\\u{hhhhh}</em></code></td> <td>(only when u flag is set) Matches the character with the Unicode value U+<code><em>hhhh</em> or </code>U+<code><em>hhhhh</em></code> (hexadecimal digits).</td> </tr> <tr> <td><code>\\</code></td> <td> <p>For characters that are usually treated literally, indicates that the next character is special and not to be interpreted literally.</p> <p>For example, <code>/b/</code> matches the character \"b\". By placing a backslash in front of \"b\", that is by using <code>/\\b/</code>, the character becomes special to mean match a word boundary.</p> <p><em>or</em></p> <p>For characters that are usually treated specially, indicates that the next character is not special and should be interpreted literally.</p> <p>For example, \"*\" is a special character that means 0 or more occurrences of the preceding character should be matched; for example, <code>/a*/</code> means match 0 or more \"a\"s. To match <code>*</code> literally, precede it with a backslash; for example, <code>/a\\*/</code> matches \"a*\".</p> </td> </tr> </tbody> <tbody> <tr id=\"character-sets\"> <th colspan=\"2\">Character Sets</th> </tr> <tr> <th>Character</th> <th>Meaning</th> </tr> <tr> <td><code>[xyz]<br>\n    [a-c]</code></td> <td> <p>A character set. Matches any one of the enclosed characters. You can specify a range of characters by using a hyphen, but if the hyphen appears as the first or last character enclosed in the square brackets it is taken as a literal hyphen to be included in the character set as a normal character. It is also possible to include a character class in a character set.</p> <p>For example, <code>[abcd]</code> is the same as <code>[a-d]</code>. They match the \"b\" in \"brisket\" and the \"c\" in \"chop\".</p> <p>For example, [abcd-] and [-abcd] match the \"b\" in \"brisket\", the \"c\" in \"chop\" and the \"-\" (hyphen) in \"non-profit\".</p> <p>For example, [\\w-] is the same as [A-Za-z0-9_-]. They match the \"b\" in \"brisket\", the \"c\" in \"chop\" and the \"n\" in \"non-profit\".</p> </td> </tr> <tr> <td> <p><code>[^xyz]<br>\n     [^a-c]</code></p> </td> <td> <p>A negated or complemented character set. That is, it matches anything that is not enclosed in the brackets. You can specify a range of characters by using a hyphen, but if the hyphen appears as the first or last character enclosed in the square brackets it is taken as a literal hyphen to be included in the character set as a normal character.</p> <p>For example, <code>[^abc]</code> is the same as <code>[^a-c]</code>. They initially match \"o\" in \"bacon\" and \"h\" in \"chop\".</p> </td> </tr> </tbody> <tbody> <tr id=\"alternation\"> <th colspan=\"2\">Alternation</th> </tr> <tr> <th>Character</th> <th>Meaning</th> </tr> <tr> <td><code><em>x</em>|<em>y</em></code></td> <td> <p>Matches either <code><em>x</em></code> or <code><em>y</em></code>.</p> <p>For example, <code>/green|red/</code> matches \"green\" in \"green apple\" and \"red\" in \"red apple\".</p> </td> </tr> </tbody> <tbody> <tr id=\"boundaries\"> <th colspan=\"2\">Boundaries</th> </tr> <tr> <th>Character</th> <th>Meaning</th> </tr> <tr> <td><code>^</code></td> <td> <p>Matches beginning of input. If the multiline flag is set to true, also matches immediately after a line break character.</p> <p>For example, <code>/^A/</code> does not match the \"A\" in \"an A\", but does match the first \"A\" in \"An A\".</p> </td> </tr> <tr> <td><code>$</code></td> <td> <p>Matches end of input. If the multiline flag is set to true, also matches immediately before a line break character.</p> <p>For example, <code>/t$/</code> does not match the \"t\" in \"eater\", but does match it in \"eat\".</p> </td> </tr> <tr> <td><code>\\b</code></td> <td> <p>Matches a word boundary. This is the position where a word character is not followed or preceded by another word-character, such as between a letter and a space. Note that a matched word boundary is not included in the match. In other words, the length of a matched word boundary is zero.</p> <p>Examples:<br> <code>/\\bm/</code> matches the 'm' in \"moon\" ;<br> <code>/oo\\b/</code> does not match the 'oo' in \"moon\", because 'oo' is followed by 'n' which is a word character;<br> <code>/oon\\b/</code> matches the 'oon' in \"moon\", because 'oon' is the end of the string, thus not followed by a word character;<br> <code>/\\w\\b\\w/</code> will never match anything, because a word character can never be followed by both a non-word and a word character.</p> </td> </tr> <tr> <td><code>\\B</code></td> <td> <p>Matches a non-word boundary. This is a position where the previous and next character are of the same type: Either both must be words, or both must be non-words. Such as between two letters or between two spaces. The beginning and end of a string are considered non-words. Same as the matched word boundary, the matched non-word boundary is also not included in the match.</p> <p>For example, <code>/\\Bon/</code> matches \"on\" in \"at noon\", and <code>/ye\\B/</code> matches \"ye\" in \"possibly yesterday\".</p> </td> </tr> </tbody> <tbody> <tr id=\"grouping-back-references\"> <th colspan=\"2\">Grouping and back references</th> </tr> <tr> <th>Character</th> <th>Meaning</th> </tr> <tr> <td><code>(<em>x</em>)</code></td> <td> <p>Matches <code><em>x</em></code> and remembers the match. These are called capturing groups.</p> <p>For example, <code>/(foo)/</code> matches and remembers \"foo\" in \"foo bar\". </p> <p>The capturing groups are numbered according to the order of left parentheses of capturing groups, starting from 1. The matched substring can be recalled from the resulting array's elements <code>[1], ..., [n]</code> or from the predefined <code>RegExp</code> object's properties <code>$1, ..., $9</code>.</p> <p>Capturing groups have a performance penalty. If you don't need the matched substring to be recalled, prefer non-capturing parentheses (see below).</p> </td> </tr> <tr> <td><code>\\<em>n</em></code></td> <td> <p>Where <code><em>n</em></code> is a positive integer. A back reference to the last substring matching the n parenthetical in the regular expression (counting left parentheses).</p> <p>For example, <code>/apple(,)\\sorange\\1/</code> matches \"apple, orange,\" in \"apple, orange, cherry, peach\". A complete example follows this table.</p> </td> </tr> <tr> <td><code>(?:<em>x</em>)</code></td> <td>Matches <code><em>x</em></code> but does not remember the match. These are called non-capturing groups. The matched substring cannot be recalled from the resulting array's elements <code>[1], ..., [n]</code> or from the predefined <code>RegExp</code> object's properties <code>$1, ..., $9</code>.</td> </tr> </tbody> <tbody> <tr id=\"quantifiers\"> <th colspan=\"2\">Quantifiers</th> </tr> <tr> <th>Character</th> <th>Meaning</th> </tr> <tr> <td><code><em>x</em>*</code></td> <td> <p>Matches the preceding item <em>x</em> 0 or more times.</p> <p>For example, <code>/bo*/</code> matches \"boooo\" in \"A ghost booooed\" and \"b\" in \"A bird warbled\", but nothing in \"A goat grunted\".</p> </td> </tr> <tr> <td><code><em>x</em>+</code></td> <td> <p>Matches the preceding item <em>x</em> 1 or more times. Equivalent to <code>{1,}</code>.</p> <p>For example, <code>/a+/</code> matches the \"a\" in \"candy\" and all the \"a\"'s in \"caaaaaaandy\".</p> </td> </tr> <tr> <td><code><em>x</em>?</code></td> <td> <p>Matches the preceding item <em>x</em> 0 or 1 time.</p> <p>For example, <code>/e?le?/</code> matches the \"el\" in \"angel\" and the \"le\" in \"angle.\"</p> <p>If used immediately after any of the quantifiers <code>*</code>, <code>+</code>, <code>?</code>, or <code>{}</code>, makes the quantifier non-greedy (matching the minimum number of times), as opposed to the default, which is greedy (matching the maximum number of times).</p> </td> </tr> <tr> <td><code><em>x</em>{<em>n</em>}</code></td> <td> <p>Where <code><em>n</em></code> is a positive integer. Matches exactly <code><em>n</em></code> occurrences of the preceding item <em>x</em>.</p> <p>For example, <code>/a{2}/</code> doesn't match the \"a\" in \"candy\", but it matches all of the \"a\"'s in \"caandy\", and the first two \"a\"'s in \"caaandy\".</p> </td> </tr> <tr> <td><code><em>x</em>{<em>n</em>,}</code></td> <td> <p>Where <code><em>n</em></code> is a positive integer. Matches at least <code><em>n</em></code> occurrences of the preceding item <em>x</em>.</p> <p>For example, <code>/a{2,}/</code> doesn't match the \"a\" in \"candy\", but matches all of the a's in \"caandy\" and in \"caaaaaaandy\".</p> </td> </tr> <tr> <td><code><em>x</em>{<em>n</em>,<em>m</em>}</code></td> <td> <p>Where <code><em>n</em></code> is 0 or a positive integer, <code><em>m</em></code> is a positive integer, and <code><em>m</em></code> &gt; <code><em>n</em></code>. Matches at least <code><em>n</em></code> and at most <code><em>m</em></code> occurrences of the preceding item <em>x</em>.</p> <p>For example, <code>/a{1,3}/</code> matches nothing in \"cndy\", the \"a\" in \"candy\", the two \"a\"'s in \"caandy\", and the first three \"a\"'s in \"caaaaaaandy\". Notice that when matching \"caaaaaaandy\", the match is \"aaa\", even though the original string had more \"a\"'s in it.</p> </td> </tr> <tr> <td> <p><code><em>x</em>*?</code><br> <code><em>x</em>+?</code><br> <code><em>x</em>??</code><br> <code><em>x</em>{n}?</code><br> <code><em>x</em>{n,}?</code><br> <code><em>x</em>{n,m}?</code></p> </td> <td> <p>Matches the preceding item <em>x</em> like <code>*</code>, <code>+</code>, <code>?</code>, and <code>{...}</code> from above, however the match is the smallest possible match.</p> <p>For example, <code>/&lt;.*?&gt;/</code> matches \"&lt;foo&gt;\" in \"&lt;foo&gt; &lt;bar&gt;\", whereas <code>/&lt;.*&gt;/</code> matches \"&lt;foo&gt; &lt;bar&gt;\".</p> <p>Quantifiers without <code>?</code> are said to be greedy. Those with <code>?</code> are called \"non-greedy\".</p> </td> </tr> </tbody> <tbody> <tr id=\"assertions\"> <th colspan=\"2\">Assertions</th> </tr> <tr> <th>Character</th> <th>Meaning</th> </tr> <tr> <td><code><em>x</em>(?=<em>y</em>)</code></td> <td> <p>Matches <code><em>x</em></code> only if <code><em>x</em></code> is followed by <code><em>y</em></code>.</p> <p>For example, /<code>Jack(?=Sprat)/</code> matches \"Jack\" only if it is followed by \"Sprat\".<br> <code>/Jack(?=Sprat|Frost)/</code> matches \"Jack\" only if it is followed by \"Sprat\" or \"Frost\". However, neither \"Sprat\" nor \"Frost\" is part of the match results.</p> </td> </tr> <tr> <td><code><em>x</em>(?!<em>y</em>)</code></td> <td> <p>Matches <code><em>x</em></code> only if <code><em>x</em></code> is not followed by <code><em>y</em></code>.</p> <p>For example, <code>/\\d+(?!\\.)/</code> matches a number only if it is not followed by a decimal point.<br> <code>/\\d+(?!\\.)/.exec('3.141')</code> matches \"141\" but not \"3.141\".</p> </td> </tr> </tbody> </table></div> <h2 id=\"Properties\">Properties</h2> <dl> <dt><a href=\"regexp/prototype\"><code>RegExp.prototype</code></a></dt> <dd>Allows the addition of properties to all objects.</dd> <dt><code>RegExp.length</code></dt> <dd>The value of <code>RegExp.length</code> is 2.</dd> <dt><a href=\"regexp/@@species\"><code>get RegExp[@@species]</code></a></dt> <dd>The constructor function that is used to create derived objects.</dd> <dt><a href=\"regexp/lastindex\"><code>RegExp.lastIndex</code></a></dt> <dd>The index at which to start the next match.</dd> </dl> <h2 id=\"Methods\">Methods</h2> <p>The global <code>RegExp</code> object has no methods of its own, however, it does inherit some methods through the prototype chain.</p> <h2 id=\"RegExp_prototype_objects_and_instances\">\n<code>RegExp</code> prototype objects and instances</h2> <h3 id=\"Properties_2\">Properties</h3> <p>See also <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Deprecated_and_obsolete_features#RegExp_Properties\">deprecated <code>RegExp</code> properties.</a></p> <p>Note that several of the <a href=\"regexp\"><code>RegExp</code></a> properties have both long and short (Perl-like) names. Both names always refer to the same value. Perl is the programming language from which JavaScript modeled its regular expressions.</p> <dl> <dt><code>RegExp.prototype.constructor</code></dt> <dd>Specifies the function that creates an object's prototype.</dd> <dt><a href=\"regexp/flags\"><code>RegExp.prototype.flags</code></a></dt> <dd>A string that contains the flags of the <code>RegExp</code> object.</dd> <dt><a href=\"regexp/global\"><code>RegExp.prototype.global</code></a></dt> <dd>Whether to test the regular expression against all possible matches in a string, or only against the first.</dd> <dt><a href=\"regexp/ignorecase\"><code>RegExp.prototype.ignoreCase</code></a></dt> <dd>Whether to ignore case while attempting a match in a string.</dd> <dt><a href=\"regexp/multiline\"><code>RegExp.prototype.multiline</code></a></dt> <dd>Whether or not to search in strings across multiple lines.</dd> <dt><a href=\"regexp/source\"><code>RegExp.prototype.source</code></a></dt> <dd>The text of the pattern.</dd> <dt><a href=\"regexp/sticky\"><code>RegExp.prototype.sticky</code></a></dt> <dd>Whether or not the search is sticky.</dd> <dt><a href=\"regexp/unicode\"><code>RegExp.prototype.unicode</code></a></dt> <dd>Whether or not Unicode features are enabled.</dd> </dl> <h3 id=\"Methods_2\">Methods</h3> <dl> <dt>\n<a href=\"regexp/compile\"><code>RegExp.prototype.compile()</code></a> \n</dt> <dd>(Re-)compiles a regular expression during execution of a script.</dd> <dt><a href=\"regexp/exec\"><code>RegExp.prototype.exec()</code></a></dt> <dd>Executes a search for a match in its string parameter.</dd> <dt><a href=\"regexp/test\"><code>RegExp.prototype.test()</code></a></dt> <dd>Tests for a match in its string parameter.</dd> <dt><a href=\"regexp/@@match\"><code>RegExp.prototype[@@match]()</code></a></dt> <dd>Performs match to given string and returns match result.</dd> <dt><a href=\"regexp/@@replace\"><code>RegExp.prototype[@@replace]()</code></a></dt> <dd>Replaces matches in given string with new substring.</dd> <dt><a href=\"regexp/@@search\"><code>RegExp.prototype[@@search]()</code></a></dt> <dd>Searches the match in given string and returns the index the pattern found in the string.</dd> <dt><a href=\"regexp/@@split\"><code>RegExp.prototype[@@split]()</code></a></dt> <dd>Splits given string into an array by separating the string into substring.</dd> <dt>\n<a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/toSource\"><code>RegExp.prototype.toSource()</code></a> \n</dt> <dd>Returns an object literal representing the specified object; you can use this value to create a new object. Overrides the <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/toSource\"><code>Object.prototype.toSource()</code></a> method.</dd> <dt><a href=\"regexp/tostring\"><code>RegExp.prototype.toString()</code></a></dt> <dd>Returns a string representing the specified object. Overrides the <a href=\"object/tostring\"><code>Object.prototype.toString()</code></a> method.</dd> </dl> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Using_a_regular_expression_to_change_data_format\">Using a regular expression to change data format</h3> <p>The following script uses the <a href=\"string/replace\"><code>replace()</code></a> method of the <a href=\"string\"><code>String</code></a> instance to match a name in the format <em>first last</em> and output it in the format <em>last, first</em>. In the replacement text, the script uses <code>$1</code> and <code>$2</code> to indicate the results of the corresponding matching parentheses in the regular expression pattern.</p> <pre data-language=\"js\">var re = /(\\w+)\\s(\\w+)/;\nvar str = 'John Smith';\nvar newstr = str.replace(re, '$2, $1');\nconsole.log(newstr);\n</pre> <p>This displays \"Smith, John\".</p> <h3 id=\"Using_regular_expression_to_split_lines_with_different_line_endingsends_of_lineline_breaks\">Using regular expression to split lines with different <strong>line endings/ends of line/line breaks</strong>\n</h3> <p>The default line ending varies depending on the platform (Unix, Windows, etc.). The line splitting provided in this example works on all platforms.</p> <pre data-language=\"js\">var text = 'Some text\\nAnd some more\\r\\nAnd yet\\rThis is the end';\nvar lines = text.split(/\\r\\n|\\r|\\n/);\nconsole.log(lines); // logs [ 'Some text', 'And some more', 'And yet', 'This is the end' ]\n</pre> <p>Note that the order of the patterns in the regular expression matters.</p> <h3 id=\"Using_regular_expression_on_multiple_lines\">Using regular expression on multiple lines</h3> <pre data-language=\"js\">var s = 'Please yes\\nmake my day!';\ns.match(/yes.*day/);\n// Returns null\ns.match(/yes[^]*day/);\n// Returns [\"yes\\nmake my day\"]\n</pre> <h3 id=\"Using_a_regular_expression_with_the_sticky_flag\">Using a regular expression with the sticky flag</h3> <p>The <a href=\"regexp/sticky\">sticky flag</a> indicates that the regular expression performs sticky matching in the target string by attempting to match starting at <a href=\"regexp/lastindex\"><code>RegExp.prototype.lastIndex</code></a>.</p> <pre data-language=\"js\">var str = '#foo#';\nvar regex = /foo/y;\n\nregex.lastIndex = 1;\nregex.test(str); // true\nregex.lastIndex = 5;\nregex.test(str); // false (lastIndex is taken into account with sticky flag)\nregex.lastIndex; // 0 (reset after match failure)</pre> <h3 id=\"Regular_expression_and_Unicode_characters\">Regular expression and Unicode characters</h3> <p>As mentioned above, <code>\\w</code> or <code>\\W</code> only matches ASCII based characters; for example, \"a\" to \"z\", \"A\" to \"Z\", \"0\" to \"9\" and \"_\". To match characters from other languages such as Cyrillic or Hebrew, use <code>\\uhhhh</code>, where \"hhhh\" is the character's Unicode value in hexadecimal. This example demonstrates how one can separate out Unicode characters from a word.</p> <pre data-language=\"js\">var text = 'Образец text на русском языке';\nvar regex = /[\\u0400-\\u04FF]+/g;\n\nvar match = regex.exec(text);\nconsole.log(match[0]);        // logs 'Образец'\nconsole.log(regex.lastIndex); // logs '7'\n\nvar match2 = regex.exec(text);\nconsole.log(match2[0]);       // logs 'на' [did not log 'text']\nconsole.log(regex.lastIndex); // logs '15'\n\n// and so on\n</pre> <p>Here's an external resource for getting the complete Unicode block range for different scripts: <a href=\"http://kourge.net/projects/regexp-unicode-block\">Regexp-Unicode-block</a>.</p> <h3 id=\"Extracting_sub-domain_name_from_URL\">Extracting sub-domain name from URL</h3> <pre data-language=\"js\">var url = 'http://xxx.domain.com';\nconsole.log(/[^.]+/.exec(url)[0].substr(7)); // logs 'xxx'\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/publications/files/ECMA-ST-ARCH/ECMA-262,%203rd%20edition,%20December%201999.pdf\" hreflang=\"en\">ECMAScript 3rd Edition (ECMA-262)</a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition. Implemented in JavaScript 1.1.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/5.1/#sec-15.10\" hreflang=\"en\">ECMAScript 5.1 (ECMA-262)<br><small>The definition of 'RegExp' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-regexp-regular-expression-objects\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'RegExp' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>The <code>RegExp</code> constructor no longer throws when the first argument is a <code>RegExp</code> and the second argument is present. Introduces Unicode and sticky flags.</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-regexp-regular-expression-objects\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'RegExp' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>   <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/RegExp/compile\"><code>compile</code></a> \n</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/RegExp/exec\"><code>exec</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/RegExp/flags\"><code>flags</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 37</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/RegExp/global\"><code>global</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/RegExp/ignoreCase\"><code>ignoreCase</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/RegExp/input\"><code>RegExp.input</code> (<code>$_</code>)</a> \n</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/RegExp/lastIndex\"><code>lastIndex</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/RegExp/lastMatch\"><code>RegExp.lastMatch</code> (<code>$&amp;</code>)</a> \n</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/RegExp/lastParen\"><code>RegExp.lastParen</code> (<code>$+</code>)</a> \n</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/RegExp/leftContext\"><code>RegExp.leftContext</code> (<code>$`</code>)</a> \n</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">lookbehind assertions (<code>(?&lt;= )</code> and <code>(?&lt;! )</code>)</th>\n<td class=\"bc-supports-yes\"> 62</td>\n<td> ? </td>\n<td> ? </td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 49</td>\n<td> ? </td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/RegExp/multiline\"><code>multiline</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/RegExp/n\"><code>RegExp.$1-$9</code></a> \n</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/RegExp/prototype\"><code>prototype</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/RegExp/rightContext\"><code>RegExp.rightContext</code> (<code>$'</code>)</a> \n</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/RegExp/source\"><code>source</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/RegExp/sticky\"><code>sticky</code></a></th>\n<td class=\"bc-supports-yes\"> 49</td>\n<td class=\"bc-supports-yes\"> 13</td>\n<td class=\"bc-supports-yes\"> 3</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 36</td>\n<td class=\"bc-supports-yes\"> 10</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/RegExp/test\"><code>test</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/RegExp/toSource\"><code>toSource</code></a> \n</th>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/RegExp/toString\"><code>toString</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/RegExp/unicode\"><code>unicode</code></a></th>\n<td class=\"bc-supports-yes\"> 50</td>\n<td class=\"bc-supports-yes bc-has-history\"> 12\n<section class=\"bc-history\" id=\"sect1\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 12\n</dt>\n<dd> Case folding is implemented in version 13</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-yes\"> 46</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 37</td>\n<td class=\"bc-supports-yes\"> 10</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/RegExp/@@match\"><code>@@match</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 49</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/RegExp/@@replace\"><code>@@replace</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 49</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/RegExp/@@search\"><code>@@search</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 49</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/RegExp/@@species\"><code>@@species</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 49</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/RegExp/@@split\"><code>@@split</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 49</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n</tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/RegExp/compile\"><code>compile</code></a> \n</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/RegExp/exec\"><code>exec</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/RegExp/flags\"><code>flags</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 37</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/RegExp/global\"><code>global</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/RegExp/ignoreCase\"><code>ignoreCase</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/RegExp/input\"><code>RegExp.input</code> (<code>$_</code>)</a> \n</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/RegExp/lastIndex\"><code>lastIndex</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/RegExp/lastMatch\"><code>RegExp.lastMatch</code> (<code>$&amp;</code>)</a> \n</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/RegExp/lastParen\"><code>RegExp.lastParen</code> (<code>$+</code>)</a> \n</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/RegExp/leftContext\"><code>RegExp.leftContext</code> (<code>$`</code>)</a> \n</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">lookbehind assertions (<code>(?&lt;= )</code> and <code>(?&lt;! )</code>)</th>\n<td class=\"bc-supports-yes\"> 62</td>\n<td class=\"bc-supports-yes\"> 62</td>\n<td> ? </td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 49</td>\n<td> ? </td>\n<td> ? </td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/RegExp/multiline\"><code>multiline</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/RegExp/n\"><code>RegExp.$1-$9</code></a> \n</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/RegExp/prototype\"><code>prototype</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/RegExp/rightContext\"><code>RegExp.rightContext</code> (<code>$'</code>)</a> \n</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/RegExp/source\"><code>source</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/RegExp/sticky\"><code>sticky</code></a></th>\n<td class=\"bc-supports-yes\"> 49</td>\n<td class=\"bc-supports-yes\"> 49</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> 36</td>\n<td class=\"bc-supports-yes\"> 10</td>\n<td class=\"bc-supports-yes\"> 5.0</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/RegExp/test\"><code>test</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/RegExp/toSource\"><code>toSource</code></a> \n</th>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/RegExp/toString\"><code>toString</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/RegExp/unicode\"><code>unicode</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 50</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 46</td>\n<td class=\"bc-supports-yes\"> 37</td>\n<td class=\"bc-supports-yes\"> 10</td>\n<td class=\"bc-supports-yes\"> 5.0</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/RegExp/@@match\"><code>@@match</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 49</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/RegExp/@@replace\"><code>@@replace</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 49</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/RegExp/@@search\"><code>@@search</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 49</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/RegExp/@@species\"><code>@@species</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 49</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/RegExp/@@split\"><code>@@split</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 49</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n</tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/RegExp/compile\"><code>compile</code></a> \n</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/RegExp/exec\"><code>exec</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/RegExp/flags\"><code>flags</code></a></th>\n<td class=\"bc-supports-yes\"> 6.0.0</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/RegExp/global\"><code>global</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/RegExp/ignoreCase\"><code>ignoreCase</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/RegExp/input\"><code>RegExp.input</code> (<code>$_</code>)</a> \n</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/RegExp/lastIndex\"><code>lastIndex</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/RegExp/lastMatch\"><code>RegExp.lastMatch</code> (<code>$&amp;</code>)</a> \n</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/RegExp/lastParen\"><code>RegExp.lastParen</code> (<code>$+</code>)</a> \n</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/RegExp/leftContext\"><code>RegExp.leftContext</code> (<code>$`</code>)</a> \n</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">lookbehind assertions (<code>(?&lt;= )</code> and <code>(?&lt;! )</code>)</th>\n<td> ? </td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/RegExp/multiline\"><code>multiline</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/RegExp/n\"><code>RegExp.$1-$9</code></a> \n</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/RegExp/prototype\"><code>prototype</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/RegExp/rightContext\"><code>RegExp.rightContext</code> (<code>$'</code>)</a> \n</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/RegExp/source\"><code>source</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/RegExp/sticky\"><code>sticky</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/RegExp/test\"><code>test</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/RegExp/toSource\"><code>toSource</code></a> \n</th>\n<td class=\"bc-supports-no\"> No</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/RegExp/toString\"><code>toString</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/RegExp/unicode\"><code>unicode</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/RegExp/@@match\"><code>@@match</code></a></th>\n<td class=\"bc-supports-yes\"> 6.0.0</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/RegExp/@@replace\"><code>@@replace</code></a></th>\n<td class=\"bc-supports-yes\"> 6.0.0</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/RegExp/@@search\"><code>@@search</code></a></th>\n<td class=\"bc-supports-yes\"> 6.0.0</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/RegExp/@@species\"><code>@@species</code></a></th>\n<td class=\"bc-supports-yes bc-has-history\"> 6.5.0\n<section class=\"bc-history\" id=\"sect2\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 6.5.0\n</dt>\n\n<dt class=\"bc-supports-yes bc-supports\"> 6.0.0<div class=\"bc-icons\">Disabled </div>\n</dt>\n<dd>Disabled From version 6.0.0: this feature is behind the <code>--harmony</code> runtime flag.</dd>\n</dl></section>\n</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/RegExp/@@split\"><code>@@split</code></a></th>\n<td class=\"bc-supports-yes\"> 6.0.0</td>\n</tr>\n</tbody>\n</table>\n</div>  <h3 id=\"Firefox-specific_notes\">Firefox-specific notes</h3> <p>Starting with Firefox 34, in the case of a capturing group with quantifiers preventing its exercise, the matched text for a capturing group is now <code>undefined</code> instead of an empty string:</p> <pre data-language=\"js\">// Firefox 33 or older\n'x'.replace(/x(.)?/g, function(m, group) {\n  console.log(\"'group:\" + group + \"'\");\n}); // 'group:'\n\n// Firefox 34 or newer\n'x'.replace(/x(.)?/g, function(m, group) {\n  console.log(\"'group:\" + group + \"'\");\n}); // 'group:undefined'\n</pre> <p>Note that due to web compatibility, <code>RegExp.$N</code> will still return an empty string instead of <code>undefined</code> (<a href=\"https://bugzilla.mozilla.org/show_bug.cgi?id=1053944\">bug 1053944</a>).</p> <h2 id=\"See_also\">See also</h2> <ul> <li>\n<a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions\">Regular Expressions</a> chapter in the <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide\">JavaScript Guide</a>\n</li> <li><a href=\"string/match\"><code>String.prototype.match()</code></a></li> <li><a href=\"string/replace\"><code>String.prototype.replace()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp</a>\n  </p>\n</div>\n","global_objects/encodeuri":"<h1>encodeURI</h1> <p>The <code><strong>encodeURI()</strong></code> function encodes a Uniform Resource Identifier (URI) by replacing each instance of certain characters by one, two, three, or four escape sequences representing the UTF-8 encoding of the character (will only be four escape sequences for characters composed of two \"surrogate\" characters).</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/globalprops-encodeuri.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\">encodeURI(<em>URI</em>)</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><code>URI</code></dt> <dd>A complete Uniform Resource Identifier.</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p>A new string representing the provided string encoded as a Uniform Resource Identifier (URI).</p> <h2 id=\"Description\">Description</h2> <p>Does not encode characters that have special meaning (reserved characters) for a URI. The following example shows all the parts that a URI \"scheme\" can possibly contain. Note how certain characters are used to signify special meaning:</p> <pre>http://username:password@www.example.com:80/path/to/file.php?foo=316&amp;bar=this+has+spaces#anchor</pre> <p>Hence encodeURI <strong>does not</strong> encode characters that are necessary to formulate a complete URI. Also, encodeURI <strong>does not</strong> encode a few additional characters, known as \"unreserved marks\", which do not have a reserved purpose but are allowed in a URI \"as is\". (See <a href=\"https://www.ietf.org/rfc/rfc2396.txt\">RFC2396)</a></p> <p><code>encodeURI</code> escapes all characters <strong>except</strong>:</p> <pre><strong>Not Escaped</strong>:\n\n    A-Z a-z 0-9 ; , / ? : @ &amp; = + $ - _ . ! ~ * ' ( ) #\n\n</pre> <p>encodeURI differs from <a href=\"encodeuricomponent\"><code>encodeURIComponent</code></a> as follows:</p> <pre data-language=\"js\">var set1 = \";,/?:@&amp;=+$#\";  // Reserved Characters\nvar set2 = \"-_.!~*'()\";   // Unreserved Marks\nvar set3 = \"ABC abc 123\"; // Alphanumeric Characters + Space\n\nconsole.log(encodeURI(set1)); // ;,/?:@&amp;=+$#\nconsole.log(encodeURI(set2)); // -_.!~*'()\nconsole.log(encodeURI(set3)); // ABC%20abc%20123 (the space gets encoded as %20)\n\nconsole.log(encodeURIComponent(set1)); // %3B%2C%2F%3F%3A%40%26%3D%2B%24%23\nconsole.log(encodeURIComponent(set2)); // -_.!~*'()\nconsole.log(encodeURIComponent(set3)); // ABC%20abc%20123 (the space gets encoded as %20)\n\n</pre> <p>Note that a <a href=\"urierror\"><code>URIError</code></a> will be thrown if one attempts to encode a surrogate which is not part of a high-low pair, e.g.,</p> <pre data-language=\"js\">// high-low pair ok\nconsole.log(encodeURIComponent('\\uD800\\uDFFF'));\n\n// lone high surrogate throws \"URIError: malformed URI sequence\"\nconsole.log(encodeURIComponent('\\uD800'));\n\n// lone low surrogate throws \"URIError: malformed URI sequence\"\nconsole.log(encodeURIComponent('\\uDFFF')); \n</pre> <p>Note that <code>encodeURI</code> by itself <em>cannot</em> form proper HTTP GET and POST requests, such as for XMLHTTPRequests, because \"&amp;\", \"+\", and \"=\" are not encoded, which are treated as special characters in GET and POST requests. <a href=\"encodeuricomponent\"><code>encodeURIComponent</code></a>, however, does encode these characters.</p> <p>Note that an <a href=\"urierror\"><code>URIError</code></a> will be thrown if one attempts to encode a surrogate which is not part of a high-low pair, e.g.,</p> <pre data-language=\"js\">// high-low pair ok\nconsole.log(encodeURI('\\uD800\\uDFFF'));\n\n// lone high surrogate throws \"URIError: malformed URI sequence\"\nconsole.log(encodeURI('\\uD800'));\n\n// lone low surrogate throws \"URIError: malformed URI sequence\"\nconsole.log(encodeURI('\\uDFFF')); </pre> <p>Also note that if one wishes to follow the more recent <a href=\"http://tools.ietf.org/html/rfc3986\">RFC3986</a> for URLs, which makes square brackets reserved (for IPv6) and thus not encoded when forming something which could be part of a URL (such as a host), the following code snippet may help:</p> <pre data-language=\"js\">function fixedEncodeURI(str) {\n    return encodeURI(str).replace(/%5B/g, '[').replace(/%5D/g, ']');\n}</pre> <p>Alternative URI encoding scheme is Base62x, which has been ported into NPM.</p> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/publications/files/ECMA-ST-ARCH/ECMA-262,%203rd%20edition,%20December%201999.pdf\" hreflang=\"en\">ECMAScript 3rd Edition (ECMA-262)</a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/5.1/#sec-15.1.3.3\" hreflang=\"en\">ECMAScript 5.1 (ECMA-262)<br><small>The definition of 'encodeURI' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-encodeuri-uri\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'encodeURI' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-encodeuri-uri\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'encodeURI' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"decodeuri\"><code>decodeURI()</code></a></li> <li><a href=\"encodeuricomponent\"><code>encodeURIComponent()</code></a></li> <li><a href=\"decodeuricomponent\"><code>decodeURIComponent()</code></a></li> <li>Base62x</li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/encodeURI$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/encodeURI\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/encodeURI</a>\n  </p>\n</div>\n","global_objects/encodeuricomponent":"<h1>encodeURIComponent</h1> <p>The <code><strong>encodeURIComponent()</strong></code> function encodes a Uniform Resource Identifier (URI) component by replacing each instance of certain characters by one, two, three, or four escape sequences representing the UTF-8 encoding of the character (will only be four escape sequences for characters composed of two \"surrogate\" characters).</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/globalprops-encodeuricomponent.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\">encodeURIComponent(str);</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><code>str</code></dt> <dd>String. A component of a URI.</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p>A new string representing the provided string encoded as a Uniform Resource Identifier (URI) component.</p> <h2 id=\"Description\">Description</h2> <p><code>encodeURIComponent</code> escapes all characters <strong>except</strong>:</p> <pre><strong>Not Escaped</strong>:\n\n    A-Z a-z 0-9 - _ . ! ~ * ' ( )\n\n</pre> <p><code>encodeURIComponent</code> differs from <code>encodeURI</code> as follows:</p> <pre data-language=\"js\">var set1 = \";,/?:@&amp;=+$\";  // Reserved Characters\nvar set2 = \"-_.!~*'()\";   // Unescaped Characters\nvar set3 = \"#\";           // Number Sign\nvar set4 = \"ABC abc 123\"; // Alphanumeric Characters + Space\n\nconsole.log(encodeURI(set1)); // ;,/?:@&amp;=+$\nconsole.log(encodeURI(set2)); // -_.!~*'()\nconsole.log(encodeURI(set3)); // #\nconsole.log(encodeURI(set4)); // ABC%20abc%20123 (the space gets encoded as %20)\n\nconsole.log(encodeURIComponent(set1)); // %3B%2C%2F%3F%3A%40%26%3D%2B%24\nconsole.log(encodeURIComponent(set2)); // -_.!~*'()\nconsole.log(encodeURIComponent(set3)); // %23\nconsole.log(encodeURIComponent(set4)); // ABC%20abc%20123 (the space gets encoded as %20)\n\n</pre> <p>Note that a <a href=\"urierror\"><code>URIError</code></a> will be thrown if one attempts to encode a surrogate which is not part of a high-low pair, e.g.,</p> <pre data-language=\"js\">// high-low pair ok\nconsole.log(encodeURIComponent('\\uD800\\uDFFF'));\n\n// lone high surrogate throws \"URIError: malformed URI sequence\"\nconsole.log(encodeURIComponent('\\uD800'));\n\n// lone low surrogate throws \"URIError: malformed URI sequence\"\nconsole.log(encodeURIComponent('\\uDFFF')); \n</pre> <p>Use <code>encodeURIComponent</code> on user-entered fields from forms POST'd to the server. This will encode \"&amp;\" symbols that may inadvertently be generated during data entry for special HTML entities or other characters that require encoding/decoding.</p> <p>For example, if a user writes \"Jack &amp; Jill\", the text may get encoded as \"Jack &amp;amp; Jill\". Without <code>encodeURIComponent</code> the ampersand could be interpretted on the server as the start of a new field and jeopardize the integrity of the data.</p> <p>For <a href=\"http://www.whatwg.org/specs/web-apps/current-work/multipage/association-of-controls-and-forms.html#application/x-www-form-urlencoded-encoding-algorithm\"><code>application/x-www-form-urlencoded</code></a>, spaces are to be replaced by '+', so one may wish to follow a <code>encodeURIComponent</code> replacement with an additional replacement of \"%20\" with \"+\".</p> <p>To be more stringent in adhering to <a href=\"http://tools.ietf.org/html/rfc3986\">RFC 3986</a> (which reserves !, ', (, ), and *), even though these characters have no formalized URI delimiting uses, the following can be safely used:</p> <pre data-language=\"js\">function fixedEncodeURIComponent(str) {\n  return encodeURIComponent(str).replace(/[!'()*]/g, function(c) {\n    return '%' + c.charCodeAt(0).toString(16);\n  });\n}\n</pre> <h2 id=\"Examples\">Examples</h2> <p>The following example provides the special encoding required within UTF-8 <code>Content-Disposition</code> and <code>Link</code> server response header parameters (e.g., UTF-8 filenames):</p> <pre data-language=\"js\">var fileName = 'my file(2).txt';\nvar header = \"Content-Disposition: attachment; filename*=UTF-8''\" \n             + encodeRFC5987ValueChars(fileName);\n\nconsole.log(header); \n// logs \"Content-Disposition: attachment; filename*=UTF-8''my%20file%282%29.txt\"\n\n\nfunction encodeRFC5987ValueChars(str) {\n    return encodeURIComponent(str).\n        // Note that although RFC3986 reserves \"!\", RFC5987 does not,\n        // so we do not need to escape it\n        replace(/['()]/g, escape). // i.e., %27 %28 %29\n        replace(/\\*/g, '%2A').\n            // The following are not required for percent-encoding per RFC5987, \n            // so we can allow for a little better readability over the wire: |`^\n            replace(/%(?:7C|60|5E)/g, unescape);\n}\n\n// here is an alternative to the above function\nfunction encodeRFC5987ValueChars2(str) {\n  return encodeURIComponent(str).\n    // Note that although RFC3986 reserves \"!\", RFC5987 does not,\n    // so we do not need to escape it\n    replace(/['()*]/g, c =&gt; \"%\" + c.charCodeAt(0).toString(16)). // i.e., %27 %28 %29 %2A\n    // The following are not required for percent-encoding per RFC5987,\n    // so we can allow for a little better readability over the wire: |`^\n    replace(/%(7C|60|5E)/g, (str, hex) =&gt; String.fromCharCode(parseInt(hex, 16)));\n}</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/publications/files/ECMA-ST-ARCH/ECMA-262,%203rd%20edition,%20December%201999.pdf\" hreflang=\"en\">ECMAScript 3rd Edition (ECMA-262)</a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/5.1/#sec-15.1.3.4\" hreflang=\"en\">ECMAScript 5.1 (ECMA-262)<br><small>The definition of 'encodeURIComponent' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-encodeuricomponent-uricomponent\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'encodeURIComponent' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-encodeuricomponent-uricomponent\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'encodeURIComponent' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> 5.5</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"decodeuri\"><code>decodeURI</code></a></li> <li><a href=\"encodeuri\"><code>encodeURI</code></a></li> <li><a href=\"decodeuricomponent\"><code>decodeURIComponent</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/encodeURIComponent$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/encodeURIComponent\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/encodeURIComponent</a>\n  </p>\n</div>\n","global_objects/eval":"<h1>eval</h1> <p>The <code><strong>eval()</strong></code> function evaluates JavaScript code represented as a string.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/globalprops-eval.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\">eval(<em>string</em>)</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><code>string</code></dt> <dd>A string representing a JavaScript expression, statement, or sequence of statements. The expression can include variables and properties of existing objects.</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p>The completion value of evaluating the given code. If the completion value is empty, <a href=\"undefined\"><code>undefined</code></a> is returned.</p> <h2 id=\"Description\">Description</h2> <p><code>eval()</code> is a function property of the global object.</p> <p>The argument of the <code>eval()</code> function is a string. If the string represents an expression, <code>eval()</code> evaluates the expression. If the argument represents one or more JavaScript statements, <code>eval()</code> evaluates the statements. Do not call <code>eval()</code> to evaluate an arithmetic expression; JavaScript evaluates arithmetic expressions automatically.</p> <p>If you construct an arithmetic expression as a string, you can use <code>eval()</code> to evaluate it at a later time. For example, suppose you have a variable <code>x</code>. You can postpone evaluation of an expression involving <code>x</code> by assigning the string value of the expression, say \"<code>3 * x + 2</code>\", to a variable, and then calling <code>eval()</code> at a later point in your script.</p> <p>If the argument of <code>eval()</code> is not a string, <code>eval()</code> returns the argument unchanged. In the following example, the <code>String</code> constructor is specified and <code>eval()</code> returns a <code>String</code> object rather than evaluating the string.</p> <pre data-language=\"js\">eval(new String('2 + 2')); // returns a String object containing \"2 + 2\"\neval('2 + 2');             // returns 4\n</pre> <p>You can work around this limitation in a generic fashion by using <code>toString()</code>.</p> <pre data-language=\"js\">var expression = new String('2 + 2');\neval(expression.toString());\n</pre> <p>If you use the <code>eval</code> function <em>indirectly,</em> by invoking it via a reference other than <code>eval</code>, <a href=\"http://www.ecma-international.org/ecma-262/5.1/#sec-10.4.2\">as of ECMAScript 5</a> it works in the global scope rather than the local scope. This means, for instance, that function declarations create global functions, and that the code being evaluated doesn't have access to local variables within the scope where it's being called.</p> <pre data-language=\"js\">function test() {\n  var x = 2, y = 4;\n  console.log(eval('x + y'));  // Direct call, uses local scope, result is 6\n  var geval = eval; // equivalent to calling eval in the global scope\n  console.log(geval('x + y')); // Indirect call, uses global scope, throws ReferenceError because `x` is undefined\n  (0, eval)('x + y'); // another example of Indirect call\n}\n</pre> <h2 id=\"Do_not_ever_use_eval!\">Do not ever use <code>eval</code>!</h2> <p><code>eval()</code> is a dangerous function, which executes the code it's passed with the privileges of the caller. If you run <code>eval()</code> with a string that could be affected by a malicious party, you may end up running malicious code on the user's machine with the permissions of your webpage / extension. More importantly, a third-party code can see the scope in which <code>eval()</code> was invoked, which can lead to possible attacks in ways to which the similar <a href=\"function\"><code>Function</code></a> is not susceptible.</p> <p><code>eval()</code> is also slower than the alternatives, since it has to invoke the JS interpreter, while many other constructs are optimized by modern JS engines.</p> <p>Additionally, modern javascript interpreters convert javascript to machine code. This means that any concept of variable naming gets obliterated. Thus, any use of eval will force the browser to do long expensive variable name lookups to figure out where the variable exists in the machine code and set it's value. Additonally, new things can be introduced to that variable through <code>eval()</code> such as changing the type of that variable, forcing the browser to reevaluate all of the generated machine code to compensate. However, there (thankfully) exists a very good alternative to eval: simply using <a href=\"function\">window.Function</a>. As an example of how you convert code using evil <code>eval()</code> to using <code>Function</code><code>()</code>, see below.</p> <p>Bad code with eval:</p> <pre data-language=\"js\">function looseJsonParse(obj){\n    return eval(obj);\n}\nconsole.log(looseJsonParse(\n   \"{a:(4-1), b:function(){}, c:new Date()}\"\n))\n</pre> <p>Better code without eval:</p> <pre data-language=\"js\">function looseJsonParse(obj){\n    return Function('\"use strict\";return (' + obj + ')')();\n}\nconsole.log(looseJsonParse(\n   \"{a:(4-1), b:function(){}, c:new Date()}\"\n))\n</pre> <p>Comparing the two code snippets above, the two code snippets might seem to work the same way, but think again: the eval one is a huge amount slower. Notice <code>c: new Date()</code> in the evaluated object. In the function without the eval, the object is being evaluated in the global scope, so it is safe for the browser to assume that <code>Date</code> refers to <code>window.Date</code> instead of a local variable called <font face=\"consolas, Liberation Mono, courier, monospace\"><span style=\"background-color: rgba(220, 220, 220, 0.5);\">Date</span></font>. But, in the code using <code>eval()</code>, the browser cannot assume this since what if your code looked like the following:</p> <pre data-language=\"js\">function Date(n){\n    return [\"Monday\",\"Tuesday\",\"Wednesday\",\"Thursday\",\"Friday\",\"Saturday\",\"Sunday\"][n%7 || 0];\n}\nfunction looseJsonParse(obj){\n    return eval(obj);\n}\nconsole.log(looseJsonParse(\n   \"{a:(4-1), b:function(){}, c:new Date()}\"\n))\n</pre> <p>Thus, in the <code>eval()</code> version of the code, the browser is forced to make the expensive lookup call to check to see if there are any local variables called <code>Date()</code>. This is incredibly innefficient compared to <code>Function()</code>.</p> <p>In a related circumstance, what if you actually wanted your <code>Date</code> function to be able to be called from the code inside <code>Function()</code>. Should you just wimp out and fall back to <code>eval()</code>? Absolutely not, never ever. Instead try the approach below.</p> <pre data-language=\"js\">function Date(n){\n    return [\"Monday\",\"Tuesday\",\"Wednesday\",\"Thursday\",\"Friday\",\"Saturday\",\"Sunday\"][n%7 || 0];\n}\nfunction runCodeWithDateFunction(obj){\n    return Function('\"use strict\";return (' + obj + ')')()(\n        Date\n    );\n}\nconsole.log(runCodeWithDateFunction(\n   \"function(Date){ return Date(5) }\"\n))\n</pre> <p>The code above may seem inefficiently slow because of the triple nested function, but let's analyse the benefits of the above efficient method:</p> <p>1. It allows the code in the string passed to <code>runCodeWithDateFunction</code> to be minified.</p> <p>2. Function call overhead is minimal, making the far smaller code size well worth the benefit</p> <p>3. <code>Function()</code> more easily allows your code to utilize the performance buttering <code>\"use strict\";</code></p> <p>4. The code does not use <code>eval()</code>, making it orders of magnitude faster than otherwise.</p> <p>Lastly, let's examine minification. With using <code>Function()</code> as shown above, you can minify the code string passed to <code>runCodeWithDateFunction</code> far more efficiently because the function arguments names can be minified too as seen in the minified code below.</p> <pre data-language=\"js\">console.log(Function('\"use strict\";return(function(a){return a(5)})')()(function(a){\nreturn\"Monday Tuesday Wednesday Thursday Friday Saturday Sunday\".split(\" \")[a%7||0]}));</pre> <p>There are also additional safer (and faster!) alternatives to <code>eval()</code> or <code>Function()</code> for common use-cases.</p> <h3 id=\"Accessing_member_properties\">Accessing member properties</h3> <p>You should not use <code>eval()</code> to convert property names into properties. Consider the following example where the property of the object to be accessed is not known until the code is executed. This can be done with eval:</p> <pre data-language=\"js\">var obj = { a: 20, b: 30 };\nvar propName = getPropName();  // returns \"a\" or \"b\"\n\neval( 'var result = obj.' + propName );\n</pre> <p>However, <code>eval()</code> is not necessary here. In fact, its use here is discouraged. Instead, use the <a href=\"../operators/property_accessors\">property accessors</a>, which are much faster and safer:</p> <pre data-language=\"js\">var obj = { a: 20, b: 30 };\nvar propName = getPropName();  // returns \"a\" or \"b\"\nvar result = obj[ propName ];  //  obj[ \"a\" ] is the same as obj.a</pre> <p>You can even use this method to access descendant properties. Using <code>eval()</code> this would look like:</p> <pre data-language=\"js\">var obj = {a: {b: {c: 0}}};\nvar propPath = getPropPath();  // returns e.g. \"a.b.c\"\n\neval( 'var result = obj.' + propPath );\n</pre> <p>Avoiding <code>eval()</code> here could be done by splitting the property path and looping through the different properties:</p> <pre data-language=\"js\">function getDescendantProp(obj, desc) {\n  var arr = desc.split('.');\n  while (arr.length) {\n    obj = obj[arr.shift()];\n  }\n  return obj;\n}\n\nvar obj = {a: {b: {c: 0}}};\nvar propPath = getPropPath();  // returns e.g. \"a.b.c\"\nvar result = getDescendantProp(obj, propPath);</pre> <p>Setting a property that way works similarly:</p> <pre data-language=\"js\">function setDescendantProp(obj, desc, value) {\n  var arr = desc.split('.');\n  while (arr.length &gt; 1) {\n    obj = obj[arr.shift()];\n  }\n  return obj[arr[0]] = value;\n}\n\nvar obj = {a: {b: {c: 0}}};\nvar propPath = getPropPath();  // returns e.g. \"a.b.c\"\nvar result = setDescendantProp(obj, propPath, 1);  // test.a.b.c will now be 1</pre> <h3 id=\"Use_functions_instead_of_evaluating_snippets_of_code\">Use functions instead of evaluating snippets of code</h3> <p>JavaScript has <a href=\"http://en.wikipedia.org/wiki/First-class_function\">first-class functions</a>, which means you can pass functions as arguments to other APIs, store them in variables and objects' properties, and so on. Many DOM APIs are designed with this in mind, so you can (and should) write:</p> <pre data-language=\"js\">// instead of setTimeout(\" ... \", 1000) use:\nsetTimeout(function() { ... }, 1000); \n\n// instead of elt.setAttribute(\"onclick\", \"...\") use:\nelt.addEventListener('click', function() { ... } , false); </pre> <p><a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Closures\">Closures</a> are also helpful as a way to create parameterized functions without concatenating strings.</p> <h3 id=\"Parsing_JSON_(converting_strings_to_JavaScript_objects)\">Parsing JSON (converting strings to JavaScript objects)</h3> <p>If the string you're calling <code>eval()</code> on contains data (for example, an array: <code>\"[1, 2, 3]\"</code>), as opposed to code, you should consider switching to <a href=\"https://developer.mozilla.org/en-US/docs/Glossary/JSON\">JSON</a>, which allows the string to use a subset of JavaScript syntax to represent data. See also <a href=\"https://developer.mozilla.org/en-US/docs/Downloading_JSON_and_JavaScript_in_extensions\">Downloading JSON and JavaScript in extensions</a>.</p> <p>Note that since JSON syntax is limited compared to JavaScript syntax, many valid JavaScript literals will not parse as JSON. For example, trailing commas are not allowed in JSON, and property names (keys) in object literals must be enclosed in quotes. Be sure to use a JSON serializer to generate strings that will be later parsed as JSON.</p> <h3 id=\"Pass_data_instead_of_code\">Pass data instead of code</h3> <p>For example, an extension designed to scrape contents of web-pages could have the scraping rules defined in <a href=\"https://developer.mozilla.org/en-US/docs/XPath\">XPath</a> instead of JavaScript code.</p> <h3 id=\"Run_code_with_limited_privileges\">Run code with limited privileges</h3> <p>If you must run the code, consider running it with reduced privileges. This advice applies mainly to extensions and XUL applications, which can use <a href=\"https://developer.mozilla.org/en-US/docs/Components.utils.evalInSandbox\">Components.utils.evalInSandbox</a> for this.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Using_eval\">Using <code>eval</code>\n</h3> <p>In the following code, both of the statements containing <code>eval()</code> return 42. The first evaluates the string \"<code>x + y + 1</code>\"; the second evaluates the string \"<code>42</code>\".</p> <pre data-language=\"js\">var x = 2;\nvar y = 39;\nvar z = '42';\neval('x + y + 1'); // returns 42\neval(z);           // returns 42 \n</pre> <h3 id=\"Using_eval_to_evaluate_a_string_of_JavaScript_statements\">Using <code>eval</code> to evaluate a string of JavaScript statements</h3> <p>The following example uses <code>eval()</code> to evaluate the string <code>str</code>. This string consists of JavaScript statements that open an alert dialog box and assign <code>z</code> a value of 42 if <code>x</code> is five, and assigns 0 to <code>z</code> otherwise. When the second statement is executed, <code>eval()</code> will cause these statements to be performed, and it will also evaluate the set of statements and return the value that is assigned to <code>z</code>.</p> <pre data-language=\"js\">var x = 5;\nvar str = \"if (x == 5) {console.log('z is 42'); z = 42;} else z = 0;\";\n\nconsole.log('z is ', eval(str));</pre> <p>If you define multiple values then the last value is returned.</p> <pre data-language=\"js\">var x = 5;\nvar str = \"if (x == 5) {console.log('z is 42'); z = 42; x = 420; } else z = 0;\"; \n\nconsole.log('x is ', eval(str)); // z is 42  x is 420 \n</pre>  <h3 id=\"Last_expression_is_evaluated\">Last expression is evaluated</h3> <p><code>eval()</code> returns the value of the last expression evaluated.</p> <pre data-language=\"js\">var str = 'if ( a ) { 1 + 1; } else { 1 + 2; }';\nvar a = true;\nvar b = eval(str);  // returns 2\n \nconsole.log('b is : ' + b);\n\na = false;\nb = eval(str);  // returns 3\n\nconsole.log('b is : ' + b);</pre> <h3 id=\"eval_as_a_string_defining_function_requires_(_and_)_as_prefix_and_suffix\">\n<code>eval</code> as a string defining function requires \"(\" and \")\" as prefix and suffix</h3> <pre data-language=\"js\">var fctStr1 = 'function a() {}'\nvar fctStr2 = '(function a() {})'\nvar fct1 = eval(fctStr1)  // return undefined\nvar fct2 = eval(fctStr2)  // return a function\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/publications/files/ECMA-ST-ARCH/ECMA-262,%201st%20edition,%20June%201997.pdf\" hreflang=\"en\">ECMAScript 1st Edition (ECMA-262)</a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/5.1/#sec-15.1.2.1\" hreflang=\"en\">ECMAScript 5.1 (ECMA-262)<br><small>The definition of 'eval' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-eval-x\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'eval' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-eval-x\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'eval' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"Firefox-specific_notes\">Firefox-specific notes</h2> <ul> <li>Historically <code>eval()</code> had an optional second argument, specifying an object in whose context the evaluation was to be performed. This argument was non-standard, and was definitely removed from Firefox 4. See <a href=\"https://bugzilla.mozilla.org/show_bug.cgi?id=531675\">bug 531675</a>.</li> </ul> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"uneval\"><code>uneval()</code></a></li> <li><a href=\"../operators/property_accessors\">Property accessors</a></li> <li><a href=\"https://developer.mozilla.org/en-US/Add-ons/WebExtensions/Content_scripts#Using_eval()_in_content_scripts\">WebExtensions: Using eval in content scripts</a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/eval$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/eval\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/eval</a>\n  </p>\n</div>\n","global_objects/webassembly":"<h1>WebAssembly</h1> <p>The <code>WebAssembly</code> JavaScript object acts as the namespace for all <a href=\"https://developer.mozilla.org/en-US/docs/WebAssembly\">WebAssembly</a>-related functionality.</p> <p>Unlike most other global objects, <code>WebAssembly</code> is not a constructor (it is not a function object). You can compare it to <a href=\"math\"><code>Math</code></a>, which is also a namespace object for mathematical constants and functions, or to <a href=\"intl\"><code>Intl</code></a> which is the namespace object for internationalization constructors and other language sensitive functions.</p> <h2 id=\"Description\">Description</h2> <p>The primary uses for the <code>WebAssembly</code> object are:</p> <ul> <li>Loading WebAssembly code, using the <a href=\"webassembly/instantiate\"><code>WebAssembly.instantiate()</code></a> function.</li> <li>Creating new memory and table instances via the <a href=\"webassembly/memory\"><code>WebAssembly.Memory()</code></a>/<a href=\"webassembly/table\"><code>WebAssembly.Table()</code></a> constructors.</li> <li>Providing facilities to handle errors that occur in WebAssembly via the <a href=\"webassembly/compileerror\"><code>WebAssembly.CompileError()</code></a>/<a href=\"webassembly/linkerror\"><code>WebAssembly.LinkError()</code></a>/<a href=\"webassembly/runtimeerror\"><code>WebAssembly.RuntimeError()</code></a> constructors.</li> </ul> <h2 id=\"Methods\">Methods</h2> <dl> <dt><a href=\"webassembly/instantiate\"><code>WebAssembly.instantiate()</code></a></dt> <dd>The primary API for compiling and instantiating WebAssembly code, returning both a <code>Module</code> and its first <code>Instance</code>.</dd> <dt><a href=\"webassembly/instantiatestreaming\"><code>WebAssembly.instantiateStreaming()</code></a></dt> <dd>Compiles and instantiates a WebAssembly module directly from a streamed underlying source, returning both a <code>Module</code> and its first <code>Instance</code>.</dd> <dt><a href=\"webassembly/compile\"><code>WebAssembly.compile()</code></a></dt> <dd>Compiles a <a href=\"webassembly/module\"><code>WebAssembly.Module</code></a> from WebAssembly binary code, leaving instantiation as a separate step.</dd> <dt><a href=\"webassembly/compilestreaming\"><code>WebAssembly.compileStreaming()</code></a></dt> <dd>compiles a <a href=\"webassembly/module\"><code>WebAssembly.Module</code></a> directly from a streamed underlying source, leaving instantiation as a separate step.</dd> <dt><a href=\"webassembly/validate\"><code>WebAssembly.validate()</code></a></dt> <dd>Validates a given typed array of WebAssembly binary code, returning whether the bytes are valid WebAssembly code (<code>true</code>) or not (<code>false</code>).</dd> </dl> <h2 id=\"Constructors\">Constructors</h2> <dl> <dt><a href=\"webassembly/global\"><code>WebAssembly.Global()</code></a></dt> <dd>Creates a new WebAssembly <code>Global</code> object.</dd> <dt><a href=\"webassembly/module\"><code>WebAssembly.Module()</code></a></dt> <dd>Creates a new WebAssembly <code>Module</code> object.</dd> <dt><a href=\"webassembly/instance\"><code>WebAssembly.Instance()</code></a></dt> <dd>Creates a new WebAssembly <code>Instance</code> object.</dd> <dt><a href=\"webassembly/memory\"><code>WebAssembly.Memory()</code></a></dt> <dd>Creates a new WebAssembly <code>Memory</code> object.</dd> <dt><a href=\"webassembly/table\"><code>WebAssembly.Table()</code></a></dt> <dd>Creates a new WebAssembly <code>Table</code> object.</dd> <dt><a href=\"webassembly/compileerror\"><code>WebAssembly.CompileError()</code></a></dt> <dd>Creates a new WebAssembly <code>CompileError</code> object.</dd> <dt><a href=\"webassembly/linkerror\"><code>WebAssembly.LinkError()</code></a></dt> <dd>Creates a new WebAssembly <code>LinkError</code> object.</dd> <dt><a href=\"webassembly/runtimeerror\"><code>WebAssembly.RuntimeError()</code></a></dt> <dd>Creates a new WebAssembly <code>RuntimeError</code> object.</dd> </dl> <h2 id=\"Examples\">Examples</h2> <p>The following example (see our <a href=\"https://github.com/mdn/webassembly-examples/blob/master/js-api-examples/instantiate-streaming.html\">instantiate-streaming.html</a> demo on GitHub, and <a href=\"https://mdn.github.io/webassembly-examples/js-api-examples/instantiate-streaming.html\">view it live</a> also) directly streams a .wasm module from an underlying source then compiles and instantiates it, the promise fulfilling with a <code>ResultObject</code>. Because the <code>instantiateStreaming()</code> function accepts a promise for a <a href=\"https://developer.mozilla.org/en-US/docs/Web/API/Response\"><code>Response</code></a> object, you can directly pass it a <a href=\"https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/fetch\"><code>WindowOrWorkerGlobalScope.fetch()</code></a> call, and it will pass the response into the function when it fulfills.</p> <pre data-language=\"js\">var importObject = { imports: { imported_func: arg =&gt; console.log(arg) } };\n\nWebAssembly.instantiateStreaming(fetch('simple.wasm'), importObject)\n.then(obj =&gt; obj.instance.exports.exported_func());</pre> <p>The <code>ResultObject</code>'s instance member is then accessed, and the contained exported function invoked.</p> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <thead> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> </thead> <tbody> <tr> <td><a href=\"https://webassembly.github.io/spec/js-api/#the-webassembly-object\" hreflang=\"en\">WebAssembly JavaScript Interface<br><small>The definition of 'WebAssembly' in that specification.</small></a></td> <td><span class=\"spec-WD\">Working Draft</span></td> <td>Initial draft definition.</td> </tr> </tbody> </table></div> <h2 name=\"Browser_compatibility\" id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>   <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 57</td>\n<td class=\"bc-supports-yes\"> 16</td>\n<td class=\"bc-supports-yes bc-has-history\"> 52\n<section class=\"bc-history\" id=\"sect1\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 52\n</dt>\n<dd> Disabled in the Firefox 52 Extended Support Release (ESR).</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 44</td>\n<td class=\"bc-supports-yes\"> 11</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/CompileError\"><code>CompileError</code></a></th>\n<td class=\"bc-supports-yes\"> 57</td>\n<td class=\"bc-supports-yes\"> 16</td>\n<td class=\"bc-supports-yes bc-has-history\"> 52\n<section class=\"bc-history\" id=\"sect4\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 52\n</dt>\n<dd> Disabled in the Firefox 52 Extended Support Release (ESR).</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 44</td>\n<td class=\"bc-supports-yes\"> 11</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Global\"><code>Global</code></a></th>\n<td class=\"bc-supports-yes\"> 69</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 62</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Instance\"><code>Instance</code></a></th>\n<td class=\"bc-supports-yes\"> 57</td>\n<td class=\"bc-supports-yes\"> 16</td>\n<td class=\"bc-supports-yes bc-has-history\"> 52\n<section class=\"bc-history\" id=\"sect7\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 52\n</dt>\n<dd> Disabled in the Firefox 52 Extended Support Release (ESR).</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 44</td>\n<td class=\"bc-supports-yes\"> 11</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/LinkError\"><code>LinkError</code></a></th>\n<td class=\"bc-supports-yes\"> 57</td>\n<td class=\"bc-supports-yes\"> 16</td>\n<td class=\"bc-supports-yes bc-has-history\"> 52\n<section class=\"bc-history\" id=\"sect10\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 52\n</dt>\n<dd> Disabled in the Firefox 52 Extended Support Release (ESR).</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 44</td>\n<td class=\"bc-supports-yes\"> 11</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Memory\"><code>Memory</code></a></th>\n<td class=\"bc-supports-yes\"> 57</td>\n<td class=\"bc-supports-yes\"> 16</td>\n<td class=\"bc-supports-yes bc-has-history\"> 52\n<section class=\"bc-history\" id=\"sect13\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 52\n</dt>\n<dd> Disabled in the Firefox 52 Extended Support Release (ESR).</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 44</td>\n<td class=\"bc-supports-yes\"> 11</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Module\"><code>Module</code></a></th>\n<td class=\"bc-supports-yes\"> 57</td>\n<td class=\"bc-supports-yes\"> 16</td>\n<td class=\"bc-supports-yes bc-has-history\"> 52\n<section class=\"bc-history\" id=\"sect16\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 52\n</dt>\n<dd> Disabled in the Firefox 52 Extended Support Release (ESR).</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 44</td>\n<td class=\"bc-supports-yes\"> 11</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/RuntimeError\"><code>RuntimeError</code></a></th>\n<td class=\"bc-supports-yes\"> 57</td>\n<td class=\"bc-supports-yes\"> 16</td>\n<td class=\"bc-supports-yes bc-has-history\"> 52\n<section class=\"bc-history\" id=\"sect19\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 52\n</dt>\n<dd> Disabled in the Firefox 52 Extended Support Release (ESR).</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 44</td>\n<td class=\"bc-supports-yes\"> 11</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Table\"><code>Table</code></a></th>\n<td class=\"bc-supports-yes\"> 57</td>\n<td class=\"bc-supports-yes\"> 16</td>\n<td class=\"bc-supports-yes bc-has-history\"> 52\n<section class=\"bc-history\" id=\"sect22\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 52\n</dt>\n<dd> Disabled in the Firefox 52 Extended Support Release (ESR).</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 44</td>\n<td class=\"bc-supports-yes\"> 11</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/compile\"><code>compile</code></a></th>\n<td class=\"bc-supports-yes\"> 57</td>\n<td class=\"bc-supports-yes\"> 16</td>\n<td class=\"bc-supports-yes bc-has-history\"> 52\n<section class=\"bc-history\" id=\"sect25\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 52\n</dt>\n<dd> Disabled in the Firefox 52 Extended Support Release (ESR).</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 44</td>\n<td class=\"bc-supports-yes\"> 11</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/compileStreaming\"><code>compileStreaming</code></a></th>\n<td class=\"bc-supports-yes\"> 61</td>\n<td class=\"bc-supports-yes\"> 16</td>\n<td class=\"bc-supports-yes\"> 58</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 47</td>\n<td class=\"bc-supports-no\"> No</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/instantiate\"><code>instantiate</code></a></th>\n<td class=\"bc-supports-yes\"> 57</td>\n<td class=\"bc-supports-yes\"> 16</td>\n<td class=\"bc-supports-yes bc-has-history\"> 52\n<section class=\"bc-history\" id=\"sect28\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 52\n</dt>\n<dd> Disabled in the Firefox 52 Extended Support Release (ESR).</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 44</td>\n<td class=\"bc-supports-yes\"> 11</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/instantiateStreaming\"><code>instantiateStreaming</code></a></th>\n<td class=\"bc-supports-yes\"> 61</td>\n<td class=\"bc-supports-yes\"> 16</td>\n<td class=\"bc-supports-yes\"> 58</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 47</td>\n<td class=\"bc-supports-no\"> No</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/validate\"><code>validate</code></a></th>\n<td class=\"bc-supports-yes\"> 57</td>\n<td class=\"bc-supports-yes\"> 16</td>\n<td class=\"bc-supports-yes bc-has-history\"> 52\n<section class=\"bc-history\" id=\"sect31\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 52\n</dt>\n<dd> Disabled in the Firefox 52 Extended Support Release (ESR).</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 44</td>\n<td class=\"bc-supports-yes\"> 11</td>\n</tr>\n</tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 57</td>\n<td class=\"bc-supports-yes\"> 57</td>\n<td class=\"bc-supports-yes bc-has-history\"> Yes<div class=\"bc-icons\">Disabled </div>\n<section class=\"bc-history\" id=\"sect2\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> Yes<div class=\"bc-icons\">Disabled </div>\n</dt>\n<dd>Disabled This feature is behind the <code>Experimental JavaScript Features</code> preference.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-yes bc-has-history\"> 52\n<section class=\"bc-history\" id=\"sect3\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 52\n</dt>\n<dd> Disabled in the Firefox 52 Extended Support Release (ESR).</dd>\n</dl></section>\n</td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 11</td>\n<td class=\"bc-supports-yes\"> 7.0</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/CompileError\"><code>CompileError</code></a></th>\n<td class=\"bc-supports-yes\"> 57</td>\n<td class=\"bc-supports-yes\"> 57</td>\n<td class=\"bc-supports-yes bc-has-history\"> Yes<div class=\"bc-icons\">Disabled </div>\n<section class=\"bc-history\" id=\"sect5\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> Yes<div class=\"bc-icons\">Disabled </div>\n</dt>\n<dd>Disabled This feature is behind the <code>Experimental JavaScript Features</code> preference.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-yes bc-has-history\"> 52\n<section class=\"bc-history\" id=\"sect6\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 52\n</dt>\n<dd> Disabled in the Firefox 52 Extended Support Release (ESR).</dd>\n</dl></section>\n</td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 11</td>\n<td class=\"bc-supports-yes\"> 7.0</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Global\"><code>Global</code></a></th>\n<td class=\"bc-supports-yes\"> 69</td>\n<td class=\"bc-supports-yes\"> 69</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 62</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Instance\"><code>Instance</code></a></th>\n<td class=\"bc-supports-yes\"> 57</td>\n<td class=\"bc-supports-yes\"> 57</td>\n<td class=\"bc-supports-yes bc-has-history\"> Yes<div class=\"bc-icons\">Disabled </div>\n<section class=\"bc-history\" id=\"sect8\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> Yes<div class=\"bc-icons\">Disabled </div>\n</dt>\n<dd>Disabled This feature is behind the <code>Experimental JavaScript Features</code> preference.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-yes bc-has-history\"> 52\n<section class=\"bc-history\" id=\"sect9\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 52\n</dt>\n<dd> Disabled in the Firefox 52 Extended Support Release (ESR).</dd>\n</dl></section>\n</td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 11</td>\n<td class=\"bc-supports-yes\"> 7.0</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/LinkError\"><code>LinkError</code></a></th>\n<td class=\"bc-supports-yes\"> 57</td>\n<td class=\"bc-supports-yes\"> 57</td>\n<td class=\"bc-supports-yes bc-has-history\"> Yes<div class=\"bc-icons\">Disabled </div>\n<section class=\"bc-history\" id=\"sect11\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> Yes<div class=\"bc-icons\">Disabled </div>\n</dt>\n<dd>Disabled This feature is behind the <code>Experimental JavaScript Features</code> preference.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-yes bc-has-history\"> 52\n<section class=\"bc-history\" id=\"sect12\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 52\n</dt>\n<dd> Disabled in the Firefox 52 Extended Support Release (ESR).</dd>\n</dl></section>\n</td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 11</td>\n<td class=\"bc-supports-yes\"> 7.0</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Memory\"><code>Memory</code></a></th>\n<td class=\"bc-supports-yes\"> 57</td>\n<td class=\"bc-supports-yes\"> 57</td>\n<td class=\"bc-supports-yes bc-has-history\"> Yes<div class=\"bc-icons\">Disabled </div>\n<section class=\"bc-history\" id=\"sect14\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> Yes<div class=\"bc-icons\">Disabled </div>\n</dt>\n<dd>Disabled This feature is behind the <code>Experimental JavaScript Features</code> preference.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-yes bc-has-history\"> 52\n<section class=\"bc-history\" id=\"sect15\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 52\n</dt>\n<dd> Disabled in the Firefox 52 Extended Support Release (ESR).</dd>\n</dl></section>\n</td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 11</td>\n<td class=\"bc-supports-yes\"> 7.0</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Module\"><code>Module</code></a></th>\n<td class=\"bc-supports-yes\"> 57</td>\n<td class=\"bc-supports-yes\"> 57</td>\n<td class=\"bc-supports-yes bc-has-history\"> Yes<div class=\"bc-icons\">Disabled </div>\n<section class=\"bc-history\" id=\"sect17\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> Yes<div class=\"bc-icons\">Disabled </div>\n</dt>\n<dd>Disabled This feature is behind the <code>Experimental JavaScript Features</code> preference.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-yes bc-has-history\"> 52\n<section class=\"bc-history\" id=\"sect18\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 52\n</dt>\n<dd> Disabled in the Firefox 52 Extended Support Release (ESR).</dd>\n</dl></section>\n</td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 11</td>\n<td class=\"bc-supports-yes\"> 7.0</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/RuntimeError\"><code>RuntimeError</code></a></th>\n<td class=\"bc-supports-yes\"> 57</td>\n<td class=\"bc-supports-yes\"> 57</td>\n<td class=\"bc-supports-yes bc-has-history\"> Yes<div class=\"bc-icons\">Disabled </div>\n<section class=\"bc-history\" id=\"sect20\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> Yes<div class=\"bc-icons\">Disabled </div>\n</dt>\n<dd>Disabled This feature is behind the <code>Experimental JavaScript Features</code> preference.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-yes bc-has-history\"> 52\n<section class=\"bc-history\" id=\"sect21\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 52\n</dt>\n<dd> Disabled in the Firefox 52 Extended Support Release (ESR).</dd>\n</dl></section>\n</td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 11</td>\n<td class=\"bc-supports-yes\"> 7.0</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Table\"><code>Table</code></a></th>\n<td class=\"bc-supports-yes\"> 57</td>\n<td class=\"bc-supports-yes\"> 57</td>\n<td class=\"bc-supports-yes bc-has-history\"> Yes<div class=\"bc-icons\">Disabled </div>\n<section class=\"bc-history\" id=\"sect23\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> Yes<div class=\"bc-icons\">Disabled </div>\n</dt>\n<dd>Disabled This feature is behind the <code>Experimental JavaScript Features</code> preference.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-yes bc-has-history\"> 52\n<section class=\"bc-history\" id=\"sect24\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 52\n</dt>\n<dd> Disabled in the Firefox 52 Extended Support Release (ESR).</dd>\n</dl></section>\n</td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 11</td>\n<td class=\"bc-supports-yes\"> 7.0</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/compile\"><code>compile</code></a></th>\n<td class=\"bc-supports-yes\"> 57</td>\n<td class=\"bc-supports-yes\"> 57</td>\n<td class=\"bc-supports-yes bc-has-history\"> Yes<div class=\"bc-icons\">Disabled </div>\n<section class=\"bc-history\" id=\"sect26\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> Yes<div class=\"bc-icons\">Disabled </div>\n</dt>\n<dd>Disabled This feature is behind the <code>Experimental JavaScript Features</code> preference.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-yes bc-has-history\"> 52\n<section class=\"bc-history\" id=\"sect27\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 52\n</dt>\n<dd> Disabled in the Firefox 52 Extended Support Release (ESR).</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-yes\"> 44</td>\n<td class=\"bc-supports-yes\"> 11</td>\n<td class=\"bc-supports-yes\"> 7.0</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/compileStreaming\"><code>compileStreaming</code></a></th>\n<td class=\"bc-supports-yes\"> 61</td>\n<td class=\"bc-supports-yes\"> 61</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 58</td>\n<td> ? </td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/instantiate\"><code>instantiate</code></a></th>\n<td class=\"bc-supports-yes\"> 57</td>\n<td class=\"bc-supports-yes\"> 57</td>\n<td class=\"bc-supports-yes bc-has-history\"> Yes<div class=\"bc-icons\">Disabled </div>\n<section class=\"bc-history\" id=\"sect29\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> Yes<div class=\"bc-icons\">Disabled </div>\n</dt>\n<dd>Disabled This feature is behind the <code>Experimental JavaScript Features</code> preference.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-yes bc-has-history\"> 52\n<section class=\"bc-history\" id=\"sect30\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 52\n</dt>\n<dd> Disabled in the Firefox 52 Extended Support Release (ESR).</dd>\n</dl></section>\n</td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 11</td>\n<td class=\"bc-supports-yes\"> 7.0</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/instantiateStreaming\"><code>instantiateStreaming</code></a></th>\n<td class=\"bc-supports-yes\"> 61</td>\n<td class=\"bc-supports-yes\"> 61</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 58</td>\n<td> ? </td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/validate\"><code>validate</code></a></th>\n<td class=\"bc-supports-yes\"> 57</td>\n<td class=\"bc-supports-yes\"> 57</td>\n<td class=\"bc-supports-yes bc-has-history\"> Yes<div class=\"bc-icons\">Disabled </div>\n<section class=\"bc-history\" id=\"sect32\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> Yes<div class=\"bc-icons\">Disabled </div>\n</dt>\n<dd>Disabled This feature is behind the <code>Experimental JavaScript Features</code> preference.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-yes bc-has-history\"> 52\n<section class=\"bc-history\" id=\"sect33\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 52\n</dt>\n<dd> Disabled in the Firefox 52 Extended Support Release (ESR).</dd>\n</dl></section>\n</td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 11</td>\n<td class=\"bc-supports-yes\"> 7.0</td>\n</tr>\n</tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 8.0.0</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/CompileError\"><code>CompileError</code></a></th>\n<td class=\"bc-supports-yes\"> 8.0.0</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Global\"><code>Global</code></a></th>\n<td class=\"bc-supports-no\"> No</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Instance\"><code>Instance</code></a></th>\n<td class=\"bc-supports-yes\"> 8.0.0</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/LinkError\"><code>LinkError</code></a></th>\n<td class=\"bc-supports-yes\"> 8.0.0</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Memory\"><code>Memory</code></a></th>\n<td class=\"bc-supports-yes\"> 8.0.0</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Module\"><code>Module</code></a></th>\n<td class=\"bc-supports-yes\"> 8.0.0</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/RuntimeError\"><code>RuntimeError</code></a></th>\n<td class=\"bc-supports-yes\"> 8.0.0</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Table\"><code>Table</code></a></th>\n<td class=\"bc-supports-yes\"> 8.0.0</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/compile\"><code>compile</code></a></th>\n<td class=\"bc-supports-yes\"> 8.0.0</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/compileStreaming\"><code>compileStreaming</code></a></th>\n<td class=\"bc-supports-no\"> No</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/instantiate\"><code>instantiate</code></a></th>\n<td class=\"bc-supports-yes\"> 8.0.0</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/instantiateStreaming\"><code>instantiateStreaming</code></a></th>\n<td class=\"bc-supports-no\"> No</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/validate\"><code>validate</code></a></th>\n<td class=\"bc-supports-yes\"> 8.0.0</td>\n</tr>\n</tbody>\n</table>\n</div>  <h2 id=\"See_also\">See also</h2> <ul> <li>\n<a href=\"https://developer.mozilla.org/en-US/docs/WebAssembly\">WebAssembly</a> overview page</li> <li><a href=\"https://developer.mozilla.org/en-US/docs/WebAssembly/Concepts\">WebAssembly concepts</a></li> <li><a href=\"https://developer.mozilla.org/en-US/docs/WebAssembly/Using_the_JavaScript_API\">Using the WebAssembly JavaScript API</a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly</a>\n  </p>\n</div>\n","global_objects/parsefloat":"<h1>parseFloat</h1>     <p>The <code><strong>parseFloat()</strong></code> function parses an argument and returns a floating point number.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/globalprops-parsefloat.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\">parseFloat(<em>value</em>)</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><code>value</code></dt> <dd>The value you want to parse.</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p>A floating point number parsed from the given value. If the value cannot be converted to a number, <a href=\"nan\"><code>NaN</code></a> is returned.</p> <h2 id=\"Description\">Description</h2> <p><code>parseFloat</code> is a top-level function and is not associated with any object.</p> <p><code>parseFloat</code> parses its argument, and returns a floating point number. If it encounters a character other than a sign (+ or -), numeral (0-9), a decimal point, or an exponent, it returns the value up to that point and ignores that character and all succeeding characters. Leading and trailing spaces are allowed.</p> <p>If the value is a string and first character cannot be converted to a number, <code>parseFloat</code> returns <a href=\"nan\"><code>NaN</code></a>.</p> <p>For arithmetic purposes, the <code>NaN</code> value is not a number in any radix. You can call the <a href=\"isnan\"><code>isNaN</code></a> function to determine if the result of <code>parseFloat</code> is <code>NaN</code>. If <code>NaN</code> is passed on to arithmetic operations, the operation results will also be <code>NaN</code>.</p> <p><code>parseFloat</code> can also parse and return the value <code>Infinity</code>. You can use the <a href=\"isfinite\"><code>isFinite</code></a> function to determine if the result is a finite number (not <code>Infinity</code>, <code>-Infinity</code>, or <code>NaN</code>).</p> <p><code>parseFloat</code> is also able to parse an object if it has a <code>toString</code> or <code>valueOf</code> method defined. The returned value is the same as if <code>parseFloat</code> had been called on the result of calling that method.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"parseFloat_returning_a_number\">\n<code>parseFloat</code> returning a number</h3> <p>The following examples all return <strong>3.14</strong></p> <pre data-language=\"js\">parseFloat(3.14);\nparseFloat('3.14');\nparseFloat('314e-2');\nparseFloat('0.0314E+2');\nparseFloat('3.14more non-digit characters');\n\nvar foo = Object.create(null);\nfoo.toString = function () { return \"3.14\"; };\nparseFloat(foo);\n\nvar foo = Object.create(null);\nfoo.valueOf = function () { return \"3.14\"; }; \nparseFloat(foo);​​​​​</pre>  <h3 id=\"parseFloat_returning_NaN\">\n<code>parseFloat</code> returning NaN</h3> <p>The following example returns <code>NaN</code></p> <pre data-language=\"js\">parseFloat('FF2');\n</pre> <h3 id=\"A_stricter_parse_function\">A stricter parse function</h3> <p>It is sometime useful to have a stricter way to parse float values, regular expressions can help :</p> <pre data-language=\"js\">var filterFloat = function(value) {\n    if (/^(\\-|\\+)?([0-9]+(\\.[0-9]+)?|Infinity)$/\n      .test(value))\n      return Number(value);\n  return NaN;\n}\n\nconsole.log(filterFloat('421'));               // 421\nconsole.log(filterFloat('-421'));              // -421\nconsole.log(filterFloat('+421'));              // 421\nconsole.log(filterFloat('Infinity'));          // Infinity\nconsole.log(filterFloat('1.61803398875'));     // 1.61803398875\nconsole.log(filterFloat('421e+0'));            // NaN\nconsole.log(filterFloat('421hop'));            // NaN\nconsole.log(filterFloat('hop1.61803398875'));  // NaN\n\n</pre> <p>Note that this code is an example only; it does not accept valid numbers such as <code>1.</code> or <code>.5</code>.</p> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/publications/files/ECMA-ST-ARCH/ECMA-262,%201st%20edition,%20June%201997.pdf\" hreflang=\"en\">ECMAScript 1st Edition (ECMA-262)</a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/5.1/#sec-15.1.2.3\" hreflang=\"en\">ECMAScript 5.1 (ECMA-262)<br><small>The definition of 'parseFloat' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-parsefloat-string\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'parseFloat' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-parsefloat-string\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'parseFloat' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"parseint\"><code>parseInt()</code></a></li> <li><a href=\"number/parsefloat\"><code>Number.parseFloat()</code></a></li> <li><a href=\"number/parseint\"><code>Number.parseInt()</code></a></li> <li><a href=\"number/tofixed\"><code>Number.toFixed()</code></a></li> <li><a href=\"isnan\"><code>isNaN()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/parseFloat$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/parseFloat\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/parseFloat</a>\n  </p>\n</div>\n","global_objects/isnan":"<h1>isNaN</h1> <p>The <code><strong>isNaN()</strong></code> function determines whether a value is <a href=\"nan\"><code>NaN</code></a> or not. Note: coercion inside the <code>isNaN</code> function has <a href=\"#Description\">interesting</a> rules; you may alternatively want to use <a href=\"number/isnan\"><code>Number.isNaN()</code></a>, as defined in ECMAScript 2015.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/globalprops-isnan.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe> <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\">isNaN(v<em>alue</em>)</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><code>value</code></dt> <dd>The value to be tested.</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p><code>true</code> if the given value is <a href=\"nan\"><code>NaN</code></a>; otherwise, <code>false</code>.</p> <h2 id=\"Description\">Description</h2> <h3 id=\"The_necessity_of_an_isNaN_function\">The necessity of an <code>isNaN</code> function</h3> <p>Unlike all other possible values in JavaScript, it is not possible to rely on the equality operators (== and ===) to determine whether a value <em>is</em> <a href=\"nan\"><code>NaN</code></a> or not, because both <code>NaN == NaN</code> and <code>NaN === NaN</code> evaluate to <code>false</code>. Hence, the necessity of an <code>isNaN</code> function.</p> <h3 id=\"Origin_of_NaN_values\">Origin of <code>NaN</code> values</h3> <p><code>NaN</code> values are generated when arithmetic operations result in <em>undefined</em> or <em>unrepresentable</em> values. Such values do not necessarily represent overflow conditions. A <code>NaN</code> also results from attempted coercion to numeric values of non-numeric values for which no primitive numeric value is available.</p> <p>For example, dividing zero by zero results in a <code>NaN</code> — but dividing other numbers by zero does not.</p> <h3 id=\"Confusing_special-case_behavior\">Confusing special-case behavior</h3> <p>Since the very earliest versions of the <code>isNaN</code> function specification, its behavior for non-numeric arguments has been confusing. When the argument to the <code>isNaN</code> function is not of type <a href=\"http://es5.github.com/#x8.5\">Number</a>, the value is first coerced to a Number. The resulting value is then tested to determine whether it is <a href=\"nan\"><code>NaN</code></a>. Thus for non-numbers that when coerced to numeric type result in a valid non-NaN numeric value (notably the empty string and boolean primitives, which when coerced give numeric values zero or one), the \"false\" returned value may be unexpected; the empty string, for example, is surely \"not a number.\" The confusion stems from the fact that the term, \"not a number\", has a specific meaning for numbers represented as IEEE-754 floating-point values. The function should be interpreted as answering the question, \"is this value, when coerced to a numeric value, an IEEE-754 'Not A Number' value?\"</p> <p>The latest version of ECMAScript (ES2015) contains the <a href=\"number/isnan\"><code>Number.isNaN()</code></a> function. <code>Number.isNaN(x)</code> will be a reliable way to test whether <code>x</code> is <code>NaN</code> or not. Even with <code>Number.isNaN</code>, however, the meaning of <code>NaN</code> remains the precise numeric meaning, and not simply, \"not a number\". Alternatively, in absense of <code>Number.isNaN</code>, the expression <code>(x != x)</code> is a more reliable way to test whether variable <code>x</code> is <code>NaN</code> or not, as the result is not subject to the false positives that make <code>isNaN</code> unreliable.</p> <p>A polyfill for <code>isNaN</code> would be (the polyfill leverages the unique never-equal-to-itself characteristic of <code>NaN</code>):</p> <pre data-language=\"js\">var isNaN = function(value) {\n    var n = Number(value);\n    return n !== n;\n};</pre> <h2 id=\"Examples\">Examples</h2> <pre data-language=\"js\">isNaN(NaN);       // true\nisNaN(undefined); // true\nisNaN({});        // true\n\nisNaN(true);      // false\nisNaN(null);      // false\nisNaN(37);        // false\n\n// strings\nisNaN('37');      // false: \"37\" is converted to the number 37 which is not NaN\nisNaN('37.37');   // false: \"37.37\" is converted to the number 37.37 which is not NaN\nisNaN(\"37,5\");    // true\nisNaN('123ABC');  // true:  parseInt(\"123ABC\") is 123 but Number(\"123ABC\") is NaN\nisNaN('');        // false: the empty string is converted to 0 which is not NaN\nisNaN(' ');       // false: a string with spaces is converted to 0 which is not NaN\n\n// dates\nisNaN(new Date());                // false\nisNaN(new Date().toString());     // true\n\n// This is a false positive and the reason why isNaN is not entirely reliable\nisNaN('blabla');   // true: \"blabla\" is converted to a number. \n                   // Parsing this as a number fails and returns NaN\n</pre> <h3 id=\"Useful_special-case_behavior\">Useful special-case behavior</h3> <p>There is a more usage oriented way to think of <code>isNaN()</code>: If <code>isNaN(x)</code> returns <code>false</code>, you can use <code>x</code> in an arithmetic expression not making the expression return <code>NaN</code>. If it returns <code>true</code>, <code>x</code> will make every arithmetic expression return <code>NaN</code>. This means that in JavaScript, <code>isNaN(x) == true</code> is equivalent to <code>x - 0</code> returning <code>NaN</code> (though in JavaScript <code>x - 0 == NaN</code> always returns false, so you can't test for it). Actually, <code>isNaN(x)</code>, <code>isNaN(x - 0)</code>, <code>isNaN(Number(x))</code>, <code>Number.isNaN(x - 0)</code>, and <code>Number.isNaN(Number(x))</code> always return the same and in JavaScript <code>isNaN(x)</code> is just the shortest possible form to express each of these terms.</p> <p>You can use this, for example, to test whether an argument to a function is arithmetically processable (usable \"like\" a number), or if it's not and you have to provide a default value or something else. This way you can have a function that makes use of the full versatility JavaScript provides by implicitly converting values depending on context.</p> <h2 id=\"Examples_2\">Examples</h2> <pre data-language=\"js\">function increment(x) {\n  if (isNaN(x)) x = 0;\n  return x + 1;\n}\n\n// The same effect with Number.isNaN():\nfunction increment(x) {\n  if (Number.isNaN(Number(x))) x = 0;\n  return x + 1;\n}\n\n// In the following cases for the function's argument x,\n// isNaN(x) is always false, although x is indeed not a\n// number, but can be used as such in arithmetical\n// expressions\nincrement('');            // 1: \"\" is converted to 0\nincrement(new String());  // 1: String object representing an empty string is converted to 0\nincrement([]);            // 1: [] is converted to 0\nincrement(new Array());   // 1: Array object representing an empty array is converted to 0\nincrement('0');           // 1: \"0\" is converted to 0\nincrement('1');           // 2: \"1\" is converted to 1\nincrement('0.1');         // 1.1: \"0.1\" is converted to 0.1\nincrement('Infinity');    // Infinity: \"Infinity\" is converted to Infinity\nincrement(null);          // 1: null is converted to 0\nincrement(false);         // 1: false is converted to 0\nincrement(true);          // 2: true is converted to 1\nincrement(new Date());    // returns current date/time in milliseconds plus 1\n\n// In the following cases for the function's argument x,\n// isNaN(x) is always false and x is indeed a number\nincrement(-1);            // 0\nincrement(-0.1);          // 0.9\nincrement(0);             // 1\nincrement(1);             // 2\nincrement(2);             // 3\n// ... and so on ...\nincrement(Infinity);      // Infinity\n\n// In the following cases for the function's argument x,\n// isNaN(x) is always true and x is really not a number,\n// thus the function replaces it by 0 and returns 1\nincrement(String);            // 1\nincrement(Array);             // 1\nincrement('blabla');          // 1\nincrement('-blabla');         // 1\nincrement(0 / 0);               // 1\nincrement('0 / 0');             // 1\nincrement(Infinity / Infinity); // 1\nincrement(NaN);               // 1\nincrement(undefined);         // 1\nincrement();                  // 1\n\n// isNaN(x) is always the same as isNaN(Number(x)),\n// but the presence of x is mandatory here!\nisNaN(x) == isNaN(Number(x)); // true for every value of x, including x == undefined,\n                              // because isNaN(undefined) == true and Number(undefined) returns NaN,\n                              // but ...\nisNaN() == isNaN(Number());   // false, because isNaN() == true and Number() == 0\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/publications/files/ECMA-ST-ARCH/ECMA-262,%201st%20edition,%20June%201997.pdf\" hreflang=\"en\">ECMAScript 1st Edition (ECMA-262)</a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/5.1/#sec-15.1.2.4\" hreflang=\"en\">ECMAScript 5.1 (ECMA-262)<br><small>The definition of 'isNaN' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-isnan-number\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'isNaN' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-isnan-number\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'isNaN' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"nan\"><code>NaN</code></a></li> <li><a href=\"number/isnan\"><code>Number.isNaN()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/isNaN$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/isNaN\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/isNaN</a>\n  </p>\n</div>\n","global_objects/uneval":"<h1>uneval</h1><div class=\"blockIndicator nonStandard nonStandardHeader\"> <p><strong> Non-standard</strong><br> This feature is non-standard and is not on a standards track. Do not use it on production sites facing the Web: it will not work for every user. There may also be large incompatibilities between implementations and the behavior may change in the future.</p> </div> <p>The <code><strong>uneval()</strong></code> function creates a string representation of the source code of an Object.</p> <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\">uneval(<var>object</var>)</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><code>object</code></dt> <dd>A JavaScript expression or statement.</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p>A string representing the source code of the given Object.</p> <div class=\"note\">\n<strong>Note:</strong> You won't get a valid JSON representation of your Object.</div> <h2 id=\"Description\">Description</h2> <p><code>uneval()</code> is a top-level function and is not associated with any object.</p> <h2 id=\"Examples\">Examples</h2> <pre data-language=\"js\">var a = 1;\nuneval(a); // returns a String containing 1\n\nvar b = '1';\nuneval(b); // returns a String containing \"1\"\n\nuneval(function foo() {}); // returns \"(function foo(){})\"\n\n\nvar a = uneval(function foo() { return 'hi'; });\nvar foo = eval(a);\nfoo(); // returns \"hi\"\n</pre> <h2 id=\"Specifications\">Specifications</h2> <p>Not part of any specifications.</p> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support \n</th>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support \n</th>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support \n</th>\n<td class=\"bc-supports-no\"> No</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"eval\"><code>eval()</code></a></li> <li><a href=\"json/stringify\"><code>JSON.stringify()</code></a></li> <li><a href=\"json/parse\"><code>JSON.parse()</code></a></li> <li><a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/toSource\"><code>Object.toSource()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/uneval$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/uneval\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/uneval</a>\n  </p>\n</div>\n","global_objects/array":"<h1>Array</h1> <p>The JavaScript <code>Array</code> object is a global object that is used in the construction of arrays; which are high-level, list-like objects.</p> <p><strong>Create an Array</strong></p> <pre data-language=\"js\">var fruits = ['Apple', 'Banana'];\n\nconsole.log(fruits.length);\n// 2\n</pre> <p><strong>Access (index into) an Array item</strong></p> <pre data-language=\"js\">var first = fruits[0];\n// Apple\n\nvar last = fruits[fruits.length - 1];\n// Banana\n</pre> <p><strong>Loop over an Array</strong></p> <pre data-language=\"js\">fruits.forEach(function(item, index, array) {\n  console.log(item, index);\n});\n// Apple 0\n// Banana 1\n</pre> <p><strong>Add to the end of an Array</strong></p> <pre data-language=\"js\">var newLength = fruits.push('Orange');\n// [\"Apple\", \"Banana\", \"Orange\"]\n</pre> <p><strong>Remove from the end of an Array</strong></p> <pre data-language=\"js\">var last = fruits.pop(); // remove Orange (from the end)\n// [\"Apple\", \"Banana\"];\n</pre> <p><strong>Remove from the front of an Array</strong></p> <pre data-language=\"js\">var first = fruits.shift(); // remove Apple from the front\n// [\"Banana\"];\n</pre> <p><strong>Add to the front of an Array</strong></p> <pre data-language=\"js\">var newLength = fruits.unshift('Strawberry') // add to the front\n// [\"Strawberry\", \"Banana\"];\n</pre> <p><strong>Find the index of an item in the Array</strong></p> <pre data-language=\"js\">fruits.push('Mango');\n// [\"Strawberry\", \"Banana\", \"Mango\"]\n\nvar pos = fruits.indexOf('Banana');\n// 1\n</pre> <p><strong>Remove an item by index position</strong></p> <pre data-language=\"js\">var removedItem = fruits.splice(pos, 1); // this is how to remove an item\n                                        \n// [\"Strawberry\", \"Mango\"]</pre> <p><strong>Remove items from an index position</strong></p> <pre data-language=\"js\">var vegetables = ['Cabbage', 'Turnip', 'Radish', 'Carrot'];\nconsole.log(vegetables); \n// [\"Cabbage\", \"Turnip\", \"Radish\", \"Carrot\"]\n\nvar pos = 1, n = 2;\n\nvar removedItems = vegetables.splice(pos, n); \n// this is how to remove items, n defines the number of items to be removed,\n// from that position(pos) onward to the end of array.\n\nconsole.log(vegetables); \n// [\"Cabbage\", \"Carrot\"] (the original array is changed)\n\nconsole.log(removedItems); \n// [\"Turnip\", \"Radish\"]</pre> <p><strong>Copy an Array</strong></p> <pre data-language=\"js\">var shallowCopy = fruits.slice(); // this is how to make a copy\n// [\"Strawberry\", \"Mango\"]\n</pre> <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\">[<var>element0</var>, <var>element1</var>, ..., <var>elementN</var>]\nnew Array(<var>element0</var>, <var>element1</var>[, ...[, <var>elementN</var>]])\nnew Array(<var>arrayLength</var>)</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><code>element<em>N</em></code></dt> <dd>A JavaScript array is initialized with the given elements, except in the case where a single argument is passed to the <code>Array</code> constructor and that argument is a number (see the arrayLength parameter below). Note that this special case only applies to JavaScript arrays created with the <code>Array</code> constructor, not array literals created with the bracket syntax.</dd> <dt><code>arrayLength</code></dt> <dd>If the only argument passed to the <code>Array</code> constructor is an integer between 0 and 2<sup>32</sup>-1 (inclusive), this returns a new JavaScript array with its <code>length</code> property set to that number (<strong>Note:</strong> this implies an array of <code>arrayLength</code> empty slots, not slots with actual <code>undefined</code> values). If the argument is any other number, a <a href=\"rangeerror\"><code>RangeError</code></a> exception is thrown.</dd> </dl> <h2 id=\"Description\">Description</h2> <p>Arrays are list-like objects whose prototype has methods to perform traversal and mutation operations. Neither the length of a JavaScript array nor the types of its elements are fixed. Since an array's length can change at any time, and data can be stored at non-contiguous locations in the array, JavaScript arrays are not guaranteed to be dense; this depends on how the programmer chooses to use them. In general, these are convenient characteristics; but if these features are not desirable for your particular use, you might consider using typed arrays.</p> <p>Arrays cannot use strings as element indexes (as in an <a href=\"https://en.wikipedia.org/wiki/Associative_array\">associative array</a>) but must use integers. Setting or accessing via non-integers using <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Working_with_Objects#Objects_and_properties\">bracket notation</a> (or <a href=\"../operators/property_accessors\">dot notation</a>) will not set or retrieve an element from the array list itself, but will set or access a variable associated with that array's <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Properties\">object property collection</a>. The array's object properties and list of array elements are separate, and the array's <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Indexed_collections#Array_methods\">traversal and mutation operations</a> cannot be applied to these named properties.</p> <h3 id=\"Accessing_array_elements\">Accessing array elements</h3> <p>JavaScript arrays are zero-indexed: the first element of an array is at index <code>0</code>, and the last element is at the index equal to the value of the array's <a href=\"array/length\"><code>length</code></a> property minus 1. Using an invalid index number returns <code>undefined</code>.</p> <pre data-language=\"js\">var arr = ['this is the first element', 'this is the second element', 'this is the last element'];\nconsole.log(arr[0]);              // logs 'this is the first element'\nconsole.log(arr[1]);              // logs 'this is the second element'\nconsole.log(arr[arr.length - 1]); // logs 'this is the last element'\n</pre> <p>Array elements are object properties in the same way that <code>toString</code> is a property, but trying to access an element of an array as follows throws a syntax error because the property name is not valid:</p> <pre data-language=\"js\">console.log(arr.0); // a syntax error\n</pre> <p>There is nothing special about JavaScript arrays and the properties that cause this. JavaScript properties that begin with a digit cannot be referenced with dot notation; and must be accessed using bracket notation. For example, if you had an object with a property named <code>'3d'</code>, it can only be referenced using bracket notation. E.g.:</p> <pre data-language=\"js\">var years = [1950, 1960, 1970, 1980, 1990, 2000, 2010];\nconsole.log(years.0);   // a syntax error\nconsole.log(years[0]);  // works properly\n</pre> <pre data-language=\"js\">renderer.3d.setTexture(model, 'character.png');     // a syntax error\nrenderer['3d'].setTexture(model, 'character.png');  // works properly\n</pre> <p>Note that in the <code>3d</code> example, <code>'3d'</code> had to be quoted. It's possible to quote the JavaScript array indexes as well (e.g., <code>years['2']</code> instead of <code>years[2]</code>), although it's not necessary. The 2 in <code>years[2]</code> is coerced into a string by the JavaScript engine through an implicit <code>toString</code> conversion. It is, for this reason, that <code>'2'</code> and <code>'02'</code> would refer to two different slots on the <code>years</code> object and the following example could be <code>true</code>:</p> <pre data-language=\"js\">console.log(years['2'] != years['02']);\n</pre> <p>Similarly, object properties which happen to be reserved words(!) can only be accessed as string literals in bracket notation (but it can be accessed by dot notation in firefox 40.0a2 at least):</p> <pre data-language=\"js\">var promise = {\n  'var'  : 'text',\n  'array': [1, 2, 3, 4]\n};\n\nconsole.log(promise['var']);\n</pre> <h3 id=\"Relationship_between_length_and_numerical_properties\">Relationship between <code>length</code> and numerical properties</h3> <p>A JavaScript array's <a href=\"array/length\"><code>length</code></a> property and numerical properties are connected. Several of the built-in array methods (e.g., <a href=\"array/join\"><code>join()</code></a>, <a href=\"array/slice\"><code>slice()</code></a>, <a href=\"array/indexof\"><code>indexOf()</code></a>, etc.) take into account the value of an array's <a href=\"array/length\"><code>length</code></a> property when they're called. Other methods (e.g., <a href=\"array/push\"><code>push()</code></a>, <a href=\"array/splice\"><code>splice()</code></a>, etc.) also result in updates to an array's <a href=\"array/length\"><code>length</code></a> property.</p> <pre data-language=\"js\">var fruits = [];\nfruits.push('banana', 'apple', 'peach');\n\nconsole.log(fruits.length); // 3\n</pre> <p>When setting a property on a JavaScript array when the property is a valid array index and that index is outside the current bounds of the array, the engine will update the array's <a href=\"array/length\"><code>length</code></a> property accordingly:</p> <pre data-language=\"js\">fruits[5] = 'mango';\nconsole.log(fruits[5]); // 'mango'\nconsole.log(Object.keys(fruits));  // ['0', '1', '2', '5']\nconsole.log(fruits.length); // 6\n</pre> <p>Increasing the <a href=\"array/length\"><code>length</code></a>.</p> <pre data-language=\"js\">fruits.length = 10;\nconsole.log(Object.keys(fruits)); // ['0', '1', '2', '5']\nconsole.log(fruits.length); // 10\n</pre> <p>Decreasing the <a href=\"array/length\"><code>length</code></a> property does, however, delete elements.</p> <pre data-language=\"js\">fruits.length = 2;\nconsole.log(Object.keys(fruits)); // ['0', '1']\nconsole.log(fruits.length); // 2\n</pre> <p>This is explained further on the <a href=\"array/length\"><code>Array.length</code></a> page.</p> <h3 id=\"Creating_an_array_using_the_result_of_a_match\">Creating an array using the result of a match</h3> <p>The result of a match between a regular expression and a string can create a JavaScript array. This array has properties and elements which provide information about the match. Such an array is returned by <a href=\"regexp/exec\"><code>RegExp.exec</code></a>, <a href=\"string/match\"><code>String.match</code></a>, and <a href=\"string/replace\"><code>String.replace</code></a>. To help explain these properties and elements, look at the following example and then refer to the table below:</p> <pre data-language=\"js\">// Match one d followed by one or more b's followed by one d\n// Remember matched b's and the following d\n// Ignore case\n\nvar myRe = /d(b+)(d)/i;\nvar myArray = myRe.exec('cdbBdbsbz');\n</pre> <p>The properties and elements returned from this match are as follows:</p> <div class=\"_table\"><table class=\"fullwidth-table\"> <tbody> <tr> <th class=\"header\">Property/Element</th> <th class=\"header\">Description</th> <th class=\"header\">Example</th> </tr> <tr> <td><code>input</code></td> <td>A read-only property that reflects the original string against which the regular expression was matched.</td> <td>cdbBdbsbz</td> </tr> <tr> <td><code>index</code></td> <td>A read-only property that is the zero-based index of the match in the string.</td> <td>1</td> </tr> <tr> <td><code>[0]</code></td> <td>A read-only element that specifies the last matched characters.</td> <td>dbBd</td> </tr> <tr> <td><code>[1], ...[n]</code></td> <td>Read-only elements that specify the parenthesized substring matches, if included in the regular expression. The number of possible parenthesized substrings is unlimited.</td> <td>[1]: bB<br> [2]: d</td> </tr> </tbody> </table></div> <h2 id=\"Properties\">Properties</h2> <dl> <dt><code>Array.length</code></dt> <dd>The <code>Array</code> constructor's length property whose value is 1.</dd> <dt><a href=\"array/@@species\"><code>get Array[@@species]</code></a></dt> <dd>The constructor function that is used to create derived objects.</dd> <dt><a href=\"array/prototype\"><code>Array.prototype</code></a></dt> <dd>Allows the addition of properties to all array objects.</dd> </dl> <h2 id=\"Methods\">Methods</h2> <dl> <dt><a href=\"array/from\"><code>Array.from()</code></a></dt> <dd>Creates a new <code>Array</code> instance from an array-like or iterable object.</dd> <dt><a href=\"array/isarray\"><code>Array.isArray()</code></a></dt> <dd>Returns true if a variable is an array, if not false.</dd> <dt><a href=\"array/of\"><code>Array.of()</code></a></dt> <dd>Creates a new <code>Array</code> instance with a variable number of arguments, regardless of number or type of the arguments.</dd> </dl> <h2 id=\"Array_instances\">\n<code>Array</code> instances</h2> <p>All <code>Array</code> instances inherit from <a href=\"array/prototype\"><code>Array.prototype</code></a>. The prototype object of the <code>Array</code> constructor can be modified to affect all <code>Array</code> instances.</p> <h3 id=\"Properties_2\">Properties</h3> <dl> <dt><code>Array.prototype.constructor</code></dt> <dd>Specifies the function that creates an object's prototype.</dd> <dt><a href=\"array/length\"><code>Array.prototype.length</code></a></dt> <dd>Reflects the number of elements in an array.</dd> <dt><a href=\"array/@@unscopables\"><code>Array.prototype[@@unscopables]</code></a></dt> <dd>A symbol containing property names to exclude from a <code><a href=\"../statements/with\">with</a></code> binding scope.</dd> </dl> <h3 id=\"Methods_2\">Methods</h3> <h4 id=\"Mutator_methods\">Mutator methods</h4> <p>These methods modify the array:</p> <dl> <dt><a href=\"array/copywithin\"><code>Array.prototype.copyWithin()</code></a></dt> <dd>Copies a sequence of array elements within the array.</dd> <dt><a href=\"array/fill\"><code>Array.prototype.fill()</code></a></dt> <dd>Fills all the elements of an array from a start index to an end index with a static value.</dd> <dt><a href=\"array/pop\"><code>Array.prototype.pop()</code></a></dt> <dd>Removes the last element from an array and returns that element.</dd> <dt><a href=\"array/push\"><code>Array.prototype.push()</code></a></dt> <dd>Adds one or more elements to the end of an array and returns the new length of the array.</dd> <dt><a href=\"array/reverse\"><code>Array.prototype.reverse()</code></a></dt> <dd>Reverses the order of the elements of an array in place — the first becomes the last, and the last becomes the first.</dd> <dt><a href=\"array/shift\"><code>Array.prototype.shift()</code></a></dt> <dd>Removes the first element from an array and returns that element.</dd> <dt><a href=\"array/sort\"><code>Array.prototype.sort()</code></a></dt> <dd>Sorts the elements of an array in place and returns the array.</dd> <dt><a href=\"array/splice\"><code>Array.prototype.splice()</code></a></dt> <dd>Adds and/or removes elements from an array.</dd> <dt><a href=\"array/unshift\"><code>Array.prototype.unshift()</code></a></dt> <dd>Adds one or more elements to the front of an array and returns the new length of the array.</dd> </dl> <h4 id=\"Accessor_methods\">Accessor methods</h4> <p>These methods do not modify the array and return some representation of the array.</p> <dl> <dt><a href=\"array/concat\"><code>Array.prototype.concat()</code></a></dt> <dd>Returns a new array comprised of this array joined with other array(s) and/or value(s).</dd> <dt><a href=\"array/includes\"><code>Array.prototype.includes()</code></a></dt> <dd>Determines whether an array contains a certain element, returning <code>true</code> or <code>false</code> as appropriate.</dd> <dt><a href=\"array/indexof\"><code>Array.prototype.indexOf()</code></a></dt> <dd>Returns the first (least) index of an element within the array equal to the specified value, or -1 if none is found.</dd> <dt><a href=\"array/join\"><code>Array.prototype.join()</code></a></dt> <dd>Joins all elements of an array into a string.</dd> <dt><a href=\"array/lastindexof\"><code>Array.prototype.lastIndexOf()</code></a></dt> <dd>Returns the last (greatest) index of an element within the array equal to the specified value, or -1 if none is found.</dd> <dt><a href=\"array/slice\"><code>Array.prototype.slice()</code></a></dt> <dd>Extracts a section of an array and returns a new array.</dd> <dt>\n<a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/toSource\"><code>Array.prototype.toSource()</code></a> \n</dt> <dd>Returns an array literal representing the specified array; you can use this value to create a new array. Overrides the <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/toSource\"><code>Object.prototype.toSource()</code></a> method.</dd> <dt><a href=\"array/tostring\"><code>Array.prototype.toString()</code></a></dt> <dd>Returns a string representing the array and its elements. Overrides the <a href=\"object/tostring\"><code>Object.prototype.toString()</code></a> method.</dd> <dt><a href=\"array/tolocalestring\"><code>Array.prototype.toLocaleString()</code></a></dt> <dd>Returns a localized string representing the array and its elements. Overrides the <a href=\"object/tolocalestring\"><code>Object.prototype.toLocaleString()</code></a> method.</dd> </dl> <h4 id=\"Iteration_methods\">Iteration methods</h4> <p>Several methods take as arguments functions to be called back while processing the array. When these methods are called, the <code>length</code> of the array is sampled, and any element added beyond this length from within the callback is not visited. Other changes to the array (setting the value of or deleting an element) may affect the results of the operation if the method visits the changed element afterwards. While the specific behavior of these methods in such cases is well-defined, you should not rely upon it so as not to confuse others who might read your code. If you must mutate the array, copy into a new array instead.</p> <dl> <dt><a href=\"array/entries\"><code>Array.prototype.entries()</code></a></dt> <dd>Returns a new <code>Array Iterator</code> object that contains the key/value pairs for each index in the array.</dd> <dt><a href=\"array/every\"><code>Array.prototype.every()</code></a></dt> <dd>Returns true if every element in this array satisfies the provided testing function.</dd> <dt><a href=\"array/filter\"><code>Array.prototype.filter()</code></a></dt> <dd>Creates a new array with all of the elements of this array for which the provided filtering function returns true.</dd> <dt><a href=\"array/find\"><code>Array.prototype.find()</code></a></dt> <dd>Returns the found value in the array, if an element in the array satisfies the provided testing function or <code>undefined</code> if not found.</dd> <dt><a href=\"array/findindex\"><code>Array.prototype.findIndex()</code></a></dt> <dd>Returns the found index in the array, if an element in the array satisfies the provided testing function or -1 if not found.</dd> <dt><a href=\"array/foreach\"><code>Array.prototype.forEach()</code></a></dt> <dd>Calls a function for each element in the array.</dd> <dt><a href=\"array/keys\"><code>Array.prototype.keys()</code></a></dt> <dd>Returns a new <code>Array Iterator</code> that contains the keys for each index in the array.</dd> <dt><a href=\"array/map\"><code>Array.prototype.map()</code></a></dt> <dd>Creates a new array with the results of calling a provided function on every element in this array.</dd> <dt><a href=\"array/reduce\"><code>Array.prototype.reduce()</code></a></dt> <dd>Apply a function against an accumulator and each value of the array (from left-to-right) as to reduce it to a single value.</dd> <dt><a href=\"array/reduceright\"><code>Array.prototype.reduceRight()</code></a></dt> <dd>Apply a function against an accumulator and each value of the array (from right-to-left) as to reduce it to a single value.</dd> <dt><a href=\"array/some\"><code>Array.prototype.some()</code></a></dt> <dd>Returns true if at least one element in this array satisfies the provided testing function.</dd> <dt><a href=\"array/values\"><code>Array.prototype.values()</code></a></dt> <dd>Returns a new <code>Array Iterator</code> object that contains the values for each index in the array.</dd> <dt><a href=\"array/@@iterator\"><code>Array.prototype[@@iterator]()</code></a></dt> <dd>Returns a new <code>Array Iterator</code> object that contains the values for each index in the array.</dd> </dl> <h2 id=\"Array_generic_methods\">\n<code>Array</code> generic methods</h2> <div class=\"warning\"> <p><strong>Array generics are non-standard, deprecated and will get removed in the near future</strong>. </p> </div> <p>Sometimes you would like to apply array methods to strings or other array-like objects (such as function <a href=\"../functions/arguments\">arguments</a>). By doing this, you treat a string as an array of characters (or otherwise treat a non-array as an array). For example, in order to check that every character in the variable <var>str</var> is a letter, you would write:</p> <pre data-language=\"js\">function isLetter(character) {\n  return character &gt;= 'a' &amp;&amp; character &lt;= 'z';\n}\n\nif (Array.prototype.every.call(str, isLetter)) {\n  console.log(\"The string '\" + str + \"' contains only letters!\");\n}\n</pre> <p>This notation is rather wasteful and JavaScript 1.6 introduced a generic shorthand:</p> <pre data-language=\"js\">if (Array.every(str, isLetter)) {\n  console.log(\"The string '\" + str + \"' contains only letters!\");\n}\n</pre> <p><a href=\"string#String_generic_methods\">Generics</a> are also available on <a href=\"string\"><code>String</code></a>.</p> <p>These are <strong>not</strong> part of ECMAScript standards and they are not supported by non-Gecko browsers. As a standard alternative, you can convert your object to a proper array using <a href=\"array/from\"><code>Array.from()</code></a>; although that method may not be supported in old browsers:</p> <pre data-language=\"js\">if (Array.from(str).every(isLetter)) { \n  console.log(\"The string '\" + str + \"' contains only letters!\"); \n}\n</pre> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Creating_an_array\">Creating an array</h3> <p>The following example creates an array, <code>msgArray</code>, with a length of 0, then assigns values to <code>msgArray[0]</code> and <code>msgArray[99]</code>, changing the length of the array to 100.</p> <pre data-language=\"js\">var msgArray = [];\nmsgArray[0] = 'Hello';\nmsgArray[99] = 'world';\n\nif (msgArray.length === 100) {\n  console.log('The length is 100.');\n}\n</pre> <h3 id=\"Creating_a_two-dimensional_array\">Creating a two-dimensional array</h3> <p>The following creates a chess board as a two-dimensional array of strings. The first move is made by copying the 'p' in (6,4) to (4,4). The old position (6,4) is made blank.</p> <pre data-language=\"js\">var board = [ \n  ['R','N','B','Q','K','B','N','R'],\n  ['P','P','P','P','P','P','P','P'],\n  [' ',' ',' ',' ',' ',' ',' ',' '],\n  [' ',' ',' ',' ',' ',' ',' ',' '],\n  [' ',' ',' ',' ',' ',' ',' ',' '],\n  [' ',' ',' ',' ',' ',' ',' ',' '],\n  ['p','p','p','p','p','p','p','p'],\n  ['r','n','b','q','k','b','n','r'] ];\n\nconsole.log(board.join('\\n') + '\\n\\n');\n\n// Move King's Pawn forward 2\nboard[4][4] = board[6][4];\nboard[6][4] = ' ';\nconsole.log(board.join('\\n'));\n</pre> <p>Here is the output:</p> <pre>R,N,B,Q,K,B,N,R\nP,P,P,P,P,P,P,P\n , , , , , , , \n , , , , , , , \n , , , , , , , \n , , , , , , , \np,p,p,p,p,p,p,p\nr,n,b,q,k,b,n,r\n\nR,N,B,Q,K,B,N,R\nP,P,P,P,P,P,P,P\n , , , , , , , \n , , , , , , , \n , , , ,p, , , \n , , , , , , , \np,p,p,p, ,p,p,p\nr,n,b,q,k,b,n,r\n</pre> <h3 id=\"Using_an_array_to_tabulate_a_set_of_values\">Using an array to tabulate a set of values</h3> <pre data-language=\"js\">values = [];\nfor (var x = 0; x &lt; 10; x++){\n values.push([\n  2 ** x,\n  2 * x ** 2\n ])\n};\nconsole.table(values)</pre> <p>Results in</p> <pre>0\t1\t0\n1\t2\t2\n2\t4\t8\n3\t8\t18\n4\t16\t32\n5\t32\t50\n6\t64\t72\n7\t128\t98\n8\t256\t128\n9\t512\t162</pre> <p>(First column is the (index))</p> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/publications/files/ECMA-ST-ARCH/ECMA-262,%201st%20edition,%20June%201997.pdf\" hreflang=\"en\">ECMAScript 1st Edition (ECMA-262)</a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/5.1/#sec-15.4\" hreflang=\"en\">ECMAScript 5.1 (ECMA-262)<br><small>The definition of 'Array' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>New methods added: <a href=\"array/isarray\"><code>Array.isArray</code></a>, <a href=\"array/indexof\"><code>indexOf</code></a>, <a href=\"array/lastindexof\"><code>lastIndexOf</code></a>, <a href=\"array/every\"><code>every</code></a>, <a href=\"array/some\"><code>some</code></a>, <a href=\"array/foreach\"><code>forEach</code></a>, <a href=\"array/map\"><code>map</code></a>, <a href=\"array/filter\"><code>filter</code></a>, <a href=\"array/reduce\"><code>reduce</code></a>, <a href=\"array/reduceright\"><code>reduceRight</code></a>\n</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-array-objects\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Array' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>New methods added: <a href=\"array/from\"><code>Array.from</code></a>, <a href=\"array/of\"><code>Array.of</code></a>, <a href=\"array/find\"><code>find</code></a>, <a href=\"array/findindex\"><code>findIndex</code></a>, <a href=\"array/fill\"><code>fill</code></a>, <a href=\"array/copywithin\"><code>copyWithin</code></a>\n</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/7.0/#sec-array-objects\" hreflang=\"en\">ECMAScript 2016 (ECMA-262)<br><small>The definition of 'Array' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>New method added: <a href=\"array/includes\"><code>Array.prototype.includes()</code></a>\n</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-array-objects\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Array' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/concat\"><code>concat</code></a></th>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> 5.5</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/copyWithin\"><code>copyWithin</code></a></th>\n<td class=\"bc-supports-yes\"> 45</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 32</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 32</td>\n<td class=\"bc-supports-yes\"> 9</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/entries\"><code>entries</code></a></th>\n<td class=\"bc-supports-yes\"> 38</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 28</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 25</td>\n<td class=\"bc-supports-yes\"> 8</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/every\"><code>every</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1.5</td>\n<td class=\"bc-supports-yes\"> 9</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/fill\"><code>fill</code></a></th>\n<td class=\"bc-supports-yes\"> 45</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 31</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 8</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/filter\"><code>filter</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1.5</td>\n<td class=\"bc-supports-yes\"> 9</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/find\"><code>find</code></a></th>\n<td class=\"bc-supports-yes\"> 45</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 25</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 32</td>\n<td class=\"bc-supports-yes\"> 8</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/findIndex\"><code>findIndex</code></a></th>\n<td class=\"bc-supports-yes\"> 45</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 25</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 32</td>\n<td class=\"bc-supports-yes\"> 8</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/flat\"><code>flat</code></a> \n</th>\n<td class=\"bc-supports-yes\"> 69</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 62</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 56</td>\n<td class=\"bc-supports-yes\"> 12</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/flatMap\"><code>flatMap</code></a> \n</th>\n<td class=\"bc-supports-yes\"> 69</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 62</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 56</td>\n<td class=\"bc-supports-yes\"> 12</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/forEach\"><code>forEach</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1.5</td>\n<td class=\"bc-supports-yes\"> 9</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/from\"><code>from</code></a></th>\n<td class=\"bc-supports-yes\"> 45</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 32</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 9</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/includes\"><code>includes</code></a></th>\n<td class=\"bc-supports-yes\"> 47</td>\n<td class=\"bc-supports-yes\"> 14</td>\n<td class=\"bc-supports-yes\"> 43</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 34</td>\n<td class=\"bc-supports-yes\"> 9</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/indexOf\"><code>indexOf</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1.5</td>\n<td class=\"bc-supports-yes\"> 9</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/isArray\"><code>isArray</code></a></th>\n<td class=\"bc-supports-yes\"> 5</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> 9</td>\n<td class=\"bc-supports-yes\"> 10.5</td>\n<td class=\"bc-supports-yes\"> 5</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/join\"><code>join</code></a></th>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> 5.5</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/keys\"><code>keys</code></a></th>\n<td class=\"bc-supports-yes\"> 38</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 28</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 25</td>\n<td class=\"bc-supports-yes\"> 8</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/lastIndexOf\"><code>lastIndexOf</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1.5</td>\n<td class=\"bc-supports-yes\"> 9</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/length\"><code>length</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/map\"><code>map</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1.5</td>\n<td class=\"bc-supports-yes\"> 9</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/observe\"><code>observe</code></a> \n</th>\n<td class=\"bc-supports-no\">36 — 52</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/of\"><code>of</code></a></th>\n<td class=\"bc-supports-yes\"> 45</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 25</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 9</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/pop\"><code>pop</code></a></th>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> 5.5</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/prototype\"><code>prototype</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/push\"><code>push</code></a></th>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> 5.5</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/reduce\"><code>reduce</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 3</td>\n<td class=\"bc-supports-yes\"> 9</td>\n<td class=\"bc-supports-yes\"> 10.5</td>\n<td class=\"bc-supports-yes\"> 4</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/reduceRight\"><code>reduceRight</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 3</td>\n<td class=\"bc-supports-yes\"> 9</td>\n<td class=\"bc-supports-yes\"> 10.5</td>\n<td class=\"bc-supports-yes\"> 4</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/reverse\"><code>reverse</code></a></th>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> 5.5</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/shift\"><code>shift</code></a></th>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> 5.5</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/slice\"><code>slice</code></a></th>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/some\"><code>some</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1.5</td>\n<td class=\"bc-supports-yes\"> 9</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/sort\"><code>sort</code></a></th>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> 5.5</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/splice\"><code>splice</code></a></th>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> 5.5</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/toLocaleString\"><code>toLocaleString</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/toSource\"><code>toSource</code></a> \n</th>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/toString\"><code>toString</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/unobserve\"><code>unobserve</code></a> \n</th>\n<td class=\"bc-supports-no\">36 — 52</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/unshift\"><code>unshift</code></a></th>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> 5.5</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/values\"><code>values</code></a></th>\n<td class=\"bc-supports-yes\"> 66</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 60</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 53</td>\n<td class=\"bc-supports-yes\"> 9</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/@@iterator\"><code>@@iterator</code></a></th>\n<td class=\"bc-supports-yes\"> 38</td>\n<td> ? </td>\n<td class=\"bc-supports-yes bc-has-history\"> 36\n<section class=\"bc-history\" id=\"sect6\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 36\n</dt>\n\n<dt class=\"bc-supports-no bc-supports\">27 — 36\n</dt>\n<dd> A placeholder property named <code>@@iterator</code> is used.</dd>\n<dd> Uses the non-standard name: <code>@@iterator</code>\n</dd>\n<dt class=\"bc-supports-no bc-supports\">17 — 27\n</dt>\n<dd> A placeholder property named <code>iterator</code> is used.</dd>\n<dd> Uses the non-standard name: <code>iterator</code>\n</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 25</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/@@species\"><code>@@species</code></a></th>\n<td> ? </td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 48</td>\n<td> ? </td>\n<td> ? </td>\n<td> ? </td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/@@unscopables\"><code>@@unscopables</code></a></th>\n<td> ? </td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 48</td>\n<td> ? </td>\n<td> ? </td>\n<td> ? </td>\n</tr>\n</tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/concat\"><code>concat</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/copyWithin\"><code>copyWithin</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 32</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/entries\"><code>entries</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 28</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 8</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/every\"><code>every</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/fill\"><code>fill</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 31</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 8</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/filter\"><code>filter</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/find\"><code>find</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 8</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/findIndex\"><code>findIndex</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 8</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/flat\"><code>flat</code></a> \n</th>\n<td class=\"bc-supports-yes\"> 69</td>\n<td class=\"bc-supports-yes\"> 69</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 62</td>\n<td class=\"bc-supports-yes\"> 56</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-no\"> No</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/flatMap\"><code>flatMap</code></a> \n</th>\n<td class=\"bc-supports-yes\"> 69</td>\n<td class=\"bc-supports-yes\"> 69</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 62</td>\n<td class=\"bc-supports-yes\"> 56</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-no\"> No</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/forEach\"><code>forEach</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/from\"><code>from</code></a></th>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 32</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/includes\"><code>includes</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 14</td>\n<td class=\"bc-supports-yes\"> 43</td>\n<td class=\"bc-supports-yes\"> 34</td>\n<td class=\"bc-supports-yes\"> 9</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/indexOf\"><code>indexOf</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/isArray\"><code>isArray</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/join\"><code>join</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/keys\"><code>keys</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 28</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 8</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/lastIndexOf\"><code>lastIndexOf</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/length\"><code>length</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/map\"><code>map</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/observe\"><code>observe</code></a> \n</th>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/of\"><code>of</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 39</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 25</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4.0</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/pop\"><code>pop</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/prototype\"><code>prototype</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/push\"><code>push</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/reduce\"><code>reduce</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/reduceRight\"><code>reduceRight</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/reverse\"><code>reverse</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/shift\"><code>shift</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/slice\"><code>slice</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/some\"><code>some</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/sort\"><code>sort</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/splice\"><code>splice</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/toLocaleString\"><code>toLocaleString</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/toSource\"><code>toSource</code></a> \n</th>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/toString\"><code>toString</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/unobserve\"><code>unobserve</code></a> \n</th>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/unshift\"><code>unshift</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/values\"><code>values</code></a></th>\n<td class=\"bc-supports-yes\"> 66</td>\n<td class=\"bc-supports-yes\"> 66</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 60</td>\n<td class=\"bc-supports-yes\"> 53</td>\n<td class=\"bc-supports-yes\"> 9</td>\n<td class=\"bc-supports-no\"> No</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/@@iterator\"><code>@@iterator</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td> ? </td>\n<td class=\"bc-supports-yes bc-has-history\"> 36\n<section class=\"bc-history\" id=\"sect7\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 36\n</dt>\n\n<dt class=\"bc-supports-no bc-supports\">27 — 36\n</dt>\n<dd> A placeholder property named <code>@@iterator</code> is used.</dd>\n<dd> Uses the non-standard name: <code>@@iterator</code>\n</dd>\n<dt class=\"bc-supports-no bc-supports\">17 — 27\n</dt>\n<dd> A placeholder property named <code>iterator</code> is used.</dd>\n<dd> Uses the non-standard name: <code>iterator</code>\n</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/@@species\"><code>@@species</code></a></th>\n<td> ? </td>\n<td> ? </td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 48</td>\n<td> ? </td>\n<td> ? </td>\n<td> ? </td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/@@unscopables\"><code>@@unscopables</code></a></th>\n<td> ? </td>\n<td> ? </td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 48</td>\n<td> ? </td>\n<td> ? </td>\n<td> ? </td>\n</tr>\n</tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/concat\"><code>concat</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/copyWithin\"><code>copyWithin</code></a></th>\n<td class=\"bc-supports-yes\"> 4.0.0</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/entries\"><code>entries</code></a></th>\n<td class=\"bc-supports-yes\"> 0.12</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/every\"><code>every</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/fill\"><code>fill</code></a></th>\n<td class=\"bc-supports-yes bc-has-history\"> 4.0.0\n<section class=\"bc-history\" id=\"sect1\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 4.0.0\n</dt>\n\n<dt class=\"bc-supports-yes bc-supports\"> 0.12<div class=\"bc-icons\">Disabled </div>\n</dt>\n<dd>Disabled From version 0.12: this feature is behind the <code>--harmony</code> runtime flag.</dd>\n</dl></section>\n</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/filter\"><code>filter</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/find\"><code>find</code></a></th>\n<td class=\"bc-supports-yes bc-has-history\"> 4.0.0\n<section class=\"bc-history\" id=\"sect2\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 4.0.0\n</dt>\n\n<dt class=\"bc-supports-yes bc-supports\"> 0.12<div class=\"bc-icons\">Disabled </div>\n</dt>\n<dd>Disabled From version 0.12: this feature is behind the <code>--harmony</code> runtime flag.</dd>\n</dl></section>\n</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/findIndex\"><code>findIndex</code></a></th>\n<td class=\"bc-supports-yes bc-has-history\"> 4.0.0\n<section class=\"bc-history\" id=\"sect3\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 4.0.0\n</dt>\n\n<dt class=\"bc-supports-yes bc-supports\"> 0.12<div class=\"bc-icons\">Disabled </div>\n</dt>\n<dd>Disabled From version 0.12: this feature is behind the <code>--harmony</code> runtime flag.</dd>\n</dl></section>\n</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/flat\"><code>flat</code></a> \n</th>\n<td class=\"bc-supports-no\"> No</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/flatMap\"><code>flatMap</code></a> \n</th>\n<td class=\"bc-supports-no\"> No</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/forEach\"><code>forEach</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/from\"><code>from</code></a></th>\n<td class=\"bc-supports-yes\"> 4.0.0</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/includes\"><code>includes</code></a></th>\n<td class=\"bc-supports-yes bc-has-history\"> 6.0.0\n<section class=\"bc-history\" id=\"sect4\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 6.0.0\n</dt>\n\n<dt class=\"bc-supports-yes bc-supports\"> 5.0.0<div class=\"bc-icons\">Disabled </div>\n</dt>\n<dd>Disabled From version 5.0.0: this feature is behind the <code>--harmony</code> runtime flag.</dd>\n</dl></section>\n</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/indexOf\"><code>indexOf</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/isArray\"><code>isArray</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/join\"><code>join</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/keys\"><code>keys</code></a></th>\n<td class=\"bc-supports-yes\"> 0.12</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/lastIndexOf\"><code>lastIndexOf</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/length\"><code>length</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/map\"><code>map</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/observe\"><code>observe</code></a> \n</th>\n<td class=\"bc-supports-no\"> No</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/of\"><code>of</code></a></th>\n<td class=\"bc-supports-yes\"> 4.0.0</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/pop\"><code>pop</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/prototype\"><code>prototype</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/push\"><code>push</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/reduce\"><code>reduce</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/reduceRight\"><code>reduceRight</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/reverse\"><code>reverse</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/shift\"><code>shift</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/slice\"><code>slice</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/some\"><code>some</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/sort\"><code>sort</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/splice\"><code>splice</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/toLocaleString\"><code>toLocaleString</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/toSource\"><code>toSource</code></a> \n</th>\n<td class=\"bc-supports-no\"> No</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/toString\"><code>toString</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/unobserve\"><code>unobserve</code></a> \n</th>\n<td class=\"bc-supports-no\"> No</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/unshift\"><code>unshift</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/values\"><code>values</code></a></th>\n<td class=\"bc-supports-yes bc-has-history\"> 10.9.0\n<section class=\"bc-history\" id=\"sect5\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 10.9.0\n</dt>\n\n<dt class=\"bc-supports-yes bc-supports\"> 6.5.0<div class=\"bc-icons\"> Disabled </div>\n</dt>\n<dd> The <code>--harmony-array-prototype-values</code> flag is required; the <code>--harmony</code> flag is not sufficient in this case.</dd>\n<dd>Disabled From version 6.5.0: this feature is behind the <code>--harmony-array-prototype-values</code> runtime flag.</dd>\n<dt class=\"bc-supports-no bc-supports\">0.12 — 4.0.0\n</dt>\n\n</dl></section>\n</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/@@iterator\"><code>@@iterator</code></a></th>\n<td class=\"bc-supports-yes\"> 0.12</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/@@species\"><code>@@species</code></a></th>\n<td class=\"bc-supports-yes bc-has-history\"> 6.5.0\n<section class=\"bc-history\" id=\"sect8\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 6.5.0\n</dt>\n\n<dt class=\"bc-supports-yes bc-supports\"> 6.0.0<div class=\"bc-icons\">Disabled </div>\n</dt>\n<dd>Disabled From version 6.0.0: this feature is behind the <code>--harmony</code> runtime flag.</dd>\n</dl></section>\n</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/@@unscopables\"><code>@@unscopables</code></a></th>\n<td class=\"bc-supports-yes\"> 0.12</td>\n</tr>\n</tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Working_with_Objects#Indexing_object_properties\">JavaScript Guide: “Indexing object properties”</a></li> <li><a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Predefined_Core_Objects#Array_Object\">JavaScript Guide: “Predefined Core Objects: <code>Array</code> Object”</a></li> <li><a href=\"../operators/array_comprehensions\">Array comprehensions</a></li> <li><a href=\"https://github.com/plusdude/array-generics\">Polyfill for JavaScript 1.8.5 Array Generics and ECMAScript 5 Array Extras</a></li> <li><a href=\"https://developer.mozilla.org/en-US/docs/JavaScript_typed_arrays\">Typed Arrays</a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array</a>\n  </p>\n</div>\n","operators/comma_operator":"<h1>Comma Operator</h1> <p>The<strong> comma operator</strong> evaluates each of its operands (from left to right) and returns the value of the last operand.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/expressions-commaoperators.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\"><em>expr1</em>, <em>expr2, expr3...</em></pre> <h2 id=\"Parameters\">Parameters</h2> <dl> <dt>\n<code>expr1</code>, <code>expr2, expr3...</code>\n</dt> <dd>Any expressions.</dd> </dl> <h2 id=\"Description\">Description</h2> <p>You can use the comma operator when you want to include multiple expressions in a location that requires a single expression. The most common usage of this operator is to supply multiple parameters in a <code>for</code> loop.</p> <h2 id=\"Examples\">Examples</h2> <p>If <code>a</code> is a 2-dimensional array with 10 elements on each side, the following code uses the comma operator to increment two variables at once.</p> <p>The following code prints the values of the diagonal elements in the array:</p> <pre data-language=\"js\">for (var i = 0, j = 9; i &lt;= 9; i++, j--)\n  console.log('a[' + i + '][' + j + '] = ' + a[i][j]);</pre> <p>Note that the comma in assignments such as the <code>var</code> statement may appear not to have the normal effect of comma operators because they don't exist within an expression. In the following example, <code>a</code> is set to the value of <code>b = 3</code> (which is 3), but the <code>c = 4</code> expression still evaluates and its result returned to console (i.e., 4). This is due to <a href=\"operator_precedence\">operator precedence and associativity</a>.</p> <pre data-language=\"js\">// Note that the following creates globals and is disallowed in strict mode.\n\na = b = 3, c = 4; // Returns 4 in console\nconsole.log(a); // 3 (left-most)\n\nx = (y = 5, z = 6); // Returns 6 in console\nconsole.log(x); // 6 (right-most)\n</pre> <p>The comma operator is fully different from the comma within arrays, objects, and function arguments and parameters.</p> <h3 id=\"Processing_and_then_returning\">Processing and then returning</h3> <p>Another example that one could make with comma operator is processing before returning. As stated, only the last element will be returned but all others are going to be evaluated as well. So, one could do:</p> <pre data-language=\"js\">function myFunc() {\n  var x = 0;\n\n  return (x += 1, x); // the same as return ++x;\n}</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-comma-operator\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Comma operator' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-comma-operator\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Comma operator' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/5.1/#sec-11.14\" hreflang=\"en\">ECMAScript 5.1 (ECMA-262)<br><small>The definition of 'Comma operator' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/publications/files/ECMA-ST-ARCH/ECMA-262,%201st%20edition,%20June%201997.pdf#sec-11.14\" hreflang=\"en\">ECMAScript 1st Edition (ECMA-262)<br><small>The definition of 'Comma operator' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition</td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Operators/Comma_operator\">Basic support</a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> 3</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Operators/Comma_operator\">Basic support</a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Operators/Comma_operator\">Basic support</a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"../statements/for\">for loop</a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Comma_Operator$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Comma_Operator\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Comma_Operator</a>\n  </p>\n</div>\n","global_objects/math":"<h1>Math</h1> <p><code>Math</code> is a built-in object that has properties and methods for mathematical constants and functions. Not a function object.</p> <h2 id=\"Description\">Description</h2> <p>Unlike the other global objects, <code>Math</code> is not a constructor. All properties and methods of <code>Math</code> are static. You refer to the constant pi as <code>Math.PI</code> and you call the sine function as <code>Math.sin(x)</code>, where <code>x</code> is the method's argument. Constants are defined with the full precision of real numbers in JavaScript.</p> <h2 id=\"Properties\">Properties</h2> <dl> <dt><a href=\"math/e\"><code>Math.E</code></a></dt> <dd>Euler's constant and the base of natural logarithms, approximately 2.718.</dd> <dt><a href=\"math/ln2\"><code>Math.LN2</code></a></dt> <dd>Natural logarithm of 2, approximately 0.693.</dd> <dt><a href=\"math/ln10\"><code>Math.LN10</code></a></dt> <dd>Natural logarithm of 10, approximately 2.303.</dd> <dt><a href=\"math/log2e\"><code>Math.LOG2E</code></a></dt> <dd>Base 2 logarithm of E, approximately 1.443.</dd> <dt><a href=\"math/log10e\"><code>Math.LOG10E</code></a></dt> <dd>Base 10 logarithm of E, approximately 0.434.</dd> <dt><a href=\"math/pi\"><code>Math.PI</code></a></dt> <dd>Ratio of the circumference of a circle to its diameter, approximately 3.14159.</dd> <dt><a href=\"math/sqrt1_2\"><code>Math.SQRT1_2</code></a></dt> <dd>Square root of 1/2; equivalently, 1 over the square root of 2, approximately 0.707.</dd> <dt><a href=\"math/sqrt2\"><code>Math.SQRT2</code></a></dt> <dd>Square root of 2, approximately 1.414.</dd> </dl> <h2 id=\"Methods\">Methods</h2> <div class=\"note\"> <p>Note that the trigonometric functions (<code>sin()</code>, <code>cos()</code>, <code>tan()</code>, <code>asin()</code>, <code>acos()</code>, <code>atan()</code>, <code>atan2()</code>) expect or return angles in radians. To convert radians to degrees, divide by <code>(Math.PI / 180)</code>, and multiply by this to convert the other way.</p> </div> <div class=\"note\"> <p>Note that many math functions have a precision that's implementation-dependent. This means that different browsers can give a different result, and even the same JS engine on a different OS or architecture can give different results.</p> </div> <dl> <dt><a href=\"math/abs\"><code>Math.abs(x)</code></a></dt> <dd>Returns the absolute value of a number.</dd> <dt><a href=\"math/acos\"><code>Math.acos(x)</code></a></dt> <dd>Returns the arccosine of a number.</dd> <dt><a href=\"math/acosh\"><code>Math.acosh(x)</code></a></dt> <dd>Returns the hyperbolic arccosine of a number.</dd> <dt><a href=\"math/asin\"><code>Math.asin(x)</code></a></dt> <dd>Returns the arcsine of a number.</dd> <dt><a href=\"math/asinh\"><code>Math.asinh(x)</code></a></dt> <dd>Returns the hyperbolic arcsine of a number.</dd> <dt><a href=\"math/atan\"><code>Math.atan(x)</code></a></dt> <dd>Returns the arctangent of a number.</dd> <dt><a href=\"math/atanh\"><code>Math.atanh(x)</code></a></dt> <dd>Returns the hyperbolic arctangent of a number.</dd> <dt><a href=\"math/atan2\"><code>Math.atan2(y, x)</code></a></dt> <dd>Returns the arctangent of the quotient of its arguments.</dd> <dt><a href=\"math/cbrt\"><code>Math.cbrt(x)</code></a></dt> <dd>Returns the cube root of a number.</dd> <dt><a href=\"math/ceil\"><code>Math.ceil(x)</code></a></dt> <dd>Returns the smallest integer greater than or equal to a number.</dd> <dt><a href=\"math/clz32\"><code>Math.clz32(x)</code></a></dt> <dd>Returns the number of leading zeroes of a 32-bit integer.</dd> <dt><a href=\"math/cos\"><code>Math.cos(x)</code></a></dt> <dd>Returns the cosine of a number.</dd> <dt><a href=\"math/cosh\"><code>Math.cosh(x)</code></a></dt> <dd>Returns the hyperbolic cosine of a number.</dd> <dt><a href=\"math/exp\"><code>Math.exp(x)</code></a></dt> <dd>Returns E<sup>x</sup>, where <var>x</var> is the argument, and E is Euler's constant (2.718…), the base of the natural logarithm.</dd> <dt><a href=\"math/expm1\"><code>Math.expm1(x)</code></a></dt> <dd>Returns subtracting 1 from <code>exp(x)</code>.</dd> <dt><a href=\"math/floor\"><code>Math.floor(x)</code></a></dt> <dd>Returns the largest integer less than or equal to a number.</dd> <dt><a href=\"math/fround\"><code>Math.fround(x)</code></a></dt> <dd>Returns the nearest <a href=\"http://en.wikipedia.org/wiki/Single-precision_floating-point_format\">single precision</a> float representation of a number.</dd> <dt><a href=\"math/hypot\"><code>Math.hypot([x[, y[, …]]])</code></a></dt> <dd>Returns the square root of the sum of squares of its arguments.</dd> <dt><a href=\"math/imul\"><code>Math.imul(x, y)</code></a></dt> <dd>Returns the result of a 32-bit integer multiplication.</dd> <dt><a href=\"math/log\"><code>Math.log(x)</code></a></dt> <dd>Returns the natural logarithm (log<sub>e</sub>, also ln) of a number.</dd> <dt><a href=\"math/log1p\"><code>Math.log1p(x)</code></a></dt> <dd>Returns the natural logarithm (log<sub>e</sub>, also ln) of <code>1 + x</code> for a number x.</dd> <dt><a href=\"math/log10\"><code>Math.log10(x)</code></a></dt> <dd>Returns the base 10 logarithm of a number.</dd> <dt><a href=\"math/log2\"><code>Math.log2(x)</code></a></dt> <dd>Returns the base 2 logarithm of a number.</dd> <dt><a href=\"math/max\"><code>Math.max([x[, y[, …]]])</code></a></dt> <dd>Returns the largest of zero or more numbers.</dd> <dt><a href=\"math/min\"><code>Math.min([x[, y[, …]]])</code></a></dt> <dd>Returns the smallest of zero or more numbers.</dd> <dt><a href=\"math/pow\"><code>Math.pow(x, y)</code></a></dt> <dd>Returns base to the exponent power, that is, <code>base<sup>exponent</sup></code>.</dd> <dt><a href=\"math/random\"><code>Math.random()</code></a></dt> <dd>Returns a pseudo-random number between 0 and 1.</dd> <dt><a href=\"math/round\"><code>Math.round(x)</code></a></dt> <dd>Returns the value of a number rounded to the nearest integer.</dd> <dt><a href=\"math/sign\"><code>Math.sign(x)</code></a></dt> <dd>Returns the sign of the x, indicating whether x is positive, negative or zero.</dd> <dt><a href=\"math/sin\"><code>Math.sin(x)</code></a></dt> <dd>Returns the sine of a number.</dd> <dt><a href=\"math/sinh\"><code>Math.sinh(x)</code></a></dt> <dd>Returns the hyperbolic sine of a number.</dd> <dt><a href=\"math/sqrt\"><code>Math.sqrt(x)</code></a></dt> <dd>Returns the positive square root of a number.</dd> <dt><a href=\"math/tan\"><code>Math.tan(x)</code></a></dt> <dd>Returns the tangent of a number.</dd> <dt><a href=\"math/tanh\"><code>Math.tanh(x)</code></a></dt> <dd>Returns the hyperbolic tangent of a number.</dd> <dt>\n<code>Math.toSource()</code> \n</dt> <dd>Returns the string <code>\"Math\"</code>.</dd> <dt><a href=\"math/trunc\"><code>Math.trunc(x)</code></a></dt> <dd>Returns the integer part of the number x, removing any fractional digits.</dd> </dl> <h2 id=\"Extending_the_Math_object\">Extending the <code>Math</code> object</h2> <p>As with most of the built-in objects in JavaScript, the <code>Math</code> object can be extended with custom properties and methods. To extend the <code>Math</code> object, you do not use <code>prototype</code>. Instead, you directly extend <code>Math</code>:</p> <pre>Math.propName = propValue;\nMath.methodName = methodRef;</pre> <p>For instance, the following example adds a method to the <code>Math</code> object for calculating the <em>greatest common divisor</em> of a list of arguments.</p> <pre data-language=\"js\">/* Variadic function -- Returns the greatest common divisor of a list of arguments */\nMath.gcd = function() {\n    if (arguments.length == 2) {\n        if (arguments[1] == 0)\n            return arguments[0];\n        else\n            return Math.gcd(arguments[1], arguments[0] % arguments[1]);\n    } else if (arguments.length &gt; 2) {\n        var result = Math.gcd(arguments[0], arguments[1]);\n        for (var i = 2; i &lt; arguments.length; i++)\n            result = Math.gcd(result, arguments[i]);\n        return result;\n    }\n};</pre> <p>Try it:</p> <pre data-language=\"js\">console.log(Math.gcd(20, 30, 15, 70, 40)); // `5`</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/publications/files/ECMA-ST-ARCH/ECMA-262,%201st%20edition,%20June%201997.pdf\" hreflang=\"en\">ECMAScript 1st Edition (ECMA-262)</a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition. Implemented in JavaScript 1.1.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/5.1/#sec-15.8\" hreflang=\"en\">ECMAScript 5.1 (ECMA-262)<br><small>The definition of 'Math' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-math-object\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Math' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>New methods <a href=\"math/log10\"><code>log10()</code></a>, <a href=\"math/log2\"><code>log2()</code></a>, <a href=\"math/log1p\"><code>log1p()</code></a>, <a href=\"math/expm1\"><code>expm1()</code></a>, <a href=\"math/cosh\"><code>cosh()</code></a>, <a href=\"math/sinh\"><code>sinh()</code></a>, <a href=\"math/tanh\"><code>tanh()</code></a>, <a href=\"math/acosh\"><code>acosh()</code></a>, <a href=\"math/asinh\"><code>asinh()</code></a>, <a href=\"math/atanh\"><code>atanh()</code></a>, <a href=\"math/hypot\"><code>hypot()</code></a>, <a href=\"math/trunc\"><code>trunc()</code></a>, <a href=\"math/sign\"><code>sign()</code></a>, <a href=\"math/imul\"><code>imul()</code></a>, <a href=\"math/fround\"><code>fround()</code></a>, <a href=\"math/cbrt\"><code>cbrt()</code></a> and <a href=\"math/clz32\"><code>clz32()</code></a> added.</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-math-object\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Math' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Math/E\"><code>E</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Math/LN2\"><code>LN2</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Math/LN10\"><code>LN10</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Math/LOG2E\"><code>LOG2E</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Math/LOG10E\"><code>LOG10E</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Math/PI\"><code>PI</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Math/SQRT1_2\"><code>SQRT1_2</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Math/SQRT2\"><code>SQRT2</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Math/abs\"><code>abs</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Math/acos\"><code>acos</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Math/acosh\"><code>acosh</code></a></th>\n<td class=\"bc-supports-yes\"> 38</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 25</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 25</td>\n<td class=\"bc-supports-yes\"> 8</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Math/asin\"><code>asin</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Math/asinh\"><code>asinh</code></a></th>\n<td class=\"bc-supports-yes\"> 38</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 25</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 25</td>\n<td class=\"bc-supports-yes\"> 8</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Math/atan\"><code>atan</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Math/atan2\"><code>atan2</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Math/atanh\"><code>atanh</code></a></th>\n<td class=\"bc-supports-yes\"> 38</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 25</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 25</td>\n<td class=\"bc-supports-yes\"> 8</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Math/cbrt\"><code>cbrt</code></a></th>\n<td class=\"bc-supports-yes\"> 38</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 25</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 25</td>\n<td class=\"bc-supports-yes\"> 8</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Math/ceil\"><code>ceil</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Math/clz32\"><code>clz32</code></a></th>\n<td class=\"bc-supports-yes\"> 38</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 31</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 25</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Math/cos\"><code>cos</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Math/cosh\"><code>cosh</code></a></th>\n<td class=\"bc-supports-yes\"> 38</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 25</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 25</td>\n<td class=\"bc-supports-yes\"> 8</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Math/exp\"><code>exp</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Math/expm1\"><code>expm1</code></a></th>\n<td class=\"bc-supports-yes\"> 38</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 25</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 25</td>\n<td class=\"bc-supports-yes\"> 8</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Math/floor\"><code>floor</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Math/fround\"><code>fround</code></a></th>\n<td class=\"bc-supports-yes\"> 38</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 26</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 25</td>\n<td class=\"bc-supports-yes\"> 8</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Math/hypot\"><code>hypot</code></a></th>\n<td class=\"bc-supports-yes\"> 38</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 27</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 25</td>\n<td class=\"bc-supports-yes\"> 8</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Math/imul\"><code>imul</code></a></th>\n<td class=\"bc-supports-yes\"> 28</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 20</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 16</td>\n<td class=\"bc-supports-yes\"> 7</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Math/log\"><code>log</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Math/log1p\"><code>log1p</code></a></th>\n<td class=\"bc-supports-yes\"> 38</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 25</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 25</td>\n<td class=\"bc-supports-yes\"> 8</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Math/log2\"><code>log2</code></a></th>\n<td class=\"bc-supports-yes\"> 38</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 25</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 25</td>\n<td class=\"bc-supports-yes\"> 8</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Math/log10\"><code>log10</code></a></th>\n<td class=\"bc-supports-yes\"> 38</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 25</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 25</td>\n<td class=\"bc-supports-yes\"> 8</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Math/max\"><code>max</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Math/min\"><code>min</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Math/pow\"><code>pow</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Math/random\"><code>random</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Math/round\"><code>round</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Math/sign\"><code>sign</code></a></th>\n<td class=\"bc-supports-yes\"> 38</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 25</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 25</td>\n<td class=\"bc-supports-yes\"> 9</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Math/sin\"><code>sin</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Math/sinh\"><code>sinh</code></a></th>\n<td class=\"bc-supports-yes\"> 38</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 25</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 25</td>\n<td class=\"bc-supports-yes\"> 8</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Math/sqrt\"><code>sqrt</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Math/tan\"><code>tan</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Math/tanh\"><code>tanh</code></a></th>\n<td class=\"bc-supports-yes\"> 38</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 25</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 25</td>\n<td class=\"bc-supports-yes\"> 8</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Math/trunc\"><code>trunc</code></a></th>\n<td class=\"bc-supports-yes\"> 38</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 25</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 25</td>\n<td class=\"bc-supports-yes\"> 8</td>\n</tr>\n</tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Math/E\"><code>E</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Math/LN2\"><code>LN2</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Math/LN10\"><code>LN10</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Math/LOG2E\"><code>LOG2E</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Math/LOG10E\"><code>LOG10E</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Math/PI\"><code>PI</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Math/SQRT1_2\"><code>SQRT1_2</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Math/SQRT2\"><code>SQRT2</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Math/abs\"><code>abs</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Math/acos\"><code>acos</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Math/acosh\"><code>acosh</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 25</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 8</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Math/asin\"><code>asin</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Math/asinh\"><code>asinh</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 25</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 8</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Math/atan\"><code>atan</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Math/atan2\"><code>atan2</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Math/atanh\"><code>atanh</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 25</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 8</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Math/cbrt\"><code>cbrt</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 25</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 8</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Math/ceil\"><code>ceil</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Math/clz32\"><code>clz32</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 31</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Math/cos\"><code>cos</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Math/cosh\"><code>cosh</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 25</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 8</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Math/exp\"><code>exp</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Math/expm1\"><code>expm1</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 25</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 8</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Math/floor\"><code>floor</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Math/fround\"><code>fround</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 26</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 8</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Math/hypot\"><code>hypot</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 27</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 8</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Math/imul\"><code>imul</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 20</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 7</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Math/log\"><code>log</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Math/log1p\"><code>log1p</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 25</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 8</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Math/log2\"><code>log2</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 25</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 8</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Math/log10\"><code>log10</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 25</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 8</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Math/max\"><code>max</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Math/min\"><code>min</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Math/pow\"><code>pow</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Math/random\"><code>random</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Math/round\"><code>round</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Math/sign\"><code>sign</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 25</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Math/sin\"><code>sin</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Math/sinh\"><code>sinh</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 25</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 8</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Math/sqrt\"><code>sqrt</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Math/tan\"><code>tan</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Math/tanh\"><code>tanh</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 25</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 8</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Math/trunc\"><code>trunc</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 25</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 8</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n</tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Math/E\"><code>E</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Math/LN2\"><code>LN2</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Math/LN10\"><code>LN10</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Math/LOG2E\"><code>LOG2E</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Math/LOG10E\"><code>LOG10E</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Math/PI\"><code>PI</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Math/SQRT1_2\"><code>SQRT1_2</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Math/SQRT2\"><code>SQRT2</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Math/abs\"><code>abs</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Math/acos\"><code>acos</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Math/acosh\"><code>acosh</code></a></th>\n<td class=\"bc-supports-yes\"> 0.12</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Math/asin\"><code>asin</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Math/asinh\"><code>asinh</code></a></th>\n<td class=\"bc-supports-yes\"> 0.12</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Math/atan\"><code>atan</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Math/atan2\"><code>atan2</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Math/atanh\"><code>atanh</code></a></th>\n<td class=\"bc-supports-yes\"> 0.12</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Math/cbrt\"><code>cbrt</code></a></th>\n<td class=\"bc-supports-yes\"> 0.12</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Math/ceil\"><code>ceil</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Math/clz32\"><code>clz32</code></a></th>\n<td class=\"bc-supports-yes\"> 0.12</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Math/cos\"><code>cos</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Math/cosh\"><code>cosh</code></a></th>\n<td class=\"bc-supports-yes\"> 0.12</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Math/exp\"><code>exp</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Math/expm1\"><code>expm1</code></a></th>\n<td class=\"bc-supports-yes\"> 0.12</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Math/floor\"><code>floor</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Math/fround\"><code>fround</code></a></th>\n<td class=\"bc-supports-yes\"> 0.12</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Math/hypot\"><code>hypot</code></a></th>\n<td class=\"bc-supports-yes\"> 0.12</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Math/imul\"><code>imul</code></a></th>\n<td class=\"bc-supports-yes\"> 0.12</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Math/log\"><code>log</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Math/log1p\"><code>log1p</code></a></th>\n<td class=\"bc-supports-yes\"> 0.12</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Math/log2\"><code>log2</code></a></th>\n<td class=\"bc-supports-yes\"> 0.12</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Math/log10\"><code>log10</code></a></th>\n<td class=\"bc-supports-yes\"> 0.12</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Math/max\"><code>max</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Math/min\"><code>min</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Math/pow\"><code>pow</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Math/random\"><code>random</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Math/round\"><code>round</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Math/sign\"><code>sign</code></a></th>\n<td class=\"bc-supports-yes\"> 0.12</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Math/sin\"><code>sin</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Math/sinh\"><code>sinh</code></a></th>\n<td class=\"bc-supports-yes\"> 0.12</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Math/sqrt\"><code>sqrt</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Math/tan\"><code>tan</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Math/tanh\"><code>tanh</code></a></th>\n<td class=\"bc-supports-yes\"> 0.12</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Math/trunc\"><code>trunc</code></a></th>\n<td class=\"bc-supports-yes\"> 0.12</td>\n</tr>\n</tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"number\"><code>Number</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math</a>\n  </p>\n</div>\n","global_objects/isfinite":"<h1>isFinite</h1> <p>The global <code><strong>isFinite()</strong></code> function determines whether the passed value is a finite number. If needed, the parameter is first converted to a number.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/globalprops-isfinite.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\">isFinite(<em>testValue</em>)</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><code>testValue</code></dt> <dd>The value to be tested for finiteness.</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p><code>false</code> if the argument is positive or negative <a href=\"infinity\"><code>Infinity</code></a> or <a href=\"nan\"><code>NaN</code></a>; otherwise, <code>true</code>.</p> <h2 id=\"Description\">Description</h2> <p><code>isFinite</code> is a top-level function and is not associated with any object.</p> <p>You can use this function to determine whether a number is a finite number. The <code>isFinite</code> function examines the number in its argument. If the argument is <code>NaN</code>, positive infinity, or negative infinity, this method returns <code>false</code>; otherwise, it returns <code>true</code>.</p> <h2 id=\"Examples\">Examples</h2> <pre data-language=\"js\">isFinite(Infinity);  // false\nisFinite(NaN);       // false\nisFinite(-Infinity); // false\n\nisFinite(0);         // true\nisFinite(2e64);      // true\nisFinite(910);       // true\n\nisFinite(null);      // true, would've been false with the \n                     // more robust Number.isFinite(null)\n\nisFinite('0');       // true, would've been false with the \n                     // more robust Number.isFinite(\"0\")\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/publications/files/ECMA-ST-ARCH/ECMA-262,%203rd%20edition,%20December%201999.pdf\" hreflang=\"en\">ECMAScript 3rd Edition (ECMA-262)</a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/5.1/#sec-15.1.2.5\" hreflang=\"en\">ECMAScript 5.1 (ECMA-262)<br><small>The definition of 'isFinite' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-isfinite-number\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'isFinite' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-isfinite-number\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'isFinite' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"number/isfinite\"><code>Number.isFinite()</code></a></li> <li><a href=\"number/nan\"><code>Number.NaN</code></a></li> <li><a href=\"number/positive_infinity\"><code>Number.POSITIVE_INFINITY</code></a></li> <li><a href=\"number/negative_infinity\"><code>Number.NEGATIVE_INFINITY</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/isFinite$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/isFinite\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/isFinite</a>\n  </p>\n</div>\n","global_objects/undefined":"<h1>undefined</h1> <p>The global <code><strong>undefined</strong></code> property represents the primitive value <code><a href=\"https://developer.mozilla.org/en-US/docs/Glossary/Undefined\">undefined</a></code>. It is one of JavaScript's <a href=\"https://developer.mozilla.org/en-US/docs/Glossary/Primitive\">primitive types</a>.</p> <div class=\"_table\"><table class=\"standard-table\"> <thead> <tr> <th colspan=\"2\" class=\"header\">Property attributes of <code>undefined</code>\n</th> </tr> </thead> <tbody> <tr> <td>Writable</td> <td>no</td> </tr> <tr> <td>Enumerable</td> <td>no</td> </tr> <tr> <td>Configurable</td> <td>no</td> </tr> </tbody> </table></div> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/globalprops-undefined.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\">undefined</pre> <h2 id=\"Description\">Description</h2> <p><code>undefined</code> is a property of the <em>global object</em>; i.e., it is a variable in global scope. The initial value of <code>undefined</code> is the primitive value <code><a href=\"https://developer.mozilla.org/en-US/docs/Glossary/Undefined\">undefined</a></code>.</p> <p>In modern browsers (JavaScript 1.8.5 / Firefox 4+), <code>undefined</code> is a non-configurable, non-writable property per the ECMAScript 5 specification. Even when this is not the case, avoid overriding it.</p> <p>A variable that has not been assigned a value is of type undefined. A method or statement also returns <code>undefined</code> if the variable that is being evaluated does not have an assigned value. A function returns <code>undefined</code> if a value was not <a href=\"../statements/return\"><code>returned</code></a>.</p> <div class=\"warning\"> <p>While it is possible to use it as an <a href=\"https://developer.mozilla.org/en-US/docs/Glossary/Identifier\">identifier</a> (variable name) in any scope other than the global scope (because <code>undefined</code> is not a <a href=\"../lexical_grammar\"><code>reserved word</code></a>), doing so is a very bad idea that will make your code difficult to maintain and debug.</p> <pre data-language=\"js\">//DON'T DO THIS\n\n// logs \"foo string\"\n(function() { var undefined = 'foo'; console.log(undefined, typeof undefined); })();\n\n// logs \"foo string\"\n(function(undefined) { console.log(undefined, typeof undefined); })('foo');\n</pre> </div> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Strict_equality_and_undefined\">Strict equality and <code>undefined</code>\n</h3> <p>You can use <code>undefined</code> and the strict equality and inequality operators to determine whether a variable has a value. In the following code, the variable <code>x</code> is not defined, and the <code>if</code> statement evaluates to true.</p> <pre data-language=\"js\">var x;\nif (x === undefined) {\n   // these statements execute\n}\nelse {\n   // these statements do not execute\n}\n</pre> <div class=\"note\"> <p>Note: The strict equality operator rather than the standard equality operator must be used here, because <code>x == undefined</code> also checks whether <code>x</code> is <code>null</code>, while strict equality doesn't. <code>null</code> is not equivalent to <code>undefined</code>. See <a href=\"../operators/comparison_operators\"><code>comparison operators</code></a> for details.</p> </div> <h3 id=\"Typeof_operator_and_undefined\">\n<code>Typeof</code> operator and <code>undefined</code>\n</h3> <p>Alternatively, <a href=\"../operators/typeof\"><code>typeof</code></a> can be used:</p> <pre data-language=\"js\">var x;\nif (typeof x === 'undefined') {\n   // these statements execute\n}\n</pre> <p>One reason to use <a href=\"../operators/typeof\"><code>typeof</code></a> is that it does not throw an error if the variable has not been declared.</p> <pre data-language=\"js\">// x has not been declared before\nif (typeof x === 'undefined') { // evaluates to true without errors\n   // these statements execute\n}\n\nif (x === undefined) { // throws a ReferenceError\n\n}\n</pre> <p>However, this kind of technique should be avoided. JavaScript is a statically scoped language, so knowing if a variable is declared can be read by seeing whether it is declared in an enclosing context. The only exception is the global scope, but the global scope is bound to the global object, so checking the existence of a variable in the global context can be done by checking the existence of a property on the <em>global object</em> (using the <a href=\"../operators/in\"><code>in</code></a> operator, for instance).</p> <h3 id=\"Void_operator_and_undefined\">\n<code>Void</code> operator and <code>undefined</code>\n</h3> <p>The <a href=\"../operators/void\"><code>void</code></a> operator is a third alternative.</p> <pre data-language=\"js\">var x;\nif (x === void 0) {\n   // these statements execute\n}\n\n// y has not been declared before\nif (y === void 0) {\n   // throws a - Uncaught ReferenceError: y is not defined\n}\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/publications/files/ECMA-ST-ARCH/ECMA-262,%201st%20edition,%20June%201997.pdf#sec-4.3.9\" hreflang=\"en\">ECMAScript 1st Edition (ECMA-262)<br><small>The definition of 'undefined' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition. Implemented in JavaScript 1.3.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/5.1/#sec-15.1.1.3\" hreflang=\"en\">ECMAScript 5.1 (ECMA-262)<br><small>The definition of 'undefined' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-undefined\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'undefined' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-undefined\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'undefined' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/undefined$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/undefined\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/undefined</a>\n  </p>\n</div>\n","global_objects/parseint":"<h1>parseInt</h1> <p>The <code><strong>parseInt()</strong></code> function parses a string argument and returns an integer of the specified radix (the base in mathematical numeral systems).</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/globalprops-parseint.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\">parseInt(<em>string</em>, <em>radix</em>);</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><code>string</code></dt> <dd>The value to parse. If the <code>string</code> argument is not a string, then it is converted to a string (using the <code><a href=\"http://www.ecma-international.org/ecma-262/6.0/#sec-tostring\">ToString</a></code> abstract operation). Leading whitespace in the string argument is ignored.</dd> <dt><code>radix</code></dt> <dd>An integer between 2 and 36 that represents the <var>radix</var> (the base in mathematical numeral systems) of the above mentioned string. </dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p>An integer number parsed from the given string. If the first character cannot be converted to a number, <a href=\"nan\"><code>NaN</code></a> is returned.</p> <h2 id=\"Description\">Description</h2> <p>The <code>parseInt</code> function converts its first argument to a string, parses it, and returns an integer or <code>NaN</code>. If not <code>NaN</code>, the returned value will be the integer that is the first argument taken as a number in the specified <var>radix</var> (base). For example, a <var>radix</var> of 10 indicates to convert from a decimal number, 8 octal, 16 hexadecimal, and so on. For radices above <code>10</code>, the letters of the alphabet indicate numerals greater than <code>9</code>. For example, for hexadecimal numbers (base 16), <code>A</code> through <code>F</code> are used.</p> <p>If <code>parseInt</code> encounters a character that is not a numeral in the specified radix, it ignores it and all succeeding characters and returns the integer value parsed up to that point. <code>parseInt</code> truncates numbers to integer values. Leading and trailing spaces are allowed.</p> <p>Because some numbers include the <code>e</code> character in their string representation (e.g. <code>6.022e23</code>), using <code>parseInt</code> to truncate numeric values will produce unexpected results when used on very large or very small numbers. <code>parseInt</code> should not be used as a substitute for <a href=\"math/floor\"><code>Math.floor()</code></a>.</p> <p>If <var>radix</var> is <code>undefined</code> or 0 (or absent), JavaScript assumes the following:</p> <ul> <li>If the input <code>string</code> begins with \"0x\" or \"0X\", <var>radix</var> is 16 (hexadecimal) and the remainder of the string is parsed.</li> <li>If the input <code>string</code> begins with \"0\", <var>radix</var> is eight (octal) or 10 (decimal). Exactly which radix is chosen is implementation-dependent. ECMAScript 5 specifies that 10 (decimal) is used, but not all browsers support this yet. For this reason <code>parseInt</code>.</li> <li>If the input <code>string</code> begins with any other value, the radix is 10 (decimal).</li> </ul> <p>If the first character cannot be converted to a number, <code>parseInt</code> returns <code>NaN</code>.</p> <p>For arithmetic purposes, the <code>NaN</code> value is not a number in any radix. You can call the <a href=\"isnan\"><code>isNaN</code></a> function to determine if the result of <code>parseInt</code> is <code>NaN</code>. If <code>NaN</code> is passed on to arithmetic operations, the operation results will also be <code>NaN</code>.</p> <p>To convert number to its string literal in a particular radix use <code>intValue.toString(radix)</code>.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Using_parseInt\">Using parseInt</h3> <p>The following examples all return <code>15</code>:</p> <pre data-language=\"js\">parseInt('0xF', 16);\nparseInt('F', 16);\nparseInt('17', 8);\nparseInt(021, 8);\nparseInt('015', 10);   // parseInt(015, 10); will return 15\nparseInt(15.99, 10);\nparseInt('15,123', 10);\nparseInt('FXX123', 16);\nparseInt('1111', 2);\nparseInt('15 * 3', 10);\nparseInt('15e2', 10);\nparseInt('15px', 10);\nparseInt('12', 13);\n</pre> <p>The following examples all return <code>NaN</code>:</p> <pre data-language=\"js\">parseInt('Hello', 8); // Not a number at all\nparseInt('546', 2);   // Digits are not valid for binary representations\n</pre> <p>The following examples all return <code>-15</code>:</p> <pre data-language=\"js\">parseInt('-F', 16);\nparseInt('-0F', 16);\nparseInt('-0XF', 16);\nparseInt(-15.1, 10);\nparseInt('-17', 8);\nparseInt('-15', 10);\nparseInt('-1111', 2);\nparseInt('-15e1', 10);\nparseInt('-12', 13);\n</pre> <p>The following examples all return <code>4</code>:</p> <pre data-language=\"js\">parseInt(4.7, 10);\nparseInt(4.7 * 1e22, 10); // Very large number becomes 4\nparseInt(0.00000000000434, 10); // Very small number becomes 4\n</pre> <p>The following example returns <code>224</code>:</p> <pre data-language=\"js\">parseInt('0e0', 16);\n</pre> <h2 id=\"Octal_interpretations_with_no_radix\">Octal interpretations with no radix</h2> <p>Although discouraged by ECMAScript 3 and forbidden by ECMAScript 5, many implementations interpret a numeric string beginning with a leading <code>0</code> as octal. The following may have an octal result, or it may have a decimal result. <strong>Always specify a radix to avoid this unreliable behavior.</strong></p> <pre data-language=\"js\">parseInt('0e0'); // 0\nparseInt('08'); // 0, '8' is not an octal digit.\n</pre> <h3 id=\"ECMAScript_5_removes_octal_interpretation\">ECMAScript 5 removes octal interpretation</h3> <p>The ECMAScript 5 specification of the function <code>parseInt</code> no longer allows implementations to treat Strings beginning with a <code>0</code> character as octal values. ECMAScript 5 states:</p> <p>The <code>parseInt</code> function produces an integer value dictated by interpretation of the contents of the string argument according to the specified radix. Leading white space in string is ignored. If radix is undefined or <code>0</code>, it is assumed to be <code>10</code> except when the number begins with the character pairs <code>0x</code> or <code>0X</code>, in which case a radix of 16 is assumed.</p> <p>This differs from ECMAScript 3, which discouraged but allowed octal interpretation.</p> <p>Many implementations have not adopted this behavior as of 2013, and because older browsers must be supported, <strong>always specify a radix</strong>.</p> <h2 id=\"A_stricter_parse_function\">A stricter parse function</h2> <p>It is sometimes useful to have a stricter way to parse int values. Regular expressions can help:</p> <pre data-language=\"js\">var filterInt = function(value) {\n  if (/^(\\-|\\+)?([0-9]+|Infinity)$/.test(value))\n    return Number(value);\n  return NaN;\n}\n\nconsole.log(filterInt('421'));               // 421\nconsole.log(filterInt('-421'));              // -421\nconsole.log(filterInt('+421'));              // 421\nconsole.log(filterInt('Infinity'));          // Infinity\nconsole.log(filterInt('421e+0'));            // NaN\nconsole.log(filterInt('421hop'));            // NaN\nconsole.log(filterInt('hop1.61803398875'));  // NaN\nconsole.log(filterInt('1.61803398875'));     // NaN\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/publications/files/ECMA-ST-ARCH/ECMA-262,%201st%20edition,%20June%201997.pdf\" hreflang=\"en\">ECMAScript 1st Edition (ECMA-262)</a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/5.1/#sec-15.1.2.2\" hreflang=\"en\">ECMAScript 5.1 (ECMA-262)<br><small>The definition of 'parseInt' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-parseint-string-radix\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'parseInt' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-parseint-string-radix\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'parseInt' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">Parses leading-zero strings are decimal, not octal</th>\n<td class=\"bc-supports-yes\"> 23</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 21</td>\n<td class=\"bc-supports-yes\"> 9</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 6</td>\n</tr>\n</tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">Parses leading-zero strings are decimal, not octal</th>\n<td class=\"bc-supports-yes\"> 4.4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 21</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 6</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n</tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">Parses leading-zero strings are decimal, not octal</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n</tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"parsefloat\"><code>parseFloat()</code></a></li> <li><a href=\"number/parsefloat\"><code>Number.parseFloat()</code></a></li> <li><a href=\"number/parseint\"><code>Number.parseInt()</code></a></li> <li><a href=\"isnan\"><code>isNaN()</code></a></li> <li><a href=\"number/tostring\"><code>Number.toString()</code></a></li> <li><a href=\"object/valueof\"><code>Object.valueOf</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/parseInt$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/parseInt\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/parseInt</a>\n  </p>\n</div>\n","operators/conditional_operator":"<h1>Conditional Operator</h1> <p>The <strong>conditional (ternary) operator</strong> is the only JavaScript operator that takes three operands. This operator is frequently used as a shortcut for the <a href=\"../statements/if...else\"><code>if</code></a> statement.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/expressions-conditionaloperators.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\"><em>condition</em> ? <em>exprT</em> : <em>exprF</em> </pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><code>condition</code></dt> <dd>An expression whose value is used as a condition.</dd> </dl> <dl> <dt>\n<code>exprT</code>, <code>exprF</code>\n</dt> <dd>Expressions with values of any type.</dd> </dl> <h2 id=\"Description\">Description</h2> <p>If <code>condition</code> can be converted to <code>true</code> (it is <a href=\"https://developer.mozilla.org/en-US/docs/Glossary/truthy\">truthy</a>), the operator returns the value of <code>exprT</code>; otherwise (when <code>condition</code> is <a href=\"https://developer.mozilla.org/en-US/docs/Glossary/falsy\">falsy</a>) it returns the value of <code>exprF</code>.</p> <p>(In either case, the other alternative expression is left unevaluated.)</p> <p>Besides <code>false</code>, possible falsy expressions are: <code>null</code>, <code><code>NaN</code></code>, <code><code><code>0</code></code></code>, the empty string (<code><code><code><code>\"\"</code></code></code></code>), and <code><code><code><code>undefined</code></code></code></code>. If <code>condition</code> is any of these, the result of the conditional expression will be <code>exprF</code>.</p> <p>A simple example:</p> <pre data-language=\"js\">var age = 26;\nvar beverage = (age &gt;= 21) ? \"Beer\" : \"Juice\";\nconsole.log(beverage); // \"Beer\"\n</pre> <p>One common usage is to handle a value that may be <code>null</code>:</p> <pre data-language=\"js\">function greeting(person) {\n    var name = person ? person.name : \"stranger\";\n    return \"Howdy, \" + name;\n}\n\nconsole.log(greeting({name: 'Alice'}));  // \"Howdy, Alice\"\nconsole.log(greeting(null));             // \"Howdy, stranger\"​​​​​\n</pre> <h3 id=\"Conditional_chains\">Conditional chains</h3> <p>The ternary operator is right-associative, which means it can be \"chained\" in the following way, similar to an <code>if … else if … else if … else</code> chain:</p> <pre data-language=\"js\">function example(…) {\n    return condition1 ? value1\n         : condition2 ? value2\n         : condition3 ? value3\n         : value4;\n}\n\n// Equivalent to:\n\nfunction example(…) {\n    if (condition1) { return value1; }\n    else if (condition2) { return value2; }\n    else if (condition3) { return value3; }\n    else { return value4; }\n}\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-conditional-operator\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Conditional Operator' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-conditional-operator\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Conditional Operator' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/5.1/#sec-11.12\" hreflang=\"en\">ECMAScript 5.1 (ECMA-262)<br><small>The definition of 'The conditional operator' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/publications/files/ECMA-ST-ARCH/ECMA-262,%201st%20edition,%20June%201997.pdf#sec-11.12\" hreflang=\"en\">ECMAScript 1st Edition (ECMA-262)<br><small>The definition of 'The conditional operator' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition. Implemented in JavaScript 1.0.</td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"../statements/if...else\">if statement</a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Conditional_Operator$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Conditional_Operator\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Conditional_Operator</a>\n  </p>\n</div>\n","operators/grouping":"<h1>Grouping</h1> <p>The grouping operator <code>( )</code> controls the precedence of evaluation in expressions.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/expressions-groupingoperator.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\"> ( )</pre> <h2 id=\"Description\">Description</h2> <p>The grouping operator consists of a pair of parentheses around an expression or sub-expression to override the normal <a href=\"operator_precedence\">operator precedence</a> so that expressions with lower precedence can be evaluated before an expression with higher priority. As it sounds it groups what's inside of the parentheses.</p> <h2 id=\"Examples\">Examples</h2> <p>Overriding multiplication and division first, then addition and subtraction to evaluate addition first.</p> <pre data-language=\"js\">var a = 1;\nvar b = 2;\nvar c = 3;\n\n// default precedence\na + b * c     // 7\n// evaluated by default like this\na + (b * c)   // 7\n\n// now overriding precedence \n// addition before multiplication   \n(a + b) * c   // 9\n\n// which is equivalent to\na * c + b * c // 9\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-grouping-operator\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'The Grouping Operator' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-grouping-operator\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'The Grouping Operator' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/5.1/#sec-11.1.6\" hreflang=\"en\">ECMAScript 5.1 (ECMA-262)<br><small>The definition of 'The Grouping Operator' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/publications/files/ECMA-ST-ARCH/ECMA-262,%201st%20edition,%20June%201997.pdf#sec-11.1.4\" hreflang=\"en\">ECMAScript 1st Edition (ECMA-262)<br><small>The definition of 'The Grouping Operator' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition. Implemented in JavaScript 1.0.</td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"operator_precedence\">Operator precedence</a></li> <li><a href=\"delete\"><code>delete</code></a></li> <li><a href=\"typeof\"><code>typeof</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Grouping$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Grouping\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Grouping</a>\n  </p>\n</div>\n","operators/array_comprehensions":"<h1>Array comprehensions</h1><div class=\"warning\">\n<strong>Non-standard. Do not use!</strong><br> The array comprehensions syntax is non-standard and removed starting with Firefox 58. For future-facing usages, consider using <a href=\"../global_objects/array/map\"><code>Array.prototype.map</code></a>, <a href=\"../global_objects/array/filter\"><code>Array.prototype.filter</code></a>, <a href=\"../functions/arrow_functions\">arrow functions</a>, and <a href=\"spread_syntax\">spread syntax</a>.</div> <div class=\"blockIndicator obsolete obsoleteHeader\"><p><strong> Obsolete since Gecko 58 (Firefox 58 / Thunderbird 58 / SeaMonkey 2.55)</strong><br>This feature is obsolete. Although it may still work in some browsers, its use is discouraged since it could be removed at any time. Try to avoid using it.</p></div>  <p>The <strong>array comprehension</strong> syntax was a JavaScript expression which allowed you to quickly assemble a new array based on an existing one. However, it has been removed from the standard and the Firefox implementation. Do not use it!</p> <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\">[for (x of iterable) x]\n[for (x of iterable) if (condition) x]\n[for (x of iterable) for (y of iterable) x + y]\n</pre> <h2 id=\"Description\">Description</h2> <p>Inside array comprehensions, these two kinds of components are allowed:</p> <ul> <li>\n<a href=\"../statements/for...of\"><code>for...of</code></a> and</li> <li><a href=\"../statements/if...else\"><code>if</code></a></li> </ul> <p>The for-of iteration is always the first component. Multiple for-of iterations or if statements are allowed.</p> <p>Array comprehension was previously proposed to be standardized in ECMAScript 2016, it provide a useful shortcut for constructing a new array based on the contents of another. Comprehensions can often be used in place of calls to <a href=\"../global_objects/array/map\"><code>map()</code></a> and <a href=\"../global_objects/array/filter\"><code>filter()</code></a>, or as a way of combining the two.</p> <p>The following comprehension takes an array of numbers and creates a new array of the double of each of those numbers.</p> <pre data-language=\"js\">var numbers = [1, 2, 3, 4];\nvar doubled = [for (i of numbers) i * 2];\nconsole.log(doubled); // logs 2,4,6,8\n</pre> <p>This is equivalent to the following <a href=\"../global_objects/array/map\"><code>map()</code></a> operation:</p> <pre data-language=\"js\">var doubled = numbers.map(i =&gt; i * 2);\n</pre> <p>Comprehensions can also be used to select items that match a particular expression. Here is a comprehension which selects only even numbers:</p> <pre data-language=\"js\">var numbers = [1, 2, 3, 21, 22, 30];\nvar evens = [for (i of numbers) if (i % 2 === 0) i];\nconsole.log(evens); // logs 2,22,30\n</pre> <p><a href=\"../global_objects/array/filter\"><code>filter()</code></a> can be used for the same purpose:</p> <pre data-language=\"js\">var evens = numbers.filter(i =&gt; i % 2 === 0);\n</pre> <p><a href=\"../global_objects/array/map\"><code>map()</code></a> and <a href=\"../global_objects/array/filter\"><code>filter()</code></a> style operations can be combined into a single array comprehension. Here is one that filters just the even numbers, then creates an array containing their doubles:</p> <pre data-language=\"js\">var numbers = [1, 2, 3, 21, 22, 30];\nvar doubledEvens = [for (i of numbers) if (i % 2 === 0) i * 2];\nconsole.log(doubledEvens); // logs 4,44,60\n</pre> <p>The square brackets of an array comprehension introduce an implicit block for scoping purposes. New variables (such as i in the example) are treated as if they had been declared using <a href=\"../statements/let\"><code>let</code></a>. This means that they will not be available outside of the comprehension.</p> <p>The input to an array comprehension does not itself need to be an array; <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Iterators_and_Generators\">iterators and generators</a> can also be used.</p> <p>Even strings may be used as input; to achieve the filter and map actions (under Array-like objects) above:</p> <pre data-language=\"js\">var str = 'abcdef';\nvar consonantsOnlyStr = [for (c of str) if (!(/[aeiouAEIOU]/).test(c)) c].join(''); // 'bcdf'\nvar interpolatedZeros = [for (c of str) c + '0' ].join(''); // 'a0b0c0d0e0f0'\n</pre> <p>Again, the input form is not preserved, so we have to use <a href=\"../global_objects/array/join\"><code>join()</code></a> to revert back to a string.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Simple_array_comprehensions\">Simple array comprehensions</h3> <pre data-language=\"js\">[for (i of [1, 2, 3]) i * i ]; \n// [1, 4, 9]\n\nvar abc = ['A', 'B', 'C'];\n[for (letters of abc) letters.toLowerCase()];\n// [\"a\", \"b\", \"c\"]</pre> <h3 id=\"Array_comprehensions_with_if_statement\">Array comprehensions with if statement</h3> <pre data-language=\"js\">var years = [1954, 1974, 1990, 2006, 2010, 2014];\n[for (year of years) if (year &gt; 2000) year];\n// [2006, 2010, 2014]\n[for (year of years) if (year &gt; 2000) if (year &lt; 2010) year];\n// [2006], the same as below:\n[for (year of years) if (year &gt; 2000 &amp;&amp; year &lt; 2010) year];\n// [2006] \n</pre> <h3 id=\"Array_comprehensions_compared_to_map_and_filter\">Array comprehensions compared to <code>map</code> and <code>filter</code>\n</h3> <p>An easy way to understand array comprehension syntax, is to compare it with the Array <a href=\"../global_objects/array/map\"><code>map</code></a> and <a href=\"../global_objects/array/filter\"><code>filter</code></a> methods:</p> <pre data-language=\"js\">var numbers = [1, 2, 3];\n\nnumbers.map(function (i) { return i * i });\nnumbers.map(i =&gt; i * i);\n[for (i of numbers) i * i];\n// all are [1, 4, 9]\n\nnumbers.filter(function (i) { return i &lt; 3 });\nnumbers.filter(i =&gt; i &lt; 3);\n[for (i of numbers) if (i &lt; 3) i];\n// all are [1, 2]\n</pre> <h3 id=\"Array_comprehensions_with_two_arrays\">Array comprehensions with two arrays</h3> <p>Using two for-of iterations to work with two arrays:</p> <pre data-language=\"js\">var numbers = [1, 2, 3];\nvar letters = ['a', 'b', 'c'];\n\nvar cross = [for (i of numbers) for (j of letters) i + j];\n// [\"1a\", \"1b\", \"1c\", \"2a\", \"2b\", \"2c\", \"3a\", \"3b\", \"3c\"]\n\nvar grid = [for (i of numbers) [for (j of letters) i + j]];\n// [\n//  [\"1a\", \"1b\", \"1c\"],\n//  [\"2a\", \"2b\", \"2c\"],\n//  [\"3a\", \"3b\", \"3c\"]\n// ]\n\n[for (i of numbers) if (i &gt; 1) for (j of letters) if(j &gt; 'a') i + j]\n// [\"2b\", \"2c\", \"3b\", \"3c\"], the same as below:\n\n[for (i of numbers) for (j of letters) if (i &gt; 1) if(j &gt; 'a') i + j]\n// [\"2b\", \"2c\", \"3b\", \"3c\"]\n\n[for (i of numbers) if (i &gt; 1) [for (j of letters) if(j &gt; 'a') i + j]]\n// [[\"2b\", \"2c\"], [\"3b\", \"3c\"]], not the same as below:\n\n[for (i of numbers) [for (j of letters) if (i &gt; 1) if(j &gt; 'a') i + j]]\n// [[], [\"2b\", \"2c\"], [\"3b\", \"3c\"]]\n</pre> <h2 id=\"Specifications\">Specifications</h2> <p>Was initially in the ECMAScript 2015 draft, but got removed in revision 27 (August 2014). Please see older revisions of ES2015 for specification semantics.</p> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support \n</th>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\">30 — 58</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support \n</th>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\">30 — 58</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support \n</th>\n<td class=\"bc-supports-no\"> No</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"Differences_to_the_older_JS1.7JS1.8_comprehensions\">Differences to the older JS1.7/JS1.8 comprehensions</h2> <div class=\"warning\">JS1.7/JS1.8 comprehensions are removed from Gecko starting with version 46 (<a href=\"https://bugzilla.mozilla.org/show_bug.cgi?id=1220564\">bug 1220564</a>).</div> <p><strong>Old comprehensions syntax (do not use anymore!):</strong></p> <pre data-language=\"js\">[X for (Y in Z)]\n[X for each (Y in Z)]\n[X for (Y of Z)]\n</pre> <p>Differences:</p> <ul> <li>ESNext comprehensions create one scope per \"for\" node instead of the comprehension as a whole. <ul> <li>Old: <code>[()=&gt;x for (x of [0, 1, 2])][1]() // 2</code>\n</li> <li>New: <code>[for (x of [0, 1, 2]) ()=&gt;x][1]() // 1, each iteration creates a fresh binding for x. </code>\n</li> </ul> </li> <li>ESNext comprehensions start with \"for\" instead of the assignment expression. <ul> <li>Old: <code>[i * 2 for (i of numbers)]</code>\n</li> <li>New: <code>[for (i of numbers) i * 2]</code>\n</li> </ul> </li> <li>ESNext comprehensions can have multiple <code>if</code> and <code>for</code> components.</li> <li>ESNext comprehensions only work with <code><a href=\"../statements/for...of\"><code>for...of</code></a></code> and not with <code><a href=\"../statements/for...in\"><code>for...in</code></a></code> iterations.</li> </ul> <p>See <a href=\"https://bugzilla.mozilla.org/show_bug.cgi?id=1220564#c42\">Bug 1220564, comment 42</a> for suggestions on updating code.</p> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"../statements/for...of\"><code>for...of</code></a></li> <li><a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Generator_comprehensions\">Generator comprehensions</a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Array_comprehensions$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Array_comprehensions\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Array_comprehensions</a>\n  </p>\n</div>\n","operators/arithmetic_operators":"<h1>Arithmetic Operators</h1> <p><strong>Arithmetic operators</strong> take numerical values (either literals or variables) as their operands and return a single numerical value. The standard arithmetic operators are addition (+), subtraction (-), multiplication (*), and division (/).</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/expressions-arithmetic.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Addition\">Addition (+)</h2> <p>The addition operator produces the sum of numeric operands or string concatenation.</p> <h3 id=\"Syntax\">Syntax</h3> <pre class=\"syntaxbox\"><strong>Operator:</strong> x + y\n</pre> <h3 id=\"Examples\">Examples</h3> <pre data-language=\"js\">// Number + Number -&gt; addition\n1 + 2 // 3\n\n// Boolean + Number -&gt; addition\ntrue + 1 // 2\n\n// Boolean + Boolean -&gt; addition\nfalse + false // 0\n\n// Number + String -&gt; concatenation\n5 + 'foo' // \"5foo\"\n\n// String + Boolean -&gt; concatenation\n'foo' + false // \"foofalse\"\n\n// String + String -&gt; concatenation\n'foo' + 'bar' // \"foobar\"\n</pre> <h2 id=\"Subtraction\">Subtraction (-)</h2> <p>The subtraction operator subtracts the two operands, producing their difference.</p> <h3 id=\"Syntax_2\">Syntax</h3> <pre class=\"syntaxbox\"><strong>Operator:</strong> x - y\n</pre> <h3 id=\"Examples_2\">Examples</h3> <pre data-language=\"js\">5 - 3 // 2\n3 - 5 // -2\n'foo' - 3 // NaN</pre> <h2 id=\"Division\">Division (/)</h2> <p>The division operator produces the quotient of its operands where the left operand is the dividend and the right operand is the divisor.</p> <h3 id=\"Syntax_3\">Syntax</h3> <pre class=\"syntaxbox\"><strong>Operator:</strong> x / y\n</pre> <h3 id=\"Examples_3\">Examples</h3> <pre data-language=\"js\">1 / 2      // returns 0.5 in JavaScript\n1 / 2      // returns 0 in Java \n// (neither number is explicitly a floating point number)\n\n1.0 / 2.0  // returns 0.5 in both JavaScript and Java\n\n2.0 / 0    // returns Infinity in JavaScript\n2.0 / 0.0  // returns Infinity too\n2.0 / -0.0 // returns -Infinity in JavaScript</pre> <h2 id=\"Multiplication\">Multiplication (*)</h2> <p>The multiplication operator produces the product of the operands.</p> <h3 id=\"Syntax_4\">Syntax</h3> <pre class=\"syntaxbox\"><strong>Operator:</strong> x * y\n</pre> <h3 id=\"Examples_4\">Examples</h3> <pre data-language=\"js\">2 * 2 // 4\n-2 * 2 // -4\nInfinity * 0 // NaN\nInfinity * Infinity // Infinity\n'foo' * 2 // NaN\n</pre> <h2 id=\"Remainder\">Remainder (%)</h2> <p>The remainder operator returns the remainder left over when one operand is divided by a second operand. It always takes the sign of the dividend.</p> <h3 id=\"Syntax_5\">Syntax</h3> <pre class=\"syntaxbox\"><strong>Operator:</strong> var1 % var2\n</pre> <h3 id=\"Examples_5\">Examples</h3> <pre data-language=\"js\">12 % 5 // 2\n-1 % 2 // -1\n1 % -2 // 1\nNaN % 2 // NaN\n1 % 2 // 1\n2 % 3 // 2\n-4 % 2 // -0\n5.5 % 2 // 1.5\n</pre> <h2 id=\"Exponentiation\">Exponentiation (**)</h2> <p>The exponentiation operator returns the result of raising first operand to the power second operand. that is, <code>var1</code><sup><code>var2</code></sup>, in the preceding statement, where <code>var1</code> and <code>var2</code> are variables. Exponentiation operator is right associative. <code>a ** b ** c</code> is equal to <code>a ** (b ** c)</code>.</p> <h3 id=\"Syntax_6\">Syntax</h3> <pre class=\"syntaxbox\"><strong>Operator:</strong> var1 ** var2\n</pre> <h3 id=\"Notes\">Notes</h3> <p>In most languages like PHP and Python and others that have an exponentiation operator (**), the exponentiation operator is defined to have a higher precedence than unary operators such as unary + and unary -, but there are a few exceptions. For example, in Bash the ** operator is defined to have a lower precedence than unary operators. In JavaScript, it is impossible to write an ambiguous exponentiation expression, i.e. you cannot put a unary operator (<code>+/-/~/!/delete/void/typeof</code>) immediately before the base number.</p> <pre data-language=\"js\">-2 ** 2; \n// 4 in Bash, -4 in other languages. \n// This is invalid in JavaScript, as the operation is ambiguous. \n\n\n-(2 ** 2); \n// -4 in JavaScript and the author's intention is unambiguous. \n</pre> <h3 id=\"Examples_6\">Examples</h3> <pre data-language=\"js\">2 ** 3 // 8\n3 ** 2 // 9\n3 ** 2.5 // 15.588457268119896\n10 ** -1 // 0.1\nNaN ** 2 // NaN\n\n2 ** 3 ** 2 // 512\n2 ** (3 ** 2) // 512\n(2 ** 3) ** 2 // 64\n</pre> <p>To invert the sign of the result of an exponentiation expression:</p> <pre data-language=\"js\">-(2 ** 2) // -4\n</pre> <p>To force the base of an exponentiation expression to be a negative number:</p> <pre data-language=\"js\">(-2) ** 2 // 4\n</pre> <div class=\"note\"> <p><strong>Note:</strong> JavaScript also has <a href=\"bitwise_operators#Bitwise_XOR\">a bitwise operator ^ (logical XOR)</a>. <code>**</code> and <code>^</code> are different (for example : <code>2 ** 3 === 8</code> when <code>2 ^ 3 === 1</code>.)</p> </div>  <h2 id=\"Increment\">Increment (++)</h2>  <p>The increment operator increments (adds one to) its operand and returns a value.</p> <ul> <li>If used postfix, with operator after operand (for example, x++), then it returns the value before incrementing.</li> <li>If used prefix with operator before operand (for example, ++x), then it returns the value after incrementing.</li> </ul> <h3 id=\"Syntax_7\">Syntax</h3> <pre class=\"syntaxbox\"><strong>Operator:</strong> x++ or ++x\n</pre> <h3 id=\"Examples_7\">Examples</h3> <pre data-language=\"js\">// Postfix \nvar x = 3;\ny = x++; // y = 3, x = 4\n\n// Prefix\nvar a = 2;\nb = ++a; // a = 3, b = 3\n</pre> <h2 id=\"Decrement\">Decrement (--)</h2> <p>The decrement operator decrements (subtracts one from) its operand and returns a value.</p> <ul> <li>If used postfix (for example, x--), then it returns the value before decrementing.</li> <li>If used prefix (for example, --x), then it returns the value after decrementing.</li> </ul> <h3 id=\"Syntax_8\">Syntax</h3> <pre class=\"syntaxbox\"><strong>Operator:</strong> x-- or --x\n</pre> <h3 id=\"Examples_8\">Examples</h3> <pre data-language=\"js\">// Postfix \nvar x = 3;\ny = x--; // y = 3, x = 2\n\n// Prefix\nvar a = 2;\nb = --a; // a = 1, b = 1\n</pre> <h2 id=\"Unary_negation\">Unary negation (-)</h2> <p>The unary negation operator precedes its operand and negates it.</p> <h3 id=\"Syntax_9\">Syntax</h3> <pre class=\"syntaxbox\"><strong>Operator:</strong> -x\n</pre> <h3 id=\"Examples_9\">Examples</h3> <pre data-language=\"js\">var x = 3;\ny = -x; // y = -3, x = 3\n\n//unary negation operator can convert non-numbers into a number\nvar x = \"4\";\ny = -x; // y = -4 \n</pre> <h2 id=\"Unary_plus\">Unary plus (+)</h2> <p>The unary plus operator precedes its operand and evaluates to its operand but attempts to convert it into a number, if it isn't already. Although unary negation (-) also can convert non-numbers, unary plus is the fastest and preferred way of converting something into a number, because it does not perform any other operations on the number. It can convert string representations of integers and floats, as well as the non-string values <code>true</code>, <code>false</code>, and <code>null</code>. Integers in both decimal and hexadecimal (\"0x\"-prefixed) formats are supported. Negative numbers are supported (though not for hex). If it cannot parse a particular value, it will evaluate to <a href=\"../global_objects/nan\">NaN</a>.</p> <h3 id=\"Syntax_10\">Syntax</h3> <pre class=\"syntaxbox\"><strong>Operator:</strong> +x\n</pre> <h3 id=\"Examples_10\">Examples</h3> <pre data-language=\"js\">+3     // 3\n+'3'   // 3\n+true  // 1\n+false // 0\n+null  // 0\n+function(val){  return val } // NaN\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/publications/files/ECMA-ST-ARCH/ECMA-262,%201st%20edition,%20June%201997.pdf\" hreflang=\"en\">ECMAScript 1st Edition (ECMA-262)</a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/5.1/#sec-11.3\" hreflang=\"en\">ECMAScript 5.1 (ECMA-262)</a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Defined in several sections of the specification: <a href=\"http://www.ecma-international.org/ecma-262/5.1/#sec-11.6\">Additive operators</a>, <a href=\"http://www.ecma-international.org/ecma-262/5.1/#sec-11.5\">Multiplicative operators</a>, <a href=\"http://www.ecma-international.org/ecma-262/5.1/#sec-11.3\">Postfix expressions</a>, <a href=\"http://www.ecma-international.org/ecma-262/5.1/#sec-11.4\">Unary operators</a>.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-postfix-expressions\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)</a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Defined in several sections of the specification: <a href=\"http://www.ecma-international.org/ecma-262/6.0/#sec-additive-operators\">Additive operators</a>, <a href=\"http://www.ecma-international.org/ecma-262/6.0/#sec-multiplicative-operators\">Multiplicative operators</a>, <a href=\"http://www.ecma-international.org/ecma-262/6.0/#sec-postfix-expressions\">Postfix expressions</a>, <a href=\"http://www.ecma-international.org/ecma-262/6.0/#sec-unary-operators\">Unary operators</a>.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/7.0/#sec-postfix-expressions\" hreflang=\"en\">ECMAScript 2016 (ECMA-262)</a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Added <a href=\"https://github.com/rwaldron/exponentiation-operator\">Exponentiation operator</a>.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/8.0/#sec-postfix-expressions\" hreflang=\"en\">ECMAScript 2017 (ECMA-262)</a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-additive-operators\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)</a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Operators/Arithmetic_Operators#Addition\">Addition (<code>+</code>)</a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Operators/Arithmetic_Operators#Decrement\">Decrement (<code>--</code>)</a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Operators/Arithmetic_Operators#Division\">Division (<code>/</code>)</a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Operators/Arithmetic_Operators#Exponentiation\">Exponentiation (<code>**</code>)</a></th>\n<td class=\"bc-supports-yes\"> 52</td>\n<td class=\"bc-supports-yes\"> 14</td>\n<td class=\"bc-supports-yes\"> 52</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 10.1</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Operators/Arithmetic_Operators#Increment\">Increment (<code>++</code>)</a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Operators/Arithmetic_Operators#Multiplication\">Multiplication (<code>*</code>)</a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Operators/Arithmetic_Operators#Remainder\">Remainder (<code>%</code>)</a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Operators/Arithmetic_Operators#Subtraction\">Subtraction (<code>-</code>)</a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Operators/Arithmetic_Operators#Unary_negation\">Unary negation (<code>-</code>)</a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Operators/Arithmetic_Operators#Unary_plus\">Unary plus (<code>+</code>)</a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n</tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Operators/Arithmetic_Operators#Addition\">Addition (<code>+</code>)</a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Operators/Arithmetic_Operators#Decrement\">Decrement (<code>--</code>)</a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Operators/Arithmetic_Operators#Division\">Division (<code>/</code>)</a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Operators/Arithmetic_Operators#Exponentiation\">Exponentiation (<code>**</code>)</a></th>\n<td class=\"bc-supports-yes\"> 51</td>\n<td class=\"bc-supports-yes\"> 52</td>\n<td class=\"bc-supports-yes\"> 14</td>\n<td class=\"bc-supports-yes\"> 52</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 10.1</td>\n<td class=\"bc-supports-yes\"> 6.0</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Operators/Arithmetic_Operators#Increment\">Increment (<code>++</code>)</a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Operators/Arithmetic_Operators#Multiplication\">Multiplication (<code>*</code>)</a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Operators/Arithmetic_Operators#Remainder\">Remainder (<code>%</code>)</a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Operators/Arithmetic_Operators#Subtraction\">Subtraction (<code>-</code>)</a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Operators/Arithmetic_Operators#Unary_negation\">Unary negation (<code>-</code>)</a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Operators/Arithmetic_Operators#Unary_plus\">Unary plus (<code>+</code>)</a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n</tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Operators/Arithmetic_Operators#Addition\">Addition (<code>+</code>)</a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Operators/Arithmetic_Operators#Decrement\">Decrement (<code>--</code>)</a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Operators/Arithmetic_Operators#Division\">Division (<code>/</code>)</a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Operators/Arithmetic_Operators#Exponentiation\">Exponentiation (<code>**</code>)</a></th>\n<td class=\"bc-supports-yes bc-has-history\"> 7.0.0\n<section class=\"bc-history\" id=\"sect1\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 7.0.0\n</dt>\n\n<dt class=\"bc-supports-yes bc-supports\"> 6.5.0<div class=\"bc-icons\">Disabled </div>\n</dt>\n<dd>Disabled From version 6.5.0: this feature is behind the <code>--harmony</code> runtime flag.</dd>\n</dl></section>\n</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Operators/Arithmetic_Operators#Increment\">Increment (<code>++</code>)</a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Operators/Arithmetic_Operators#Multiplication\">Multiplication (<code>*</code>)</a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Operators/Arithmetic_Operators#Remainder\">Remainder (<code>%</code>)</a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Operators/Arithmetic_Operators#Subtraction\">Subtraction (<code>-</code>)</a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Operators/Arithmetic_Operators#Unary_negation\">Unary negation (<code>-</code>)</a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Operators/Arithmetic_Operators#Unary_plus\">Unary plus (<code>+</code>)</a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n</tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"assignment_operators\">Assignment operators</a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Arithmetic_Operators$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Arithmetic_Operators\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Arithmetic_Operators</a>\n  </p>\n</div>\n","global_objects/object":"<h1>Object</h1> <p>The <code><strong>Object</strong></code> constructor creates an object wrapper.</p> <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\">// Object initialiser or literal\n{ [ <var>nameValuePair1</var>[, <var>nameValuePair2</var>[, ...<var>nameValuePairN</var>] ] ] }\n\n// Called as a constructor\nnew Object([<var>value</var>])</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><code>nameValuePair1, nameValuePair2, ... nameValuePair<em>N</em></code></dt> <dd>Pairs of names (strings) and values (any value) where the name is separated from the value by a colon.</dd> <dt><code>value</code></dt> <dd>Any value.</dd> </dl> <h2 id=\"Description\">Description</h2> <p>The <code>Object</code> constructor creates an object wrapper for the given value. If the value is <a href=\"null\"><code>null</code></a> or <a href=\"undefined\"><code>undefined</code></a>, it will create and return an empty object, otherwise, it will return an object of a Type that corresponds to the given value. If the value is an object already, it will return the value.</p> <p>When called in a non-constructor context, <code>Object</code> behaves identically to <code>new Object()</code>.</p> <p>See also the <a href=\"../operators/object_initializer\">object initializer / literal syntax</a>.</p> <h2 id=\"Properties_of_the_Object_constructor\">Properties of the <code>Object</code> constructor</h2> <dl> <dt><code>Object.length</code></dt> <dd>Has a value of 1.</dd> <dt><a href=\"object/prototype\"><code>Object.prototype</code></a></dt> <dd>Allows the addition of properties to all objects of type Object.</dd> </dl> <h2 id=\"Methods_of_the_Object_constructor\">Methods of the <code>Object</code> constructor</h2> <dl> <dt><a href=\"object/assign\"><code>Object.assign()</code></a></dt> <dd>Copies the values of all enumerable own properties from one or more source objects to a target object.</dd> <dt><a href=\"object/create\"><code>Object.create()</code></a></dt> <dd>Creates a new object with the specified prototype object and properties.</dd> <dt><a href=\"object/defineproperty\"><code>Object.defineProperty()</code></a></dt> <dd>Adds the named property described by a given descriptor to an object.</dd> <dt><a href=\"object/defineproperties\"><code>Object.defineProperties()</code></a></dt> <dd>Adds the named properties described by the given descriptors to an object.</dd> <dt><a href=\"object/entries\"><code>Object.entries()</code></a></dt> <dd>Returns an array containing all of the <code>[key, value]</code> pairs of a given object's <strong>own</strong> enumerable string properties.</dd> <dt><a href=\"object/freeze\"><code>Object.freeze()</code></a></dt> <dd>Freezes an object: other code can't delete or change any properties.</dd> <dt><a href=\"object/fromentries\"><code>Object.fromEntries()</code></a></dt> <dd>Returns a new object from an iterable of key-value pairs (reverses <a href=\"object/entries\"><code>Object.entries</code></a>).</dd> <dt><a href=\"object/getownpropertydescriptor\"><code>Object.getOwnPropertyDescriptor()</code></a></dt> <dd>Returns a property descriptor for a named property on an object.</dd> <dt><a href=\"object/getownpropertydescriptors\"><code>Object.getOwnPropertyDescriptors()</code></a></dt> <dd>Returns an object containing all own property descriptors for an object.</dd> <dt><a href=\"object/getownpropertynames\"><code>Object.getOwnPropertyNames()</code></a></dt> <dd>Returns an array containing the names of all of the given object's <strong>own</strong> enumerable and non-enumerable properties.</dd> <dt><a href=\"object/getownpropertysymbols\"><code>Object.getOwnPropertySymbols()</code></a></dt> <dd>Returns an array of all symbol properties found directly upon a given object.</dd> <dt><a href=\"object/getprototypeof\"><code>Object.getPrototypeOf()</code></a></dt> <dd>Returns the prototype of the specified object.</dd> <dt><a href=\"object/is\"><code>Object.is()</code></a></dt> <dd>Compares if two values are the same value. Equates all NaN values (which differs from both Abstract Equality Comparison and Strict Equality Comparison).</dd> <dt><a href=\"object/isextensible\"><code>Object.isExtensible()</code></a></dt> <dd>Determines if extending of an object is allowed.</dd> <dt><a href=\"object/isfrozen\"><code>Object.isFrozen()</code></a></dt> <dd>Determines if an object was frozen.</dd> <dt><a href=\"object/issealed\"><code>Object.isSealed()</code></a></dt> <dd>Determines if an object is sealed.</dd> <dt><a href=\"object/keys\"><code>Object.keys()</code></a></dt> <dd>Returns an array containing the names of all of the given object's <strong>own</strong> enumerable string properties.</dd> <dt><a href=\"object/preventextensions\"><code>Object.preventExtensions()</code></a></dt> <dd>Prevents any extensions of an object.</dd> <dt><a href=\"object/seal\"><code>Object.seal()</code></a></dt> <dd>Prevents other code from deleting properties of an object.</dd> <dt><a href=\"object/setprototypeof\"><code>Object.setPrototypeOf()</code></a></dt> <dd>Sets the prototype (i.e., the internal <code>[[Prototype]]</code> property).</dd> <dt><a href=\"object/values\"><code>Object.values()</code></a></dt> <dd>Returns an array containing the values that correspond to all of a given object's <strong>own</strong> enumerable string properties.</dd> </dl> <h2 id=\"Object_instances_and_Object_prototype_object\">\n<code>Object</code> instances and <code>Object</code> prototype object</h2> <p>All objects in JavaScript are descended from <code>Object</code>; all objects inherit methods and properties from <a href=\"object/prototype\"><code>Object.prototype</code></a>, although they may be overridden. For example, other constructors' prototypes override the <code>constructor</code> property and provide their own <code>toString()</code> methods. Changes to the <code>Object</code> prototype object are propagated to all objects unless the properties and methods subject to those changes are overridden further along the prototype chain.</p> <h3 id=\"Properties\">Properties</h3> <dl> <dt><a href=\"object/constructor\"><code>Object.prototype.constructor</code></a></dt> <dd>Specifies the function that creates an object's prototype.</dd> <dt>\n<a href=\"object/proto\"><code>Object.prototype.__proto__</code></a> \n</dt> <dd>Points to the object which was used as prototype when the object was instantiated.</dd> <dt>\n<a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/__noSuchMethod__\"><code>Object.prototype.__noSuchMethod__</code></a> \n</dt> <dd>Allows a function to be defined that will be executed when an undefined object member is called as a method.</dd> <dt><s class=\"obsoleteElement\"><a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/count\"><code>Object.prototype.__count__</code></a> </s></dt> <dd><s class=\"obsoleteElement\">Used to return the number of enumerable properties directly on a user-defined object, but has been removed.</s></dd> <dt><s class=\"obsoleteElement\"><a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/parent\"><code>Object.prototype.__parent__</code></a> </s></dt> <dd><s class=\"obsoleteElement\">Used to point to an object's context, but has been removed.</s></dd> </dl> <h3 id=\"Methods\">Methods</h3> <dl> <dt>\n<a href=\"object/__definegetter__\"><code>Object.prototype.__defineGetter__()</code></a>  \n</dt> <dd>Associates a function with a property that, when accessed, executes that function and returns its return value.</dd> <dt>\n<a href=\"object/__definesetter__\"><code>Object.prototype.__defineSetter__()</code></a>  \n</dt> <dd>Associates a function with a property that, when set, executes that function which modifies the property.</dd> <dt>\n<a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/__lookupGetter__\"><code>Object.prototype.__lookupGetter__()</code></a>  \n</dt> <dd>Returns the function associated with the specified property by the <a href=\"object/__definegetter__\"><code>__defineGetter__()</code></a> method.</dd> <dt>\n<a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/__lookupSetter__\"><code>Object.prototype.__lookupSetter__()</code></a>  \n</dt> <dd>Returns the function associated with the specified property by the <a href=\"object/__definesetter__\"><code>__defineSetter__()</code></a> method.</dd> <dt><a href=\"object/hasownproperty\"><code>Object.prototype.hasOwnProperty()</code></a></dt> <dd>Returns a boolean indicating whether an object contains the specified property as a direct property of that object and not inherited through the prototype chain.</dd> <dt><a href=\"object/isprototypeof\"><code>Object.prototype.isPrototypeOf()</code></a></dt> <dd>Returns a boolean indicating whether the object this method is called upon is in the prototype chain of the specified object.</dd> <dt><a href=\"object/propertyisenumerable\"><code>Object.prototype.propertyIsEnumerable()</code></a></dt> <dd>Returns a boolean indicating if the internal <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Properties\">ECMAScript [[Enumerable]] attribute</a> is set.</dd> <dt>\n<a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/toSource\"><code>Object.prototype.toSource()</code></a> \n</dt> <dd>Returns string containing the source of an object literal representing the object that this method is called upon; you can use this value to create a new object.</dd> <dt><a href=\"object/tolocalestring\"><code>Object.prototype.toLocaleString()</code></a></dt> <dd>Calls <a href=\"object/tostring\"><code>toString()</code></a>.</dd> <dt><a href=\"object/tostring\"><code>Object.prototype.toString()</code></a></dt> <dd>Returns a string representation of the object.</dd> <dt>\n<a href=\"object/unwatch\"><code>Object.prototype.unwatch()</code></a> \n</dt> <dd>Removes a watchpoint from a property of the object.</dd> <dt><a href=\"object/valueof\"><code>Object.prototype.valueOf()</code></a></dt> <dd>Returns the primitive value of the specified object.</dd> <dt>\n<a href=\"object/watch\"><code>Object.prototype.watch()</code></a> \n</dt> <dd>Adds a watchpoint to a property of the object.</dd> <dt><s class=\"obsoleteElement\"><a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/eval\"><code>Object.prototype.eval()</code></a> </s></dt> <dd><s class=\"obsoleteElement\">Used to evaluate a string of JavaScript code in the context of the specified object, but has been removed.</s></dd> </dl> <h2 id=\"Deleting_a_property_from_an_object\">Deleting a property from an object</h2> <p>There isn't any method in an Object itself to delete its own properties (e.g. like <code><a href=\"map/delete\">Map.prototype.delete()</a></code>). To do so one has to use the <a href=\"../operators/delete\">delete operator</a>.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Using_Object_given_undefined_and_null_types\">Using <code>Object</code> given <code>undefined</code> and <code>null</code> types</h3> <p>The following examples store an empty <code>Object</code> object in <code>o</code>:</p> <pre data-language=\"js\">var o = new Object();\n</pre> <pre data-language=\"js\">var o = new Object(undefined);\n</pre> <pre data-language=\"js\">var o = new Object(null);\n</pre> <h3 id=\"Using_Object_to_create_Boolean_objects\">Using <code>Object</code> to create <code>Boolean</code> objects</h3> <p>The following examples store <a href=\"boolean\"><code>Boolean</code></a> objects in <code>o</code>:</p> <pre data-language=\"js\">// equivalent to o = new Boolean(true);\nvar o = new Object(true);\n</pre> <pre data-language=\"js\">// equivalent to o = new Boolean(false);\nvar o = new Object(Boolean());\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/publications/files/ECMA-ST-ARCH/ECMA-262,%201st%20edition,%20June%201997.pdf\" hreflang=\"en\">ECMAScript 1st Edition (ECMA-262)</a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition. Implemented in JavaScript 1.0.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/5.1/#sec-15.2\" hreflang=\"en\">ECMAScript 5.1 (ECMA-262)<br><small>The definition of 'Object' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-object-objects\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Object' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Added Object.assign, Object.getOwnPropertySymbols, Object.setPrototypeOf, Object.is</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-object-objects\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Object' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td>Added Object.entries, Object.values and Object.getOwnPropertyDescriptors.</td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>   <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object/prototype\"><code>prototype</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object/count\"><code>__count__</code></a> \n</th>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object/noSuchMethod\"><code>__noSuchMethod__</code></a> \n</th>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\">1 — 43</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object/parent\"><code>__parent__</code></a> \n</th>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object/proto\"><code>__proto__</code></a> \n</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> 11</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object/constructor\"><code>constructor</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object/assign\"><code>assign</code></a></th>\n<td class=\"bc-supports-yes\"> 45</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 34</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 32</td>\n<td class=\"bc-supports-yes\"> 9</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object/create\"><code>create</code></a></th>\n<td class=\"bc-supports-yes\"> 5</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> 9</td>\n<td class=\"bc-supports-yes\"> 11.6</td>\n<td class=\"bc-supports-yes\"> 5</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object/defineProperties\"><code>defineProperties</code></a></th>\n<td class=\"bc-supports-yes\"> 5</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> 9</td>\n<td class=\"bc-supports-yes\"> 11.6</td>\n<td class=\"bc-supports-yes\"> 5</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object/defineProperty\"><code>defineProperty</code></a></th>\n<td class=\"bc-supports-yes\"> 5</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes bc-has-history\"> 9\n<section class=\"bc-history\" id=\"sect1\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 9\n</dt>\n<dd> Also supported in Internet Explorer 8, but only on DOM objects and with some non-standard behaviors.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-yes\"> 11.6</td>\n<td class=\"bc-supports-yes bc-has-history\"> 5.1\n<section class=\"bc-history\" id=\"sect2\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 5.1\n</dt>\n<dd> Also supported in Safari 5, but not on DOM objects.</dd>\n</dl></section>\n</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object/entries\"><code>entries</code></a></th>\n<td class=\"bc-supports-yes\"> 54</td>\n<td class=\"bc-supports-yes\"> 14</td>\n<td class=\"bc-supports-yes\"> 47</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 41</td>\n<td class=\"bc-supports-yes\"> 10.1</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object/freeze\"><code>freeze</code></a></th>\n<td class=\"bc-supports-yes\"> 6</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> 9</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 5.1</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object/fromEntries\"><code>fromEntries</code></a></th>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 63</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object/getNotifier\"><code>getNotifier</code></a> \n</th>\n<td class=\"bc-supports-no\">36 — 52</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object/getOwnPropertyDescriptor\"><code>getOwnPropertyDescriptor</code></a></th>\n<td class=\"bc-supports-yes\"> 5</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> 8</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 5</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object/getOwnPropertyDescriptors\"><code>getOwnPropertyDescriptors</code></a></th>\n<td class=\"bc-supports-yes\"> 54</td>\n<td class=\"bc-supports-yes\"> 15</td>\n<td class=\"bc-supports-yes\"> 50</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 41</td>\n<td class=\"bc-supports-yes\"> 10</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object/getOwnPropertyNames\"><code>getOwnPropertyNames</code></a></th>\n<td class=\"bc-supports-yes\"> 5</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> 9</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 5</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object/getOwnPropertySymbols\"><code>getOwnPropertySymbols</code></a></th>\n<td class=\"bc-supports-yes\"> 38</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 36</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 25</td>\n<td class=\"bc-supports-yes\"> 9</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object/getPrototypeOf\"><code>getPrototypeOf</code></a></th>\n<td class=\"bc-supports-yes\"> 5</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 3.5</td>\n<td class=\"bc-supports-yes\"> 9</td>\n<td class=\"bc-supports-yes\"> 12.1</td>\n<td class=\"bc-supports-yes\"> 5</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object/is\"><code>is</code></a></th>\n<td class=\"bc-supports-yes\"> 30</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 22</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 9</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object/isExtensible\"><code>isExtensible</code></a></th>\n<td class=\"bc-supports-yes\"> 6</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> 9</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 5.1</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object/isFrozen\"><code>isFrozen</code></a></th>\n<td class=\"bc-supports-yes\"> 6</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> 9</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 5.1</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object/isSealed\"><code>isSealed</code></a></th>\n<td class=\"bc-supports-yes\"> 6</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> 9</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 5.1</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object/keys\"><code>keys</code></a></th>\n<td class=\"bc-supports-yes\"> 5</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> 9</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 5</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object/observe\"><code>observe</code></a> \n</th>\n<td class=\"bc-supports-no\">36 — 52</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object/preventExtensions\"><code>preventExtensions</code></a></th>\n<td class=\"bc-supports-yes\"> 6</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> 9</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 5.1</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object/__defineGetter__\"><code>__defineGetter__</code></a> \n</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes bc-has-history\"> 1\n<section class=\"bc-history\" id=\"sect5\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 1\n</dt>\n<dd> Starting with Firefox 48, this method can no longer be called at the global scope without any object. A <code>TypeError</code> will be thrown otherwise. Previously, the global object was used in these cases automatically, but this is no longer the case.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-yes\"> 11</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object/__defineSetter__\"><code>__defineSetter__</code></a> \n</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes bc-has-history\"> 1\n<section class=\"bc-history\" id=\"sect6\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 1\n</dt>\n<dd> Starting with Firefox 48, this method can no longer be called at the global scope without any object. A <code>TypeError</code> will be thrown otherwise. Previously, the global object was used in these cases automatically, but this is no longer the case.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-yes\"> 11</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object/__lookupGetter__\"><code>__lookupGetter__</code></a> \n</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> 11</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object/__lookupSetter__\"><code>__lookupSetter__</code></a> \n</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> 11</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object/eval\"><code>eval</code></a> \n</th>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object/hasOwnProperty\"><code>hasOwnProperty</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object/isPrototypeOf\"><code>isPrototypeOf</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object/propertyIsEnumerable\"><code>propertyIsEnumerable</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object/toLocaleString\"><code>toLocaleString</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object/toSource\"><code>toSource</code></a> \n</th>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object/toString\"><code>toString</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object/unwatch\"><code>unwatch</code></a> \n</th>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\">1 — 58</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object/valueOf\"><code>valueOf</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object/watch\"><code>watch</code></a> \n</th>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\">1 — 58</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object/seal\"><code>seal</code></a></th>\n<td class=\"bc-supports-yes\"> 6</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> 9</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 5.1</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object/setPrototypeOf\"><code>setPrototypeOf</code></a></th>\n<td class=\"bc-supports-yes\"> 34</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 31</td>\n<td class=\"bc-supports-yes\"> 11</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 9</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object/unobserve\"><code>unobserve</code></a> \n</th>\n<td class=\"bc-supports-no\">36 — 52</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object/values\"><code>values</code></a></th>\n<td class=\"bc-supports-yes\"> 54</td>\n<td class=\"bc-supports-yes\"> 14</td>\n<td class=\"bc-supports-yes\"> 47</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 41</td>\n<td class=\"bc-supports-yes\"> 10.1</td>\n</tr>\n</tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object/prototype\"><code>prototype</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object/count\"><code>__count__</code></a> \n</th>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object/noSuchMethod\"><code>__noSuchMethod__</code></a> \n</th>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\">4 — 43</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object/parent\"><code>__parent__</code></a> \n</th>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object/proto\"><code>__proto__</code></a> \n</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object/constructor\"><code>constructor</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object/assign\"><code>assign</code></a></th>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 45</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 34</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 5.0</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object/create\"><code>create</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> 11.5</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object/defineProperties\"><code>defineProperties</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> 11.5</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object/defineProperty\"><code>defineProperty</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> 11.5</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object/entries\"><code>entries</code></a></th>\n<td class=\"bc-supports-yes\"> 54</td>\n<td class=\"bc-supports-yes\"> 54</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 47</td>\n<td class=\"bc-supports-yes\"> 41</td>\n<td class=\"bc-supports-yes\"> 10.1</td>\n<td class=\"bc-supports-yes\"> 6.0</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object/freeze\"><code>freeze</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object/fromEntries\"><code>fromEntries</code></a></th>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 63</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object/getNotifier\"><code>getNotifier</code></a> \n</th>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object/getOwnPropertyDescriptor\"><code>getOwnPropertyDescriptor</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object/getOwnPropertyDescriptors\"><code>getOwnPropertyDescriptors</code></a></th>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 54</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 50</td>\n<td> ? </td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 6.0</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object/getOwnPropertyNames\"><code>getOwnPropertyNames</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object/getOwnPropertySymbols\"><code>getOwnPropertySymbols</code></a></th>\n<td class=\"bc-supports-yes\"> 38</td>\n<td class=\"bc-supports-yes\"> 38</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 36</td>\n<td class=\"bc-supports-yes\"> 25</td>\n<td class=\"bc-supports-yes\"> 9</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object/getPrototypeOf\"><code>getPrototypeOf</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object/is\"><code>is</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 22</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 9</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object/isExtensible\"><code>isExtensible</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object/isFrozen\"><code>isFrozen</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object/isSealed\"><code>isSealed</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object/keys\"><code>keys</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object/observe\"><code>observe</code></a> \n</th>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object/preventExtensions\"><code>preventExtensions</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object/__defineGetter__\"><code>__defineGetter__</code></a> \n</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object/__defineSetter__\"><code>__defineSetter__</code></a> \n</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object/__lookupGetter__\"><code>__lookupGetter__</code></a> \n</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object/__lookupSetter__\"><code>__lookupSetter__</code></a> \n</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object/eval\"><code>eval</code></a> \n</th>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object/hasOwnProperty\"><code>hasOwnProperty</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object/isPrototypeOf\"><code>isPrototypeOf</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object/propertyIsEnumerable\"><code>propertyIsEnumerable</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object/toLocaleString\"><code>toLocaleString</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object/toSource\"><code>toSource</code></a> \n</th>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object/toString\"><code>toString</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object/unwatch\"><code>unwatch</code></a> \n</th>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\">4 — 58</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object/valueOf\"><code>valueOf</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object/watch\"><code>watch</code></a> \n</th>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\">4 — 58</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object/seal\"><code>seal</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object/setPrototypeOf\"><code>setPrototypeOf</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 31</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object/unobserve\"><code>unobserve</code></a> \n</th>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object/values\"><code>values</code></a></th>\n<td class=\"bc-supports-yes\"> 54</td>\n<td class=\"bc-supports-yes\"> 54</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 47</td>\n<td class=\"bc-supports-yes\"> 41</td>\n<td class=\"bc-supports-yes\"> 10.3</td>\n<td class=\"bc-supports-yes\"> 6.0</td>\n</tr>\n</tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object/prototype\"><code>prototype</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object/count\"><code>__count__</code></a> \n</th>\n<td class=\"bc-supports-no\"> No</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object/noSuchMethod\"><code>__noSuchMethod__</code></a> \n</th>\n<td class=\"bc-supports-no\"> No</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object/parent\"><code>__parent__</code></a> \n</th>\n<td class=\"bc-supports-no\"> No</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object/proto\"><code>__proto__</code></a> \n</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object/constructor\"><code>constructor</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object/assign\"><code>assign</code></a></th>\n<td class=\"bc-supports-yes\"> 4.0.0</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object/create\"><code>create</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object/defineProperties\"><code>defineProperties</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object/defineProperty\"><code>defineProperty</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object/entries\"><code>entries</code></a></th>\n<td class=\"bc-supports-yes bc-has-history\"> 7.0.0\n<section class=\"bc-history\" id=\"sect3\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 7.0.0\n</dt>\n\n<dt class=\"bc-supports-yes bc-supports\"> 6.5.0<div class=\"bc-icons\">Disabled </div>\n</dt>\n<dd>Disabled From version 6.5.0: this feature is behind the <code>--harmony</code> runtime flag.</dd>\n</dl></section>\n</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object/freeze\"><code>freeze</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object/fromEntries\"><code>fromEntries</code></a></th>\n<td class=\"bc-supports-no\"> No</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object/getNotifier\"><code>getNotifier</code></a> \n</th>\n<td class=\"bc-supports-no\"> No</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object/getOwnPropertyDescriptor\"><code>getOwnPropertyDescriptor</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object/getOwnPropertyDescriptors\"><code>getOwnPropertyDescriptors</code></a></th>\n<td class=\"bc-supports-yes bc-has-history\"> 7.0.0\n<section class=\"bc-history\" id=\"sect4\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 7.0.0\n</dt>\n\n<dt class=\"bc-supports-yes bc-supports\"> 6.5.0<div class=\"bc-icons\">Disabled </div>\n</dt>\n<dd>Disabled From version 6.5.0: this feature is behind the <code>--harmony</code> runtime flag.</dd>\n</dl></section>\n</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object/getOwnPropertyNames\"><code>getOwnPropertyNames</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object/getOwnPropertySymbols\"><code>getOwnPropertySymbols</code></a></th>\n<td class=\"bc-supports-yes\"> 0.12</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object/getPrototypeOf\"><code>getPrototypeOf</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object/is\"><code>is</code></a></th>\n<td class=\"bc-supports-yes\"> 0.10</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object/isExtensible\"><code>isExtensible</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object/isFrozen\"><code>isFrozen</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object/isSealed\"><code>isSealed</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object/keys\"><code>keys</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object/observe\"><code>observe</code></a> \n</th>\n<td class=\"bc-supports-no\"> No</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object/preventExtensions\"><code>preventExtensions</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object/__defineGetter__\"><code>__defineGetter__</code></a> \n</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object/__defineSetter__\"><code>__defineSetter__</code></a> \n</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object/__lookupGetter__\"><code>__lookupGetter__</code></a> \n</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object/__lookupSetter__\"><code>__lookupSetter__</code></a> \n</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object/eval\"><code>eval</code></a> \n</th>\n<td class=\"bc-supports-no\"> No</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object/hasOwnProperty\"><code>hasOwnProperty</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object/isPrototypeOf\"><code>isPrototypeOf</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object/propertyIsEnumerable\"><code>propertyIsEnumerable</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object/toLocaleString\"><code>toLocaleString</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object/toSource\"><code>toSource</code></a> \n</th>\n<td class=\"bc-supports-no\"> No</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object/toString\"><code>toString</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object/unwatch\"><code>unwatch</code></a> \n</th>\n<td class=\"bc-supports-no\"> No</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object/valueOf\"><code>valueOf</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object/watch\"><code>watch</code></a> \n</th>\n<td class=\"bc-supports-no\"> No</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object/seal\"><code>seal</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object/setPrototypeOf\"><code>setPrototypeOf</code></a></th>\n<td class=\"bc-supports-yes\"> 0.12</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object/unobserve\"><code>unobserve</code></a> \n</th>\n<td class=\"bc-supports-no\"> No</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object/values\"><code>values</code></a></th>\n<td class=\"bc-supports-yes bc-has-history\"> 7.0.0\n<section class=\"bc-history\" id=\"sect7\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 7.0.0\n</dt>\n\n<dt class=\"bc-supports-yes bc-supports\"> 6.5.0<div class=\"bc-icons\">Disabled </div>\n</dt>\n<dd>Disabled From version 6.5.0: this feature is behind the <code>--harmony</code> runtime flag.</dd>\n</dl></section>\n</td>\n</tr>\n</tbody>\n</table>\n</div>  <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"../operators/object_initializer\">Object initializer</a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object</a>\n  </p>\n</div>\n","operators/logical_operators":"<h1>Logical Operators</h1> <p>Logical operators are typically used with <a href=\"../global_objects/boolean\"><code>Boolean</code></a> (logical) values. When they are, they return a Boolean value. However, the <code>&amp;&amp;</code> and <code>||</code> operators actually return the value of one of the specified operands, so if these operators are used with non-Boolean values, they may return a non-Boolean value.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/expressions-logicaloperator.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Description\">Description</h2> <p>The logical operators are described in the following table:</p> <div class=\"_table\"><table class=\"fullwidth-table\"> <tbody> <tr> <th>Operator</th> <th>Usage</th> <th>Description</th> </tr> <tr> <td>Logical AND (<code>&amp;&amp;</code>)</td> <td><code><em>expr1</em> &amp;&amp; <em>expr2</em></code></td> <td>Returns <code>expr1</code> if it can be converted to <code>false</code>; otherwise, returns <code>expr2</code>. Thus, when used with Boolean values, <code>&amp;&amp;</code> returns <code>true</code> if both operands are true; otherwise, returns <code>false</code>.</td> </tr> <tr> <td>Logical OR (<code>||</code>)</td> <td><code><em>expr1</em> || <em>expr2</em></code></td> <td>Returns <code>expr1</code> if it can be converted to <code>true</code>; otherwise, returns <code>expr2</code>. Thus, when used with Boolean values, <code>||</code> returns <code>true</code> if either operand is <code>true</code>.</td> </tr> <tr> <td>Logical NOT (<code>!</code>)</td> <td><code>!<em>expr</em></code></td> <td>Returns <code>false</code> if its single operand can be converted to <code>true</code>; otherwise, returns <code>true</code>.</td> </tr> </tbody> </table></div> <p>If a value can be converted to <code>true</code>, the value is so-called <a href=\"https://developer.mozilla.org/en-US/docs/Glossary/truthy\">truthy</a>. If a value can be converted to <code>false</code>, the value is so-called <a href=\"https://developer.mozilla.org/en-US/docs/Glossary/falsy\">falsy</a>.</p> <p>Examples of expressions that can be converted to <a href=\"https://developer.mozilla.org/en-US/docs/Glossary/Falsy\">false</a> are:</p> <ul> <li>\n<code>null</code>;</li> <li><code>NaN;</code></li> <li>\n<code>0</code>;</li> <li>empty string (<code>\"\"</code> or <code>''</code> or <code>``</code>); </li> <li>\n<code>undefined</code>.</li> </ul> <p>Even though the <code>&amp;&amp;</code> and <code>||</code> operators can be used with operands that are not Boolean values, they can still be considered Boolean operators since their return values can always be converted to Boolean values.</p> <h3 id=\"Short-circuit_evaluation\">Short-circuit evaluation</h3> <p>As logical expressions are evaluated left to right, they are tested for possible \"short-circuit\" evaluation using the following rules:</p> <ul> <li>\n<code>false &amp;&amp; (<em>anything)</em></code> is short-circuit evaluated to false.</li> <li>\n<code>true || (<em>anything)</em></code> is short-circuit evaluated to true.</li> </ul> <p>The rules of logic guarantee that these evaluations are always correct. Note that the <code><em>anything</em></code> part of the above expressions is not evaluated, so any side effects of doing so do not take effect. Also, note that the <code><em>anything</em></code> part of the above expression is any single logical expression (as indicated by the parentheses).</p> <p>For example, the following two functions are equivalent.</p> <pre data-language=\"js\">function shortCircuitEvaluation() {  \n  // logical OR (||)\n  doSomething() || doSomethingElse();\n  \n  // logical AND (&amp;&amp;)\n  doSomething() &amp;&amp; doSomethingElse();\n}\n\nfunction equivalentEvaluation() {\n\n  // logical OR (||)\n  var orFlag = doSomething();\n  if (!orFlag) {\n    doSomethingElse();\n  }\n  \n  \n  // logical AND (&amp;&amp;)\n  var andFlag = doSomething();\n  if (andFlag) {\n    doSomethingElse();\n  }\n}\n</pre> <p>However, the following expressions are not equivalent due to <a href=\"operator_precedence\">operator precedence</a> and stresses the importance of requiring the right-hand operand to be a single expression (grouped if needed by parentheses).</p> <pre data-language=\"js\">false &amp;&amp; true  || true      // returns true\nfalse &amp;&amp; (true || true)     // returns false</pre> <h3 id=\"Logical_AND\">Logical AND (&amp;&amp;)</h3> <p>The following code shows examples of the <code>&amp;&amp;</code> (logical AND) operator.</p> <pre data-language=\"js\">a1 = true  &amp;&amp; true       // t &amp;&amp; t returns true\na2 = true  &amp;&amp; false      // t &amp;&amp; f returns false\na3 = false &amp;&amp; true       // f &amp;&amp; t returns false\na4 = false &amp;&amp; (3 == 4)   // f &amp;&amp; f returns false\na5 = 'Cat' &amp;&amp; 'Dog'      // t &amp;&amp; t returns \"Dog\"\na6 = false &amp;&amp; 'Cat'      // f &amp;&amp; t returns false\na7 = 'Cat' &amp;&amp; false      // t &amp;&amp; f returns false\na8 = ''    &amp;&amp; false      // f &amp;&amp; f returns \"\"\na9 = false &amp;&amp; ''         // f &amp;&amp; f returns false\n</pre> <h3 id=\"Logical_OR\">Logical OR (||)</h3> <p>The following code shows examples of the <code>||</code> (logical OR) operator.</p> <pre data-language=\"js\">o1 = true  || true       // t || t returns true\no2 = false || true       // f || t returns true\no3 = true  || false      // t || f returns true\no4 = false || (3 == 4)   // f || f returns false\no5 = 'Cat' || 'Dog'      // t || t returns \"Cat\"\no6 = false || 'Cat'      // f || t returns \"Cat\"\no7 = 'Cat' || false      // t || f returns \"Cat\"\no8 = ''    || false      // f || f returns false\no9 = false || ''         // f || f returns \"\"\n</pre> <h3 id=\"Logical_NOT\">Logical NOT (!)</h3> <p>The following code shows examples of the <code>!</code> (logical NOT) operator.</p> <pre data-language=\"js\">n1 = !true               // !t returns false\nn2 = !false              // !f returns true\nn3 = !'Cat'              // !t returns false\n</pre> <h3 id=\"Conversion_rules\">Conversion rules</h3> <h4 id=\"Converting_AND_to_OR\">Converting AND to OR</h4> <p>the following operation involving Booleans:</p> <pre data-language=\"js\">bCondition1 &amp;&amp; bCondition2</pre> <p>is always equal to:</p> <pre data-language=\"js\">!(!bCondition1 || !bCondition2)</pre> <h4 id=\"Converting_OR_to_AND\">Converting OR to AND</h4> <p>the following operation involving Booleans:</p> <pre data-language=\"js\">bCondition1 || bCondition2</pre> <p>is always equal to:</p> <pre data-language=\"js\">!(!bCondition1 &amp;&amp; !bCondition2)</pre> <h4 id=\"Converting_between_NOTs\">Converting between NOTs</h4> <p>the following operation involving Booleans:</p> <pre data-language=\"js\">!!bCondition</pre> <p>is always equal to:</p> <pre data-language=\"js\">bCondition</pre> <h3 id=\"Removing_nested_parentheses\">Removing nested parentheses</h3> <p>As logical expressions are evaluated left to right, it is always possible to remove parentheses from a complex expression following some rules.</p> <h4 id=\"Removing_nested_AND\">Removing nested AND</h4> <p>The following composite operation involving Booleans:</p> <pre data-language=\"js\">bCondition1 || (bCondition2 &amp;&amp; bCondition3)</pre> <p>is always equal to:</p> <pre data-language=\"js\">bCondition1 || bCondition2 &amp;&amp; bCondition3</pre> <h4 id=\"Removing_nested_OR\">Removing nested OR</h4> <p>The following composite operation involving Booleans:</p> <pre data-language=\"js\">bCondition1 &amp;&amp; (bCondition2 || bCondition3)</pre> <p>is always equal to:</p> <pre data-language=\"js\">!(!bCondition1 || !bCondition2 &amp;&amp; !bCondition3)</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/publications/files/ECMA-ST-ARCH/ECMA-262,%201st%20edition,%20June%201997.pdf\" hreflang=\"en\">ECMAScript 1st Edition (ECMA-262)</a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/5.1/#sec-11.11\" hreflang=\"en\">ECMAScript 5.1 (ECMA-262)</a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Defined in several sections of the specification: <a href=\"http://www.ecma-international.org/ecma-262/5.1/#sec-11.4.9\">Logical NOT Operator</a>, <a href=\"http://www.ecma-international.org/ecma-262/5.1/#sec-11.11\">Binary Logical Operators</a>\n</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-binary-logical-operators\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)</a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Defined in several sections of the specification: <a href=\"http://www.ecma-international.org/ecma-262/6.0/#sec-logical-not-operator\">Logical NOT Operator</a>, <a href=\"http://www.ecma-international.org/ecma-262/6.0/#sec-binary-logical-operators\">Binary Logical Operators</a>\n</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-binary-logical-operators\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)</a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td>Defined in several sections of the specification: <a href=\"http://tc39.github.io/ecma262/#sec-logical-not-operator\">Logical NOT Operator</a>, <a href=\"http://tc39.github.io/ecma262/#sec-binary-logical-operators\">Binary Logical Operators</a>\n</td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Operators/Logical_Operators#Logical_AND\">Logical AND (<code>&amp;&amp;</code>)</a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Operators/Logical_Operators#Logical_OR\">Logical OR (<code>||</code>)</a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Operators/Logical_Operators#Logical_NOT\">Logical NOT (<code>!</code>)</a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n</tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Operators/Logical_Operators#Logical_AND\">Logical AND (<code>&amp;&amp;</code>)</a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Operators/Logical_Operators#Logical_OR\">Logical OR (<code>||</code>)</a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Operators/Logical_Operators#Logical_NOT\">Logical NOT (<code>!</code>)</a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n</tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Operators/Logical_Operators#Logical_AND\">Logical AND (<code>&amp;&amp;</code>)</a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Operators/Logical_Operators#Logical_OR\">Logical OR (<code>||</code>)</a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Operators/Logical_Operators#Logical_NOT\">Logical NOT (<code>!</code>)</a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n</tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"bitwise_operators\">Bitwise operators</a></li> <li><a href=\"../global_objects/boolean\">Boolean</a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Logical_Operators$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Logical_Operators\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Logical_Operators</a>\n  </p>\n</div>\n","operators/property_accessors":"<h1>Property Accessors</h1> <p>Property accessors provide access to an object's properties by using the dot notation or the bracket notation.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/expressions-propertyaccessors.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\">object.property\nobject['property']\n</pre> <h2 id=\"Description\">Description</h2> <p>One can think of an object as an <em>associative array</em> (a.k.a. <em>map</em>, <em>dictionary</em>, <em>hash</em>, <em>lookup table</em>). The <em>keys</em> in this array are the names of the object's properties. It's typical when speaking of an object's properties to make a distinction between properties and methods. However, the property/method distinction is little more than a convention. A method is simply a property that can be called, for example if it has a reference to a <a href=\"../functions\">Function</a> instance as its value.</p> <p>There are two ways to access properties: dot notation and bracket notation.</p> <h3 id=\"Dot_notation\">Dot notation</h3> <pre data-language=\"js\">get = object.property;\nobject.property = set;\n</pre> <p>In this code, <code>property</code> must be a valid JavaScript identifier, i.e. a sequence of alphanumerical characters, also including the underscore (\"<code>_</code>\") and dollar sign (\"<code>$</code>\"), that cannot start with a number. For example, <code>object.$1</code> is valid, while <code>object.1</code> is not.</p> <pre data-language=\"js\">document.createElement('pre');\n</pre> <p>Here, the method named \"createElement\" is retrieved from <code>document</code> and is called.</p> <p>If you use a method for a numeric literal and the numeric literal has no exponent and no decimal point, leave white-space(s) before the dot that precedes the method call to prevent the dot from being interpreted as a decimal point.</p> <pre data-language=\"js\">77 .toExponential();\n// or\n77\n.toExponential();\n// or\n(77).toExponential();\n// or\n77..toExponential();\n// or\n77.0.toExponential();\n// because 77. === 77.0, no ambiguity</pre> <h3 id=\"Bracket_notation\">Bracket notation</h3> <pre data-language=\"js\">get = object[property_name];\nobject[property_name] = set;\n</pre> <p><code>property_name</code> is a string. The string does not have to be a valid identifier; it can have any value, e.g. \"1foo\", \"!bar!\", or even \" \" (a space).</p> <pre data-language=\"js\">document['createElement']('pre');\n</pre> <p>This does the exact same thing as the previous example.</p> <p>A space before bracket notation is allowed.</p> <pre data-language=\"js\">document ['createElement']('pre');</pre> <h3 id=\"Property_names\">Property names</h3> <p>Property names must be strings. This means that non-string objects cannot be used as keys in the object. Any non-string object, including a number, is typecasted into a string via the <a href=\"../global_objects/object/tostring\">toString</a> method.</p> <pre data-language=\"js\">var object = {};\nobject['1'] = 'value';\nconsole.log(object[1]);\n</pre> <p>This outputs \"value\", since 1 is type-casted into '1'.</p> <pre data-language=\"js\">var foo = {unique_prop: 1}, bar = {unique_prop: 2}, object = {};\nobject[foo] = 'value';\nconsole.log(object[bar]);\n</pre> <p>This also outputs \"value\", since both foo and bar are converted to the same string. In the <a href=\"https://developer.mozilla.org/en-US/docs/Mozilla/Projects/SpiderMonkey\">SpiderMonkey</a> JavaScript engine, this string would be \"['object Object']\".</p> <h3 id=\"Method_binding\">Method binding</h3> <p>A method is not bound to the object that it is a method of. Specifically, <code>this</code> is not fixed in a method, i.e., <code>this</code> does not necessarily refer to an object containing the method. <code>this</code> is instead \"passed\" by the function call. See <a href=\"this#Method_binding\">method binding</a>.</p> <h3 id=\"Note_on_eval\">Note on <code>eval</code>\n</h3> <p>JavaScript novices often make the mistake of using <a href=\"../global_objects/eval\">eval</a> where the bracket notation can be used instead. For example, the following syntax is often seen in many scripts.</p> <pre data-language=\"js\">x = eval('document.forms.form_name.elements.' + strFormControl + '.value');\n</pre> <p><a href=\"https://www.nczonline.net/blog/2013/06/25/eval-isnt-evil-just-misunderstood/\"><code>eval</code></a> is slow and should be avoided whenever possible. Also, <code>strFormControl</code> would have to hold an identifier, which is not required for names and IDs of form controls. It is better to use bracket notation instead:</p> <pre data-language=\"js\">x = document.forms['form_name'].elements[strFormControl].value;\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-property-accessors\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Property Accessors' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-property-accessors\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Property Accessors' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/5.1/#sec-11.2.1\" hreflang=\"en\">ECMAScript 5.1 (ECMA-262)<br><small>The definition of 'Property Accessors' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/publications/files/ECMA-ST-ARCH/ECMA-262,%201st%20edition,%20June%201997.pdf#sec-11.2.1\" hreflang=\"en\">ECMAScript 1st Edition (ECMA-262)<br><small>The definition of 'Property Accessors' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition. Implemented in JavaScript 1.0.</td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"../global_objects/object\"><code>Object</code></a></li> <li><a href=\"../global_objects/object/defineproperty\"><code>Object/defineProperty</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Property_Accessors$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Property_Accessors\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Property_Accessors</a>\n  </p>\n</div>\n","global_objects/date":"<h1>Date</h1> <p>Creates a JavaScript <code>Date</code> instance that represents a single moment in time. <code>Date</code> objects are based on a time value that is the number of milliseconds since 1 January 1970 UTC.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/date-constructor.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\">new Date();\nnew Date(<var>value</var>);\nnew Date(<var>dateString</var>);\nnew Date(<var>year</var>, <var>monthIndex</var> [, <var>day</var> [, <var>hours</var> [, <var>minutes</var> [, <var>seconds</var> [, <var>milliseconds</var>]]]]]);\n</pre> <div class=\"note\"> <p><strong>Note:</strong> JavaScript <code>Date</code> objects can only be instantiated by calling JavaScript <code>Date</code> as a constructor: calling it as a regular function (i.e. without the <a href=\"../operators/new\"><code>new</code></a> operator) will return a string rather than a <code>Date</code> object; unlike other JavaScript object types, JavaScript <code>Date</code> objects have no literal syntax.</p> </div> <h3 id=\"Parameters\">Parameters</h3> <div class=\"note\"> <p><strong>Note:</strong> The argument <code>monthIndex</code> is 0-based. This means that <code>January = 0</code> and <code>December = 11</code>.</p> </div> <div class=\"note\"> <p><strong>Note:</strong> Where <code>Date</code> is called as a constructor with more than one argument, if values are greater than their logical range (e.g. 13 is provided as the month value or 70 for the minute value), the adjacent value will be adjusted. E.g. <code>new Date(2013, 13, 1)</code> is equivalent to <code>new Date(2014, 1, 1)</code>, both create a date for <code>2014-02-01</code> (note that the month is 0-based). Similarly for other values: <code>new Date(2013, 2, 1, 0, 70)</code> is equivalent to <code>new Date(2013, 2, 1, 1, 10)</code> which both create a date for <code>2013-03-01T01:10:00</code>.</p> </div> <div class=\"note\"> <p><strong>Note:</strong> Where <code>Date</code> is called as a constructor with more than one argument, the specified arguments represent local time. If UTC is desired, use <code>new Date(<a href=\"date/utc\"><code>Date.UTC(...)</code></a>)</code> with the same arguments.</p> </div> <dl> <dt><code>value</code></dt> <dd>Integer value representing the number of milliseconds since January 1, 1970, 00:00:00 UTC, with leap seconds ignored (Unix Epoch; but consider that most Unix timestamp functions count in seconds).</dd> <dt><code>dateString</code></dt> <dd>String value representing a date. The string should be in a format recognized by the <a href=\"date/parse\"><code>Date.parse()</code></a> method (<a href=\"http://tools.ietf.org/html/rfc2822#page-14\">IETF-compliant RFC 2822 timestamps</a> and also a <a href=\"http://www.ecma-international.org/ecma-262/5.1/#sec-15.9.1.15\">version of ISO8601</a>). <div class=\"note\"> <p><strong>Note:</strong> parsing of date strings with the <code>Date</code> constructor (and <code>Date.parse</code>, they are equivalent) is strongly discouraged due to browser differences and inconsistencies. Support for RFC 2822 format strings is by convention only. Support for ISO 8601 formats differs in that date-only strings (e.g. \"1970-01-01\") are treated as UTC, not local.</p> </div> </dd> <dt><code>year</code></dt> <dd>Integer value representing the year. Values from 0 to 99 map to the years 1900 to 1999. See the <a href=\"#Two_digit_years_map_to_1900_-_1999\">example below</a>.</dd> <dt><code>monthIndex</code></dt> <dd>Integer value representing the month, beginning with 0 for January to 11 for December.</dd> <dt>\n<code>day</code> <span class=\"inlineIndicator optional optionalInline\">Optional</span>\n</dt> <dd>Integer value representing the day of the month.</dd> <dt>\n<code>hours</code> <span class=\"inlineIndicator optional optionalInline\">Optional</span>\n</dt> <dd>Integer value representing the hour of the day.</dd> <dt>\n<code>minutes</code> <span class=\"inlineIndicator optional optionalInline\">Optional</span>\n</dt> <dd>Integer value representing the minute segment of a time.</dd> <dt>\n<code>seconds</code> <span class=\"inlineIndicator optional optionalInline\">Optional</span>\n</dt> <dd>Integer value representing the second segment of a time.</dd> <dt>\n<code>milliseconds</code> <span class=\"inlineIndicator optional optionalInline\">Optional</span>\n</dt> <dd>Integer value representing the millisecond segment of a time.</dd> </dl> <h2 id=\"Description\">Description</h2> <ul> <li>If no arguments are provided, the constructor creates a JavaScript <code>Date</code> object for the current date and time according to system settings for timezone offset.</li> <li>If at least two arguments are supplied, missing arguments are either set to 1 (if the day is missing) or 0 for all others.</li> <li>The JavaScript date is based on a time value that is milliseconds since midnight January 1, 1970, UTC. A day holds 86,400,000 milliseconds. The JavaScript <code>Date</code> object range is -100,000,000 days to 100,000,000 days relative to January 1, 1970 UTC.</li> <li>The JavaScript <code>Date</code> object provides uniform behavior across platforms. The time value can be passed between systems to create a date that represents the same moment in time.</li> <li>The JavaScript <code>Date</code> object supports a number of UTC (universal) methods, as well as local time methods. UTC, also known as Greenwich Mean Time (GMT), refers to the time as set by the World Time Standard. The local time is the time known to the computer where JavaScript is executed.</li> <li>Invoking JavaScript <code>Date</code> as a function (i.e., without the <a href=\"../operators/new\"><code>new</code></a> operator) will return a string representing the current date and time.</li> </ul> <h2 id=\"Properties\">Properties</h2> <dl> <dt><a href=\"date/prototype\"><code>Date.prototype</code></a></dt> <dd>Allows the addition of properties to a JavaScript <code>Date</code> object.</dd> <dt><code>Date.length</code></dt> <dd>The value of <code>Date.length</code> is 7. This is the number of arguments handled by the constructor.</dd> </dl> <h2 id=\"Methods\">Methods</h2> <dl> <dt><a href=\"date/now\"><code>Date.now()</code></a></dt> <dd>Returns the numeric value corresponding to the current time - the number of milliseconds elapsed since January 1, 1970 00:00:00 UTC, with leap seconds ignored.</dd> <dt><a href=\"date/parse\"><code>Date.parse()</code></a></dt> <dd>Parses a string representation of a date and returns the number of milliseconds since 1 January, 1970, 00:00:00, UTC, with leap seconds ignored. <div class=\"note\"> <p><strong>Note:</strong> Parsing of strings with <code>Date.parse</code> is strongly discouraged due to browser differences and inconsistencies.</p> </div> </dd> <dt><a href=\"date/utc\"><code>Date.UTC()</code></a></dt> <dd>Accepts the same parameters as the longest form of the constructor (i.e. 2 to 7) and returns the number of milliseconds since January 1, 1970, 00:00:00 UTC, with leap seconds ignored.</dd> </dl> <h2 id=\"JavaScript_Date_instances\">JavaScript <code>Date</code> instances</h2> <p>All <code>Date</code> instances inherit from <a href=\"date/prototype\"><code>Date.prototype</code></a>. The prototype object of the <code>Date</code> constructor can be modified to affect all <code>Date</code> instances.</p> <h3 id=\"Date.prototype_Methods\">Date.prototype Methods</h3> <h3 id=\"Getter\">Getter</h3> <dl> <dt><a href=\"date/getdate\"><code>Date.prototype.getDate()</code></a></dt> <dd>Returns the day of the month (1-31) for the specified date according to local time.</dd> <dt><a href=\"date/getday\"><code>Date.prototype.getDay()</code></a></dt> <dd>Returns the day of the week (0-6) for the specified date according to local time.</dd> <dt><a href=\"date/getfullyear\"><code>Date.prototype.getFullYear()</code></a></dt> <dd>Returns the year (4 digits for 4-digit years) of the specified date according to local time.</dd> <dt><a href=\"date/gethours\"><code>Date.prototype.getHours()</code></a></dt> <dd>Returns the hour (0-23) in the specified date according to local time.</dd> <dt><a href=\"date/getmilliseconds\"><code>Date.prototype.getMilliseconds()</code></a></dt> <dd>Returns the milliseconds (0-999) in the specified date according to local time.</dd> <dt><a href=\"date/getminutes\"><code>Date.prototype.getMinutes()</code></a></dt> <dd>Returns the minutes (0-59) in the specified date according to local time.</dd> <dt><a href=\"date/getmonth\"><code>Date.prototype.getMonth()</code></a></dt> <dd>Returns the month (0-11) in the specified date according to local time.</dd> <dt><a href=\"date/getseconds\"><code>Date.prototype.getSeconds()</code></a></dt> <dd>Returns the seconds (0-59) in the specified date according to local time.</dd> <dt><a href=\"date/gettime\"><code>Date.prototype.getTime()</code></a></dt> <dd>Returns the numeric value of the specified date as the number of milliseconds since January 1, 1970, 00:00:00 UTC (negative for prior times).</dd> <dt><a href=\"date/gettimezoneoffset\"><code>Date.prototype.getTimezoneOffset()</code></a></dt> <dd>Returns the time-zone offset in minutes for the current locale.</dd> <dt><a href=\"date/getutcdate\"><code>Date.prototype.getUTCDate()</code></a></dt> <dd>Returns the day (date) of the month (1-31) in the specified date according to universal time.</dd> <dt><a href=\"date/getutcday\"><code>Date.prototype.getUTCDay()</code></a></dt> <dd>Returns the day of the week (0-6) in the specified date according to universal time.</dd> <dt><a href=\"date/getutcfullyear\"><code>Date.prototype.getUTCFullYear()</code></a></dt> <dd>Returns the year (4 digits for 4-digit years) in the specified date according to universal time.</dd> <dt><a href=\"date/getutchours\"><code>Date.prototype.getUTCHours()</code></a></dt> <dd>Returns the hours (0-23) in the specified date according to universal time.</dd> <dt><a href=\"date/getutcmilliseconds\"><code>Date.prototype.getUTCMilliseconds()</code></a></dt> <dd>Returns the milliseconds (0-999) in the specified date according to universal time.</dd> <dt><a href=\"date/getutcminutes\"><code>Date.prototype.getUTCMinutes()</code></a></dt> <dd>Returns the minutes (0-59) in the specified date according to universal time.</dd> <dt><a href=\"date/getutcmonth\"><code>Date.prototype.getUTCMonth()</code></a></dt> <dd>Returns the month (0-11) in the specified date according to universal time.</dd> <dt><a href=\"date/getutcseconds\"><code>Date.prototype.getUTCSeconds()</code></a></dt> <dd>Returns the seconds (0-59) in the specified date according to universal time.</dd> <dt>\n<a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getYear\"><code>Date.prototype.getYear()</code></a> \n</dt> <dd>Returns the year (usually 2-3 digits) in the specified date according to local time. Use <a href=\"date/getfullyear\"><code>getFullYear()</code></a> instead.</dd> </dl> <h3 id=\"Setter\">Setter</h3> <dl> <dt><a href=\"date/setdate\"><code>Date.prototype.setDate()</code></a></dt> <dd>Sets the day of the month for a specified date according to local time.</dd> <dt><a href=\"date/setfullyear\"><code>Date.prototype.setFullYear()</code></a></dt> <dd>Sets the full year (e.g. 4 digits for 4-digit years) for a specified date according to local time.</dd> <dt><a href=\"date/sethours\"><code>Date.prototype.setHours()</code></a></dt> <dd>Sets the hours for a specified date according to local time.</dd> <dt><a href=\"date/setmilliseconds\"><code>Date.prototype.setMilliseconds()</code></a></dt> <dd>Sets the milliseconds for a specified date according to local time.</dd> <dt><a href=\"date/setminutes\"><code>Date.prototype.setMinutes()</code></a></dt> <dd>Sets the minutes for a specified date according to local time.</dd> <dt><a href=\"date/setmonth\"><code>Date.prototype.setMonth()</code></a></dt> <dd>Sets the month for a specified date according to local time.</dd> <dt><a href=\"date/setseconds\"><code>Date.prototype.setSeconds()</code></a></dt> <dd>Sets the seconds for a specified date according to local time.</dd> <dt><a href=\"date/settime\"><code>Date.prototype.setTime()</code></a></dt> <dd>Sets the <a href=\"date\"><code>Date</code></a> object to the time represented by a number of milliseconds since January 1, 1970, 00:00:00 UTC, allowing for negative numbers for times prior.</dd> <dt><a href=\"date/setutcdate\"><code>Date.prototype.setUTCDate()</code></a></dt> <dd>Sets the day of the month for a specified date according to universal time.</dd> <dt><a href=\"date/setutcfullyear\"><code>Date.prototype.setUTCFullYear()</code></a></dt> <dd>Sets the full year (e.g. 4 digits for 4-digit years) for a specified date according to universal time.</dd> <dt><a href=\"date/setutchours\"><code>Date.prototype.setUTCHours()</code></a></dt> <dd>Sets the hour for a specified date according to universal time.</dd> <dt><a href=\"date/setutcmilliseconds\"><code>Date.prototype.setUTCMilliseconds()</code></a></dt> <dd>Sets the milliseconds for a specified date according to universal time.</dd> <dt><a href=\"date/setutcminutes\"><code>Date.prototype.setUTCMinutes()</code></a></dt> <dd>Sets the minutes for a specified date according to universal time.</dd> <dt><a href=\"date/setutcmonth\"><code>Date.prototype.setUTCMonth()</code></a></dt> <dd>Sets the month for a specified date according to universal time.</dd> <dt><a href=\"date/setutcseconds\"><code>Date.prototype.setUTCSeconds()</code></a></dt> <dd>Sets the seconds for a specified date according to universal time.</dd> <dt>\n<a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setYear\"><code>Date.prototype.setYear()</code></a> \n</dt> <dd>Sets the year (usually 2-3 digits) for a specified date according to local time. Use <a href=\"date/setfullyear\"><code>setFullYear()</code></a> instead.</dd> </dl> <h3 id=\"Conversion_getter\">Conversion getter</h3> <dl> <dt><a href=\"date/todatestring\"><code>Date.prototype.toDateString()</code></a></dt> <dd>Returns the \"date\" portion of the <a href=\"date\"><code>Date</code></a> as a human-readable string like 'Thu Apr 12 2018'</dd> <dt><a href=\"date/toisostring\"><code>Date.prototype.toISOString()</code></a></dt> <dd>Converts a date to a string following the ISO 8601 Extended Format.</dd> <dt><a href=\"date/tojson\"><code>Date.prototype.toJSON()</code></a></dt> <dd>Returns a string representing the <a href=\"date\"><code>Date</code></a> using <a href=\"date/toisostring\"><code>toISOString()</code></a>. Intended for use by <a href=\"json/stringify\"><code>JSON.stringify()</code></a>.</dd> <dt>\n<a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toGMTString\"><code>Date.prototype.toGMTString()</code></a> \n</dt> <dd>Returns a string representing the <a href=\"date\"><code>Date</code></a> based on the GMT (UT) time zone. Use <a href=\"date/toutcstring\"><code>toUTCString()</code></a> instead.</dd> <dt><a href=\"date/tolocaledatestring\"><code>Date.prototype.toLocaleDateString()</code></a></dt> <dd>Returns a string with a locality sensitive representation of the date portion of this date based on system settings.</dd> <dt>\n<a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toLocaleFormat\"><code>Date.prototype.toLocaleFormat()</code></a> \n</dt> <dd>Converts a date to a string, using a format string.</dd> <dt><a href=\"date/tolocalestring\"><code>Date.prototype.toLocaleString()</code></a></dt> <dd>Returns a string with a locality sensitive representation of this date. Overrides the <a href=\"object/tolocalestring\"><code>Object.prototype.toLocaleString()</code></a> method.</dd> <dt><a href=\"date/tolocaletimestring\"><code>Date.prototype.toLocaleTimeString()</code></a></dt> <dd>Returns a string with a locality sensitive representation of the time portion of this date based on system settings.</dd> <dt>\n<a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toSource\"><code>Date.prototype.toSource()</code></a> \n</dt> <dd>Returns a string representing the source for an equivalent <a href=\"date\"><code>Date</code></a> object; you can use this value to create a new object. Overrides the <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/toSource\"><code>Object.prototype.toSource()</code></a> method.</dd> <dt><a href=\"date/tostring\"><code>Date.prototype.toString()</code></a></dt> <dd>Returns a string representing the specified <a href=\"date\"><code>Date</code></a> object. Overrides the <a href=\"object/tostring\"><code>Object.prototype.toString()</code></a> method.</dd> <dt><a href=\"date/totimestring\"><code>Date.prototype.toTimeString()</code></a></dt> <dd>Returns the \"time\" portion of the <a href=\"date\"><code>Date</code></a> as a human-readable string.</dd> <dt><a href=\"date/toutcstring\"><code>Date.prototype.toUTCString()</code></a></dt> <dd>Converts a date to a string using the UTC timezone.</dd> <dt><a href=\"date/valueof\"><code>Date.prototype.valueOf()</code></a></dt> <dd>Returns the primitive value of a <a href=\"date\"><code>Date</code></a> object. Overrides the <a href=\"object/valueof\"><code>Object.prototype.valueOf()</code></a> method.</dd> </dl> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Several_ways_to_create_a_Date_object\">Several ways to create a <code>Date</code> object</h3> <p>The following examples show several ways to create JavaScript dates:</p> <div class=\"note\"> <p><strong>Note:</strong> parsing of date strings with the <code>Date</code> constructor (and <code>Date.parse</code>, they are equivalent) is strongly discouraged due to browser differences and inconsistencies.</p> </div> <pre data-language=\"js\">var today = new Date();\nvar birthday = new Date('December 17, 1995 03:24:00');\nvar birthday = new Date('1995-12-17T03:24:00');\nvar birthday = new Date(1995, 11, 17);\nvar birthday = new Date(1995, 11, 17, 3, 24, 0);\n</pre> <h3 id=\"Two_digit_years_map_to_1900_-_1999\">Two digit years map to 1900 - 1999</h3> <p>In order to create and get dates between the years 0 and 99 the <a href=\"date/setfullyear\"><code>Date.prototype.setFullYear()</code></a> and <a href=\"date/getfullyear\"><code>Date.prototype.getFullYear()</code></a> methods should be used.</p> <pre data-language=\"js\">var date = new Date(98, 1); // Sun Feb 01 1998 00:00:00 GMT+0000 (GMT)\n\n// Deprecated method, 98 maps to 1998 here as well\ndate.setYear(98);           // Sun Feb 01 1998 00:00:00 GMT+0000 (GMT)\n\ndate.setFullYear(98);       // Sat Feb 01 0098 00:00:00 GMT+0000 (BST)\n</pre> <h3 id=\"Calculating_elapsed_time\">Calculating elapsed time</h3> <p>The following examples show how to determine the elapsed time between two JavaScript dates in milliseconds.</p> <p>Due to the differing lengths of days (due to daylight saving changeover), months and years, expressing elapsed time in units greater than hours, minutes and seconds requires addressing a number of issues and should be thoroughly researched before being attempted.</p> <pre data-language=\"js\">// using Date objects\nvar start = Date.now();\n\n// the event to time goes here:\ndoSomethingForALongTime();\nvar end = Date.now();\nvar elapsed = end - start; // elapsed time in milliseconds\n</pre> <pre data-language=\"js\">// using built-in methods\nvar start = new Date();\n\n// the event to time goes here:\ndoSomethingForALongTime();\nvar end = new Date();\nvar elapsed = end.getTime() - start.getTime(); // elapsed time in milliseconds\n</pre> <pre data-language=\"js\">// to test a function and get back its return\nfunction printElapsedTime(fTest) {\n  var nStartTime = Date.now(),\n      vReturn = fTest(),\n      nEndTime = Date.now();\n\n  console.log('Elapsed time: ' + String(nEndTime - nStartTime) + ' milliseconds');\n  return vReturn;\n}\n\nvar yourFunctionReturn = printElapsedTime(yourFunction);\n</pre> <div class=\"note\"> <p><strong>Note:</strong> In browsers that support the <a href=\"https://developer.mozilla.org/en-US/docs/Web/API/Window/performance\">Web Performance API</a>'s high-resolution time feature, <a href=\"https://developer.mozilla.org/en-US/docs/Web/API/Performance/now\"><code>Performance.now()</code></a> can provide more reliable and precise measurements of elapsed time than <a href=\"date/now\"><code>Date.now()</code></a>.</p> </div> <h3 id=\"Get_the_number_of_seconds_since_Unix_Epoch\">Get the number of seconds since Unix Epoch</h3> <pre data-language=\"js\">var seconds = Math.floor(Date.now() / 1000);\n</pre> <p>In this case it's important to return only an integer (so a simple division won't do), and also to only return actually elapsed seconds (that's why this code uses <a href=\"math/floor\"><code>Math.floor()</code></a> and not <a href=\"math/round\"><code>Math.round()</code></a>).</p> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-date-objects\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Date' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-date-objects\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Date' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/5.1/#sec-15.9\" hreflang=\"en\">ECMAScript 5.1 (ECMA-262)<br><small>The definition of 'Date' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/publications/files/ECMA-ST-ARCH/ECMA-262,%201st%20edition,%20June%201997.pdf\" hreflang=\"en\">ECMAScript 1st Edition (ECMA-262)</a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition. Implemented in JavaScript 1.1.</td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes bc-has-history\"> Yes\n<section class=\"bc-history\" id=\"sect1\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> Yes\n</dt>\n<dd> The <a href=\"https://docs.microsoft.com/en-us/scripting/javascript/date-and-time-strings-javascript\">ISO8601 Date Format</a> is not supported in Internet Explorer 8.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Date/@@toPrimitive\"><code>@@toPrimitive</code></a></th>\n<td> ? </td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 44</td>\n<td> ? </td>\n<td> ? </td>\n<td> ? </td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Date/UTC\"><code>UTC</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Date/getDate\"><code>getDate</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Date/getDay\"><code>getDay</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Date/getFullYear\"><code>getFullYear</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Date/getHours\"><code>getHours</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Date/getMilliseconds\"><code>getMilliseconds</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Date/getMinutes\"><code>getMinutes</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Date/getMonth\"><code>getMonth</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Date/getSeconds\"><code>getSeconds</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Date/getTime\"><code>getTime</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Date/getTimezoneOffset\"><code>getTimezoneOffset</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> 5</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Date/getUTCDate\"><code>getUTCDate</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Date/getUTCDay\"><code>getUTCDay</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Date/getUTCFullYear\"><code>getUTCFullYear</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Date/getUTCHours\"><code>getUTCHours</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Date/getUTCMilliseconds\"><code>getUTCMilliseconds</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Date/getUTCMinutes\"><code>getUTCMinutes</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Date/getUTCMonth\"><code>getUTCMonth</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Date/getUTCSeconds\"><code>getUTCSeconds</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Date/getYear\"><code>getYear</code></a> \n</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Date/now\"><code>now</code></a></th>\n<td class=\"bc-supports-yes\"> 5</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 3</td>\n<td class=\"bc-supports-yes\"> 9</td>\n<td class=\"bc-supports-yes\"> 10.5</td>\n<td class=\"bc-supports-yes\"> 4</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Date/parse\"><code>parse</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<code>parse</code>: ISO 8601 format</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> 9</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Date/prototype\"><code>prototype</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<code>prototype</code>: Ordinary object (ES2015)</th>\n<td> ? </td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 41</td>\n<td> ? </td>\n<td> ? </td>\n<td> ? </td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Date/setDate\"><code>setDate</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Date/setFullYear\"><code>setFullYear</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Date/setHours\"><code>setHours</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Date/setMilliseconds\"><code>setMilliseconds</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Date/setMinutes\"><code>setMinutes</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Date/setMonth\"><code>setMonth</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Date/setSeconds\"><code>setSeconds</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Date/setTime\"><code>setTime</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Date/setUTCDate\"><code>setUTCDate</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Date/setUTCFullYear\"><code>setUTCFullYear</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Date/setUTCHours\"><code>setUTCHours</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Date/setUTCMilliseconds\"><code>setUTCMilliseconds</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Date/setUTCMinutes\"><code>setUTCMinutes</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Date/setUTCMonth\"><code>setUTCMonth</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Date/setUTCSeconds\"><code>setUTCSeconds</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Date/setYear\"><code>setYear</code></a> \n</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Date/toDateString\"><code>toDateString</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Date/toGMTString\"><code>toGMTString</code></a> \n</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Date/toISOString\"><code>toISOString</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> 9</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Date/toJSON\"><code>toJSON</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> 8</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Date/toLocaleDateString\"><code>toLocaleDateString</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><code>toLocaleDateString.locales</code></th>\n<td class=\"bc-supports-yes\"> 24</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 29</td>\n<td class=\"bc-supports-yes\"> 11</td>\n<td class=\"bc-supports-yes\"> 15</td>\n<td class=\"bc-supports-yes\"> 10</td>\n</tr>\n<tr>\n<th scope=\"row\"><code>toLocaleDateString.options</code></th>\n<td class=\"bc-supports-yes\"> 24</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 29</td>\n<td class=\"bc-supports-yes\"> 11</td>\n<td class=\"bc-supports-yes\"> 15</td>\n<td class=\"bc-supports-yes\"> 10</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<code>toLocaleDateString</code>: IANA time zone names in <code>timeZone</code> option</th>\n<td class=\"bc-supports-yes\"> 24</td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 52</td>\n<td> ? </td>\n<td> ? </td>\n<td> ? </td>\n</tr>\n<tr>\n<th scope=\"row\">\n<a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Date/toLocaleFormat\"><code>toLocaleFormat</code></a> \n</th>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\">1.5 — 58</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Date/toLocaleString\"><code>toLocaleString</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><code>toLocaleString.locales</code></th>\n<td class=\"bc-supports-yes\"> 24</td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 29</td>\n<td class=\"bc-supports-yes\"> 11</td>\n<td class=\"bc-supports-yes\"> 15</td>\n<td class=\"bc-supports-yes\"> 10</td>\n</tr>\n<tr>\n<th scope=\"row\"><code>toLocaleString.options</code></th>\n<td class=\"bc-supports-yes\"> 24</td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 29</td>\n<td class=\"bc-supports-yes\"> 11</td>\n<td class=\"bc-supports-yes\"> 15</td>\n<td class=\"bc-supports-yes\"> 10</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<code>toLocaleString</code>: IANA time zone names in <code>timeZone</code> option</th>\n<td class=\"bc-supports-yes\"> 24</td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 52</td>\n<td> ? </td>\n<td> ? </td>\n<td> ? </td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Date/toLocaleTimeString\"><code>toLocaleTimeString</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><code>toLocaleTimeString.locales</code></th>\n<td class=\"bc-supports-yes\"> 24</td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 29</td>\n<td class=\"bc-supports-yes\"> 11</td>\n<td class=\"bc-supports-yes\"> 15</td>\n<td class=\"bc-supports-yes\"> 10</td>\n</tr>\n<tr>\n<th scope=\"row\"><code>toLocaleTimeString.options</code></th>\n<td class=\"bc-supports-yes\"> 24</td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 29</td>\n<td class=\"bc-supports-yes\"> 11</td>\n<td class=\"bc-supports-yes\"> 15</td>\n<td class=\"bc-supports-yes\"> 10</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<code>toLocaleTimeString</code>: IANA time zone names in <code>timeZone</code> option</th>\n<td class=\"bc-supports-yes\"> 24</td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 52</td>\n<td> ? </td>\n<td> ? </td>\n<td> ? </td>\n</tr>\n<tr>\n<th scope=\"row\">\n<a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Date/toSource\"><code>toSource</code></a> \n</th>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Date/toString\"><code>toString</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Date/toTimeString\"><code>toTimeString</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Date/toUTCString\"><code>toUTCString</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Date/valueOf\"><code>valueOf</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n</tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Date/@@toPrimitive\"><code>@@toPrimitive</code></a></th>\n<td> ? </td>\n<td> ? </td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 44</td>\n<td> ? </td>\n<td> ? </td>\n<td> ? </td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Date/UTC\"><code>UTC</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Date/getDate\"><code>getDate</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Date/getDay\"><code>getDay</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Date/getFullYear\"><code>getFullYear</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Date/getHours\"><code>getHours</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Date/getMilliseconds\"><code>getMilliseconds</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Date/getMinutes\"><code>getMinutes</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Date/getMonth\"><code>getMonth</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Date/getSeconds\"><code>getSeconds</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Date/getTime\"><code>getTime</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Date/getTimezoneOffset\"><code>getTimezoneOffset</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Date/getUTCDate\"><code>getUTCDate</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Date/getUTCDay\"><code>getUTCDay</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Date/getUTCFullYear\"><code>getUTCFullYear</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Date/getUTCHours\"><code>getUTCHours</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Date/getUTCMilliseconds\"><code>getUTCMilliseconds</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Date/getUTCMinutes\"><code>getUTCMinutes</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Date/getUTCMonth\"><code>getUTCMonth</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Date/getUTCSeconds\"><code>getUTCSeconds</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Date/getYear\"><code>getYear</code></a> \n</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Date/now\"><code>now</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Date/parse\"><code>parse</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<code>parse</code>: ISO 8601 format</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Date/prototype\"><code>prototype</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<code>prototype</code>: Ordinary object (ES2015)</th>\n<td> ? </td>\n<td> ? </td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 41</td>\n<td> ? </td>\n<td> ? </td>\n<td> ? </td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Date/setDate\"><code>setDate</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Date/setFullYear\"><code>setFullYear</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Date/setHours\"><code>setHours</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Date/setMilliseconds\"><code>setMilliseconds</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Date/setMinutes\"><code>setMinutes</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Date/setMonth\"><code>setMonth</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Date/setSeconds\"><code>setSeconds</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Date/setTime\"><code>setTime</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Date/setUTCDate\"><code>setUTCDate</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Date/setUTCFullYear\"><code>setUTCFullYear</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Date/setUTCHours\"><code>setUTCHours</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Date/setUTCMilliseconds\"><code>setUTCMilliseconds</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Date/setUTCMinutes\"><code>setUTCMinutes</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Date/setUTCMonth\"><code>setUTCMonth</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Date/setUTCSeconds\"><code>setUTCSeconds</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Date/setYear\"><code>setYear</code></a> \n</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Date/toDateString\"><code>toDateString</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Date/toGMTString\"><code>toGMTString</code></a> \n</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Date/toISOString\"><code>toISOString</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Date/toJSON\"><code>toJSON</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Date/toLocaleDateString\"><code>toLocaleDateString</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><code>toLocaleDateString.locales</code></th>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 26</td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 56</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 10</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><code>toLocaleDateString.options</code></th>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 26</td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 56</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 10</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<code>toLocaleDateString</code>: IANA time zone names in <code>timeZone</code> option</th>\n<td> ? </td>\n<td> ? </td>\n<td> ? </td>\n<td class=\"bc-supports-no\"> No</td>\n<td> ? </td>\n<td> ? </td>\n<td> ? </td>\n</tr>\n<tr>\n<th scope=\"row\">\n<a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Date/toLocaleFormat\"><code>toLocaleFormat</code></a> \n</th>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\">4 — 58</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Date/toLocaleString\"><code>toLocaleString</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><code>toLocaleString.locales</code></th>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 26</td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 56</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 10</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><code>toLocaleString.options</code></th>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 26</td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 56</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 10</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<code>toLocaleString</code>: IANA time zone names in <code>timeZone</code> option</th>\n<td> ? </td>\n<td> ? </td>\n<td> ? </td>\n<td class=\"bc-supports-no\"> No</td>\n<td> ? </td>\n<td> ? </td>\n<td> ? </td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Date/toLocaleTimeString\"><code>toLocaleTimeString</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><code>toLocaleTimeString.locales</code></th>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 26</td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 56</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 10</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><code>toLocaleTimeString.options</code></th>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 26</td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 56</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 10</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<code>toLocaleTimeString</code>: IANA time zone names in <code>timeZone</code> option</th>\n<td> ? </td>\n<td> ? </td>\n<td> ? </td>\n<td class=\"bc-supports-no\"> No</td>\n<td> ? </td>\n<td> ? </td>\n<td> ? </td>\n</tr>\n<tr>\n<th scope=\"row\">\n<a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Date/toSource\"><code>toSource</code></a> \n</th>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Date/toString\"><code>toString</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Date/toTimeString\"><code>toTimeString</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Date/toUTCString\"><code>toUTCString</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Date/valueOf\"><code>valueOf</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n</tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Date/@@toPrimitive\"><code>@@toPrimitive</code></a></th>\n<td class=\"bc-supports-yes\"> 6.0.0</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Date/UTC\"><code>UTC</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Date/getDate\"><code>getDate</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Date/getDay\"><code>getDay</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Date/getFullYear\"><code>getFullYear</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Date/getHours\"><code>getHours</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Date/getMilliseconds\"><code>getMilliseconds</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Date/getMinutes\"><code>getMinutes</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Date/getMonth\"><code>getMonth</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Date/getSeconds\"><code>getSeconds</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Date/getTime\"><code>getTime</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Date/getTimezoneOffset\"><code>getTimezoneOffset</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Date/getUTCDate\"><code>getUTCDate</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Date/getUTCDay\"><code>getUTCDay</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Date/getUTCFullYear\"><code>getUTCFullYear</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Date/getUTCHours\"><code>getUTCHours</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Date/getUTCMilliseconds\"><code>getUTCMilliseconds</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Date/getUTCMinutes\"><code>getUTCMinutes</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Date/getUTCMonth\"><code>getUTCMonth</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Date/getUTCSeconds\"><code>getUTCSeconds</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Date/getYear\"><code>getYear</code></a> \n</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Date/now\"><code>now</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Date/parse\"><code>parse</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<code>parse</code>: ISO 8601 format</th>\n<td> ? </td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Date/prototype\"><code>prototype</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<code>prototype</code>: Ordinary object (ES2015)</th>\n<td> ? </td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Date/setDate\"><code>setDate</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Date/setFullYear\"><code>setFullYear</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Date/setHours\"><code>setHours</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Date/setMilliseconds\"><code>setMilliseconds</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Date/setMinutes\"><code>setMinutes</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Date/setMonth\"><code>setMonth</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Date/setSeconds\"><code>setSeconds</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Date/setTime\"><code>setTime</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Date/setUTCDate\"><code>setUTCDate</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Date/setUTCFullYear\"><code>setUTCFullYear</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Date/setUTCHours\"><code>setUTCHours</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Date/setUTCMilliseconds\"><code>setUTCMilliseconds</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Date/setUTCMinutes\"><code>setUTCMinutes</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Date/setUTCMonth\"><code>setUTCMonth</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Date/setUTCSeconds\"><code>setUTCSeconds</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Date/setYear\"><code>setYear</code></a> \n</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Date/toDateString\"><code>toDateString</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Date/toGMTString\"><code>toGMTString</code></a> \n</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Date/toISOString\"><code>toISOString</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Date/toJSON\"><code>toJSON</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Date/toLocaleDateString\"><code>toLocaleDateString</code></a></th>\n<td> ? </td>\n</tr>\n<tr>\n<th scope=\"row\"><code>toLocaleDateString.locales</code></th>\n<td> ? </td>\n</tr>\n<tr>\n<th scope=\"row\"><code>toLocaleDateString.options</code></th>\n<td> ? </td>\n</tr>\n<tr>\n<th scope=\"row\">\n<code>toLocaleDateString</code>: IANA time zone names in <code>timeZone</code> option</th>\n<td> ? </td>\n</tr>\n<tr>\n<th scope=\"row\">\n<a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Date/toLocaleFormat\"><code>toLocaleFormat</code></a> \n</th>\n<td class=\"bc-supports-no\"> No</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Date/toLocaleString\"><code>toLocaleString</code></a></th>\n<td> ? </td>\n</tr>\n<tr>\n<th scope=\"row\"><code>toLocaleString.locales</code></th>\n<td> ? </td>\n</tr>\n<tr>\n<th scope=\"row\"><code>toLocaleString.options</code></th>\n<td> ? </td>\n</tr>\n<tr>\n<th scope=\"row\">\n<code>toLocaleString</code>: IANA time zone names in <code>timeZone</code> option</th>\n<td> ? </td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Date/toLocaleTimeString\"><code>toLocaleTimeString</code></a></th>\n<td> ? </td>\n</tr>\n<tr>\n<th scope=\"row\"><code>toLocaleTimeString.locales</code></th>\n<td> ? </td>\n</tr>\n<tr>\n<th scope=\"row\"><code>toLocaleTimeString.options</code></th>\n<td> ? </td>\n</tr>\n<tr>\n<th scope=\"row\">\n<code>toLocaleTimeString</code>: IANA time zone names in <code>timeZone</code> option</th>\n<td> ? </td>\n</tr>\n<tr>\n<th scope=\"row\">\n<a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Date/toSource\"><code>toSource</code></a> \n</th>\n<td class=\"bc-supports-no\"> No</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Date/toString\"><code>toString</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Date/toTimeString\"><code>toTimeString</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Date/toUTCString\"><code>toUTCString</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Date/valueOf\"><code>valueOf</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n</tbody>\n</table>\n</div><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date</a>\n  </p>\n</div>\n","operators/operator_precedence":"<h1>Operator Precedence</h1> <p>Operator precedence determines the way in which operators are parsed with respect to each other. Operators with higher precedence become the operands of operators with lower precedence.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/expressions-operatorprecedence.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Associativity\">Associativity</h2> <p>Associativity determines the way in which operators of the same precedence are parsed. For example, consider an expression:</p> <pre class=\"syntaxbox\">a OP b OP c\n</pre> <p>Left-associativity (left-to-right) means that it is processed as <code>(a OP b) OP c</code>, while right-associativity (right-to-left) means it is interpreted as <code>a OP (b OP c)</code>. Assignment operators are right-associative, so you can write:</p> <pre data-language=\"js\">a = b = 5;\n</pre> <p>with the expected result that <code>a</code> and <code>b</code> get the value 5. This is because the assignment operator returns the value that is assigned. First, <code>b</code> is set to 5. Then the <code>a</code> is also set to 5, the return value of <code>b = 5</code>, aka right operand of the assignment.</p> <h2 id=\"Table\">Table</h2> <p>The following table is ordered from highest (20) to lowest (1) precedence.</p> <div class=\"_table\"><table class=\"fullwidth-table\"> <tbody> <tr> <th>Precedence</th> <th>Operator type</th> <th>Associativity</th> <th>Individual operators</th> </tr> <tr> <td>20</td> <td><a href=\"grouping\"><code>Grouping</code></a></td> <td>n/a</td> <td><code>( … )</code></td> </tr> <tr> <td colspan=\"1\" rowspan=\"4\">19</td> <td><a href=\"property_accessors#Dot_notation\"><code>Member Access</code></a></td> <td>left-to-right</td> <td><code>… . …</code></td> </tr> <tr> <td><a href=\"property_accessors#Bracket_notation\"><code>Computed Member Access</code></a></td> <td>left-to-right</td> <td><code>… [ … ]</code></td> </tr> <tr> <td>\n<a href=\"new\"><code>new</code></a> (with argument list)</td> <td>n/a</td> <td><code>new … ( … )</code></td> </tr> <tr> <td><a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Functions\">Function Call</a></td> <td>left-to-right</td> <td><code>… ( <var>… </var>)</code></td> </tr> <tr> <td rowspan=\"1\">18</td> <td>\n<a href=\"new\"><code>new</code></a> (without argument list)</td> <td>right-to-left</td> <td><code>new …</code></td> </tr> <tr> <td rowspan=\"2\">17</td> <td><a href=\"arithmetic_operators#Increment\"><code>Postfix Increment</code></a></td> <td colspan=\"1\" rowspan=\"2\">n/a</td> <td><code>… ++</code></td> </tr> <tr> <td><a href=\"arithmetic_operators#Decrement\"><code>Postfix Decrement</code></a></td> <td><code>… --</code></td> </tr> <tr> <td colspan=\"1\" rowspan=\"10\">16</td> <td><a href=\"logical_operators#Logical_NOT\">Logical NOT</a></td> <td colspan=\"1\" rowspan=\"10\">right-to-left</td> <td><code>! …</code></td> </tr> <tr> <td><a href=\"bitwise_operators#Bitwise_NOT\">Bitwise NOT</a></td> <td><code>~ …</code></td> </tr> <tr> <td><a href=\"arithmetic_operators#Unary_plus\">Unary Plus</a></td> <td><code>+ …</code></td> </tr> <tr> <td><a href=\"arithmetic_operators#Unary_negation\">Unary Negation</a></td> <td><code>- …</code></td> </tr> <tr> <td><a href=\"arithmetic_operators#Increment\">Prefix Increment</a></td> <td><code>++ …</code></td> </tr> <tr> <td><a href=\"arithmetic_operators#Decrement\">Prefix Decrement</a></td> <td><code>-- …</code></td> </tr> <tr> <td><a href=\"typeof\">typeof</a></td> <td><code>typeof …</code></td> </tr> <tr> <td><a href=\"void\">void</a></td> <td><code>void …</code></td> </tr> <tr> <td><a href=\"delete\">delete</a></td> <td><code>delete …</code></td> </tr> <tr> <td><a href=\"await\">await</a></td> <td><code>await …</code></td> </tr> <tr> <td>15</td> <td><a href=\"arithmetic_operators#Exponentiation\">Exponentiation</a></td> <td>right-to-left</td> <td><code>… ** …</code></td> </tr> <tr> <td rowspan=\"3\">14</td> <td><a href=\"arithmetic_operators#Multiplication\">Multiplication</a></td> <td colspan=\"1\" rowspan=\"3\">left-to-right</td> <td><code>… * …</code></td> </tr> <tr> <td><a href=\"arithmetic_operators#Division\">Division</a></td> <td><code>… / …</code></td> </tr> <tr> <td><a href=\"arithmetic_operators#Remainder\">Remainder</a></td> <td><code>… % …</code></td> </tr> <tr> <td rowspan=\"2\">13</td> <td><a href=\"arithmetic_operators#Addition\">Addition</a></td> <td colspan=\"1\" rowspan=\"2\">left-to-right</td> <td><code>… + …</code></td> </tr> <tr> <td><a href=\"arithmetic_operators#Subtraction\">Subtraction</a></td> <td><code>… - …</code></td> </tr> <tr> <td rowspan=\"3\">12</td> <td><a href=\"bitwise_operators\">Bitwise Left Shift</a></td> <td colspan=\"1\" rowspan=\"3\">left-to-right</td> <td><code>… &lt;&lt; …</code></td> </tr> <tr> <td><a href=\"bitwise_operators\">Bitwise Right Shift</a></td> <td><code>… &gt;&gt; …</code></td> </tr> <tr> <td><a href=\"bitwise_operators\">Bitwise Unsigned Right Shift</a></td> <td><code>… &gt;&gt;&gt; …</code></td> </tr> <tr> <td rowspan=\"6\">11</td> <td><a href=\"comparison_operators#Less_than_operator\">Less Than</a></td> <td colspan=\"1\" rowspan=\"6\">left-to-right</td> <td><code>… &lt; …</code></td> </tr> <tr> <td><a href=\"comparison_operators#Less_than__or_equal_operator\">Less Than Or Equal</a></td> <td><code>… &lt;= …</code></td> </tr> <tr> <td><a href=\"comparison_operators#Greater_than_operator\">Greater Than</a></td> <td><code>… &gt; …</code></td> </tr> <tr> <td><a href=\"comparison_operators#Greater_than_or_equal_operator\">Greater Than Or Equal</a></td> <td><code>… &gt;= …</code></td> </tr> <tr> <td><a href=\"in\">in</a></td> <td><code>… in …</code></td> </tr> <tr> <td><a href=\"instanceof\">instanceof</a></td> <td><code>… instanceof …</code></td> </tr> <tr> <td rowspan=\"4\">10</td> <td><a href=\"comparison_operators#Equality\">Equality</a></td> <td colspan=\"1\" rowspan=\"4\">left-to-right</td> <td><code>… == …</code></td> </tr> <tr> <td><a href=\"comparison_operators#Inequality\">Inequality</a></td> <td><code>… != …</code></td> </tr> <tr> <td><a href=\"comparison_operators#Identity\">Strict Equality</a></td> <td><code>… === …</code></td> </tr> <tr> <td><a href=\"comparison_operators#Nonidentity\">Strict Inequality</a></td> <td><code>… !== …</code></td> </tr> <tr> <td>9</td> <td><a href=\"bitwise_operators#Bitwise_AND\">Bitwise AND</a></td> <td>left-to-right</td> <td><code>… &amp; …</code></td> </tr> <tr> <td>8</td> <td><a href=\"bitwise_operators#Bitwise_XOR\">Bitwise XOR</a></td> <td>left-to-right</td> <td><code>… ^ …</code></td> </tr> <tr> <td>7</td> <td><a href=\"bitwise_operators#Bitwise_OR\">Bitwise OR</a></td> <td>left-to-right</td> <td><code>… | …</code></td> </tr> <tr> <td>6</td> <td><a href=\"logical_operators#Logical_AND\">Logical AND</a></td> <td>left-to-right</td> <td><code>… &amp;&amp; …</code></td> </tr> <tr> <td>5</td> <td><a href=\"logical_operators#Logical_OR\">Logical OR</a></td> <td>left-to-right</td> <td><code>… || …</code></td> </tr> <tr> <td>4</td> <td><a href=\"conditional_operator\">Conditional</a></td> <td>right-to-left</td> <td><code>… ? … : …</code></td> </tr> <tr> <td rowspan=\"13\">3</td> <td rowspan=\"13\"><a href=\"assignment_operators\">Assignment</a></td> <td rowspan=\"13\">right-to-left</td> <td><code>… = …</code></td> </tr> <tr> <td><code>… += …</code></td> </tr> <tr> <td><code>… -= …</code></td> </tr> <tr> <td><code>… **= …</code></td> </tr> <tr> <td><code>… *= …</code></td> </tr> <tr> <td><code>… /= …</code></td> </tr> <tr> <td><code>… %= …</code></td> </tr> <tr> <td><code>… &lt;&lt;= …</code></td> </tr> <tr> <td><code>… &gt;&gt;= …</code></td> </tr> <tr> <td><code>… &gt;&gt;&gt;= …</code></td> </tr> <tr> <td><code>… &amp;= …</code></td> </tr> <tr> <td><code>… ^= …</code></td> </tr> <tr> <td><code>… |= …</code></td> </tr> <tr> <td rowspan=\"2\">2</td> <td><a href=\"yield\">yield</a></td> <td colspan=\"1\" rowspan=\"2\">right-to-left</td> <td><code>yield …</code></td> </tr> <tr> <td><a href=\"yield*\">yield*</a></td> <td><code>yield* …</code></td> </tr> <tr> <td>1</td> <td><a href=\"comma_operator\">Comma / Sequence</a></td> <td>left-to-right</td> <td><code>… , …</code></td> </tr> </tbody> </table></div><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Operator_Precedence$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Operator_Precedence\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Operator_Precedence</a>\n  </p>\n</div>\n","operators/class":"<h1>class</h1> <p>The <strong>class expression</strong> is one way to define a class in ECMAScript 2015. Similar to <a href=\"function\">function expressions</a>, class expressions can be named or unnamed. If named, the name of the class is local to the class body only. JavaScript classes use prototype-based inheritance.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/expressions-classexpression.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\">var MyClass = class <em>[className]</em> [extends] {\n  // class body\n};</pre> <h2 id=\"Description\">Description</h2> <p>A class expression has a similar syntax to a <a href=\"../statements/class\">class statement (declaration)</a>. However, with class expressions, you are able to omit the class name (\"binding identifier\"), which you can't with class statements. Additionally, class expressions allow you to redefine/re-declare classes and <strong>don't throw</strong> any type errors like <a href=\"../statements/class\">class declaration</a>. The constructor property is optional. And, <em>typeof </em>the classes generated using this keyword will always be \"function\".</p> <p>Just like with class statements, the class body of class expressions is executed in <a href=\"../strict_mode\">strict mode</a>.</p> <pre data-language=\"js\">'use strict';\nvar Foo = class {}; // constructor property is optional\nvar Foo = class {}; // Re-declaration is allowed\n\ntypeof Foo; //returns \"function\"\ntypeof class {}; //returns \"function\"\n\nFoo instanceof Object; // true\nFoo instanceof Function; // true\nclass Foo {}; // Throws TypeError, doesn't allow re-declaration\n</pre> <h2 id=\"Examples\">Examples</h2> <h3 id=\"A_simple_class_expression\">A simple class expression</h3> <p>This is just a simple anonymous class expression which you can refer to using the variable \"Foo\".</p> <pre data-language=\"js\">var Foo = class {\n  constructor() {}\n  bar() {\n    return 'Hello World!';\n  }\n};\n\nvar instance = new Foo();\ninstance.bar(); // \"Hello World!\"\nFoo.name; // \"Foo\"\n</pre> <h3 id=\"Named_class_expressions\">Named class expressions</h3> <p>If you want to refer to the current class inside the class body, you can create a named class expression. This name is only visible in the scope of the class expression itself.</p> <pre data-language=\"js\">var Foo = class NamedFoo {\n  constructor() {}\n  whoIsThere() {\n    return NamedFoo.name;\n  }\n}\nvar bar = new Foo();\nbar.whoIsThere(); // \"NamedFoo\"\nNamedFoo.name; // ReferenceError: NamedFoo is not defined\nFoo.name; // \"NamedFoo\"\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-class-definitions\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Class definitions' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/7.0/#sec-class-definitions\" hreflang=\"en\">ECMAScript 2016 (ECMA-262)<br><small>The definition of 'Class definitions' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/8.0/#sec-class-definitions\" hreflang=\"en\">ECMAScript 2017 (ECMA-262)<br><small>The definition of 'Class definitions' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-class-definitions\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Class definitions' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 42</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 45</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 42</td>\n<td class=\"bc-supports-yes\"> 42</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 45</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4.0</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes bc-has-history\"> 6.0.0\n<section class=\"bc-history\" id=\"sect1\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 6.0.0\n</dt>\n\n<dt class=\"bc-supports-yes bc-supports\"> 5.0.0<div class=\"bc-icons\">Disabled </div>\n</dt>\n<dd>Disabled From version 5.0.0: this feature is behind the <code>--harmony</code> runtime flag.</dd>\n</dl></section>\n</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"function\"><code>function</code> expression</a></li> <li><a href=\"../statements/class\"><code>class</code> statement</a></li> <li><a href=\"../classes\">Classes</a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/class$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/class\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/class</a>\n  </p>\n</div>\n","operators/assignment_operators":"<h1>Assignment Operators</h1> <p>An <strong>assignment operator</strong> assigns a value to its left operand based on the value of its right operand.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/expressions-assignment.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Overview\">Overview</h2> <p>The basic assignment operator is equal (<code>=</code>), which assigns the value of its right operand to its left operand. That is, <code>x = y</code> assigns the value of <code>y</code> to <code>x</code>. The other assignment operators are usually shorthand for standard operations, as shown in the following definitions and examples.</p> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th>Name</th> <th>Shorthand operator</th> <th>Meaning</th> </tr> <tr> <td><a href=\"#Assignment\">Assignment</a></td> <td><code>x = y</code></td> <td><code>x = y</code></td> </tr> <tr> <td><a href=\"#Addition_assignment\">Addition assignment</a></td> <td><code>x += y</code></td> <td><code>x = x + y</code></td> </tr> <tr> <td><a href=\"#Subtraction_assignment\">Subtraction assignment</a></td> <td><code>x -= y</code></td> <td><code>x = x - y</code></td> </tr> <tr> <td><a href=\"#Multiplication_assignment\">Multiplication assignment</a></td> <td><code>x *= y</code></td> <td><code>x = x * y</code></td> </tr> <tr> <td><a href=\"#Division_assignment\">Division assignment</a></td> <td><code>x /= y</code></td> <td><code>x = x / y</code></td> </tr> <tr> <td><a href=\"#Remainder_assignment\">Remainder assignment</a></td> <td><code>x %= y</code></td> <td><code>x = x % y</code></td> </tr> <tr> <td><a href=\"#Exponentiation_assignment\">Exponentiation assignment</a></td> <td><code>x **= y</code></td> <td><code>x = x ** y</code></td> </tr> <tr> <td><a href=\"#Left_shift_assignment\">Left shift assignment</a></td> <td><code>x &lt;&lt;= y</code></td> <td><code>x = x &lt;&lt; y</code></td> </tr> <tr> <td><a href=\"#Right_shift_assignment\">Right shift assignment</a></td> <td><code>x &gt;&gt;= y</code></td> <td><code>x = x &gt;&gt; y</code></td> </tr> <tr> <td><a href=\"#Unsigned_right_shift_assignment\">Unsigned right shift assignment</a></td> <td><code>x &gt;&gt;&gt;= y</code></td> <td><code>x = x &gt;&gt;&gt; y</code></td> </tr> <tr> <td><a href=\"#Bitwise_AND_assignment\">Bitwise AND assignment</a></td> <td><code>x &amp;= y</code></td> <td><code>x = x &amp; y</code></td> </tr> <tr> <td><a href=\"#Bitwise_XOR_assignment\">Bitwise XOR assignment</a></td> <td><code>x ^= y</code></td> <td><code>x = x ^ y</code></td> </tr> <tr> <td><a href=\"#Bitwise_OR_assignment\">Bitwise OR assignment</a></td> <td><code>x |= y</code></td> <td><code>x = x | y</code></td> </tr> </tbody> </table></div> <h2 id=\"Assignment\">Assignment</h2> <p>Simple assignment operator is used to assign a value to a variable. The assignment operation evaluates to the assigned value. Chaining the assignment operator is possible in order to assign a single value to multiple variables. See the example.</p> <h4 id=\"Syntax\">Syntax</h4> <pre class=\"syntaxbox\"><strong>Operator:</strong> x = y\n</pre> <h4 id=\"Examples\">Examples</h4> <pre data-language=\"js\">// Assuming the following variables\n//  x = 5\n//  y = 10\n//  z = 25\n\nx = y     // x is 10\nx = y = z // x, y and z are all 25\n</pre> <h3 id=\"Addition_assignment\">Addition assignment</h3> <p>The addition assignment operator <strong>adds</strong> the value of the right operand to a variable and assigns the result to the variable. The types of the two operands determine the behavior of the addition assignment operator. Addition or concatenation is possible. See the <a href=\"arithmetic_operators#Addition\">addition operator</a> for more details.</p> <h4 id=\"Syntax_2\">Syntax</h4> <pre class=\"syntaxbox\"><strong>Operator:</strong> x += y \n<strong>Meaning:</strong>  x  = x + y\n</pre> <h4 id=\"Examples_2\">Examples</h4> <pre data-language=\"js\">// Assuming the following variables\n//  foo = 'foo'\n//  bar = 5\n//  baz = true\n\n\n// Number + Number -&gt; addition\nbar += 2 // 7\n\n// Boolean + Number -&gt; addition\nbaz += 1 // 2\n\n// Boolean + Boolean -&gt; addition\nbaz += false // 1\n\n// Number + String -&gt; concatenation\nbar += 'foo' // \"5foo\"\n\n// String + Boolean -&gt; concatenation\nfoo += false // \"foofalse\"\n\n// String + String -&gt; concatenation\nfoo += 'bar' // \"foobar\"\n</pre> <h3 id=\"Subtraction_assignment\">Subtraction assignment</h3> <p>The subtraction assignment operator <strong>subtracts</strong> the value of the right operand from a variable and assigns the result to the variable. See the <a href=\"arithmetic_operators#Subtraction\">subtraction operator</a> for more details.</p> <h4 id=\"Syntax_3\">Syntax</h4> <pre class=\"syntaxbox\"><strong>Operator:</strong> x -= y \n<strong>Meaning:</strong>  x  = x - y\n</pre> <h4 id=\"Examples_3\">Examples</h4> <pre data-language=\"js\">// Assuming the following variable\n//  bar = 5\n\nbar -= 2     // 3\nbar -= 'foo' // NaN\n</pre> <h3 id=\"Multiplication_assignment\">Multiplication assignment</h3> <p>The multiplication assignment operator <strong>multiplies</strong> a variable by the value of the right operand and assigns the result to the variable. See the <a href=\"arithmetic_operators#Multiplication\">multiplication operator</a> for more details.</p> <h4 id=\"Syntax_4\">Syntax</h4> <pre class=\"syntaxbox\"><strong>Operator:</strong> x *= y \n<strong>Meaning:</strong>  x  = x * y\n</pre> <h4 id=\"Examples_4\">Examples</h4> <pre data-language=\"js\">// Assuming the following variable\n//  bar = 5\n\nbar *= 2     // 10\nbar *= 'foo' // NaN\n</pre> <h3 id=\"Division_assignment\">Division assignment</h3> <p>The division assignment operator <strong>divides</strong> a variable by the value of the right operand and assigns the result to the variable. See the <a href=\"arithmetic_operators#Division\">division operator</a> for more details.</p> <h4 id=\"Syntax_5\">Syntax</h4> <pre class=\"syntaxbox\"><strong>Operator:</strong> x /= y \n<strong>Meaning:</strong>  x  = x / y\n</pre> <h4 id=\"Examples_5\">Examples</h4> <pre data-language=\"js\">// Assuming the following variable\n//  bar = 5\n\nbar /= 2     // 2.5\nbar /= 'foo' // NaN\nbar /= 0     // Infinity\n</pre> <h3 id=\"Remainder_assignment\">Remainder assignment</h3> <p>The remainder assignment operator <strong>divides</strong> a variable by the value of the right operand and assigns the <strong>remainder</strong> to the variable. See the <a href=\"arithmetic_operators#Remainder\">remainder operator</a> for more details.</p> <h4 id=\"Syntax_6\">Syntax</h4> <pre class=\"syntaxbox\"><strong>Operator:</strong> x %= y \n<strong>Meaning:</strong>  x  = x % y\n</pre> <h4 id=\"Examples_6\">Examples</h4> <pre data-language=\"js\">// Assuming the following variable\n//  bar = 5\n\nbar %= 2     // 1\nbar %= 'foo' // NaN\nbar %= 0     // NaN\n</pre> <h3 id=\"Exponentiation_assignment\">Exponentiation assignment</h3> <p>The exponentiation assignment operator evaluates to the result of raising first operand to the <strong>power</strong> second operand. See the <a href=\"arithmetic_operators#Exponentiation\">exponentiation operator</a> for more details.</p> <h4 id=\"Syntax_7\">Syntax</h4> <pre class=\"syntaxbox\"><strong>Operator:</strong> x **= y \n<strong>Meaning:</strong>  x  = x ** y\n</pre> <h4 id=\"Examples_7\">Examples</h4> <pre data-language=\"js\">// Assuming the following variable\n//  bar = 5\n\nbar **= 2     // 25\nbar **= 'foo' // NaN</pre> <h3 id=\"Left_shift_assignment\">Left shift assignment</h3> <p>The left shift assignment operator moves the specified amount of bits to the left and assigns the result to the variable. See the <a href=\"bitwise_operators#Left_shift\">left shift operator</a> for more details.</p> <h4 id=\"Syntax_8\">Syntax</h4> <pre class=\"syntaxbox\"><strong>Operator:</strong> x &lt;&lt;= y \n<strong>Meaning:</strong>  x   = x &lt;&lt; y\n</pre> <h4 id=\"Examples_8\">Examples</h4> <pre data-language=\"js\">var bar = 5; //  (00000000000000000000000000000101)\nbar &lt;&lt;= 2; // 20 (00000000000000000000000000010100)\n</pre> <h3 id=\"Right_shift_assignment\">Right shift assignment</h3> <p>The right shift assignment operator moves the specified amount of bits to the right and assigns the result to the variable. See the <a href=\"bitwise_operators#Right_shift\">right shift operator</a> for more details.</p> <h4 id=\"Syntax_9\">Syntax</h4> <pre class=\"syntaxbox\"><strong>Operator:</strong> x &gt;&gt;= y \n<strong>Meaning:</strong>  x   = x &gt;&gt; y\n</pre> <h4 id=\"Examples_9\">Examples</h4> <pre data-language=\"js\">var bar = 5; //   (00000000000000000000000000000101)\nbar &gt;&gt;= 2;   // 1 (00000000000000000000000000000001)\n\nvar bar = -5; //    (-00000000000000000000000000000101)\nbar &gt;&gt;= 2;  // -2 (-00000000000000000000000000000010)\n</pre> <h3 id=\"Unsigned_right_shift_assignment\">Unsigned right shift assignment</h3> <p>The unsigned right shift assignment operator moves the specified amount of bits to the right and assigns the result to the variable. See the <a href=\"bitwise_operators#Unsigned_right_shift\"> unsigned right shift operator</a> for more details.</p> <h4 id=\"Syntax_10\">Syntax</h4> <pre class=\"syntaxbox\"><strong>Operator:</strong> x &gt;&gt;&gt;= y \n<strong>Meaning:</strong>  x    = x &gt;&gt;&gt; y\n</pre> <h4 id=\"Examples_10\">Examples</h4> <pre data-language=\"js\">var bar = 5; //   (00000000000000000000000000000101)\nbar &gt;&gt;&gt;= 2;  // 1 (00000000000000000000000000000001)\n\nvar bar = -5; // (-00000000000000000000000000000101)\nbar &gt;&gt;&gt;= 2; // 1073741822 (00111111111111111111111111111110)</pre> <h3 id=\"Bitwise_AND_assignment\">Bitwise AND assignment</h3> <p>The bitwise AND assignment operator uses the binary representation of both operands, does a bitwise AND operation on them and assigns the result to the variable. See the <a href=\"bitwise_operators#Bitwise_AND\">bitwise AND operator</a> for more details.</p> <h4 id=\"Syntax_11\">Syntax</h4> <pre class=\"syntaxbox\"><strong>Operator:</strong> x &amp;= y \n<strong>Meaning:</strong>  x  = x &amp; y\n</pre> <h4 id=\"Example\">Example</h4> <pre data-language=\"js\">var bar = 5;\n// 5:     00000000000000000000000000000101\n// 2:     00000000000000000000000000000010\nbar &amp;= 2; // 0\n</pre> <h3 id=\"Bitwise_XOR_assignment\">Bitwise XOR assignment</h3> <p>The bitwise XOR assignment operator uses the binary representation of both operands, does a bitwise XOR operation on them and assigns the result to the variable. See the <a href=\"bitwise_operators#Bitwise_XOR\">bitwise XOR operator</a> for more details.</p> <h4 id=\"Syntax_12\">Syntax</h4> <pre class=\"syntaxbox\"><strong>Operator:</strong> x ^= y \n<strong>Meaning:</strong>  x  = x ^ y\n</pre> <h4 id=\"Example_2\">Example</h4> <pre data-language=\"js\">var bar = 5;\nbar ^= 2; // 7\n// 5: 00000000000000000000000000000101\n// 2: 00000000000000000000000000000010\n// -----------------------------------\n// 7: 00000000000000000000000000000111\n</pre> <h3 id=\"Bitwise_OR_assignment\">Bitwise OR assignment</h3> <p>The bitwise OR assignment operator uses the binary representation of both operands, does a bitwise OR operation on them and assigns the result to the variable. See the <a href=\"bitwise_operators#Bitwise_OR\">bitwise OR operator</a> for more details.</p> <h4 id=\"Syntax_13\">Syntax</h4> <pre class=\"syntaxbox\"><strong>Operator:</strong> x |= y \n<strong>Meaning:</strong>  x  = x | y\n</pre> <h4 id=\"Example_3\">Example</h4> <pre data-language=\"js\">var bar = 5;\nbar |= 2; // 7\n// 5: 00000000000000000000000000000101\n// 2: 00000000000000000000000000000010\n// -----------------------------------\n// 7: 00000000000000000000000000000111\n</pre> <h2 id=\"Examples_11\">Examples</h2> <h3 id=\"Left_operand_with_another_assignment_operator\">Left operand with another assignment operator</h3> <p>In unusual situations, the assignment operator (e.g.<code> x += y</code>) is not identical to the meaning expression (here <code>x = x + y</code>). When the left operand of an assignment operator itself contains an assignment operator, the left operand is evaluated only once. For example:</p> <pre data-language=\"js\">a[i++] += 5         // i is evaluated only once\na[i++] = a[i++] + 5 // i is evaluated twice\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-assignment-operators\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Assignment operators' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-assignment-operators\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Assignment operators' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/5.1/#sec-11.13\" hreflang=\"en\">ECMAScript 5.1 (ECMA-262)<br><small>The definition of 'Assignment operators' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/publications/files/ECMA-ST-ARCH/ECMA-262,%201st%20edition,%20June%201997.pdf#sec-11.13\" hreflang=\"en\">ECMAScript 1st Edition (ECMA-262)<br><small>The definition of 'Assignment operators' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Operators/Assignment_Operators#Addition_assignment\">Addition assignment (<code>x += y</code>)</a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Operators/Assignment_Operators#Bitwise_AND_assignment\">Bitwise AND assignment (<code>x &amp;= y</code>)</a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Operators/Assignment_Operators#Bitwise_OR_assignment\">Bitwise OR assignment (<code>x |= y</code>)</a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Operators/Assignment_Operators#Bitwise_XOR_assignment\">Bitwise XOR assignment (<code>x ^= y</code>)</a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Operators/Assignment_Operators#Division_assignment\">Division assignment (<code>x /= y</code>)</a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Operators/Assignment_Operators#Exponentiation_assignment\">Exponentiation assignment (<code>x **= y</code>)</a></th>\n<td class=\"bc-supports-yes\"> 52</td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 52</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 10.1</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Operators/Assignment_Operators#Left_shift_assignment\">Left shift assignment (<code>x &lt;&lt;= y</code>)</a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Operators/Assignment_Operators#Multiplication_assignment\">Multiplication assignment (<code>x *= y</code>)</a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Operators/Assignment_Operators#Remainder_assignment\">Remainder assignment (<code>x %= y</code>)</a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Operators/Assignment_Operators#Right_shift_assignment\">Right shift assignment (<code>x &gt;&gt;= y</code>)</a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Operators/Assignment_Operators#Assignment\">Assignment (<code>x = y</code>)</a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Operators/Assignment_Operators#Subtraction_assignment\">Subtraction assignment (<code>x -= y</code>)</a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Operators/Assignment_Operators#Unsigned_right_shift_assignment\">Unsigned right shift assignment (<code>x &gt;&gt;&gt;= y</code>)</a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n</tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Operators/Assignment_Operators#Addition_assignment\">Addition assignment (<code>x += y</code>)</a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Operators/Assignment_Operators#Bitwise_AND_assignment\">Bitwise AND assignment (<code>x &amp;= y</code>)</a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Operators/Assignment_Operators#Bitwise_OR_assignment\">Bitwise OR assignment (<code>x |= y</code>)</a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Operators/Assignment_Operators#Bitwise_XOR_assignment\">Bitwise XOR assignment (<code>x ^= y</code>)</a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Operators/Assignment_Operators#Division_assignment\">Division assignment (<code>x /= y</code>)</a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Operators/Assignment_Operators#Exponentiation_assignment\">Exponentiation assignment (<code>x **= y</code>)</a></th>\n<td class=\"bc-supports-yes\"> 51</td>\n<td class=\"bc-supports-yes\"> 52</td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 52</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 10.1</td>\n<td class=\"bc-supports-yes\"> 6.0</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Operators/Assignment_Operators#Left_shift_assignment\">Left shift assignment (<code>x &lt;&lt;= y</code>)</a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Operators/Assignment_Operators#Multiplication_assignment\">Multiplication assignment (<code>x *= y</code>)</a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Operators/Assignment_Operators#Remainder_assignment\">Remainder assignment (<code>x %= y</code>)</a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Operators/Assignment_Operators#Right_shift_assignment\">Right shift assignment (<code>x &gt;&gt;= y</code>)</a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Operators/Assignment_Operators#Assignment\">Assignment (<code>x = y</code>)</a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Operators/Assignment_Operators#Subtraction_assignment\">Subtraction assignment (<code>x -= y</code>)</a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Operators/Assignment_Operators#Unsigned_right_shift_assignment\">Unsigned right shift assignment (<code>x &gt;&gt;&gt;= y</code>)</a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n</tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Operators/Assignment_Operators#Addition_assignment\">Addition assignment (<code>x += y</code>)</a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Operators/Assignment_Operators#Bitwise_AND_assignment\">Bitwise AND assignment (<code>x &amp;= y</code>)</a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Operators/Assignment_Operators#Bitwise_OR_assignment\">Bitwise OR assignment (<code>x |= y</code>)</a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Operators/Assignment_Operators#Bitwise_XOR_assignment\">Bitwise XOR assignment (<code>x ^= y</code>)</a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Operators/Assignment_Operators#Division_assignment\">Division assignment (<code>x /= y</code>)</a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Operators/Assignment_Operators#Exponentiation_assignment\">Exponentiation assignment (<code>x **= y</code>)</a></th>\n<td class=\"bc-supports-yes bc-has-history\"> 7.0.0\n<section class=\"bc-history\" id=\"sect1\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 7.0.0\n</dt>\n\n<dt class=\"bc-supports-yes bc-supports\"> 6.5.0<div class=\"bc-icons\">Disabled </div>\n</dt>\n<dd>Disabled From version 6.5.0: this feature is behind the <code>--harmony</code> runtime flag.</dd>\n</dl></section>\n</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Operators/Assignment_Operators#Left_shift_assignment\">Left shift assignment (<code>x &lt;&lt;= y</code>)</a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Operators/Assignment_Operators#Multiplication_assignment\">Multiplication assignment (<code>x *= y</code>)</a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Operators/Assignment_Operators#Remainder_assignment\">Remainder assignment (<code>x %= y</code>)</a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Operators/Assignment_Operators#Right_shift_assignment\">Right shift assignment (<code>x &gt;&gt;= y</code>)</a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Operators/Assignment_Operators#Assignment\">Assignment (<code>x = y</code>)</a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Operators/Assignment_Operators#Subtraction_assignment\">Subtraction assignment (<code>x -= y</code>)</a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Operators/Assignment_Operators#Unsigned_right_shift_assignment\">Unsigned right shift assignment (<code>x &gt;&gt;&gt;= y</code>)</a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n</tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"arithmetic_operators\">Arithmetic operators</a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Assignment_Operators$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Assignment_Operators\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Assignment_Operators</a>\n  </p>\n</div>\n","operators/comparison_operators":"<h1>Comparison Operators</h1> <p>JavaScript has both strict and type–converting comparisons. A strict comparison (e.g., <code>===</code>) is only true if the operands are of the same type and the contents match. The more commonly-used abstract comparison (e.g. <code>==</code>) converts the operands to the same type before making the comparison. For relational abstract comparisons (e.g., <code>&lt;=</code>), the operands are first converted to primitives, then to the same type, before comparison.</p> <p>Strings are compared based on standard lexicographical ordering, using Unicode values.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/expressions-comparisonoperators.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <p>Features of comparisons:</p> <ul> <li>Two strings are strictly equal when they have the same sequence of characters, same length, and same characters in corresponding positions.</li> <li>Two numbers are strictly equal when they are numerically equal (have the same number value). <a href=\"../global_objects/nan\">NaN</a> is not equal to anything, including NaN. Positive and negative zeros are equal to one another.</li> <li>Two Boolean operands are strictly equal if both are <code>true</code> or both are <code>false</code>.</li> <li>Two distinct objects are never equal for either strict or abstract comparisons.</li> <li>An expression comparing Objects is only true if the operands reference the same Object.</li> <li>Null and Undefined Types are strictly equal to themselves and abstractly equal to each other.</li> </ul> <h2 id=\"Equality_operators\">Equality operators</h2> <h3 name=\"Equality\" id=\"Equality\">Equality (==)</h3> <p>The equality operator converts the operands if they are <strong>not of the same type</strong>, then applies strict comparison. If <strong>both operands are objects</strong>, then JavaScript compares internal references which are equal when operands refer to the same object in memory.</p> <h4 id=\"Syntax\">Syntax</h4> <pre class=\"syntaxbox\">x == y\n</pre> <h4 id=\"Examples\">Examples</h4> <pre data-language=\"js\">1    ==  1         // true\n'1'  ==  1         // true\n1    == '1'        // true\n0    == false      // true\n0    == null       // false\nvar object1 = {'key': 'value'}, object2 = {'key': 'value'}; \nobject1 == object2 //false\n0    == undefined  // false\nnull == undefined  // true\n</pre> <h3 name=\"Inequality\" id=\"Inequality\">Inequality (!=)</h3> <p>The inequality operator returns true if the operands are not equal. If the two operands are <strong>not of the same type</strong>, JavaScript attempts to convert the operands to an appropriate type for the comparison. If <strong>both operands are objects</strong>, then JavaScript compares internal references which are not equal when operands refer to different objects in memory.</p> <h4 id=\"Syntax_2\">Syntax</h4> <pre class=\"syntaxbox\">x != y</pre> <h4 id=\"Examples_2\">Examples</h4> <pre data-language=\"js\">1 !=   2     // true\n1 !=  '1'    // false\n1 !=  \"1\"    // false\n1 !=  true   // false\n0 !=  false  // false\n</pre> <h3 name=\"Identity\" id=\"Identity\">Identity / strict equality (===)</h3> <p>The identity operator returns true if the operands are strictly equal (see above) <strong>with no type conversion</strong>.</p> <h4 id=\"Syntax_3\">Syntax</h4> <pre class=\"syntaxbox\">x === y</pre> <h4 id=\"Examples_3\">Examples</h4> <pre data-language=\"js\">3 === 3   // true\n3 === '3' // false\nvar object1 = {'key': 'value'}, object2 = {'key': 'value'};\nobject1 === object2 //false</pre> <h3 name=\"Nonidentity\" id=\"Nonidentity\">Non-identity / strict inequality (!==)</h3> <p>The non-identity operator returns true if the operands <strong>are not equal and/or not of the same type</strong>.</p> <h4 id=\"Syntax_4\">Syntax</h4> <pre class=\"syntaxbox\">x !== y</pre> <h4 id=\"Examples_4\">Examples</h4> <pre data-language=\"js\">3 !== '3' // true\n4 !== 3   // true\n</pre> <h2 id=\"Relational_operators\">Relational operators</h2> <p>Each of these operators will call the <code>valueOf()</code> function on each operand before a comparison is made.</p> <h3 name=\"Greater_than_operator\" id=\"Greater_than_operator\">Greater than operator (&gt;)</h3> <p>The greater than operator returns true if the left operand is greater than the right operand.</p> <h4 id=\"Syntax_5\">Syntax</h4> <pre class=\"syntaxbox\">x &gt; y</pre> <h4 id=\"Examples_5\">Examples</h4> <pre data-language=\"js\">4 &gt; 3 // true\n</pre> <h3 name=\"Greater_than_or_equal_operator\" id=\"Greater_than_or_equal_operator\">Greater than or equal operator (&gt;=)</h3> <p>The greater than or equal operator returns true if the left operand is greater than or equal to the right operand.</p> <h4 id=\"Syntax_6\">Syntax</h4> <pre class=\"syntaxbox\"> x &gt;= y</pre> <h4 id=\"Examples_6\">Examples</h4> <pre data-language=\"js\">4 &gt;= 3 // true\n3 &gt;= 3 // true\n</pre> <h3 name=\"Less_than_operator\" id=\"Less_than_operator\">Less than operator (&lt;)</h3> <p>The less than operator returns true if the left operand is less than the right operand.</p> <h4 id=\"Syntax_7\">Syntax</h4> <pre class=\"syntaxbox\"> x &lt; y</pre> <h4 id=\"Examples_7\">Examples</h4> <pre data-language=\"js\">3 &lt; 4 // true\n</pre> <h3 name=\"Less_than_or_equal_operator\" id=\"Less_than_or_equal_operator\">Less than or equal operator (&lt;=)</h3> <p>The less than or equal operator returns true if the left operand is less than or equal to the right operand.</p> <h4 id=\"Syntax_8\">Syntax</h4> <pre class=\"syntaxbox\"> x &lt;= y</pre> <h4 id=\"Examples_8\">Examples</h4> <pre data-language=\"js\">3 &lt;= 4 // true\n</pre> <h2 id=\"Using_the_equality_operators\">Using the equality operators</h2> <p>The standard equality operators (<code>==</code> and <code>!=</code>) use the <a href=\"http://www.ecma-international.org/ecma-262/5.1/#sec-11.9.3\">Abstract Equality Comparison Algorithm</a> to compare two operands. If the operands are of different types, it will attempt to convert them to the same type before making the comparison, e.g., in the expression <code>5 == '5'</code>, the string on the right is converted to <a href=\"../global_objects/number\"><code>Number</code></a> before the comparison is made.</p> <p>The strict equality operators (<code>===</code> and <code>!==</code>) use the <a href=\"http://www.ecma-international.org/ecma-262/5.1/#sec-11.9.6\">Strict Equality Comparison Algorithm</a> and are intended for performing equality comparisons on operands of the same type. If the operands are of different types, the result is always <code>false</code> so <code>5 !== '5'</code>.</p> <p>Use strict equality operators if the operands must be of a specific type as well as value or if the exact type of the operands is important. Otherwise, use the standard equality operators, which allow you to compare the identity of two operands even if they are not of the same type.</p> <p>When type conversion is involved in the comparison (i.e., non–strict comparison), JavaScript converts the types <a href=\"../global_objects/string\"><code>String</code></a>, <a href=\"../global_objects/number\"><code>Number</code></a>, <a href=\"../global_objects/boolean\"><code>Boolean</code></a>, or <a href=\"../global_objects/object\"><code>Object</code></a> operands as follows:</p> <ul> <li>When comparing a number and a string, the string is converted to a number value. JavaScript attempts to convert the string numeric literal to a <code>Number</code> type value. First, a mathematical value is derived from the string numeric literal. Next, this value is rounded to nearest <code>Number</code> type value.</li> <li>If one of the operands is <code>Boolean</code>, the Boolean operand is converted to 1 if it is <code>true</code> and +0 if it is <code>false</code>.</li> <li>If an object is compared with a number or string, JavaScript attempts to return the default value for the object. Operators attempt to convert the object to a primitive value, a <code>String</code> or <code>Number</code> value, using the <code>valueOf</code> and <code>toString</code> methods of the objects. If this attempt to convert the object fails, a runtime error is generated.</li> <li>Note that an object is converted into a primitive if, and only if, its comparand is a primitive. If both operands are objects, they're compared as objects, and the equality test is true only if both refer the same object.</li> </ul> <div class=\"note\">\n<strong>Note:</strong> String objects are Type Object, not String! String objects are rarely used, so the following results might be surprising:</div> <pre data-language=\"js\">// true as both operands are type String (i.e. string primitives):\n'foo' === 'foo'\n\nvar a = new String('foo');\nvar b = new String('foo');\n\n// false as a and b are type Object and reference different objects\na == b \n\n// false as a and b are type Object and reference different objects\na === b \n\n// true as a and 'foo' are of different type and, the Object (a) \n// is converted to String 'foo' before comparison\na == 'foo'</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <thead> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> </thead> <tbody> <tr> <td><a href=\"https://www.ecma-international.org/publications/files/ECMA-ST-ARCH/ECMA-262,%201st%20edition,%20June%201997.pdf\" hreflang=\"en\">ECMAScript 1st Edition (ECMA-262)</a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition. Implemented in JavaScript 1.0</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/publications/files/ECMA-ST-ARCH/ECMA-262,%203rd%20edition,%20December%201999.pdf\" hreflang=\"en\">ECMAScript 3rd Edition (ECMA-262)</a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Adds <code>===</code> and <code>!==</code> operators. Implemented in JavaScript 1.3</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/5.1/#sec-11.8\" hreflang=\"en\">ECMAScript 5.1 (ECMA-262)</a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Defined in several sections of the specification: <a href=\"http://www.ecma-international.org/ecma-262/5.1/#sec-11.8\">Relational Operators</a>, <a href=\"http://www.ecma-international.org/ecma-262/5.1/#sec-11.9\">Equality Operators</a>\n</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-relational-operators\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)</a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Defined in several sections of the specification: <a href=\"http://www.ecma-international.org/ecma-262/6.0/#sec-relational-operators\">Relational Operators</a>, <a href=\"http://www.ecma-international.org/ecma-262/6.0/#sec-equality-operators\">Equality Operators</a>\n</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-relational-operators\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)</a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td>Defined in several sections of the specification: <a href=\"http://tc39.github.io/ecma262/#sec-relational-operators\">Relational Operators</a>, <a href=\"http://tc39.github.io/ecma262/#sec-equality-operators\">Equality Operators</a>\n</td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Operators/Comparison_Operators#Equality\">Equality (<code>a == b</code>)</a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Operators/Comparison_Operators#Inequality\">Inequality (<code>a != b</code>)</a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Operators/Comparison_Operators#Identity\">Identity (<code>a === b</code>)</a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Operators/Comparison_Operators#Nonidentity\">Non-identity (<code>a !== b</code>)</a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Operators/Comparison_Operators#Greater_than_operator\">Greater than (<code>a &gt; b</code>)</a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Operators/Comparison_Operators#Greater_than_or_equal_operator\">Greater than or equal (<code>a &gt;= b</code>)</a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Operators/Comparison_Operators#Less_than_operator\">Less than (<code>a &lt; b</code>)</a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Operators/Comparison_Operators#Less_than_or_equal_operator\">Less than or equal (<code>a &lt;= b</code>)</a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n</tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Operators/Comparison_Operators#Equality\">Equality (<code>a == b</code>)</a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Operators/Comparison_Operators#Inequality\">Inequality (<code>a != b</code>)</a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Operators/Comparison_Operators#Identity\">Identity (<code>a === b</code>)</a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Operators/Comparison_Operators#Nonidentity\">Non-identity (<code>a !== b</code>)</a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Operators/Comparison_Operators#Greater_than_operator\">Greater than (<code>a &gt; b</code>)</a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Operators/Comparison_Operators#Greater_than_or_equal_operator\">Greater than or equal (<code>a &gt;= b</code>)</a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Operators/Comparison_Operators#Less_than_operator\">Less than (<code>a &lt; b</code>)</a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Operators/Comparison_Operators#Less_than_or_equal_operator\">Less than or equal (<code>a &lt;= b</code>)</a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n</tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Operators/Comparison_Operators#Equality\">Equality (<code>a == b</code>)</a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Operators/Comparison_Operators#Inequality\">Inequality (<code>a != b</code>)</a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Operators/Comparison_Operators#Identity\">Identity (<code>a === b</code>)</a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Operators/Comparison_Operators#Nonidentity\">Non-identity (<code>a !== b</code>)</a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Operators/Comparison_Operators#Greater_than_operator\">Greater than (<code>a &gt; b</code>)</a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Operators/Comparison_Operators#Greater_than_or_equal_operator\">Greater than or equal (<code>a &gt;= b</code>)</a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Operators/Comparison_Operators#Less_than_operator\">Less than (<code>a &lt; b</code>)</a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Operators/Comparison_Operators#Less_than_or_equal_operator\">Less than or equal (<code>a &lt;= b</code>)</a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n</tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"../global_objects/object/is\"><code>Object.is()</code></a></li> <li><a href=\"../global_objects/math/sign\"><code>Math.sign()</code></a></li> <li><a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Equality_comparisons_and_sameness\">Equality comparisons and sameness</a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Comparison_Operators$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Comparison_Operators\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Comparison_Operators</a>\n  </p>\n</div>\n","operators/pipeline_operator":"<h1>Pipeline operator</h1> <div class=\"blockIndicator experimental indicator-warning\"> <p> <strong>This is an <a href=\"https://developer.mozilla.org/en-US/docs/MDN/Contribute/Guidelines/Conventions_definitions#Experimental\">experimental technology</a></strong><br>Check the <a href=\"#Browser_compatibility\">Browser compatibility table</a> carefully before using this in production.</p> </div> <p>The experimental pipeline operator <code>|&gt;</code> (currently at stage 1) allows the creation of chained function calls in a readable manner. Basically, the pipeline operator provides syntactic sugar on a function call with a single argument allowing you to write</p> <p><code>'%21' |&gt; decodeURI</code> instead of <code>decodeURI('%21')</code>.</p> <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\">expression |&gt; function</pre> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Chaining_function_calls\">Chaining function calls</h3> <p>The pipeline operator can improve readability when chaining several functions.</p> <pre data-language=\"js\">const double = (n) =&gt; n * 2;\nconst increment = (n) =&gt; n + 1;\n\n// without pipeline operator\ndouble(increment(double(double(5)))); // 42\n\n// with pipeline operator\n5 |&gt; double |&gt; double |&gt; increment |&gt; double; // 42\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <thead> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> </thead> <tbody> <tr> <td><a href=\"https://tc39.github.io/proposal-pipeline-operator/#sec-intro\">Pipeline operator draft</a></td> <td>Stage 1</td> <td>Not part of the ECMAScript specification yet.</td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>   <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support \n</th>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes bc-has-history\"> 58<div class=\"bc-icons\">Disabled </div>\n<section class=\"bc-history\" id=\"sect1\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 58<div class=\"bc-icons\">Disabled </div>\n</dt>\n<dd>Disabled From version 58: this feature is behind the <code>--enable-pipeline-operator</code> compile flag.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support \n</th>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes bc-has-history\"> 58<div class=\"bc-icons\">Disabled </div>\n<section class=\"bc-history\" id=\"sect2\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 58<div class=\"bc-icons\">Disabled </div>\n</dt>\n<dd>Disabled From version 58: this feature is behind the <code>--enable-pipeline-operator</code> compile flag.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support \n</th>\n<td class=\"bc-supports-no\"> No</td>\n</tr></tbody>\n</table>\n</div>  <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"https://github.com/tc39/proposals\">TC39 proposals</a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Pipeline_operator$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Pipeline_operator\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Pipeline_operator</a>\n  </p>\n</div>\n","operators/in":"<h1>in</h1> <p>The <code>in</code> returns <code>true</code> if the specified property is in the specified object or its prototype chain.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/expressions-inoperator.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\"><em>prop</em> in <em>object</em></pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><code>prop</code></dt> <dd>A string or symbol representing a property name or array index (non-symbols will be coerced to strings).</dd> </dl> <dl> <dt><code>object</code></dt> <dd>Object to check if it (or its prototype chain) <span id=\"result_box\" class=\"short_text\"><span>contains</span></span> the property with specified name.</dd> </dl> <h2 id=\"Description\">Description</h2> <p>The following examples show some uses of the <code>in</code> operator.</p> <pre data-language=\"js\">// Arrays\nvar trees = ['redwood', 'bay', 'cedar', 'oak', 'maple'];\n0 in trees        // returns true\n3 in trees        // returns true\n6 in trees        // returns false\n'bay' in trees    // returns false (you must specify the index number, not the value at that index)\n'length' in trees // returns true (length is an Array property)\nSymbol.iterator in trees // returns true (arrays are iterable, works only in ES2015+)\n\n// Predefined objects\n'PI' in Math          // returns true\n\n// Custom objects\nvar mycar = {make: 'Honda', model: 'Accord', year: 1998};\n'make' in mycar  // returns true\n'model' in mycar // returns true\n</pre> <p>You must specify an object on the right side of the <code>in</code> operator. For example, you can specify a string created with the <code>String</code> constructor, but you cannot specify a string literal.</p> <pre data-language=\"js\">var color1 = new String('green');\n'length' in color1 // returns true\n\nvar color2 = 'coral';\n// generates an error (color2 is not a String object)\n'length' in color2\n</pre> <h3 id=\"Using_in_with_deleted_or_undefined_properties\">Using <code>in</code> with deleted or undefined properties</h3> <p>If you delete a property with the <code><a href=\"delete\">delete</a></code> operator, the <code>in</code> operator returns <code>false</code> for that property.</p> <pre data-language=\"js\">var mycar = {make: 'Honda', model: 'Accord', year: 1998};\ndelete mycar.make;\n'make' in mycar;  // returns false\n\nvar trees = new Array('redwood', 'bay', 'cedar', 'oak', 'maple');\ndelete trees[3];\n3 in trees; // returns false\n</pre> <p>If you set a property to <a href=\"../global_objects/undefined\"><code>undefined</code></a> but do not delete it, the <code>in</code> operator returns true for that property.</p> <pre data-language=\"js\">var mycar = {make: 'Honda', model: 'Accord', year: 1998};\nmycar.make = undefined;\n'make' in mycar;  // returns true\n</pre> <pre data-language=\"js\">var trees = new Array('redwood', 'bay', 'cedar', 'oak', 'maple');\ntrees[3] = undefined;\n3 in trees; // returns true\n</pre> <h3 id=\"Inherited_properties\">Inherited properties</h3> <p>The <code>in</code> operator returns <code>true</code> for properties in the prototype chain.</p> <pre data-language=\"js\">'toString' in {}; // returns true\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-relational-operators\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Relational Operators' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-relational-operators\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Relational Operators' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/5.1/#sec-11.8.7\" hreflang=\"en\">ECMAScript 5.1 (ECMA-262)<br><small>The definition of 'The in Operator' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/publications/files/ECMA-ST-ARCH/ECMA-262,%203rd%20edition,%20December%201999.pdf#sec-11.8.7\" hreflang=\"en\">ECMAScript 3rd Edition (ECMA-262)<br><small>The definition of 'The in Operator' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition. Implemented in JavaScript 1.4.</td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><code><a href=\"../statements/for...in\">for...in</a></code></li> <li><code><a href=\"delete\">delete</a></code></li> <li><a href=\"../global_objects/object/hasownproperty\"><code>Object.prototype.hasOwnProperty()</code></a></li> <li><a href=\"../global_objects/reflect/has\"><code>Reflect.has()</code></a></li> <li><a href=\"https://developer.mozilla.org/en-US/docs/Enumerability_and_ownership_of_properties\">Enumerability and ownership of properties</a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/in$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/in\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/in</a>\n  </p>\n</div>\n","operators/bitwise_operators":"<h1>Bitwise Operators</h1> <p><strong>Bitwise operators</strong> treat their operands as a sequence of 32 bits (zeroes and ones), rather than as decimal, hexadecimal, or octal <code><a href=\"../global_objects/number\">numbers</a></code>. For example, the decimal number nine has a binary representation of 1001. Bitwise operators perform their operations on such binary representations, but they return standard JavaScript numerical values.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/expressions-bitwiseoperators.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <p>The following table summarizes JavaScript's bitwise operators:</p> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th>Operator</th> <th>Usage</th> <th>Description</th> </tr> <tr> <td><a href=\"bitwise_operators#(Bitwise_AND)\">Bitwise AND</a></td> <td><code>a &amp; b</code></td> <td>Returns a <code>1</code> in each bit position for which the corresponding bits of both operands are <code>1</code>s.</td> </tr> <tr> <td><a href=\"bitwise_operators#(Bitwise_OR)\">Bitwise OR</a></td> <td><code>a | b</code></td> <td>Returns a <code>1</code> in each bit position for which the corresponding bits of either or both operands are <code>1</code>s.</td> </tr> <tr> <td><a href=\"bitwise_operators#(Bitwise_XOR)\">Bitwise XOR</a></td> <td><code>a ^ b</code></td> <td>Returns a <code>1</code> in each bit position for which the corresponding bits of either but not both operands are <code>1</code>s.</td> </tr> <tr> <td><a href=\"bitwise_operators#(Bitwise_NOT)\">Bitwise NOT</a></td> <td><code>~ a</code></td> <td>Inverts the bits of its operand.</td> </tr> <tr> <td><a href=\"bitwise_operators#%3C%3C_(Left_shift)\">Left shift</a></td> <td><code>a &lt;&lt; b</code></td> <td>Shifts <code>a</code> in binary representation <code>b</code> (&lt; 32) bits to the left, shifting in <code>0</code>s from the right.</td> </tr> <tr> <td><a href=\"bitwise_operators#%3E%3E_(Sign-propagating_right_shift)\">Sign-propagating right shift</a></td> <td><code>a &gt;&gt; b</code></td> <td>Shifts <code>a</code> in binary representation <code>b</code> (&lt; 32) bits to the right, discarding bits shifted off.</td> </tr> <tr> <td><a href=\"bitwise_operators#%3E%3E%3E_(Zero-fill_right_shift)\">Zero-fill right shift</a></td> <td><code>a &gt;&gt;&gt; b</code></td> <td>Shifts <code>a</code> in binary representation <code>b</code> (&lt; 32) bits to the right, discarding bits shifted off, and shifting in <code>0</code>s from the left.</td> </tr> </tbody> </table></div> <h2 id=\"Signed_32-bit_integers\">Signed 32-bit integers</h2> <p>The operands of all bitwise operators are converted to signed 32-bit integers in two's complement format. Two's complement format means that a number's negative counterpart (e.g. 5 vs. -5) is all the number's bits inverted (bitwise NOT of the number, a.k.a. ones' complement of the number) plus one. For example, the following encodes the integer 314:</p> <pre data-language=\"js\">00000000000000000000000100111010\n</pre> <p>The following encodes <code>~314</code>, i.e. the ones' complement of <code>314</code>:</p> <pre data-language=\"js\">11111111111111111111111011000101\n</pre> <p>Finally, the following encodes <code>-314,</code> i.e. the two's complement of <code>314</code>:</p> <pre data-language=\"js\">11111111111111111111111011000110\n</pre> <p>The two's complement guarantees that the left-most bit is 0 when the number is positive and 1 when the number is negative. Thus, it is called the <em>sign bit</em>.</p> <p>The number <code>0</code> is the integer that is composed completely of 0 bits.</p> <pre data-language=\"js\">0 (base 10) = 00000000000000000000000000000000 (base 2)\n</pre> <p>The number <code>-1</code> is the integer that is composed completely of 1 bits.</p> <pre data-language=\"js\">-1 (base 10) = 11111111111111111111111111111111 (base 2)\n</pre> <p>The number <code>-2147483648</code> (hexadecimal representation: <code>-0x80000000</code>) is the integer that is composed completely of 0 bits except the first (left-most) one.</p> <pre data-language=\"js\">-2147483648 (base 10) = 10000000000000000000000000000000 (base 2)\n</pre> <p>The number <code>2147483647</code> (hexadecimal representation: <code>0x7fffffff</code>) is the integer that is composed completely of 1 bits except the first (left-most) one.</p> <pre data-language=\"js\">2147483647 (base 10) = 01111111111111111111111111111111 (base 2)\n</pre> <p>The numbers <code>-2147483648</code> and <code>2147483647</code> are the minimum and the maximum integers representable through a 32bit signed number.</p> <h2 id=\"Bitwise_logical_operators\">Bitwise logical operators</h2> <p>Conceptually, the bitwise logical operators work as follows:</p> <ul> <li>The operands are converted to 32-bit integers and expressed by a series of bits (zeroes and ones). Numbers with more than 32 bits get their most significant bits discarded. For example, the following integer with more than 32 bits will be converted to a 32 bit integer: <pre data-language=\"js\">Before: 11100110111110100000000000000110000000000001\nAfter:              10100000000000000110000000000001</pre> </li> <li>Each bit in the first operand is paired with the corresponding bit in the second operand: first bit to first bit, second bit to second bit, and so on.</li> <li>The operator is applied to each pair of bits, and the result is constructed bitwise.</li> </ul> <h3 id=\"Bitwise_AND\">&amp; (Bitwise AND)</h3> <p>Performs the AND operation on each pair of bits. <code>a</code> AND <code>b</code> yields 1 only if both <code>a</code> and <code>b</code> are <code>1</code>. The truth table for the AND operation is:</p> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th class=\"header\">a</th> <th class=\"header\">b</th> <th class=\"header\">a AND b</th> </tr> <tr> <td>0</td> <td>0</td> <td>0</td> </tr> <tr> <td>0</td> <td>1</td> <td>0</td> </tr> <tr> <td>1</td> <td>0</td> <td>0</td> </tr> <tr> <td>1</td> <td>1</td> <td>1</td> </tr> </tbody> </table></div> <pre data-language=\"js\">.    9 (base 10) = 00000000000000000000000000001001 (base 2)\n    14 (base 10) = 00000000000000000000000000001110 (base 2)\n                   --------------------------------\n14 &amp; 9 (base 10) = 00000000000000000000000000001000 (base 2) = 8 (base 10)\n</pre> <p>Bitwise ANDing any number <code>x</code> with <code>0</code> yields <code>0</code>. Bitwise ANDing any number <code>x</code> with <code>-1</code> yields <code>x</code>.</p> <h3 id=\"Bitwise_OR\">| (Bitwise OR)</h3> <p>Performs the OR operation on each pair of bits. <code>a</code> OR <code>b</code> yields 1 if either <code>a</code> or <code>b</code> is <code>1</code>. The truth table for the <code>OR</code> operation is:</p> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th class=\"header\">a</th> <th class=\"header\">b</th> <th class=\"header\">a OR b</th> </tr> <tr> <td>0</td> <td>0</td> <td>0</td> </tr> <tr> <td>0</td> <td>1</td> <td>1</td> </tr> <tr> <td>1</td> <td>0</td> <td>1</td> </tr> <tr> <td>1</td> <td>1</td> <td>1</td> </tr> </tbody> </table></div> <pre data-language=\"js\">.    9 (base 10) = 00000000000000000000000000001001 (base 2)\n    14 (base 10) = 00000000000000000000000000001110 (base 2)\n                   --------------------------------\n14 | 9 (base 10) = 00000000000000000000000000001111 (base 2) = 15 (base 10)\n</pre> <p>Bitwise ORing any number <code>x</code> with <code>0</code> yields <code>x</code>. Bitwise ORing any number <code>x</code> with <code>-1</code> yields <code>-1</code>.</p> <h3 id=\"Bitwise_XOR\">^ (Bitwise XOR)</h3> <p>Performs the XOR operation on each pair of bits. <code>a</code> XOR <code>b</code> yields 1 if <code>a</code> and <code>b</code> are different. The truth table for the <code>XOR</code> operation is:</p> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th class=\"header\">a</th> <th class=\"header\">b</th> <th class=\"header\">a XOR b</th> </tr> <tr> <td>0</td> <td>0</td> <td>0</td> </tr> <tr> <td>0</td> <td>1</td> <td>1</td> </tr> <tr> <td>1</td> <td>0</td> <td>1</td> </tr> <tr> <td>1</td> <td>1</td> <td>0</td> </tr> </tbody> </table></div> <pre data-language=\"js\">.    9 (base 10) = 00000000000000000000000000001001 (base 2)\n    14 (base 10) = 00000000000000000000000000001110 (base 2)\n                   --------------------------------\n14 ^ 9 (base 10) = 00000000000000000000000000000111 (base 2) = 7 (base 10)\n</pre> <p>Bitwise XORing any number <code>x</code> with <code>0</code> yields x. Bitwise XORing any number <code>x</code> with <code>-1</code> yields <code>~x</code>.</p> <h3 id=\"Bitwise_NOT\">~ (Bitwise NOT)</h3> <p>Performs the NOT operator on each bit. NOT <code>a</code> yields the inverted value (a.k.a. one's complement) of <code>a</code>. The truth table for the <code>NOT</code> operation is:</p> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th class=\"header\">a</th> <th class=\"header\">NOT a</th> </tr> <tr> <td>0</td> <td>1</td> </tr> <tr> <td>1</td> <td>0</td> </tr> </tbody> </table></div> <pre data-language=\"js\"> 9 (base 10) = 00000000000000000000000000001001 (base 2)\n               --------------------------------\n~9 (base 10) = 11111111111111111111111111110110 (base 2) = -10 (base 10)\n</pre> <p>Bitwise NOTing any number <code>x</code> yields <code>-(x + 1)</code>. For example, <code>~-5</code> yields <code>4</code>.</p> <p>Note that due to using 32-bit representation for numbers both <code>~-1</code> and <code>~4294967295</code> (2<sup>32</sup>-1) results in <code>0</code>.</p> <h2 id=\"Bitwise_shift_operators\">Bitwise shift operators</h2> <p>The bitwise shift operators take two operands: the first is a quantity to be shifted, and the second specifies the number of bit positions by which the first operand is to be shifted. The direction of the shift operation is controlled by the operator used.</p> <p>Shift operators convert their operands to 32-bit integers in big-endian order and return a result of the same type as the left operand. The right operand should be less than 32, but if not only the low five bits will be used.</p> <h3 id=\"Left_shift\">&lt;&lt; (Left shift)</h3> <p>This operator shifts the first operand the specified number of bits to the left. Excess bits shifted off to the left are discarded. Zero bits are shifted in from the right.</p> <p>For example, <code>9 &lt;&lt; 2</code> yields 36:</p> <pre data-language=\"js\">.    9 (base 10): 00000000000000000000000000001001 (base 2)\n                  --------------------------------\n9 &lt;&lt; 2 (base 10): 00000000000000000000000000100100 (base 2) = 36 (base 10)\n</pre> <p>Bitwise shifting any number <code>x</code> to the left by <code>y</code> bits yields <code>x * 2 ** y</code>.</p> <h3 id=\"Right_shift\">&gt;&gt; (Sign-propagating right shift)</h3> <p>This operator shifts the first operand the specified number of bits to the right. Excess bits shifted off to the right are discarded. Copies of the leftmost bit are shifted in from the left. Since the new leftmost bit has the same value as the previous leftmost bit, the sign bit (the leftmost bit) does not change. Hence the name \"sign-propagating\".</p> <p>For example, <code>9 &gt;&gt; 2</code> yields 2:</p> <pre data-language=\"js\">.    9 (base 10): 00000000000000000000000000001001 (base 2)\n                  --------------------------------\n9 &gt;&gt; 2 (base 10): 00000000000000000000000000000010 (base 2) = 2 (base 10)\n</pre> <p>Likewise, <code>-9 &gt;&gt; 2</code> yields <code>-3</code>, because the sign is preserved:</p> <pre data-language=\"js\">.    -9 (base 10): 11111111111111111111111111110111 (base 2)\n                   --------------------------------\n-9 &gt;&gt; 2 (base 10): 11111111111111111111111111111101 (base 2) = -3 (base 10)\n</pre> <h3 id=\"Unsigned_right_shift\">&gt;&gt;&gt; (Zero-fill right shift)</h3> <p>This operator shifts the first operand the specified number of bits to the right. Excess bits shifted off to the right are discarded. Zero bits are shifted in from the left. The sign bit becomes 0, so the result is always non-negative.</p> <p>For non-negative numbers, zero-fill right shift and sign-propagating right shift yield the same result. For example, <code>9 &gt;&gt;&gt; 2</code> yields 2, the same as <code>9 &gt;&gt; 2</code>:</p> <pre data-language=\"js\">.     9 (base 10): 00000000000000000000000000001001 (base 2)\n                   --------------------------------\n9 &gt;&gt;&gt; 2 (base 10): 00000000000000000000000000000010 (base 2) = 2 (base 10)\n</pre> <p>However, this is not the case for negative numbers. For example, <code>-9 &gt;&gt;&gt; 2</code> yields 1073741821, which is different than <code>-9 &gt;&gt; 2</code> (which yields <code>-3</code>):</p> <pre data-language=\"js\">.     -9 (base 10): 11111111111111111111111111110111 (base 2)\n                    --------------------------------\n-9 &gt;&gt;&gt; 2 (base 10): 00111111111111111111111111111101 (base 2) = 1073741821 (base 10)\n</pre> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Flags_and_bitmasks\">Flags and bitmasks</h3> <p>The bitwise logical operators are often used to create, manipulate, and read sequences of <em>flags</em>, which are like binary variables. Variables could be used instead of these sequences, but binary flags take much less memory (by a factor of 32).</p> <p>Suppose there are 4 flags:</p> <ul> <li>flag A: we have an ant problem</li> <li>flag B: we own a bat</li> <li>flag C: we own a cat</li> <li>flag D: we own a duck</li> </ul> <p>These flags are represented by a sequence of bits: DCBA. When a flag is <em>set</em>, it has a value of 1. When a flag is <em>cleared</em>, it has a value of 0. Suppose a variable <code>flags</code> has the binary value 0101:</p> <pre data-language=\"js\">var flags = 5;   // binary 0101\n</pre> <p>This value indicates:</p> <ul> <li>flag A is true (we have an ant problem);</li> <li>flag B is false (we don't own a bat);</li> <li>flag C is true (we own a cat);</li> <li>flag D is false (we don't own a duck);</li> </ul> <p>Since bitwise operators are 32-bit, 0101 is actually 00000000000000000000000000000101, but the preceding zeroes can be neglected since they contain no meaningful information.</p> <p>A <em>bitmask</em> is a sequence of bits that can manipulate and/or read flags. Typically, a \"primitive\" bitmask for each flag is defined:</p> <pre data-language=\"js\">var FLAG_A = 1; // 0001\nvar FLAG_B = 2; // 0010\nvar FLAG_C = 4; // 0100\nvar FLAG_D = 8; // 1000\n</pre> <p>New bitmasks can be created by using the bitwise logical operators on these primitive bitmasks. For example, the bitmask 1011 can be created by ORing FLAG_A, FLAG_B, and FLAG_D:</p> <pre data-language=\"js\">var mask = FLAG_A | FLAG_B | FLAG_D; // 0001 | 0010 | 1000 =&gt; 1011\n</pre> <p>Individual flag values can be extracted by ANDing them with a bitmask, where each bit with the value of one will \"extract\" the corresponding flag. The bitmask <em>masks</em> out the non-relevant flags by ANDing with zeroes (hence the term \"bitmask\"). For example, the bitmask 0100 can be used to see if flag C is set:</p> <pre data-language=\"js\">// if we own a cat\nif (flags &amp; FLAG_C) { // 0101 &amp; 0100 =&gt; 0100 =&gt; true\n   // do stuff\n}\n</pre> <p>A bitmask with multiple set flags acts like an \"either/or\". For example, the following two are equivalent:</p> <pre data-language=\"js\">// if we own a bat or we own a cat\n// (0101 &amp; 0010) || (0101 &amp; 0100) =&gt; 0000 || 0100 =&gt; true\nif ((flags &amp; FLAG_B) || (flags &amp; FLAG_C)) {\n   // do stuff\n}\n</pre> <pre data-language=\"js\">// if we own a bat or cat\nvar mask = FLAG_B | FLAG_C; // 0010 | 0100 =&gt; 0110\nif (flags &amp; mask) { // 0101 &amp; 0110 =&gt; 0100 =&gt; true\n   // do stuff\n}\n</pre> <p>Flags can be set by ORing them with a bitmask, where each bit with the value one will set the corresponding flag, if that flag isn't already set. For example, the bitmask 1100 can be used to set flags C and D:</p> <pre data-language=\"js\">// yes, we own a cat and a duck\nvar mask = FLAG_C | FLAG_D; // 0100 | 1000 =&gt; 1100\nflags |= mask;   // 0101 | 1100 =&gt; 1101\n</pre> <p>Flags can be cleared by ANDing them with a bitmask, where each bit with the value zero will clear the corresponding flag, if it isn't already cleared. This bitmask can be created by NOTing primitive bitmasks. For example, the bitmask 1010 can be used to clear flags A and C:</p> <pre data-language=\"js\">// no, we don't have an ant problem or own a cat\nvar mask = ~(FLAG_A | FLAG_C); // ~0101 =&gt; 1010\nflags &amp;= mask;   // 1101 &amp; 1010 =&gt; 1000\n</pre> <p>The mask could also have been created with <code>~FLAG_A &amp; ~FLAG_C</code> (De Morgan's law):</p> <pre data-language=\"js\">// no, we don't have an ant problem, and we don't own a cat\nvar mask = ~FLAG_A &amp; ~FLAG_C;\nflags &amp;= mask;   // 1101 &amp; 1010 =&gt; 1000\n</pre> <p>Flags can be toggled by XORing them with a bitmask, where each bit with the value one will toggle the corresponding flag. For example, the bitmask 0110 can be used to toggle flags B and C:</p> <pre data-language=\"js\">// if we didn't have a bat, we have one now, \n// and if we did have one, bye-bye bat\n// same thing for cats\nvar mask = FLAG_B | FLAG_C;\nflags = flags ^ mask;   // 1100 ^ 0110 =&gt; 1010\n</pre> <p>Finally, the flags can all be flipped with the NOT operator:</p> <pre data-language=\"js\">// entering parallel universe...\nflags = ~flags;    // ~1010 =&gt; 0101\n</pre> <h3 id=\"Conversion_snippets\">Conversion snippets</h3> <p>Convert a binary <code><a href=\"../global_objects/string\">String</a></code> to a decimal <code><a href=\"../global_objects/number\">Number</a></code>:</p> <pre data-language=\"js\">var sBinString = '1011';\nvar nMyNumber = parseInt(sBinString, 2);\nalert(nMyNumber); // prints 11, i.e. 1011\n</pre> <p>Convert a decimal <code><a href=\"../global_objects/number\">Number</a></code> to a binary <code><a href=\"../global_objects/string\">String</a></code>:</p> <pre data-language=\"js\">var nMyNumber = 11;\nvar sBinString = nMyNumber.toString(2);\nalert(sBinString); // prints 1011, i.e. 11\n</pre> <h3 id=\"Automate_Mask_Creation\">Automate Mask Creation</h3> <p>You can create multiple masks from a set of <code><a href=\"../global_objects/boolean\">Boolean</a></code> values, like this:</p> <pre data-language=\"js\">function createMask() {\n  var nMask = 0, nFlag = 0, nLen = arguments.length &gt; 32 ? 32 : arguments.length;\n  for (nFlag; nFlag &lt; nLen; nMask |= arguments[nFlag] &lt;&lt; nFlag++);\n  return nMask;\n}\nvar mask1 = createMask(true, true, false, true); // 11, i.e.: 1011\nvar mask2 = createMask(false, false, true); // 4, i.e.: 0100\nvar mask3 = createMask(true); // 1, i.e.: 0001\n// etc.\n\nalert(mask1); // prints 11, i.e.: 1011\n</pre> <h3 id=\"Reverse_algorithm_an_array_of_booleans_from_a_mask\">Reverse algorithm: an array of booleans from a mask</h3> <p>If you want to create an <code><a href=\"../global_objects/array\">Array</a></code> of <code><a href=\"../global_objects/boolean\">Booleans</a></code> from a mask you can use this code:</p> <pre data-language=\"js\">function arrayFromMask(nMask) {\n  // nMask must be between -2147483648 and 2147483647\n  if (nMask &gt; 0x7fffffff || nMask &lt; -0x80000000) { \n    throw new TypeError('arrayFromMask - out of range'); \n  }\n  for (var nShifted = nMask, aFromMask = []; nShifted; \n       aFromMask.push(Boolean(nShifted &amp; 1)), nShifted &gt;&gt;&gt;= 1);\n  return aFromMask;\n}\n\nvar array1 = arrayFromMask(11);\nvar array2 = arrayFromMask(4);\nvar array3 = arrayFromMask(1);\n\nalert('[' + array1.join(', ') + ']');\n// prints \"[true, true, false, true]\", i.e.: 11, i.e.: 1011\n</pre> <p>You can test both algorithms at the same time…</p> <pre data-language=\"js\">var nTest = 19; // our custom mask\nvar nResult = createMask.apply(this, arrayFromMask(nTest));\n\nalert(nResult); // 19\n</pre> <p>For didactic purpose only (since there is the <code><a href=\"../global_objects/number/tostring\">Number.toString(2)</a></code> method), we show how it is possible to modify the <code>arrayFromMask</code> algorithm in order to create a <code><a href=\"../global_objects/string\">String</a></code> containing the binary representation of a <code><a href=\"../global_objects/number\">Number</a></code>, rather than an <code><a href=\"../global_objects/array\">Array</a></code> of <code><a href=\"../global_objects/boolean\">Booleans</a></code>:</p> <pre data-language=\"js\">function createBinaryString(nMask) {\n  // nMask must be between -2147483648 and 2147483647\n  for (var nFlag = 0, nShifted = nMask, sMask = ''; nFlag &lt; 32;\n       nFlag++, sMask += String(nShifted &gt;&gt;&gt; 31), nShifted &lt;&lt;= 1);\n  return sMask;\n}\n\nvar string1 = createBinaryString(11);\nvar string2 = createBinaryString(4);\nvar string3 = createBinaryString(1);\n\nalert(string1);\n// prints 00000000000000000000000000001011, i.e. 11\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/publications/files/ECMA-ST-ARCH/ECMA-262,%201st%20edition,%20June%201997.pdf\" hreflang=\"en\">ECMAScript 1st Edition (ECMA-262)</a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/5.1/#sec-11.7\" hreflang=\"en\">ECMAScript 5.1 (ECMA-262)</a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Defined in several sections of the specification: <a href=\"http://www.ecma-international.org/ecma-262/5.1/#sec-11.4.8\">Bitwise NOT operator</a>, <a href=\"http://www.ecma-international.org/ecma-262/5.1/#sec-11.7\">Bitwise shift operators</a>, <a href=\"http://www.ecma-international.org/ecma-262/5.1/#sec-11.10\">Binary bitwise operators</a>\n</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-bitwise-shift-operators\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)</a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Defined in several sections of the specification: <a href=\"http://www.ecma-international.org/ecma-262/6.0/#sec-bitwise-not-operator\">Bitwise NOT operator</a>, <a href=\"http://www.ecma-international.org/ecma-262/6.0/#sec-bitwise-shift-operators\">Bitwise shift operators</a>, <a href=\"http://www.ecma-international.org/ecma-262/6.0/#sec-binary-bitwise-operators\">Binary bitwise operators</a>\n</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-bitwise-shift-operators\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)</a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td>Defined in several sections of the specification: <a href=\"http://tc39.github.io/ecma262/#sec-bitwise-not-operator\">Bitwise NOT operator</a>, <a href=\"http://tc39.github.io/ecma262/#sec-bitwise-shift-operators\">Bitwise shift operators</a>, <a href=\"http://tc39.github.io/ecma262/#sec-binary-bitwise-operators\">Binary bitwise operators</a>\n</td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Operators/Bitwise_Operators#Bitwise_AND\">Bitwise AND (<code>a &amp; b</code>)</a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Operators/Bitwise_Operators#Left_shift\">Bitwise left shift (<code>a &lt;&lt; b</code>)</a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Operators/Bitwise_Operators#Bitwise_NOT\">Bitwise NOT (<code>~a</code>)</a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Operators/Bitwise_Operators#Bitwise_OR\">Bitwise OR (<code>a | b</code>)</a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Operators/Bitwise_Operators#Right_shift\">Bitwise right shift (<code>a &gt;&gt; b</code>)</a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Operators/Bitwise_Operators#Unsigned_right_shift\">Bitwise unsigned right shift (<code>a &gt;&gt;&gt; b</code>)</a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Operators/Bitwise_Operators#Bitwise_XOR\">Bitwise XOR (<code>a ^ b</code>)</a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n</tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Operators/Bitwise_Operators#Bitwise_AND\">Bitwise AND (<code>a &amp; b</code>)</a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Operators/Bitwise_Operators#Left_shift\">Bitwise left shift (<code>a &lt;&lt; b</code>)</a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Operators/Bitwise_Operators#Bitwise_NOT\">Bitwise NOT (<code>~a</code>)</a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Operators/Bitwise_Operators#Bitwise_OR\">Bitwise OR (<code>a | b</code>)</a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Operators/Bitwise_Operators#Right_shift\">Bitwise right shift (<code>a &gt;&gt; b</code>)</a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Operators/Bitwise_Operators#Unsigned_right_shift\">Bitwise unsigned right shift (<code>a &gt;&gt;&gt; b</code>)</a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Operators/Bitwise_Operators#Bitwise_XOR\">Bitwise XOR (<code>a ^ b</code>)</a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n</tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Operators/Bitwise_Operators#Bitwise_AND\">Bitwise AND (<code>a &amp; b</code>)</a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Operators/Bitwise_Operators#Left_shift\">Bitwise left shift (<code>a &lt;&lt; b</code>)</a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Operators/Bitwise_Operators#Bitwise_NOT\">Bitwise NOT (<code>~a</code>)</a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Operators/Bitwise_Operators#Bitwise_OR\">Bitwise OR (<code>a | b</code>)</a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Operators/Bitwise_Operators#Right_shift\">Bitwise right shift (<code>a &gt;&gt; b</code>)</a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Operators/Bitwise_Operators#Unsigned_right_shift\">Bitwise unsigned right shift (<code>a &gt;&gt;&gt; b</code>)</a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Operators/Bitwise_Operators#Bitwise_XOR\">Bitwise XOR (<code>a ^ b</code>)</a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n</tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"logical_operators\">Logical operators</a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Bitwise_Operators$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Bitwise_Operators\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Bitwise_Operators</a>\n  </p>\n</div>\n","operators/destructuring_assignment":"<h1>Destructuring assignment</h1> <p>The <strong>destructuring assignment</strong> syntax is a JavaScript expression that makes it possible to unpack values from arrays, or properties from objects, into distinct variables.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/expressions-destructuringassignment.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre data-language=\"js\">var a, b, rest;\n[a, b] = [10, 20];\nconsole.log(a); // 10\nconsole.log(b); // 20\n\n[a, b, ...rest] = [10, 20, 30, 40, 50];\nconsole.log(a); // 10\nconsole.log(b); // 20\nconsole.log(rest); // [30, 40, 50]\n\n({ a, b } = { a: 10, b: 20 });\nconsole.log(a); // 10\nconsole.log(b); // 20\n\n\n// Stage 4(finished) proposal\n({a, b, ...rest} = {a: 10, b: 20, c: 30, d: 40});\nconsole.log(a); // 10\nconsole.log(b); // 20\nconsole.log(rest); // {c: 30, d: 40}\n</pre> <h2 id=\"Description\">Description</h2> <p>The object and array literal expressions provide an easy way to create <em>ad hoc</em> packages of data.</p> <pre data-language=\"js\">var x = [1, 2, 3, 4, 5];</pre> <p>The destructuring assignment uses similar syntax, but on the left-hand side of the assignment to define what values to unpack from the sourced variable.</p> <pre data-language=\"js\">var x = [1, 2, 3, 4, 5];\nvar [y, z] = x;\nconsole.log(y); // 1\nconsole.log(z); // 2\n</pre> <p>This capability is similar to features present in languages such as Perl and Python.</p> <h2 id=\"Array_destructuring\">Array destructuring</h2> <h3 id=\"Basic_variable_assignment\">Basic variable assignment</h3> <pre data-language=\"js\">var foo = ['one', 'two', 'three'];\n\nvar [one, two, three] = foo;\nconsole.log(one); // \"one\"\nconsole.log(two); // \"two\"\nconsole.log(three); // \"three\"\n</pre> <h3 id=\"Assignment_separate_from_declaration\">Assignment separate from declaration</h3> <p>A variable can be assigned its value via destructuring separate from the variable's declaration.</p> <pre data-language=\"js\">var a, b;\n\n[a, b] = [1, 2];\nconsole.log(a); // 1\nconsole.log(b); // 2\n</pre> <h3 id=\"Default_values\">Default values</h3> <p>A variable can be assigned a default, in the case that the value unpacked from the array is <code>undefined</code>.</p> <pre data-language=\"js\">var a, b;\n\n[a=5, b=7] = [1];\nconsole.log(a); // 1\nconsole.log(b); // 7\n</pre> <h3 id=\"Swapping_variables\">Swapping variables</h3> <p>Two variables values can be swapped in one destructuring expression.</p> <p>Without destructuring assignment, swapping two values requires a temporary variable (or, in some low-level languages, the <a href=\"https://en.wikipedia.org/wiki/XOR_swap_algorithm\">XOR-swap trick</a>).</p> <pre data-language=\"js\">var a = 1;\nvar b = 3;\n\n[a, b] = [b, a];\nconsole.log(a); // 3\nconsole.log(b); // 1\n</pre> <h3 id=\"Parsing_an_array_returned_from_a_function\">Parsing an array returned from a function</h3> <p>It's always been possible to return an array from a function. Destructuring can make working with an array return value more concise.</p> <p>In this example, <code>f()</code> returns the values <code>[1, 2]</code> as its output, which can be parsed in a single line with destructuring.</p> <pre data-language=\"js\">function f() {\n  return [1, 2];\n}\n\nvar a, b; \n[a, b] = f(); \nconsole.log(a); // 1\nconsole.log(b); // 2\n</pre> <h3 id=\"Ignoring_some_returned_values\">Ignoring some returned values</h3> <p>You can ignore return values that you're not interested in:</p> <pre data-language=\"js\">function f() {\n  return [1, 2, 3];\n}\n\nvar [a, , b] = f();\nconsole.log(a); // 1\nconsole.log(b); // 3\n</pre> <p>You can also ignore all returned values:</p> <pre data-language=\"js\">[,,] = f();\n</pre> <h3 id=\"Assigning_the_rest_of_an_array_to_a_variable\">Assigning the rest of an array to a variable</h3> <p>When destructuring an array, you can unpack and assign the remaining part of it to a variable using the rest pattern:</p> <pre data-language=\"js\">var [a, ...b] = [1, 2, 3];\nconsole.log(a); // 1\nconsole.log(b); // [2, 3]</pre> <p>Be aware that a <a href=\"../global_objects/syntaxerror\"><code>SyntaxError</code></a> will be thrown if a trailing comma is used on the left-hand side with a rest element:</p> <pre data-language=\"js\">var [a, ...b,] = [1, 2, 3];\n// SyntaxError: rest element may not have a trailing comma</pre> <h3 id=\"Unpacking_values_from_a_regular_expression_match\">Unpacking values from a regular expression match</h3> <p>When the regular expression <code><a href=\"../global_objects/regexp/exec\"> exec()</a></code> method finds a match, it returns an array containing first the entire matched portion of the string and then the portions of the string that matched each parenthesized group in the regular expression. Destructuring assignment allows you to unpack the parts out of this array easily, ignoring the full match if it is not needed.</p> <pre data-language=\"js\">function parseProtocol(url) { \n  var parsedURL = /^(\\w+)\\:\\/\\/([^\\/]+)\\/(.*)$/.exec(url);\n  if (!parsedURL) {\n    return false;\n  }\n  console.log(parsedURL); // [\"https://developer.mozilla.org/en-US/Web/JavaScript\", \"https\", \"developer.mozilla.org\", \"en-US/Web/JavaScript\"]\n\n  var [, protocol, fullhost, fullpath] = parsedURL;\n  return protocol;\n}\n\nconsole.log(parseProtocol('https://developer.mozilla.org/en-US/Web/JavaScript')); // \"https\"\n</pre> <h2 id=\"Object_destructuring\">Object destructuring</h2> <h3 id=\"Basic_assignment\">Basic assignment</h3> <pre data-language=\"js\">var o = {p: 42, q: true};\nvar {p, q} = o;\n\nconsole.log(p); // 42\nconsole.log(q); // true \n</pre> <h3 id=\"Assignment_without_declaration\">Assignment without declaration</h3> <p>A variable can be assigned its value with destructuring separate from its declaration.</p> <pre data-language=\"js\">var a, b;\n\n({a, b} = {a: 1, b: 2});</pre> <div class=\"note\"> <p><strong>Notes</strong>: The parentheses <code>( ... )</code> around the assignment statement are required when using object literal destructuring assignment without a declaration.</p> <p><code>{a, b} = {a: 1, b: 2}</code> is not valid stand-alone syntax, as the <code>{a, b}</code> on the left-hand side is considered a block and not an object literal.</p> <p>However, <code>({a, b} = {a: 1, b: 2})</code> is valid, as is <code>var {a, b} = {a: 1, b: 2}</code></p> <p>Your <code>( ... )</code> expression needs to be preceded by a semicolon or it may be used to execute a function on the previous line.</p> </div> <h3 id=\"Assigning_to_new_variable_names\">Assigning to new variable names</h3> <p>A property can be unpacked from an object and assigned to a variable with a different name than the object property.</p> <pre data-language=\"js\">var o = {p: 42, q: true};\nvar {p: foo, q: bar} = o;\n \nconsole.log(foo); // 42 \nconsole.log(bar); // true  </pre> <h3 id=\"Default_values_2\">Default values</h3> <p>A variable can be assigned a default, in the case that the value unpacked from the object is <code>undefined</code>.</p> <pre data-language=\"js\">var {a = 10, b = 5} = {a: 3};\n\nconsole.log(a); // 3\nconsole.log(b); // 5</pre> <h3 id=\"Assigning_to_new_variables_names_and_providing_default_values\">Assigning to new variables names and providing default values</h3> <p>A property can be both 1) unpacked from an object and assigned to a variable with a different name and 2) assigned a default value in case the unpacked value is <code>undefined</code>.</p> <pre data-language=\"js\">var {a: aa = 10, b: bb = 5} = {a: 3};\n\nconsole.log(aa); // 3\nconsole.log(bb); // 5\n</pre> <h3 id=\"Setting_a_function_parameter's_default_value\">Setting a function parameter's default value</h3> <h4 id=\"ES5_version\">ES5 version</h4> <pre data-language=\"js\">function drawES5Chart(options) {\n  options = options === undefined ? {} : options;\n  var size = options.size === undefined ? 'big' : options.size;\n  var cords = options.cords === undefined ? {x: 0, y: 0} : options.cords;\n  var radius = options.radius === undefined ? 25 : options.radius;\n  console.log(size, cords, radius);\n  // now finally do some chart drawing\n}\n\ndrawES5Chart({\n  cords: {x: 18, y: 30},\n  radius: 30\n});</pre> <h4 id=\"ES2015_version\">ES2015 version</h4> <pre data-language=\"js\">function drawES2015Chart({size = 'big', cords = {x: 0, y: 0}, radius = 25} = {}) {\n  console.log(size, cords, radius);\n  // do some chart drawing\n}\n\ndrawES2015Chart({\n  cords: {x: 18, y: 30},\n  radius: 30\n});</pre> <div class=\"note\"> <p>In the function signature for <code>drawES2015Chart</code> above, the destructured left-hand side is assigned to an empty object literal on the right-hand side: <code>{size = 'big', cords = {x: 0, y: 0}, radius = 25} = {}</code>. You could have also written the function without the right-hand side assignment. However, if you leave out the right-hand side assignment, the function will look for at least one argument to be supplied when invoked, whereas in its current form, you can simply call <code><strong>drawES2015Chart()</strong></code> without supplying any parameters. The current design is useful if you want to be able to call the function without supplying any parameters, the other can be useful when you want to ensure an object is passed to the function.</p> </div> <h3 id=\"Nested_object_and_array_destructuring\">Nested object and array destructuring</h3> <pre data-language=\"js\">const metadata = {\n    title: 'Scratchpad',\n    translations: [\n       {\n        locale: 'de',\n        localization_tags: [],\n        last_edit: '2014-04-14T08:43:37',\n        url: '/de/docs/Tools/Scratchpad',\n        title: 'JavaScript-Umgebung'\n       }\n    ],\n    url: '/en-US/docs/Tools/Scratchpad'\n};\n\nlet {\n    title: englishTitle,// rename\n    translations: [\n        {\n            title: localeTitle,// rename\n        },\n    ],\n} = metadata;\n\nconsole.log(englishTitle); // \"Scratchpad\"\nconsole.log(localeTitle);  // \"JavaScript-Umgebung\"</pre> <h3 id=\"For_of_iteration_and_destructuring\">For of iteration and destructuring</h3> <pre data-language=\"js\">var people = [\n  {\n    name: 'Mike Smith',\n    family: {\n      mother: 'Jane Smith',\n      father: 'Harry Smith',\n      sister: 'Samantha Smith'\n    },\n    age: 35\n  },\n  {\n    name: 'Tom Jones',\n    family: {\n      mother: 'Norah Jones',\n      father: 'Richard Jones',\n      brother: 'Howard Jones'\n    },\n    age: 25\n  }\n];\n\nfor (var {name: n, family: {father: f}} of people) {\n  console.log('Name: ' + n + ', Father: ' + f);\n}\n\n// \"Name: Mike Smith, Father: Harry Smith\"\n// \"Name: Tom Jones, Father: Richard Jones\"</pre> <h3 id=\"Unpacking_fields_from_objects_passed_as_function_parameter\">Unpacking fields from objects passed as function parameter</h3> <pre data-language=\"js\">function userId({id}) {\n  return id;\n}\n\nfunction whois({displayName, fullName: {firstName: name}}) {\n  console.log(displayName + ' is ' + name);\n}\n\nvar user = { \n  id: 42, \n  displayName: 'jdoe',\n  fullName: { \n      firstName: 'John',\n      lastName: 'Doe'\n  }\n};\n\nconsole.log('userId: ' + userId(user)); // \"userId: 42\"\nwhois(user); // \"jdoe is John\"</pre> <p>This unpacks the <code>id</code>, <code>displayName</code> and <code>firstName</code> from the user object and prints them.</p> <h3 id=\"Computed_object_property_names_and_destructuring\">Computed object property names and destructuring</h3> <p>Computed property names, like on <a href=\"object_initializer#Computed_property_names\">object literals</a>, can be used with destructuring.</p> <pre data-language=\"js\">let key = 'z';\nlet {[key]: foo} = {z: 'bar'};\n\nconsole.log(foo); // \"bar\"\n</pre> <h3 id=\"Rest_in_Object_Destructuring\">Rest in Object Destructuring</h3> <p>The <a href=\"https://github.com/tc39/proposal-object-rest-spread\">Rest/Spread Properties for ECMAScript</a> proposal (stage 3) adds the <a href=\"../functions/rest_parameters\">rest</a> syntax to destructuring. Rest properties collect the remaining own enumerable property keys that are not already picked off by the destructuring pattern.</p> <pre data-language=\"js\">let {a, b, ...rest} = {a: 10, b: 20, c: 30, d: 40}\na; // 10 \nb; // 20 \nrest; // { c: 30, d: 40 }</pre> <h3 id=\"Invalid_JavaScript_identifier_as_a_property_name\">Invalid JavaScript identifier as a property name</h3> <p>Destructuring can be used with property names that are not valid JavaScript <a href=\"https://developer.mozilla.org/en-US/docs/Glossary/Identifier\">identifiers</a> by providing an alternative identifer that is valid.</p> <pre data-language=\"js\">const foo = { 'fizz-buzz': true };\nconst { 'fizz-buzz': fizzBuzz } = foo;\n\nconsole.log(fizzBuzz); // \"true\"\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-destructuring-assignment\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Destructuring assignment' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-destructuring-assignment\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Destructuring assignment' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>   <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 49</td>\n<td class=\"bc-supports-yes\"> 14</td>\n<td class=\"bc-supports-yes bc-has-history\"> 41\n<section class=\"bc-history\" id=\"sect1\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 41\n</dt>\n<dd> Firefox provided a non-standard destructuring implementation from Firefox 2 to 40.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 8</td>\n</tr>\n<tr>\n<th scope=\"row\">Computed property names</th>\n<td class=\"bc-supports-yes\"> 49</td>\n<td class=\"bc-supports-yes\"> 14</td>\n<td class=\"bc-supports-yes\"> 34</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-no\"> No</td>\n</tr>\n<tr>\n<th scope=\"row\">Rest in arrays</th>\n<td class=\"bc-supports-yes\"> 49</td>\n<td class=\"bc-supports-yes bc-has-history\"> 14<div class=\"bc-icons\">Disabled </div>\n<section class=\"bc-history\" id=\"sect3\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 14<div class=\"bc-icons\">Disabled </div>\n</dt>\n<dd>Disabled From version 14: this feature is behind the <code>Enable experimental Javascript features</code> preference.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-yes\"> 34</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-no\"> No</td>\n</tr>\n<tr>\n<th scope=\"row\">Rest in objects \n</th>\n<td class=\"bc-supports-yes\"> 60</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 55</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 11.1</td>\n</tr>\n</tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 49</td>\n<td class=\"bc-supports-yes\"> 49</td>\n<td class=\"bc-supports-yes\"> 14</td>\n<td class=\"bc-supports-yes bc-has-history\"> 41\n<section class=\"bc-history\" id=\"sect2\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 41\n</dt>\n<dd> Firefox provided a non-standard destructuring implementation from Firefox 2 to 40.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 8</td>\n<td class=\"bc-supports-yes\"> 5.0</td>\n</tr>\n<tr>\n<th scope=\"row\">Computed property names</th>\n<td class=\"bc-supports-yes\"> 49</td>\n<td class=\"bc-supports-yes\"> 49</td>\n<td class=\"bc-supports-yes\"> 14</td>\n<td class=\"bc-supports-yes\"> 34</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 5.0</td>\n</tr>\n<tr>\n<th scope=\"row\">Rest in arrays</th>\n<td class=\"bc-supports-yes\"> 49</td>\n<td class=\"bc-supports-yes\"> 49</td>\n<td class=\"bc-supports-yes bc-has-history\"> 14<div class=\"bc-icons\">Disabled </div>\n<section class=\"bc-history\" id=\"sect4\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 14<div class=\"bc-icons\">Disabled </div>\n</dt>\n<dd>Disabled From version 14: this feature is behind the <code>Enable experimental Javascript features</code> preference.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-yes\"> 34</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 5.0</td>\n</tr>\n<tr>\n<th scope=\"row\">Rest in objects \n</th>\n<td class=\"bc-supports-yes\"> 60</td>\n<td class=\"bc-supports-yes\"> 60</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 55</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 11.1</td>\n<td class=\"bc-supports-no\"> No</td>\n</tr>\n</tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 6.0.0</td>\n</tr>\n<tr>\n<th scope=\"row\">Computed property names</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">Rest in arrays</th>\n<td class=\"bc-supports-yes\"> 6.0.0</td>\n</tr>\n<tr>\n<th scope=\"row\">Rest in objects \n</th>\n<td class=\"bc-supports-yes\"> 8.3.0</td>\n</tr>\n</tbody>\n</table>\n</div>  <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"assignment_operators\">Assignment operators</a></li> <li><a href=\"https://hacks.mozilla.org/2015/05/es6-in-depth-destructuring/\">\"ES6 in Depth: Destructuring\" on hacks.mozilla.org</a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Destructuring_assignment$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Destructuring_assignment\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Destructuring_assignment</a>\n  </p>\n</div>\n","operators/async_function":"<h1>async function</h1> <p>The <code>async function</code> keyword can be used to define <code>async</code> functions inside expressions.</p> <p>You can also define async functions using an <a href=\"../statements/async_function\">async function statement</a>.</p> <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\">async function [<em>name</em>]([<em>param1</em>[, <em>param2[</em>, ..., <em>paramN</em>]]]) {\n   <em>statements</em>\n}</pre> <p>As of ES2015, you can also use <a href=\"../functions/arrow_functions\">arrow functions</a>.</p> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><code>name</code></dt> <dd>The function name. Can be omitted, in which case the function is <em>anonymous</em>. The name is only local to the function body.</dd> <dt><code>paramN</code></dt> <dd>The name of an argument to be passed to the function.</dd> <dt><code>statements</code></dt> <dd>The statements which comprise the body of the function.</dd> </dl> <h2 id=\"Description\">Description</h2> <p>An <code>async function</code> expression is very similar to, and has almost the same syntax as, an <a href=\"../statements/async_function\"><code>async function statement</code></a>. The main difference between an async <code>function</code> expression and an async <code>function</code> statement is the <em>function name,</em> which can be omitted in <code>async function</code> expressions to create <em>anonymous</em> functions. An <code>async function</code> expression can be used as an <a href=\"https://developer.mozilla.org/en-US/docs/Glossary/IIFE\">IIFE</a> (Immediately Invoked Function Expression) which runs as soon as it is defined. See also the chapter about <a href=\"../functions\">functions</a> for more information.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Simple_example\">Simple example</h3> <pre data-language=\"js\">function resolveAfter2Seconds(x) {\n  return new Promise(resolve =&gt; {\n    setTimeout(() =&gt; {\n      resolve(x);\n    }, 2000);\n  });\n};\n\n\nvar add = async function(x) { // async function expression assigned to a variable\n  var a = await resolveAfter2Seconds(20);\n  var b = await resolveAfter2Seconds(30);\n  return x + a + b;\n};\n\nadd(10).then(v =&gt; {\n  console.log(v);  // prints 60 after 4 seconds.\n});\n\n\n(async function(x) { // async function expression used as an IIFE\n  var p_a = resolveAfter2Seconds(20);\n  var p_b = resolveAfter2Seconds(30);\n  return x + await p_a + await p_b;\n})(10).then(v =&gt; {\n  console.log(v);  // prints 60 after 2 seconds.\n});\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <thead> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> </thead> <tbody> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-async-function-definitions\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'async function' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/9.0/#sec-async-function-definitions\" hreflang=\"en\">ECMAScript 2018 (ECMA-262)<br><small>The definition of 'async function' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/8.0/#sec-async-function-definitions\" hreflang=\"en\">ECMAScript 2017 (ECMA-262)<br><small>The definition of 'async function' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>   <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 55</td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 52</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 42</td>\n<td class=\"bc-supports-yes\"> 10.1</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 55</td>\n<td class=\"bc-supports-yes\"> 55</td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 52</td>\n<td class=\"bc-supports-yes\"> 42</td>\n<td class=\"bc-supports-yes\"> 10.1</td>\n<td class=\"bc-supports-yes\"> 6.0</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes bc-has-history\"> 7.6.0\n<section class=\"bc-history\" id=\"sect1\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 7.6.0\n</dt>\n\n<dt class=\"bc-supports-yes bc-supports\"> 7.0.0<div class=\"bc-icons\">Disabled </div>\n</dt>\n<dd>Disabled From version 7.0.0: this feature is behind the <code>--harmony</code> runtime flag.</dd>\n</dl></section>\n</td>\n</tr></tbody>\n</table>\n</div>  <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"../statements/async_function\"><code>async function</code></a></li> <li>\n<a href=\"../global_objects/asyncfunction\"><code>AsyncFunction</code></a> object</li> <li><a href=\"await\"><code>await</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/async_function$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/async_function\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/async_function</a>\n  </p>\n</div>\n","operators/function":"<h1>function</h1> <p>The <code>function</code> keyword can be used to define a function inside an expression.</p> <p>You can also define functions using the <a href=\"../global_objects/function\"><code>Function</code></a> constructor and a <a href=\"../statements/function\"><code>function declaration</code></a>.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/expressions-functionexpression.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\">var myFunction = function [<em>name</em>]([<em>param1</em>[, <em>param2[</em>, ..., <em>paramN</em>]]]) {\n   <em>statements</em>\n};</pre> <p>As of ES2015, you can also use <a href=\"../functions/arrow_functions\">arrow functions</a>.</p> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><code>name</code></dt> <dd>The function name. Can be omitted, in which case the function is <em>anonymous</em>. The name is only local to the function body.</dd> <dt><code>paramN</code></dt> <dd>The name of an argument to be passed to the function.</dd> <dt><code>statements</code></dt> <dd>The statements which comprise the body of the function.</dd> </dl> <h2 id=\"Description\">Description</h2> <p>A function expression is very similar to and has almost the same syntax as a function statement (see <a href=\"../statements/function\">function statement</a> for details). The main difference between a function expression and a function statement is the <em>function name,</em> which can be omitted in function expressions to create <em>anonymous</em> functions. A function expression can be used as a <a href=\"https://developer.mozilla.org/en-US/docs/Glossary/IIFE\">IIFE (Immediately Invoked Function Expression)</a> which runs as soon as it is defined. See also the chapter about <a href=\"../functions\">functions</a> for more information.</p> <h3 id=\"Function_expression_hoisting\">Function expression hoisting</h3> <p>Function expressions in JavaScript are not hoisted, unlike <a href=\"../statements/function#Function_declaration_hoisting\"><code>function declarations</code></a>. You can't use function expressions before you define them:</p> <pre data-language=\"js\">console.log(notHoisted) // undefined \n//even though the variable name is hoisted, the definition isn't. so it's undefined.\nnotHoisted(); // TypeError: notHoisted is not a function\n\nvar notHoisted = function() {\n   console.log('bar');\n};\n</pre> <h3 id=\"Named_function_expression\">Named function expression</h3> <p>If you want to refer to the current function inside the function body, you need to create a named function expression. <u><strong>This name is then local only to the function body (scope)</strong></u>. This also avoids using the non-standard <code><a href=\"../functions/arguments/callee\">arguments.callee</a></code> property.</p> <pre data-language=\"js\">var math = {\n  'factit': function factorial(n) {\n    console.log(n)\n    if (n &lt;= 1) {\n      return 1;\n    }\n    return n * factorial(n - 1);\n  }\n};\n\nmath.factit(3) //3;2;1;\n</pre> <p>The variable the function expression is assigned to will have a <code>name</code> property. The name doesn't change if it's assigned to a different variable. If function name is omitted, it will be the variable name (implicit name). If function name is present, it will be the function name (explicit name). This also applies to <a href=\"../functions/arrow_functions\">arrow functions</a> (arrows don't have a name so you can only give the variable an implicit name).</p> <pre data-language=\"js\">var foo = function() {}\nfoo.name // \"foo\"\n\nvar foo2 = foo\nfoo2.name // \"foo\"\n\nvar bar = function baz() {}\nbar.name // \"baz\"\n\nconsole.log(foo === foo2); // true\nconsole.log(typeof baz); // undefined\nconsole.log(bar === baz); // false (errors because baz == undefined)\n</pre> <h2 id=\"Examples\">Examples</h2> <p>The following example defines an unnamed function and assigns it to <code>x</code>. The function returns the square of its argument:</p> <pre data-language=\"js\">var x = function(y) {\n   return y * y;\n};\n</pre> <p>More commonly it is used as a <a href=\"https://developer.mozilla.org/en-US/docs/Glossary/Callback_function\">callback</a>:</p> <pre data-language=\"js\">button.addEventListener('click', function(event) {\n    console.log('button is clicked!')\n})</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-function-definitions\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Function definitions' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-function-definitions\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Function definitions' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/5.1/#sec-13\" hreflang=\"en\">ECMAScript 5.1 (ECMA-262)<br><small>The definition of 'Function definition' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/publications/files/ECMA-ST-ARCH/ECMA-262,%203rd%20edition,%20December%201999.pdf#sec-13\" hreflang=\"en\">ECMAScript 3rd Edition (ECMA-262)<br><small>The definition of 'Function definition' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition. Implemented in JavaScript 1.5.</td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">Trailing comma in parameters</th>\n<td class=\"bc-supports-yes\"> 58</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 52</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 45</td>\n<td class=\"bc-supports-no\"> No</td>\n</tr>\n</tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">Trailing comma in parameters</th>\n<td class=\"bc-supports-yes\"> 58</td>\n<td class=\"bc-supports-yes\"> 58</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 52</td>\n<td class=\"bc-supports-yes\"> 45</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 7.0</td>\n</tr>\n</tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">Trailing comma in parameters</th>\n<td class=\"bc-supports-yes\"> 8.0.0</td>\n</tr>\n</tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Arrow_functions\"><code>Arrow functions</code></a></li> <li><a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions\"><code>Functions and function scope</code></a></li> <li><a href=\"../global_objects/function\"><code>Function</code></a></li> <li><a href=\"../statements/function\"><code>function statement</code></a></li> <li><a href=\"../statements/function*\"><code>function* statement</code></a></li> <li><a href=\"function*\"><code>function* expression</code></a></li> <li><a href=\"../global_objects/generatorfunction\"><code>GeneratorFunction</code></a></li> <li><a href=\"../statements/async_function\"><code>async function</code></a></li> <li><a href=\"async_function\"><code>async function expression</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/function$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/function\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/function</a>\n  </p>\n</div>\n","operators/instanceof":"<h1>instanceof</h1> <p>The <code>instanceof</code> tests whether the <code>prototype</code> property of a constructor appears anywhere in the prototype chain of an object.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/expressions-instanceof.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\"><em>object</em> instanceof <em>constructor</em></pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><code>object</code></dt> <dd>The object to test.</dd> </dl> <dl> <dt><code>constructor</code></dt> <dd>Function to test against</dd> </dl> <h2 id=\"Description\">Description</h2> <p>The <code>instanceof</code> operator tests the presence of <code>constructor.prototype</code> in <code>object</code>'s prototype chain.</p> <pre data-language=\"js\">// defining constructors\nfunction C() {}\nfunction D() {}\n\nvar o = new C();\n\n// true, because: Object.getPrototypeOf(o) === C.prototype\no instanceof C;\n\n// false, because D.prototype is nowhere in o's prototype chain\no instanceof D;\n\no instanceof Object; // true, because:\nC.prototype instanceof Object // true\n\nC.prototype = {};\nvar o2 = new C();\n\no2 instanceof C; // true\n\n// false, because C.prototype is nowhere in\n// o's prototype chain anymore\no instanceof C; \n\nD.prototype = new C(); // add C to [[Prototype]] linkage of D\nvar o3 = new D();\no3 instanceof D; // true\no3 instanceof C; // true since C.prototype is now in o3's prototype chain\n</pre> <p>Note that the value of an <code>instanceof</code> test can change based on changes to the <code>prototype</code> property of constructors, and it can also be changed by changing an object prototype using <code>Object.setPrototypeOf</code>. It is also possible using the non-standard <code>__proto__</code> pseudo-property.</p> <h3 id=\"instanceof_and_multiple_context_(e.g._frames_or_windows)\">\n<code>instanceof</code> and multiple context (e.g. frames or windows)</h3> <p>Different scopes have different execution environments. This means that they have different built-ins (different global object, different constructors, etc.). This may result in unexpected results. For instance, <code>[] instanceof window.frames[0].Array</code> will return <code>false</code>, because <code>Array.prototype !== </code><code>window.frames[0].Array</code> and arrays inherit from the former.</p> <p>This may not make sense at first but when you start dealing with multiple frames or windows in your script and pass objects from one context to another via functions, this will be a valid and strong issue. For instance, you can securely check if a given object is, in fact, an Array using <code>Array.isArray(myObj)</code></p> <p>For example checking if a <a href=\"https://developer.mozilla.org/en-US/docs/Web/API/Node\">Nodes</a> is a <a href=\"https://developer.mozilla.org/en-US/docs/Web/API/SVGElement\">SVGElement</a> in a different context you can use <code>myNode instanceof myNode.ownerDocument.defaultView.SVGElement</code></p> <div class=\"note\">\n<strong>Note for Mozilla developers:</strong><br> In code using XPCOM <code>instanceof</code> has special effect: <code>obj instanceof </code><em><code>xpcomInterface</code></em> (e.g. <code>Components.interfaces.nsIFile</code>) calls <code>obj.QueryInterface(<em>xpcomInterface</em>)</code> and returns <code>true</code> if QueryInterface succeeded. A side effect of such call is that you can use <em><code>xpcomInterface</code></em>'s properties on <code>obj</code> after a successful <code>instanceof</code> test. Unlike standard JavaScript globals, the test <code>obj instanceof xpcomInterface</code> works as expected even if <code>obj</code> is from a different scope.</div> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Demonstrating_that_String_and_Date_are_of_type_Object_and_exceptional_cases\">Demonstrating that <code>String</code> and <code>Date</code> are of type <code>Object</code> and exceptional cases</h3> <p>The following code uses <code>instanceof</code> to demonstrate that <code>String</code> and <code>Date</code> objects are also of type <code>Object</code> (they are derived from <code>Object</code>).</p> <p>However, objects created with the object literal notation are an exception here: Although the prototype is undefined, <code>instanceof Object</code> returns <code>true</code>.</p> <pre data-language=\"js\">var simpleStr = 'This is a simple string'; \nvar myString  = new String();\nvar newStr    = new String('String created with constructor');\nvar myDate    = new Date();\nvar myObj     = {};\nvar myNonObj  = Object.create(null);\n\nsimpleStr instanceof String; // returns false, checks the prototype chain, finds undefined\nmyString  instanceof String; // returns true\nnewStr    instanceof String; // returns true\nmyString  instanceof Object; // returns true\n\nmyObj    instanceof Object;    // returns true, despite an undefined prototype\n({})     instanceof Object;    // returns true, same case as above\nmyNonObj instanceof Object;    // returns false, a way to create an object that is not an instance of Object\n\nmyString instanceof Date;   // returns false\n\nmyDate instanceof Date;     // returns true\nmyDate instanceof Object;   // returns true\nmyDate instanceof String;   // returns false\n</pre> <h3 id=\"Demonstrating_that_mycar_is_of_type_Car_and_type_Object\">Demonstrating that <code>mycar</code> is of type <code>Car</code> and type <code>Object</code>\n</h3> <p>The following code creates an object type <code>Car</code> and an instance of that object type, <code>mycar</code>. The <code>instanceof</code> operator demonstrates that the <code>mycar</code> object is of type <code>Car</code> and of type <code>Object</code>.</p> <pre data-language=\"js\">function Car(make, model, year) {\n  this.make = make;\n  this.model = model;\n  this.year = year;\n}\nvar mycar = new Car('Honda', 'Accord', 1998);\nvar a = mycar instanceof Car;    // returns true\nvar b = mycar instanceof Object; // returns true\n</pre> <h3 id=\"Not_an_instanceof\">Not an instanceof</h3> <p>To test if an object is not an instanceof a specific Constructor, you can do</p> <pre data-language=\"js\">if (!(mycar instanceof Car)) {\n  // Do something, like mycar = new Car(mycar)\n}\n</pre> <p>This is really different from</p> <pre data-language=\"js\">if (!mycar instanceof Car)</pre> <p>that will always be false (<code>!mycar</code> will be treated before <code>instanceof</code>, so you always try to know if a boolean is an instance of <code>Car</code>).</p> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-relational-operators\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Relational Operators' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-relational-operators\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Relational Operators' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/5.1/#sec-11.8.6\" hreflang=\"en\">ECMAScript 5.1 (ECMA-262)<br><small>The definition of 'The instanceof operator' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/publications/files/ECMA-ST-ARCH/ECMA-262,%203rd%20edition,%20December%201999.pdf#sec-11.8.6\" hreflang=\"en\">ECMAScript 3rd Edition (ECMA-262)<br><small>The definition of 'The instanceof operator' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition. Implemented in JavaScript 1.4.</td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><code><a href=\"typeof\">typeof</a></code></li> <li><a href=\"../global_objects/symbol/hasinstance\"><code>Symbol.hasInstance</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/instanceof$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/instanceof\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/instanceof</a>\n  </p>\n</div>\n","operators/object_initializer":"<h1>Object initializer</h1> <p>Objects can be initialized using <a href=\"../global_objects/object\"><code>new Object()</code></a>,<code> <a href=\"../global_objects/object/create\">Object.create()</a></code>, or using the <em>literal</em> notation (<em>initializer</em> notation). An object initializer is a comma-delimited list of zero or more pairs of property names and associated values of an object, enclosed in curly braces (<code>{}</code>).</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/expressions-objectinitializer.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre data-language=\"js\">var o = {};\nvar o = {a: 'foo', b: 42, c: {}};\n\nvar a = 'foo', b = 42, c = {};\nvar o = {a: a, b: b, c: c};\n\nvar o = {\n  <var>property: function </var>(<var>parameters</var>) {},\n  get <var>property</var>() {},\n  set <var>property</var>(<var>value</var>) {}\n};\n</pre> <h3 id=\"New_notations_in_ECMAScript_2015\">New notations in ECMAScript 2015</h3> <p>Please see the compatibility table for support for these notations. In non-supporting environments, these notations will lead to syntax errors.</p> <pre data-language=\"js\">// Shorthand property names (ES2015)\nvar a = 'foo', b = 42, c = {};\nvar o = {a, b, c};\n\n// Shorthand method names (ES2015)\nvar o = {\n  <var>property</var>(<var>parameters</var>) {}\n};\n\n// Computed property names (ES2015)\nvar prop = 'foo';\nvar o = {\n  [prop]: 'hey',\n  ['b' + 'ar']: 'there'\n};</pre> <h2 id=\"Description\">Description</h2> <p>An object initializer is an expression that describes the initialization of an <a href=\"../global_objects/object\"><code>Object</code></a>. Objects consist of <em>properties</em>, which are used to describe an object. Values of object properties can either contain <a href=\"https://developer.mozilla.org/en-US/docs/Glossary/primitive\">primitive</a> data types or other objects.</p> <h3 id=\"Creating_objects\">Creating objects</h3> <p>An empty object with no properties can be created like this:</p> <pre data-language=\"js\">var object = {};</pre> <p>However, the advantage of the <em>literal</em> or <em>initializer</em> notation is, that you are able to quickly create objects with properties inside the curly braces. You simply notate a list of <code>key: value</code> pairs delimited by comma. The following code creates an object with three properties and the keys are <code>\"foo\"</code>, <code>\"age\"</code> and <code>\"baz\"</code>. The values of these keys are a string <code>\"bar\"</code>, a number <code>42</code>, and another object.</p> <pre data-language=\"js\">var object = {\n  foo: 'bar',\n  age: 42,\n  baz: {myProp: 12}\n}</pre> <h3 id=\"Accessing_properties\">Accessing properties</h3> <p>Once you have created an object, you might want to read or change them. Object properties can be accessed by using the dot notation or the bracket notation. See <a href=\"property_accessors\">property accessors</a> for detailed information.</p> <pre data-language=\"js\">object.foo; // \"bar\"\nobject['age']; // 42\n\nobject.foo = 'baz';\n</pre> <h3 id=\"Property_definitions\">Property definitions</h3> <p>We have already learned how to notate properties using the initializer syntax. Oftentimes, there are variables in your code that you would like to put into an object. You will see code like this:</p> <pre data-language=\"js\">var a = 'foo', \n    b = 42,\n    c = {};\n\nvar o = { \n  a: a,\n  b: b,\n  c: c\n};</pre> <p>With ECMAScript 2015, there is a shorter notation available to achieve the same:</p> <pre data-language=\"js\">var a = 'foo', \n    b = 42, \n    c = {};\n\n// Shorthand property names (ES2015)\nvar o = {a, b, c};\n\n// In other words,\nconsole.log((o.a === {a}.a)); // true\n</pre> <h4 id=\"Duplicate_property_names\">Duplicate property names</h4> <p>When using the same name for your properties, the second property will overwrite the first.</p> <pre data-language=\"js\">var a = {x: 1, x: 2};\nconsole.log(a); // {x: 2}\n</pre> <p>In ECMAScript 5 strict mode code, duplicate property names were considered a <a href=\"../global_objects/syntaxerror\"><code>SyntaxError</code></a>. With the introduction of computed property names making duplication possible at runtime, ECMAScript 2015 has removed this restriction.</p> <pre data-language=\"js\">function haveES2015DuplicatePropertySemantics() {\n  'use strict';\n  try {\n    ({prop: 1, prop: 2});\n\n    // No error thrown, duplicate property names allowed in strict mode\n    return true;\n  } catch(e) {\n    // Error thrown, duplicates prohibited in strict mode\n    return false;\n  }\n}</pre> <h3 id=\"Method_definitions\">Method definitions</h3> <p>A property of an object can also refer to a <a href=\"../functions\">function</a> or a <a href=\"../functions/get\">getter</a> or <a href=\"../functions/set\">setter</a> method.</p> <pre data-language=\"js\">var o = {\n  <var>property: function </var>(<var>parameters</var>) {},\n  get <var>property</var>() {},\n  set <var>property</var>(<var>value</var>) {}\n};</pre> <p>In ECMAScript 2015, a shorthand notation is available, so that the keyword \"function\" is no longer necessary.</p> <pre data-language=\"js\">// Shorthand method names (ES2015)\nvar o = {\n  <var>property</var>(<var>parameters</var>) {},\n  *<var>generator</var>() {}\n};</pre> <p>In ECMAScript 2015 There is a way to concisely define properties whose values are generator functions:</p> <pre data-language=\"js\">var o = {\n  *<var>generator</var>() {\n    ...........\n  }\n};</pre> <p>Which is equivalent to this ES5-like notation (but note that ECMAScript 5 has no generators):</p> <pre data-language=\"js\">var o = {\n  generator<var>: function* </var>() {\n    ...........\n  }\n};</pre> <p>For more information and examples about methods, see <a href=\"../functions/method_definitions\">method definitions</a>.</p> <h3 id=\"Computed_property_names\">Computed property names</h3> <p>Starting with ECMAScript 2015, the object initializer syntax also supports computed property names. That allows you to put an expression in brackets <code>[]</code>, that will be computed and used as the property name. This is reminiscent of the bracket notation of the <a href=\"property_accessors\">property accessor</a> syntax, which you might have used to read and set properties already. Now you can use a similar syntax in object literals, too:</p> <pre data-language=\"js\">// Computed property names (ES2015)\nvar i = 0;\nvar a = {\n  ['foo' + ++i]: i,\n  ['foo' + ++i]: i,\n  ['foo' + ++i]: i\n};\n\nconsole.log(a.foo1); // 1\nconsole.log(a.foo2); // 2\nconsole.log(a.foo3); // 3\n\nvar param = 'size';\nvar config = {\n  [param]: 12,\n  ['mobile' + param.charAt(0).toUpperCase() + param.slice(1)]: 4\n};\n\nconsole.log(config); // {size: 12, mobileSize: 4}</pre> <h3 id=\"Spread_properties\">Spread properties</h3> <p>The <a href=\"https://github.com/tc39/proposal-object-rest-spread\">Rest/Spread Properties for ECMAScript</a> proposal (stage 4) adds <a href=\"spread_syntax\">spread</a> properties to object literals. It copies own enumerable properties from a provided object onto a new object.</p> <p>Shallow-cloning (excluding prototype) or merging objects is now possible using a shorter syntax than <a href=\"../global_objects/object/assign\"><code>Object.assign()</code></a>.</p> <pre data-language=\"js\">var obj1 = { foo: 'bar', x: 42 };\nvar obj2 = { foo: 'baz', y: 13 };\n\nvar clonedObj = { ...obj1 };\n// Object { foo: \"bar\", x: 42 }\n\nvar mergedObj = { ...obj1, ...obj2 };\n// Object { foo: \"baz\", x: 42, y: 13 }</pre> <p>Note that <a href=\"../global_objects/object/assign\"><code>Object.assign()</code></a> triggers <a href=\"../functions/set\">setters</a> whereas the spread operator doesn't.</p> <h3 id=\"Prototype_mutation\">Prototype mutation</h3> <p>A property definition of the form <code>__proto__: value</code> or <code>\"__proto__\": value</code> does not create a property with the name <code>__proto__</code>. Instead, if the provided value is an object or <a href=\"../global_objects/null\"><code>null</code></a>, it changes the <code>[[Prototype]]</code> of the created object to that value. (If the value is not an object or null, the object is not changed.)</p> <pre data-language=\"js\">var obj1 = {};\nassert(Object.getPrototypeOf(obj1) === Object.prototype);\n\nvar obj2 = {__proto__: null};\nassert(Object.getPrototypeOf(obj2) === null);\n\nvar protoObj = {};\nvar obj3 = {'__proto__': protoObj};\nassert(Object.getPrototypeOf(obj3) === protoObj);\n\nvar obj4 = {__proto__: 'not an object or null'};\nassert(Object.getPrototypeOf(obj4) === Object.prototype);\nassert(!obj4.hasOwnProperty('__proto__'));\n</pre> <p>Only a single prototype mutation is permitted in an object literal: multiple prototype mutations are a syntax error.</p> <p>Property definitions that do not use \"colon\" notation are not prototype mutations: they are property definitions that behave identically to similar definitions using any other name.</p> <pre data-language=\"js\">var __proto__ = 'variable';\n\nvar obj1 = {__proto__};\nassert(Object.getPrototypeOf(obj1) === Object.prototype);\nassert(obj1.hasOwnProperty('__proto__'));\nassert(obj1.__proto__ === 'variable');\n\nvar obj2 = {__proto__() { return 'hello'; }};\nassert(obj2.__proto__() === 'hello');\n\nvar obj3 = {['__prot' + 'o__']: 17};\nassert(obj3.__proto__ === 17);\n</pre> <h2 id=\"Object_literal_notation_vs_JSON\">Object literal notation vs JSON</h2> <p>The object literal notation is not the same as the <strong>J</strong>ava<strong>S</strong>cript <strong>O</strong>bject <strong>N</strong>otation (<a href=\"https://developer.mozilla.org/en-US/docs/Glossary/JSON\">JSON</a>). Although they look similar, there are differences between them:</p> <ul> <li>JSON permits <em>only</em> property definition using <code>\"property\": value</code> syntax. The property name must be double-quoted, and the definition cannot be a shorthand.</li> <li>In JSON the values can only be strings, numbers, arrays, <code>true</code>, <code>false</code>, <code>null</code>, or another (JSON) object.</li> <li>A function value (see \"Methods\" above) can not be assigned to a value in JSON.</li> <li>Objects like <a href=\"../global_objects/date\"><code>Date</code></a> will be a string after <a href=\"../global_objects/json/parse\"><code>JSON.parse()</code></a>.</li> <li>\n<a href=\"../global_objects/json/parse\"><code>JSON.parse()</code></a> will reject computed property names and an error will be thrown.</li> </ul> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/publications/files/ECMA-ST-ARCH/ECMA-262,%201st%20edition,%20June%201997.pdf\" hreflang=\"en\">ECMAScript 1st Edition (ECMA-262)</a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>initial definition.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/5.1/#sec-11.1.5\" hreflang=\"en\">ECMAScript 5.1 (ECMA-262)<br><small>The definition of 'Object Initializer' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>\n<a href=\"../functions/get\">getter</a> and <a href=\"../functions/set\">setter</a> added.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-object-initializer\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Object Initializer' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Shorthand method/property names and computed property names added.</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-object-initializer\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Object Initializer' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>   <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n</tr>\n<tr>\n<th scope=\"row\">Computed property names</th>\n<td class=\"bc-supports-yes\"> 47</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 34</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 34</td>\n<td class=\"bc-supports-yes\"> 8</td>\n</tr>\n<tr>\n<th scope=\"row\">Shorthand property names</th>\n<td class=\"bc-supports-yes\"> 47</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 33</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 34</td>\n<td class=\"bc-supports-yes\"> 9</td>\n</tr>\n<tr>\n<th scope=\"row\">Shorthand method names</th>\n<td class=\"bc-supports-yes\"> 47</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 34</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 34</td>\n<td class=\"bc-supports-yes\"> 9</td>\n</tr>\n<tr>\n<th scope=\"row\">Spread properties \n</th>\n<td class=\"bc-supports-yes\"> 60</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 55</td>\n<td class=\"bc-supports-no\"> No</td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 11.1</td>\n</tr>\n</tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> 18</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">Computed property names</th>\n<td class=\"bc-supports-yes\"> 47</td>\n<td class=\"bc-supports-yes\"> 47</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 34</td>\n<td class=\"bc-supports-yes\"> 34</td>\n<td class=\"bc-supports-yes\"> 8</td>\n<td class=\"bc-supports-yes\"> 5.0</td>\n</tr>\n<tr>\n<th scope=\"row\">Shorthand property names</th>\n<td class=\"bc-supports-yes\"> 47</td>\n<td class=\"bc-supports-yes\"> 47</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 33</td>\n<td class=\"bc-supports-yes\"> 34</td>\n<td class=\"bc-supports-yes\"> 9</td>\n<td class=\"bc-supports-yes\"> 5.0</td>\n</tr>\n<tr>\n<th scope=\"row\">Shorthand method names</th>\n<td class=\"bc-supports-yes\"> 47</td>\n<td class=\"bc-supports-yes\"> 47</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 34</td>\n<td class=\"bc-supports-yes\"> 34</td>\n<td class=\"bc-supports-yes\"> 9</td>\n<td class=\"bc-supports-yes\"> 5.0</td>\n</tr>\n<tr>\n<th scope=\"row\">Spread properties \n</th>\n<td class=\"bc-supports-yes\"> 60</td>\n<td class=\"bc-supports-yes\"> 60</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 55</td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 11.1</td>\n<td class=\"bc-supports-no\"> No</td>\n</tr>\n</tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">Computed property names</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">Shorthand property names</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">Shorthand method names</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">Spread properties \n</th>\n<td class=\"bc-supports-yes\"> 8.3.0</td>\n</tr>\n</tbody>\n</table>\n</div>  <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"property_accessors\">Property accessors</a></li> <li>\n<code><a href=\"../functions/get\">get</a></code> / <code><a href=\"../functions/set\">set</a></code>\n</li> <li><a href=\"../functions/method_definitions\">Method definitions</a></li> <li><a href=\"../lexical_grammar\">Lexical grammar</a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Object_initializer$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Object_initializer\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Object_initializer</a>\n  </p>\n</div>\n","operators/await":"<h1>await</h1> <p>The <code>await</code> operator is used to wait for a <a href=\"../global_objects/promise\"><code>Promise</code></a>. It can only be used inside an <a href=\"../statements/async_function\"><code>async function</code></a>.</p> <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\">[<em>rv</em>] = await <em>expression</em>;</pre> <dl> <dt><code>expression</code></dt> <dd>A <a href=\"../global_objects/promise\"><code>Promise</code></a> or any value to wait for.</dd> <dt><code>rv</code></dt> <dd> <p>Returns the fulfilled value of the promise, or the value itself if it's not a <code>Promise</code>.</p> </dd> </dl> <h2 id=\"Description\">Description</h2> <p>The <code>await</code> expression causes <code>async</code> function execution to pause until a <code>Promise</code> is resolved, that is fulfilled or rejected, and to resume execution of the <code>async</code> function after fulfillment. When resumed, the value of the <code>await</code> expression is that of the fulfilled <code>Promise</code>.</p> <p>If the <code>Promise</code> is rejected, the <code>await</code> expression throws the rejected value.</p> <p>If the value of the <em>expression</em> following the <code>await</code> operator is not a <code>Promise</code>, it's converted to a <a href=\"../global_objects/promise/resolve\">resolved Promise</a>.</p> <h2 id=\"Examples\">Examples</h2> <p>If a <code>Promise</code> is passed to an <code>await</code> expression, it waits for the <code>Promise</code> to be fulfilled and returns the fulfilled value.</p> <pre data-language=\"js\">function resolveAfter2Seconds(x) { \n  return new Promise(resolve =&gt; {\n    setTimeout(() =&gt; {\n      resolve(x);\n    }, 2000);\n  });\n}\n\nasync function f1() {\n  var x = await resolveAfter2Seconds(10);\n  console.log(x); // 10\n}\nf1();\n</pre> <p>If the value is not a <code>Promise</code>, it converts the value to a resolved <code>Promise</code>, and waits for it.</p> <pre data-language=\"js\">async function f2() {\n  var y = await 20;\n  console.log(y); // 20\n}\nf2();</pre> <p>If the <code>Promise</code> is rejected, the rejected value is thrown.</p> <pre data-language=\"js\">async function f3() {\n  try {\n    var z = await Promise.reject(30);\n  } catch(e) {\n    console.log(e); // 30\n  }\n}\nf3();</pre> <p>Handle rejected <code>Promise</code> without try block.</p> <pre data-language=\"js\">var response = await promisedFunction().catch((err) =&gt; { console.log(err); });\n// response will be undefined if the promise is rejected\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <thead> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> </thead> <tbody> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-async-function-definitions\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'async functions' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/9.0/#sec-async-function-definitions\" hreflang=\"en\">ECMAScript 2018 (ECMA-262)<br><small>The definition of 'async functions' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/8.0/#sec-async-function-definitions\" hreflang=\"en\">ECMAScript 2017 (ECMA-262)<br><small>The definition of 'async functions' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>   <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 55</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 52</td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 42</td>\n<td class=\"bc-supports-yes\"> 10.1</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 55</td>\n<td class=\"bc-supports-yes\"> 55</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 52</td>\n<td class=\"bc-supports-yes\"> 42</td>\n<td class=\"bc-supports-yes\"> 10.1</td>\n<td class=\"bc-supports-yes\"> 6.0</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes bc-has-history\"> 7.6.0\n<section class=\"bc-history\" id=\"sect1\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 7.6.0\n</dt>\n\n<dt class=\"bc-supports-yes bc-supports\"> 7.0.0<div class=\"bc-icons\">Disabled </div>\n</dt>\n<dd>Disabled From version 7.0.0: this feature is behind the <code>--harmony</code> runtime flag.</dd>\n</dl></section>\n</td>\n</tr></tbody>\n</table>\n</div>  <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"../statements/async_function\"><code>async function</code></a></li> <li><a href=\"async_function\"><code>async function expression</code></a></li> <li>\n<a href=\"../global_objects/asyncfunction\"><code>AsyncFunction</code></a> object</li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/await$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/await\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/await</a>\n  </p>\n</div>\n","operators/super":"<h1>super</h1> <p>The <strong>super</strong> keyword is used to access and call functions on an object's parent.</p> <p>The <code>super.prop</code> and <code>super[expr]</code> expressions are valid in any <a href=\"../functions/method_definitions\">method definition</a> in both <a href=\"../classes\">classes</a> and <a href=\"object_initializer\">object literals</a>.</p> <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\">super([arguments]); // calls the parent constructor.\nsuper.functionOnParent([arguments]);\n</pre> <h2 id=\"Description\">Description</h2> <p>When used in a constructor, the <code>super</code> keyword appears alone and must be used before the <code>this</code> keyword is used. The <code>super</code> keyword can also be used to call functions on a parent object.</p> <h2 id=\"Example\">Example</h2> <h3 id=\"Using_super_in_classes\">Using <code>super</code> in classes</h3> <p>This code snippet is taken from the <a href=\"https://github.com/GoogleChrome/samples/blob/gh-pages/classes-es6/index.html\">classes sample</a> (<a href=\"https://googlechrome.github.io/samples/classes-es6/index.html\">live demo</a>). Here <code>super()</code> is called to avoid duplicating the constructor parts' that are common between <code>Rectangle</code> and <code>Square</code>.</p> <pre data-language=\"js\">class Rectangle {\n  constructor(height, width) {\n    this.name = 'Rectangle';\n    this.height = height;\n    this.width = width;\n  }\n  sayName() {\n    console.log('Hi, I am a ', this.name + '.');\n  }\n  get area() {\n    return this.height * this.width;\n  }\n  set area(value) {\n    this.height = this.width = Math.sqrt(value);\n  }\n}\n\nclass Square extends Rectangle {\n  constructor(length) {\n     // Here, it calls the parent class' constructor with lengths\n     // provided for the Rectangle's width and height\n      super(length, length);\n\n    this.height; // ReferenceError, super needs to be called first!\n \n    // Note: In derived classes, super() must be called before you\n    // can use 'this'. Leaving this out will cause a reference error.\n    this.name = 'Square';\n  }\n}</pre> <h3 id=\"Super-calling_static_methods\">Super-calling static methods</h3> <p>You are also able to call super on <a href=\"../classes/static\">static</a> methods.</p> <pre data-language=\"js\">class Rectangle {\n  constructor() {}\n  static logNbSides() {\n    return 'I have 4 sides';\n  }\n}\n\nclass Square extends Rectangle {\n  constructor() {}\n  static logDescription() {\n    return super.logNbSides() + ' which are all equal';\n  }\n}\nSquare.logDescription(); // 'I have 4 sides which are all equal'\n</pre> <h3 id=\"Deleting_super_properties_will_throw_an_error\">Deleting super properties will throw an error</h3> <p>You cannot use the <a href=\"delete\">delete operator</a> and <code>super.prop</code> or <code>super[expr]</code> to delete a parent class' property, it will throw a <a href=\"../global_objects/referenceerror\"><code>ReferenceError</code></a>.</p> <pre data-language=\"js\">class Base {\n  constructor() {}\n  foo() {}\n}\nclass Derived extends Base {\n  constructor() {}\n  delete() {\n    delete super.foo; // this is bad\n  }\n}\n\nnew Derived().delete(); // ReferenceError: invalid delete involving 'super'. </pre> <h3 id=\"super.prop_cannot_overwrite_non-writable_properties\">\n<code>super.prop</code> cannot overwrite non-writable properties</h3> <p>When defining non-writable properties with e.g. <a href=\"../global_objects/object/defineproperty\"><code>Object.defineProperty</code></a>, <code>super</code> cannot overwrite the value of the property.</p> <pre data-language=\"js\">class X {\n  constructor() {\n    Object.defineProperty(this, 'prop', {\n      configurable: true,\n      writable: false, \n      value: 1\n    });\n  }\n}\n\nclass Y extends X {\n  constructor() {\n    super();\n  }\n  foo() {\n    super.prop = 2;   // Cannot overwrite the value.\n  }\n}\n\nvar y = new Y();\ny.foo(); // TypeError: \"prop\" is read-only\nconsole.log(y.prop); // 1\n</pre> <h3 id=\"Using_super.prop_in_object_literals\">Using <code>super.prop</code> in object literals</h3> <p>Super can also be used in the <a href=\"object_initializer\">object initializer / literal</a> notation. In this example, two objects define a method. In the second object, <code>super</code> calls the first object's method. This works with the help of <a href=\"../global_objects/object/setprototypeof\"><code>Object.setPrototypeOf()</code></a> with which we are able to set the prototype of <code>obj2</code> to <code>obj1</code>, so that <code>super</code> is able to find <code>method1</code> on <code>obj1</code>.</p> <pre data-language=\"js\">var obj1 = {\n  method1() {\n    console.log('method 1');\n  }\n}\n\nvar obj2 = {\n  method2() {\n   super.method1();\n  }\n}\n\nObject.setPrototypeOf(obj2, obj1);\nobj2.method2(); // logs \"method 1\"\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-super-keyword\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'super' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-super-keyword\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'super' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 42</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 45</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 42</td>\n<td class=\"bc-supports-yes\"> 42</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 45</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4.0</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"../classes\">Classes</a></li> <li><a href=\"https://medium.com/beginners-guide-to-mobile-web-development/super-and-extends-in-javascript-es6-understanding-the-tough-parts-6120372d3420\">Anurag Majumdar - Super &amp; Extends in JavaScript</a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/super$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/super\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/super</a>\n  </p>\n</div>\n","global_objects/typedarray":"<h1>TypedArray</h1> <p>A <strong><em>TypedArray</em></strong> object describes an array-like view of an underlying <a href=\"arraybuffer\">binary data buffer</a>. There is no global property named <code>TypedArray</code>, nor is there a directly visible <code>TypedArray</code> constructor. Instead, there are a number of different global properties, whose values are typed array constructors for specific element types, listed below. On the following pages you will find common properties and methods that can be used with any typed array containing elements of any type.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/typedarray-constructor.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\">new <em>TypedArray</em>(); // new in ES2017\nnew<em> TypedArray</em>(length);\nnew <em>TypedArray</em>(typedArray);\nnew <em>TypedArray</em>(object);\nnew <em>TypedArray</em>(buffer [, byteOffset [, length]]);\n\nwhere <em>TypedArray()</em> is one of:\n\nInt8Array();\nUint8Array();\nUint8ClampedArray();\nInt16Array();\nUint16Array();\nInt32Array();\nUint32Array();\nFloat32Array();\nFloat64Array();\n</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt>length</dt> <dd>When called with a <code>length</code> argument, an internal array buffer is created in memory, of size <em>length multiplied by BYTES_PER_ELEMENT</em> bytes, containing zeros.</dd> <dt>typedArray</dt> <dd>When called with a <code>typedArray</code> argument, which can be an object of any of the typed array types (such as <code>Int32Array</code>), the <code>typedArray</code> gets copied into a new typed array. Each value in <code>typedArray</code> is converted to the corresponding type of the constructor before being copied into the new array. The length of the new typed array will be same as the length of the <code>typedArray</code> argument.</dd> <dt>object</dt> <dd>When called with an <code>object</code> argument, a new typed array is created as if by the <code><em>TypedArray</em>.from()</code> method.</dd> <dt>buffer, byteOffset, length</dt> <dd>When called with a <code>buffer</code>, and optionally a <code>byteOffset</code> and a <code>length</code> argument, a new typed array view is created that views the specified <a href=\"arraybuffer\"><code>ArrayBuffer</code></a>. The <code>byteOffset</code> and <code>length</code> parameters specify the memory range that will be exposed by the typed array view. If both are omitted, all of <code>buffer</code> is viewed; if only <code>length</code> is omitted, the remainder of <code>buffer</code> is viewed.</dd> </dl> <h2 id=\"Description\">Description</h2> <p>ECMAScript 2015 defines a <em>TypedArray</em> constructor that serves as the <code>[[Prototype]]</code> of all <em>TypedArray</em> constructors. This constructor is not directly exposed: there is no global <code>%TypedArray%</code> or <code>TypedArray</code> property. It is only directly accessible through <code>Object.getPrototypeOf(Int8Array)</code> and similar. All <em>TypedArray</em>s constructors inherit common properties from the <code>%TypedArray%</code> constructor function. Additionally, all typed array prototypes (<em>TypedArray</em><code>.prototype</code>) have <code>%TypedArray%.prototype</code> as their <code>[[Prototype]]</code>.</p> <p>The <code>%TypedArray%</code> constructor on its own is not particularly useful. Calling it or using it in a <code>new</code> expression will throw a <code>TypeError</code>, except when used during object creation in JS engines that support subclassing. There are at present no such engines, so <code>%TypedArray%</code> is only useful to polyfill functions or properties onto all <em>TypedArray</em> constructors.</p> <p>When creating an instance of a <em>TypedArray</em> (e.g. <code>Int8Array</code>), an array buffer is created internally in memory or, if an <code>ArrayBuffer</code> object is given as constructor argument, then this is used instead. The buffer address is saved as an internal property of the instance and all the methods of %<code>TypedArray</code>%.<code>prototype</code>, i.e. set value and get value etc., operate on that array buffer address.</p> <h3 id=\"Property_access\">Property access</h3> <p>You can reference elements in the array using standard array index syntax (that is, using bracket notation). However, getting or setting indexed properties on typed arrays will not search in the prototype chain for this property, even when the indices are out of bound. Indexed properties will consult the <a href=\"arraybuffer\"><code>ArrayBuffer</code></a> and will never look at object properties. You can still use named properties, just like with all objects.</p> <pre data-language=\"js\">// Setting and getting using standard array syntax\nvar int16 = new Int16Array(2);\nint16[0] = 42;\nconsole.log(int16[0]); // 42\n\n// Indexed properties on prototypes are not consulted (Fx 25)\nInt8Array.prototype[20] = 'foo';\n(new Int8Array(32))[20]; // 0\n// even when out of bound\nInt8Array.prototype[20] = 'foo';\n(new Int8Array(8))[20]; // undefined\n// or with negative integers\nInt8Array.prototype[-1] = 'foo';\n(new Int8Array(8))[-1]; // undefined\n\n// Named properties are allowed, though (Fx 30)\nInt8Array.prototype.foo = 'bar';\n(new Int8Array(32)).foo; // \"bar\"</pre> <h2 id=\"TypedArray_objects\">TypedArray objects</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th class=\"header\">Type</th> <th class=\"header\">Value Range</th> <th class=\"header\">Size in bytes</th> <th class=\"header\">Description</th> <th class=\"header\">Web IDL type</th> <th class=\"header\">Equivalent C type</th> </tr> <tr> <td><a href=\"int8array\"><code>Int8Array</code></a></td> <td>-128 to 127</td> <td>1</td> <td>8-bit two's complement signed integer</td> <td><code>byte</code></td> <td><code>int8_t</code></td> </tr> <tr> <td><a href=\"uint8array\"><code>Uint8Array</code></a></td> <td>0 to 255</td> <td>1</td> <td>8-bit unsigned integer</td> <td><code>octet</code></td> <td><code>uint8_t</code></td> </tr> <tr> <td><a href=\"uint8clampedarray\"><code>Uint8ClampedArray</code></a></td> <td>0 to 255</td> <td>1</td> <td>8-bit unsigned integer (clamped)</td> <td><code>octet</code></td> <td><code>uint8_t</code></td> </tr> <tr> <td><a href=\"int16array\"><code>Int16Array</code></a></td> <td>-32768 to 32767</td> <td>2</td> <td>16-bit two's complement signed integer</td> <td><code>short</code></td> <td><code>int16_t</code></td> </tr> <tr> <td><a href=\"uint16array\"><code>Uint16Array</code></a></td> <td>0 to 65535</td> <td>2</td> <td>16-bit unsigned integer</td> <td><code>unsigned short</code></td> <td><code>uint16_t</code></td> </tr> <tr> <td><a href=\"int32array\"><code>Int32Array</code></a></td> <td>-2147483648 to 2147483647</td> <td>4</td> <td>32-bit two's complement signed integer</td> <td><code>long</code></td> <td><code>int32_t</code></td> </tr> <tr> <td><a href=\"uint32array\"><code>Uint32Array</code></a></td> <td>0 to 4294967295</td> <td>4</td> <td>32-bit unsigned integer</td> <td><code>unsigned long</code></td> <td><code>uint32_t</code></td> </tr> <tr> <td><a href=\"float32array\"><code>Float32Array</code></a></td> <td>1.2x10<sup>-38</sup> to 3.4x10<sup>38</sup>\n</td> <td>4</td> <td>32-bit IEEE floating point number ( 7 significant digits e.g. 1.1234567)</td> <td><code>unrestricted float</code></td> <td><code>float</code></td> </tr> <tr> <td><a href=\"float64array\"><code>Float64Array</code></a></td> <td>5.0x10<sup>-324</sup> to 1.8x10<sup>308</sup>\n</td> <td>8</td> <td>64-bit IEEE floating point number (16 significant digits e.g. 1.123...15)</td> <td><code>unrestricted double</code></td> <td><code>double</code></td> </tr> </tbody> </table></div> <h2 id=\"Properties\">Properties</h2> <dl> <dt><a href=\"typedarray/bytes_per_element\"><code>TypedArray.BYTES_PER_ELEMENT</code></a></dt> <dd>Returns a number value of the element size for the different typed array objects.</dd> <dt>\n<em>TypedArray</em>.length</dt> <dd>Length property whose value is 0.</dd> <dt><a href=\"typedarray/name\"><code>TypedArray.name</code></a></dt> <dd>Returns the string value of the constructor name. E.g \"Int8Array\".</dd> <dt><a href=\"typedarray/@@species\"><code>get TypedArray[@@species]</code></a></dt> <dd>The constructor function that is used to create derived objects.</dd> <dt><a href=\"typedarray/prototype\"><code>TypedArray.prototype</code></a></dt> <dd>Prototype for the <em>TypedArray</em> objects.</dd> </dl> <h2 id=\"Methods\">Methods</h2> <dl> <dt><a href=\"typedarray/from\"><code>TypedArray.from()</code></a></dt> <dd>Creates a new typed array from an array-like or iterable object. See also <a href=\"array/from\"><code>Array.from()</code></a>.</dd> <dt><a href=\"typedarray/of\"><code>TypedArray.of()</code></a></dt> <dd>Creates a new typed array with a variable number of arguments. See also <a href=\"array/of\"><code>Array.of()</code></a>.</dd> </dl> <h2 id=\"TypedArray_prototype\">TypedArray prototype</h2> <p>All <em>TypedArray</em>s inherit from <a href=\"typedarray/prototype\"><code>TypedArray.prototype</code></a>.</p> <h3 id=\"Properties_2\">Properties</h3> <dl> <dt><code>TypedArray.prototype.constructor</code></dt> <dd>Returns the function that created an instance's prototype. This is one the corresponding <a href=\"typedarray#TypedArray_objects\">typed array type</a> functions by default.</dd> <dt>\n<a href=\"typedarray/buffer\"><code>TypedArray.prototype.buffer</code></a> <span class=\"inlineIndicator readOnly readOnlyInline\">Read only </span>\n</dt> <dd>Returns the <a href=\"arraybuffer\"><code>ArrayBuffer</code></a> referenced by the typed array. Fixed at construction time and thus <strong>read only</strong>.</dd> <dt>\n<a href=\"typedarray/bytelength\"><code>TypedArray.prototype.byteLength</code></a> <span class=\"inlineIndicator readOnly readOnlyInline\">Read only </span>\n</dt> <dd>Returns the length (in bytes) of the typed array. Fixed at construction time and thus <strong>read only.</strong>\n</dd> <dt>\n<a href=\"typedarray/byteoffset\"><code>TypedArray.prototype.byteOffset</code></a> <span class=\"inlineIndicator readOnly readOnlyInline\">Read only </span>\n</dt> <dd>Returns the offset (in bytes) of the typed array from the start of its <a href=\"arraybuffer\"><code>ArrayBuffer</code></a>. Fixed at construction time and thus <strong>read only.</strong>\n</dd> <dt>\n<a href=\"typedarray/length\"><code>TypedArray.prototype.length</code></a> <span class=\"inlineIndicator readOnly readOnlyInline\">Read only </span>\n</dt> <dd>Returns the number of elements held in the typed array. Fixed at construction time and thus <strong>read only.</strong>\n</dd> </dl> <h3 id=\"Methods_2\">Methods</h3> <dl> <dt><a href=\"typedarray/copywithin\"><code>TypedArray.prototype.copyWithin()</code></a></dt> <dd>Copies a sequence of array elements within the array. See also <a href=\"array/copywithin\"><code>Array.prototype.copyWithin()</code></a>.</dd> <dt><a href=\"typedarray/entries\"><code>TypedArray.prototype.entries()</code></a></dt> <dd>Returns a new <code>Array Iterator</code> object that contains the key/value pairs for each index in the array. See also <a href=\"array/entries\"><code>Array.prototype.entries()</code></a>.</dd> <dt><a href=\"typedarray/every\"><code>TypedArray.prototype.every()</code></a></dt> <dd>Tests whether all elements in the array pass the test provided by a function. See also <a href=\"array/every\"><code>Array.prototype.every()</code></a>.</dd> <dt><a href=\"typedarray/fill\"><code>TypedArray.prototype.fill()</code></a></dt> <dd>Fills all the elements of an array from a start index to an end index with a static value. See also <a href=\"array/fill\"><code>Array.prototype.fill()</code></a>.</dd> <dt><a href=\"typedarray/filter\"><code>TypedArray.prototype.filter()</code></a></dt> <dd>Creates a new array with all of the elements of this array for which the provided filtering function returns true. See also <a href=\"array/filter\"><code>Array.prototype.filter()</code></a>.</dd> <dt><a href=\"typedarray/find\"><code>TypedArray.prototype.find()</code></a></dt> <dd>Returns the found value in the array, if an element in the array satisfies the provided testing function or <code>undefined</code> if not found. See also <a href=\"array/find\"><code>Array.prototype.find()</code></a>.</dd> <dt><a href=\"typedarray/findindex\"><code>TypedArray.prototype.findIndex()</code></a></dt> <dd>Returns the found index in the array, if an element in the array satisfies the provided testing function or -1 if not found. See also <a href=\"array/findindex\"><code>Array.prototype.findIndex()</code></a>.</dd> <dt><a href=\"typedarray/foreach\"><code>TypedArray.prototype.forEach()</code></a></dt> <dd>Calls a function for each element in the array. See also <a href=\"array/foreach\"><code>Array.prototype.forEach()</code></a>.</dd> <dt>\n<a href=\"typedarray/includes\"><code>TypedArray.prototype.includes()</code></a> \n</dt> <dd>Determines whether a typed array includes a certain element, returning <code>true</code> or <code>false</code> as appropriate. See also <a href=\"array/includes\"><code>Array.prototype.includes()</code></a>.</dd> <dt><a href=\"typedarray/indexof\"><code>TypedArray.prototype.indexOf()</code></a></dt> <dd>Returns the first (least) index of an element within the array equal to the specified value, or -1 if none is found. See also <a href=\"array/indexof\"><code>Array.prototype.indexOf()</code></a>.</dd> <dt><a href=\"typedarray/join\"><code>TypedArray.prototype.join()</code></a></dt> <dd>Joins all elements of an array into a string. See also <a href=\"array/join\"><code>Array.prototype.join()</code></a>.</dd> <dt><a href=\"typedarray/keys\"><code>TypedArray.prototype.keys()</code></a></dt> <dd>Returns a new <code>Array Iterator</code> that contains the keys for each index in the array. See also <a href=\"array/keys\"><code>Array.prototype.keys()</code></a>.</dd> <dt><a href=\"typedarray/lastindexof\"><code>TypedArray.prototype.lastIndexOf()</code></a></dt> <dd>Returns the last (greatest) index of an element within the array equal to the specified value, or -1 if none is found. See also <a href=\"array/lastindexof\"><code>Array.prototype.lastIndexOf()</code></a>.</dd> <dt><a href=\"typedarray/map\"><code>TypedArray.prototype.map()</code></a></dt> <dd>Creates a new array with the results of calling a provided function on every element in this array. See also <a href=\"array/map\"><code>Array.prototype.map()</code></a>.</dd> <dt>\n<a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/move\"><code>TypedArray.prototype.move()</code></a>  <span class=\"inlineIndicator unimplemented unimplementedInline\">Unimplemented</span>\n</dt> <dd>Former non-standard version of <a href=\"typedarray/copywithin\"><code>TypedArray.prototype.copyWithin()</code></a>.</dd> <dt><a href=\"typedarray/reduce\"><code>TypedArray.prototype.reduce()</code></a></dt> <dd>Apply a function against an accumulator and each value of the array (from left-to-right) as to reduce it to a single value. See also <a href=\"array/reduce\"><code>Array.prototype.reduce()</code></a>.</dd> <dt><a href=\"typedarray/reduceright\"><code>TypedArray.prototype.reduceRight()</code></a></dt> <dd>Apply a function against an accumulator and each value of the array (from right-to-left) as to reduce it to a single value. See also <a href=\"array/reduceright\"><code>Array.prototype.reduceRight()</code></a>.</dd> <dt><a href=\"typedarray/reverse\"><code>TypedArray.prototype.reverse()</code></a></dt> <dd>Reverses the order of the elements of an array — the first becomes the last, and the last becomes the first. See also <a href=\"array/reverse\"><code>Array.prototype.reverse()</code></a>.</dd> <dt><a href=\"typedarray/set\"><code>TypedArray.prototype.set()</code></a></dt> <dd>Stores multiple values in the typed array, reading input values from a specified array.</dd> <dt><a href=\"typedarray/slice\"><code>TypedArray.prototype.slice()</code></a></dt> <dd>Extracts a section of an array and returns a new array. See also <a href=\"array/slice\"><code>Array.prototype.slice()</code></a>.</dd> <dt><a href=\"typedarray/some\"><code>TypedArray.prototype.some()</code></a></dt> <dd>Returns true if at least one element in this array satisfies the provided testing function. See also <a href=\"array/some\"><code>Array.prototype.some()</code></a>.</dd> <dt><a href=\"typedarray/sort\"><code>TypedArray.prototype.sort()</code></a></dt> <dd>Sorts the elements of an array in place and returns the array. See also <a href=\"array/sort\"><code>Array.prototype.sort()</code></a>.</dd> <dt><a href=\"typedarray/subarray\"><code>TypedArray.prototype.subarray()</code></a></dt> <dd>Returns a new TypedArray from the given start and end element index.</dd> <dt><a href=\"typedarray/values\"><code>TypedArray.prototype.values()</code></a></dt> <dd>Returns a new <code>Array Iterator</code> object that contains the values for each index in the array. See also <a href=\"array/values\"><code>Array.prototype.values()</code></a>.</dd> <dt><a href=\"typedarray/tolocalestring\"><code>TypedArray.prototype.toLocaleString()</code></a></dt> <dd>Returns a localized string representing the array and its elements. See also <a href=\"array/tolocalestring\"><code>Array.prototype.toLocaleString()</code></a>.</dd> <dt><a href=\"typedarray/tostring\"><code>TypedArray.prototype.toString()</code></a></dt> <dd>Returns a string representing the array and its elements. See also <a href=\"array/tostring\"><code>Array.prototype.toString()</code></a>.</dd> <dt><a href=\"typedarray/@@iterator\"><code>TypedArray.prototype[@@iterator]()</code></a></dt> <dd>Returns a new <code>Array Iterator</code> object that contains the values for each index in the array.</dd> </dl> <h3 id=\"Methods_Polyfill\">Methods Polyfill</h3> <p>Many of the methods used in Typed Arrays can be polyfilled using the methods present in regular Javascript Arrays. The following snippet of JavaScript demonstrates how you might polyfill any missing Typed Array methods.</p> <pre data-language=\"js\">var typedArrayTypes = [<a href=\"int8array\">Int8Array</a>, <a href=\"uint8array\">Uint8Array</a>, <a href=\"uint8clampedarray\">Uint8ClampedArray</a>, <a href=\"int16array\">Int16Array</a>,\n          <a href=\"uint16array\">Uint16Array</a>, ​​​<a href=\"int32array\">Int32Array</a>, <a href=\"uint32array\">Uint32Array</a>, ​​​<a href=\"float32array\">Float32Array</a>, <a href=\"float64array\">Float64Array</a>];\n\nfor (var k in typedArrayTypes)\n    for (var v in Array.prototype)\n        if (Array.prototype.hasOwnProperty(v) &amp;&amp; \n          !typedArrayTypes[k].prototype.hasOwnProperty(v))\n            typedArrayTypes[k].prototype[v] = Array.prototype[v];\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.khronos.org/registry/typedarray/specs/latest/\" hreflang=\"en\">Typed Array Specification</a></td> <td><span class=\"spec-Obsolete\">Obsolete</span></td> <td>Defined as <code>TypedArray</code> and <code>ArrayBufferView</code> interface with typed array view types. Superseded by ECMAScript 2015.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-typedarray-objects\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'TypedArray Objects' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition in an ECMA standard. Specified behaviour for indexed and named properties. Specified that <code>new</code> is required.</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-typedarray-objects\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'TypedArray Objects' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td>ECMAScript 2017 changed the TypedArray constructor to use the <code>ToIndex</code> operation and allows constructors with no arguments.</td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 7</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> 10</td>\n<td class=\"bc-supports-yes\"> 11.6</td>\n<td class=\"bc-supports-yes\"> 5.1</td>\n</tr>\n<tr>\n<th scope=\"row\">Constructor without arguments</th>\n<td> ? </td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 55</td>\n<td class=\"bc-supports-yes\"> 10</td>\n<td> ? </td>\n<td> ? </td>\n</tr>\n<tr>\n<th scope=\"row\">Indexed properties not consulting prototype</th>\n<td class=\"bc-supports-yes bc-has-history\"> Yes\n<section class=\"bc-history\" id=\"sect1\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> Yes\n</dt>\n<dd> Negative integers are not considered as indexed properties and therefore return the value of the prototype property.</dd>\n</dl></section>\n</td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 25</td>\n<td class=\"bc-supports-yes bc-has-history\"> 10\n<section class=\"bc-history\" id=\"sect2\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 10\n</dt>\n<dd> Negative integers are not considered as indexed properties and therefore return the value of the prototype property.</dd>\n</dl></section>\n</td>\n<td> ? </td>\n<td> ? </td>\n</tr>\n<tr>\n<th scope=\"row\">Iterable in constructor</th>\n<td> ? </td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 52</td>\n<td class=\"bc-supports-yes\"> 10</td>\n<td> ? </td>\n<td> ? </td>\n</tr>\n<tr>\n<th scope=\"row\">Named properties</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 30</td>\n<td class=\"bc-supports-yes\"> 10</td>\n<td> ? </td>\n<td> ? </td>\n</tr>\n<tr>\n<th scope=\"row\">\n<code>TypedArray()</code> without <code>new</code> throws</th>\n<td> ? </td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 44</td>\n<td class=\"bc-supports-no\"> No</td>\n<td> ? </td>\n<td> ? </td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/BYTES_PER_ELEMENT\"><code>BYTES_PER_ELEMENT</code></a></th>\n<td class=\"bc-supports-yes\"> 7</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> 10</td>\n<td class=\"bc-supports-yes\"> 11.6</td>\n<td class=\"bc-supports-yes\"> 5.1</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/buffer\"><code>buffer</code></a></th>\n<td class=\"bc-supports-yes\"> 7</td>\n<td class=\"bc-supports-yes\"> 14</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> 10</td>\n<td class=\"bc-supports-yes\"> 11.6</td>\n<td class=\"bc-supports-yes\"> 5.1</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/byteLength\"><code>byteLength</code></a></th>\n<td class=\"bc-supports-yes\"> 7</td>\n<td class=\"bc-supports-yes\"> 14</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> 10</td>\n<td class=\"bc-supports-yes\"> 11.6</td>\n<td class=\"bc-supports-yes\"> 5.1</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/byteOffset\"><code>byteOffset</code></a></th>\n<td class=\"bc-supports-yes\"> 7</td>\n<td class=\"bc-supports-yes\"> 14</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> 10</td>\n<td class=\"bc-supports-yes\"> 11.6</td>\n<td class=\"bc-supports-yes\"> 5.1</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/copyWithin\"><code>copyWithin</code></a></th>\n<td class=\"bc-supports-yes\"> 45</td>\n<td class=\"bc-supports-yes\"> 14</td>\n<td class=\"bc-supports-yes\"> 34</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 36</td>\n<td class=\"bc-supports-no\"> No</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/entries\"><code>entries</code></a></th>\n<td class=\"bc-supports-yes\"> 45</td>\n<td class=\"bc-supports-yes\"> 14</td>\n<td class=\"bc-supports-yes\"> 37</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 36</td>\n<td class=\"bc-supports-no\"> No</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/every\"><code>every</code></a></th>\n<td class=\"bc-supports-yes\"> 45</td>\n<td class=\"bc-supports-yes\"> 14</td>\n<td class=\"bc-supports-yes\"> 37</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 36</td>\n<td class=\"bc-supports-no\"> No</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/fill\"><code>fill</code></a></th>\n<td class=\"bc-supports-yes\"> 45</td>\n<td class=\"bc-supports-yes\"> 14</td>\n<td class=\"bc-supports-yes\"> 37</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 36</td>\n<td class=\"bc-supports-no\"> No</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/filter\"><code>filter</code></a></th>\n<td class=\"bc-supports-yes\"> 45</td>\n<td class=\"bc-supports-yes\"> 14</td>\n<td class=\"bc-supports-yes\"> 38</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/find\"><code>find</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 14</td>\n<td class=\"bc-supports-yes\"> 37</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/findIndex\"><code>findIndex</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 14</td>\n<td class=\"bc-supports-yes\"> 37</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/forEach\"><code>forEach</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 14</td>\n<td class=\"bc-supports-yes\"> 38</td>\n<td class=\"bc-supports-no\"> No</td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 10</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/from\"><code>from</code></a></th>\n<td class=\"bc-supports-yes\"> 45</td>\n<td class=\"bc-supports-yes\"> 14</td>\n<td class=\"bc-supports-yes\"> 38</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 10</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/includes\"><code>includes</code></a></th>\n<td class=\"bc-supports-yes\"> 47</td>\n<td class=\"bc-supports-yes\"> 14</td>\n<td class=\"bc-supports-yes\"> 43</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 34</td>\n<td class=\"bc-supports-yes\"> 10</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/indexOf\"><code>indexOf</code></a></th>\n<td class=\"bc-supports-yes\"> 45</td>\n<td class=\"bc-supports-yes\"> 14</td>\n<td class=\"bc-supports-yes bc-has-history\"> 37\n<section class=\"bc-history\" id=\"sect7\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 37\n</dt>\n<dd> Starting with Firefox 47, this method will no longer return <code>-0</code>. For example, <code>new Uint8Array([0]).indexOf(0, -0)</code> will now always return <code>+0</code>.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 32</td>\n<td class=\"bc-supports-no\"> No</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/join\"><code>join</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 14</td>\n<td class=\"bc-supports-yes\"> 37</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/keys\"><code>keys</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 14</td>\n<td class=\"bc-supports-yes\"> 37</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 10</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/lastIndexOf\"><code>lastIndexOf</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 14</td>\n<td class=\"bc-supports-yes bc-has-history\"> 37\n<section class=\"bc-history\" id=\"sect9\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 37\n</dt>\n<dd> Starting with Firefox 47, this method will no longer return <code>-0</code>. For example, <code>new Uint8Array([0]).lastIndexOf(0, -0)</code> will now always return <code>+0</code>.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 10</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/length\"><code>length</code></a></th>\n<td class=\"bc-supports-yes\"> 7</td>\n<td class=\"bc-supports-yes\"> 14</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> 10</td>\n<td class=\"bc-supports-yes\"> 11.6</td>\n<td class=\"bc-supports-yes\"> 5.1</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/map\"><code>map</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 14</td>\n<td class=\"bc-supports-yes\"> 38</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/move\"><code>move</code></a> \n</th>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no bc-has-history\">16 — 34\n<section class=\"bc-history\" id=\"sect11\"><dl>\n<dt class=\"bc-supports-no bc-supports\">16 — 34\n</dt>\n<dd> Was available in Aurora and Nightly channels only.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/name\"><code>name</code></a></th>\n<td class=\"bc-supports-yes\"> 7</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> 10</td>\n<td class=\"bc-supports-yes\"> 11.6</td>\n<td class=\"bc-supports-yes\"> 5.1</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/of\"><code>of</code></a></th>\n<td class=\"bc-supports-yes\"> 45</td>\n<td class=\"bc-supports-yes\"> 14</td>\n<td class=\"bc-supports-yes\"> 38</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/prototype\"><code>prototype</code></a></th>\n<td class=\"bc-supports-yes\"> 7</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> 10</td>\n<td class=\"bc-supports-yes\"> 11.6</td>\n<td class=\"bc-supports-yes\"> 5.1</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/reduce\"><code>reduce</code></a></th>\n<td class=\"bc-supports-yes\"> 45</td>\n<td class=\"bc-supports-yes\"> 14</td>\n<td class=\"bc-supports-yes\"> 37</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 32</td>\n<td class=\"bc-supports-yes\"> 10</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/reduceRight\"><code>reduceRight</code></a></th>\n<td class=\"bc-supports-yes\"> 45</td>\n<td class=\"bc-supports-yes\"> 14</td>\n<td class=\"bc-supports-yes\"> 37</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 32</td>\n<td class=\"bc-supports-yes\"> 10</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/reverse\"><code>reverse</code></a></th>\n<td class=\"bc-supports-yes\"> 45</td>\n<td class=\"bc-supports-yes\"> 14</td>\n<td class=\"bc-supports-yes\"> 37</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 32</td>\n<td class=\"bc-supports-yes\"> 10</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/set\"><code>set</code></a></th>\n<td class=\"bc-supports-yes\"> 7</td>\n<td class=\"bc-supports-yes\"> 14</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> 10</td>\n<td class=\"bc-supports-yes\"> 11.6</td>\n<td class=\"bc-supports-yes\"> 5.1</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/slice\"><code>slice</code></a></th>\n<td class=\"bc-supports-yes\"> 45</td>\n<td class=\"bc-supports-yes\"> 14</td>\n<td class=\"bc-supports-yes\"> 38</td>\n<td class=\"bc-supports-no\"> No</td>\n<td> ? </td>\n<td> ? </td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/some\"><code>some</code></a></th>\n<td class=\"bc-supports-yes\"> 45</td>\n<td class=\"bc-supports-yes\"> 14</td>\n<td class=\"bc-supports-yes\"> 37</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 32</td>\n<td class=\"bc-supports-yes\"> 10</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/sort\"><code>sort</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 14</td>\n<td class=\"bc-supports-yes\"> 46</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td> ? </td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/subarray\"><code>subarray</code></a></th>\n<td class=\"bc-supports-yes\"> 7</td>\n<td class=\"bc-supports-yes\"> 14</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> 10</td>\n<td class=\"bc-supports-yes\"> 11.6</td>\n<td class=\"bc-supports-yes\"> 5.1</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/toLocaleString\"><code>toLocaleString</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 51</td>\n<td class=\"bc-supports-yes\"> 10</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/toString\"><code>toString</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 51</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/values\"><code>values</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 14</td>\n<td class=\"bc-supports-yes\"> 37</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 26</td>\n<td class=\"bc-supports-yes\"> 10</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/@@iterator\"><code>@@iterator</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td> ? </td>\n<td class=\"bc-supports-yes bc-has-history\"> 36\n<section class=\"bc-history\" id=\"sect13\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 36\n</dt>\n\n<dt class=\"bc-supports-no bc-supports\">27 — 36\n</dt>\n<dd> A placeholder property named <code>@@iterator</code> is used.</dd>\n<dd> Uses the non-standard name: <code>@@iterator</code>\n</dd>\n<dt class=\"bc-supports-no bc-supports\">17 — 27\n</dt>\n<dd> A placeholder property named <code>iterator</code> is used.</dd>\n<dd> Uses the non-standard name: <code>iterator</code>\n</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/@@species\"><code>@@species</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 48</td>\n<td class=\"bc-supports-no\"> No</td>\n<td> ? </td>\n<td> ? </td>\n</tr>\n</tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> 11.6</td>\n<td class=\"bc-supports-yes\"> 4.2</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">Constructor without arguments</th>\n<td> ? </td>\n<td> ? </td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 55</td>\n<td> ? </td>\n<td> ? </td>\n<td> ? </td>\n</tr>\n<tr>\n<th scope=\"row\">Indexed properties not consulting prototype</th>\n<td class=\"bc-supports-yes bc-has-history\"> Yes\n<section class=\"bc-history\" id=\"sect3\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> Yes\n</dt>\n<dd> Negative integers are not considered as indexed properties and therefore return the value of the prototype property.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-yes bc-has-history\"> Yes\n<section class=\"bc-history\" id=\"sect4\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> Yes\n</dt>\n<dd> Negative integers are not considered as indexed properties and therefore return the value of the prototype property.</dd>\n</dl></section>\n</td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 25</td>\n<td> ? </td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">Iterable in constructor</th>\n<td> ? </td>\n<td> ? </td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 52</td>\n<td> ? </td>\n<td> ? </td>\n<td> ? </td>\n</tr>\n<tr>\n<th scope=\"row\">Named properties</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 30</td>\n<td> ? </td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<code>TypedArray()</code> without <code>new</code> throws</th>\n<td> ? </td>\n<td> ? </td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 44</td>\n<td> ? </td>\n<td> ? </td>\n<td> ? </td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/BYTES_PER_ELEMENT\"><code>BYTES_PER_ELEMENT</code></a></th>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> 11.6</td>\n<td class=\"bc-supports-yes\"> 4.2</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/buffer\"><code>buffer</code></a></th>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> 11.6</td>\n<td class=\"bc-supports-yes\"> 4.2</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/byteLength\"><code>byteLength</code></a></th>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> 11.6</td>\n<td class=\"bc-supports-yes\"> 4.2</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/byteOffset\"><code>byteOffset</code></a></th>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> 11.6</td>\n<td class=\"bc-supports-yes\"> 4.2</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/copyWithin\"><code>copyWithin</code></a></th>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 34</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/entries\"><code>entries</code></a></th>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 37</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/every\"><code>every</code></a></th>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 37</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/fill\"><code>fill</code></a></th>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 37</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/filter\"><code>filter</code></a></th>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 38</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/find\"><code>find</code></a></th>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 37</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/findIndex\"><code>findIndex</code></a></th>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 37</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/forEach\"><code>forEach</code></a></th>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 38</td>\n<td> ? </td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/from\"><code>from</code></a></th>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 38</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 10</td>\n<td class=\"bc-supports-no\"> No</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/includes\"><code>includes</code></a></th>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 47</td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 43</td>\n<td class=\"bc-supports-yes\"> 34</td>\n<td class=\"bc-supports-yes\"> 10</td>\n<td class=\"bc-supports-yes\"> 5.0</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/indexOf\"><code>indexOf</code></a></th>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 45</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes bc-has-history\"> 37\n<section class=\"bc-history\" id=\"sect8\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 37\n</dt>\n<dd> Starting with Firefox 47, this method will no longer return <code>-0</code>. For example, <code>new Uint8Array([0]).indexOf(0, -0)</code> will now always return <code>+0</code>.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-yes\"> 32</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 5.0</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/join\"><code>join</code></a></th>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 37</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/keys\"><code>keys</code></a></th>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 37</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 10</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/lastIndexOf\"><code>lastIndexOf</code></a></th>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes bc-has-history\"> 37\n<section class=\"bc-history\" id=\"sect10\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 37\n</dt>\n<dd> Starting with Firefox 47, this method will no longer return <code>-0</code>. For example, <code>new Uint8Array([0]).lastIndexOf(0, -0)</code> will now always return <code>+0</code>.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 10</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/length\"><code>length</code></a></th>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> 11.6</td>\n<td class=\"bc-supports-yes\"> 4.2</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/map\"><code>map</code></a></th>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 38</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/move\"><code>move</code></a> \n</th>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no bc-has-history\">38 — 34\n<section class=\"bc-history\" id=\"sect12\"><dl>\n<dt class=\"bc-supports-no bc-supports\">38 — 34\n</dt>\n<dd> Was available in Aurora and Nightly channels only.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/name\"><code>name</code></a></th>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> 11.6</td>\n<td class=\"bc-supports-yes\"> 4.2</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/of\"><code>of</code></a></th>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 38</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/prototype\"><code>prototype</code></a></th>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> 11.6</td>\n<td class=\"bc-supports-yes\"> 4.2</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/reduce\"><code>reduce</code></a></th>\n<td> ? </td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 37</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 10</td>\n<td> ? </td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/reduceRight\"><code>reduceRight</code></a></th>\n<td> ? </td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 37</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 10</td>\n<td> ? </td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/reverse\"><code>reverse</code></a></th>\n<td> ? </td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 37</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 10</td>\n<td> ? </td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/set\"><code>set</code></a></th>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> 11.6</td>\n<td class=\"bc-supports-yes\"> 4.2</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/slice\"><code>slice</code></a></th>\n<td> ? </td>\n<td> ? </td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 38</td>\n<td> ? </td>\n<td> ? </td>\n<td> ? </td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/some\"><code>some</code></a></th>\n<td> ? </td>\n<td> ? </td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 37</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 10</td>\n<td> ? </td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/sort\"><code>sort</code></a></th>\n<td> ? </td>\n<td> ? </td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 46</td>\n<td> ? </td>\n<td> ? </td>\n<td> ? </td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/subarray\"><code>subarray</code></a></th>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> 11.6</td>\n<td class=\"bc-supports-yes\"> 4.2</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/toLocaleString\"><code>toLocaleString</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 51</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/toString\"><code>toString</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 51</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/values\"><code>values</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 37</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 10</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/@@iterator\"><code>@@iterator</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td> ? </td>\n<td class=\"bc-supports-yes bc-has-history\"> 36\n<section class=\"bc-history\" id=\"sect14\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 36\n</dt>\n\n<dt class=\"bc-supports-no bc-supports\">27 — 36\n</dt>\n<dd> A placeholder property named <code>@@iterator</code> is used.</dd>\n<dd> Uses the non-standard name: <code>@@iterator</code>\n</dd>\n<dt class=\"bc-supports-no bc-supports\">17 — 27\n</dt>\n<dd> A placeholder property named <code>iterator</code> is used.</dd>\n<dd> Uses the non-standard name: <code>iterator</code>\n</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/@@species\"><code>@@species</code></a></th>\n<td> ? </td>\n<td> ? </td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 48</td>\n<td> ? </td>\n<td> ? </td>\n<td> ? </td>\n</tr>\n</tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">Constructor without arguments</th>\n<td> ? </td>\n</tr>\n<tr>\n<th scope=\"row\">Indexed properties not consulting prototype</th>\n<td> ? \n<section class=\"bc-history\" id=\"sect5\"><dl>\n<dt> ? \n</dt>\n<dd> Negative integers are not considered as indexed properties and therefore return the value of the prototype property.</dd>\n</dl></section>\n</td>\n</tr>\n<tr>\n<th scope=\"row\">Iterable in constructor</th>\n<td class=\"bc-supports-yes\"> 4.0.0</td>\n</tr>\n<tr>\n<th scope=\"row\">Named properties</th>\n<td> ? </td>\n</tr>\n<tr>\n<th scope=\"row\">\n<code>TypedArray()</code> without <code>new</code> throws</th>\n<td class=\"bc-supports-yes\"> 0.12</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/BYTES_PER_ELEMENT\"><code>BYTES_PER_ELEMENT</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/buffer\"><code>buffer</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/byteLength\"><code>byteLength</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/byteOffset\"><code>byteOffset</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/copyWithin\"><code>copyWithin</code></a></th>\n<td class=\"bc-supports-yes\"> 4.0.0</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/entries\"><code>entries</code></a></th>\n<td class=\"bc-supports-yes\"> 0.12</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/every\"><code>every</code></a></th>\n<td class=\"bc-supports-yes\"> 4.0.0</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/fill\"><code>fill</code></a></th>\n<td class=\"bc-supports-yes\"> 4.0.0</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/filter\"><code>filter</code></a></th>\n<td class=\"bc-supports-yes\"> 4.0.0</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/find\"><code>find</code></a></th>\n<td class=\"bc-supports-yes\"> 4.0.0</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/findIndex\"><code>findIndex</code></a></th>\n<td class=\"bc-supports-yes\"> 4.0.0</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/forEach\"><code>forEach</code></a></th>\n<td class=\"bc-supports-yes\"> 4.0.0</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/from\"><code>from</code></a></th>\n<td class=\"bc-supports-yes\"> 4.0.0</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/includes\"><code>includes</code></a></th>\n<td class=\"bc-supports-yes bc-has-history\"> 6.0.0\n<section class=\"bc-history\" id=\"sect6\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 6.0.0\n</dt>\n\n<dt class=\"bc-supports-yes bc-supports\"> 5.0.0<div class=\"bc-icons\">Disabled </div>\n</dt>\n<dd>Disabled From version 5.0.0: this feature is behind the <code>--harmony</code> runtime flag.</dd>\n</dl></section>\n</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/indexOf\"><code>indexOf</code></a></th>\n<td class=\"bc-supports-yes\"> 4.0.0</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/join\"><code>join</code></a></th>\n<td class=\"bc-supports-yes\"> 4.0.0</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/keys\"><code>keys</code></a></th>\n<td class=\"bc-supports-yes\"> 0.12</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/lastIndexOf\"><code>lastIndexOf</code></a></th>\n<td class=\"bc-supports-yes\"> 4.0.0</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/length\"><code>length</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/map\"><code>map</code></a></th>\n<td class=\"bc-supports-yes\"> 4.0.0</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/move\"><code>move</code></a> \n</th>\n<td class=\"bc-supports-no\"> No</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/name\"><code>name</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/of\"><code>of</code></a></th>\n<td class=\"bc-supports-yes\"> 4.0.0</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/prototype\"><code>prototype</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/reduce\"><code>reduce</code></a></th>\n<td class=\"bc-supports-yes\"> 4.0.0</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/reduceRight\"><code>reduceRight</code></a></th>\n<td class=\"bc-supports-yes\"> 4.0.0</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/reverse\"><code>reverse</code></a></th>\n<td class=\"bc-supports-yes\"> 4.0.0</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/set\"><code>set</code></a></th>\n<td> ? </td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/slice\"><code>slice</code></a></th>\n<td class=\"bc-supports-yes\"> 4.0.0</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/some\"><code>some</code></a></th>\n<td class=\"bc-supports-yes\"> 4.0.0</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/sort\"><code>sort</code></a></th>\n<td class=\"bc-supports-yes\"> 4.0.0</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/subarray\"><code>subarray</code></a></th>\n<td class=\"bc-supports-yes\"> 0.12</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/toLocaleString\"><code>toLocaleString</code></a></th>\n<td> ? </td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/toString\"><code>toString</code></a></th>\n<td> ? </td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/values\"><code>values</code></a></th>\n<td class=\"bc-supports-yes\"> 0.12</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/@@iterator\"><code>@@iterator</code></a></th>\n<td class=\"bc-supports-yes\"> 0.12</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/@@species\"><code>@@species</code></a></th>\n<td class=\"bc-supports-yes bc-has-history\"> 6.5.0\n<section class=\"bc-history\" id=\"sect15\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 6.5.0\n</dt>\n\n<dt class=\"bc-supports-yes bc-supports\"> 6.0.0<div class=\"bc-icons\">Disabled </div>\n</dt>\n<dd>Disabled From version 6.0.0: this feature is behind the <code>--harmony</code> runtime flag.</dd>\n</dl></section>\n</td>\n</tr>\n</tbody>\n</table>\n</div> <h2 id=\"Compatibility_notes\">Compatibility notes</h2> <p>Starting with ECMAScript 2015, <code>TypedArray</code> constructors require to be constructed with a <a href=\"../operators/new\"><code>new</code></a> operator. Calling a <code>TypedArray</code> constructor as a function without <code>new</code>, will throw a <a href=\"typeerror\"><code>TypeError</code></a> from now on.</p> <pre data-language=\"js\">var dv = Int8Array([1, 2, 3]);\n// TypeError: calling a builtin Int8Array constructor \n// without new is forbidden</pre> <pre data-language=\"js\">var dv = new Int8Array([1, 2, 3]);</pre> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Typed_arrays\">JavaScript typed arrays</a></li> <li><a href=\"arraybuffer\"><code>ArrayBuffer</code></a></li> <li><a href=\"dataview\"><code>DataView</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray</a>\n  </p>\n</div>\n","operators/function*":"<h1>function*</h1> <p>The <code>function*</code> keyword can be used to define a generator function inside an expression.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/expressions-functionasteriskexpression.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\">function* [<em>name</em>]([<em>param1</em>[, <em>param2[</em>, ..., <em>paramN</em>]]]) {\n   <em>statements</em>\n}</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><code>name</code></dt> <dd>The function name. Can be omitted, in which case the function is <em>anonymous</em>. The name is only local to the function body.</dd> <dt><code>paramN</code></dt> <dd>The name of an argument to be passed to the function. A function can have up to 255 arguments.</dd> <dt><code>statements</code></dt> <dd>The statements which comprise the body of the function.</dd> </dl> <h2 id=\"Description\">Description</h2> <p>A <code>function*</code> expression is very similar to and has almost the same syntax as a <a href=\"../statements/function*\"><code>function* statement</code></a>. The main difference between a <code>function*</code> expression and a <code>function*</code> statement is the <em>function name,</em> which can be omitted in <code>function*</code> expressions to create <em>anonymous</em> generator functions. See also the chapter about <a href=\"../functions\">functions</a> for more information.</p> <h2 id=\"Examples\">Examples</h2> <p>The following example defines an unnamed generator function and assigns it to <code>x</code>. The function yields the square of its argument:</p> <pre data-language=\"js\">var x = function*(y) {\n   yield y * y;\n};\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-generator-function-definitions\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'function*' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-generator-function-definitions\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'function*' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 26</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 10</td>\n</tr>\n<tr>\n<th scope=\"row\">Trailing comma in parameters</th>\n<td class=\"bc-supports-yes\"> 58</td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 52</td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 45</td>\n<td> ? </td>\n</tr>\n</tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 26</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 10</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">Trailing comma in parameters</th>\n<td class=\"bc-supports-yes\"> 58</td>\n<td class=\"bc-supports-yes\"> 58</td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 52</td>\n<td class=\"bc-supports-yes\"> 45</td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 7.0</td>\n</tr>\n</tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">Trailing comma in parameters</th>\n<td class=\"bc-supports-yes\"> 8.0.0</td>\n</tr>\n</tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"../statements/function*\"><code>function* statement</code></a></li> <li>\n<a href=\"../global_objects/generatorfunction\"><code>GeneratorFunction</code></a> object</li> <li><a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/The_Iterator_protocol\">The Iterator protocol</a></li> <li><a href=\"yield\"><code>yield</code></a></li> <li><a href=\"yield*\"><code>yield*</code></a></li> <li>\n<a href=\"../global_objects/function\"><code>Function</code></a> object</li> <li><a href=\"../statements/function\"><code>function statement</code></a></li> <li><a href=\"function\"><code>function expression</code></a></li> <li><a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions\"><code>Functions and function scope</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/function*$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/function*\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/function*</a>\n  </p>\n</div>\n","operators/spread_syntax":"<h1>Spread syntax</h1> <p><strong>Spread syntax</strong> allows an iterable such as an array expression or string to be expanded in places where zero or more arguments (for function calls) or elements (for array literals) are expected, or an object expression to be expanded in places where zero or more key-value pairs (for object literals) are expected.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/expressions-spreadsyntax.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <p>For function calls:</p> <pre class=\"syntaxbox\">myFunction(...iterableObj);\n</pre> <p>For array literals or strings:</p> <pre class=\"syntaxbox\">[...iterableObj, '4', 'five', 6];</pre> <p>For object literals (new in ECMAScript 2018):</p> <pre class=\"syntaxbox\">let objClone = { ...obj };</pre> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Spread_in_function_calls\">Spread in function calls</h3> <h4 id=\"Replace_apply\">Replace apply</h4> <p>It is common to use <a href=\"../global_objects/function/apply\"><code>Function.prototype.apply</code></a> in cases where you want to use the elements of an array as arguments to a function.</p> <pre data-language=\"js\">function myFunction(x, y, z) { }\nvar args = [0, 1, 2];\nmyFunction.apply(null, args);</pre> <p>With spread syntax the above can be written as:</p> <pre data-language=\"js\">function myFunction(x, y, z) { }\nvar args = [0, 1, 2];\nmyFunction(...args);</pre> <p>Any argument in the argument list can use spread syntax and it can be used multiple times.</p> <pre data-language=\"js\">function myFunction(v, w, x, y, z) { }\nvar args = [0, 1];\nmyFunction(-1, ...args, 2, ...[3]);</pre> <h4 id=\"Apply_for_new\">Apply for new</h4> <p>When calling a constructor with <code>new</code>, it's not possible to <strong>directly</strong> use an array and <code>apply</code> (<code>apply</code> does a <code>[[Call]]</code> and not a <code>[[Construct]]</code>). However, an array can be easily used with <code>new</code> thanks to spread syntax:</p> <pre data-language=\"js\">var dateFields = [1970, 0, 1];  // 1 Jan 1970\nvar d = new Date(...dateFields);\n</pre> <p>To use new with an array of parameters without spread syntax, you would have to do it <strong>indirectly</strong> through partial application:</p> <pre data-language=\"js\">function applyAndNew(constructor, args) {\n   function partial () {\n      return constructor.apply(this, args);\n   };\n   if (typeof constructor.prototype === \"object\") {\n      partial.prototype = Object.create(constructor.prototype);\n   }\n   return partial;\n}\n\n\nfunction myConstructor () {\n   console.log(\"arguments.length: \" + arguments.length);\n   console.log(arguments);\n   this.prop1=\"val1\";\n   this.prop2=\"val2\";\n};\n\nvar myArguments = [\"hi\", \"how\", \"are\", \"you\", \"mr\", null];\nvar myConstructorWithArguments = applyAndNew(myConstructor, myArguments);\n\nconsole.log(new myConstructorWithArguments);\n// (internal log of myConstructor):           arguments.length: 6\n// (internal log of myConstructor):           [\"hi\", \"how\", \"are\", \"you\", \"mr\", null]\n// (log of \"new myConstructorWithArguments\"): {prop1: \"val1\", prop2: \"val2\"}</pre> <h3 id=\"Spread_in_array_literals\">Spread in array literals</h3> <h4 id=\"A_more_powerful_array_literal\">A more powerful array literal</h4> <p>Without spread syntax, to create a new array using an existing array as one part of it, the array literal syntax is no longer sufficient and imperative code must be used instead using a combination of <code>push</code>, <code>splice</code>, <code>concat</code>, etc. With spread syntax this becomes much more succinct:</p> <pre data-language=\"js\">var parts = ['shoulders', 'knees']; \nvar lyrics = ['head', ...parts, 'and', 'toes']; \n// [\"head\", \"shoulders\", \"knees\", \"and\", \"toes\"]\n</pre> <p>Just like spread for argument lists, <code>...</code> can be used anywhere in the array literal and it can be used multiple times.</p> <h4 id=\"Copy_an_array\">Copy an array</h4> <pre data-language=\"js\">var arr = [1, 2, 3];\nvar arr2 = [...arr]; // like arr.slice()\narr2.push(4); \n\n// arr2 becomes [1, 2, 3, 4]\n// arr remains unaffected\n</pre> <p><strong>Note:</strong> Spread syntax effectively goes one level deep while copying an array. Therefore, it may be unsuitable for copying multidimensional arrays as the following example shows (it's the same with <a href=\"../global_objects/object/assign\"><code>Object.assign()</code></a> and spread syntax).</p> <pre data-language=\"js\">var a = [[1], [2], [3]];\nvar b = [...a];\nb.shift().shift(); // 1\n// Now array a is affected as well: [[], [2], [3]]\n</pre> <h4 id=\"A_better_way_to_concatenate_arrays\">A better way to concatenate arrays</h4> <p><a href=\"../global_objects/array/concat\"><code>Array.concat</code></a> is often used to concatenate an array to the end of an existing array. Without spread syntax this is done as:</p> <pre data-language=\"js\">var arr1 = [0, 1, 2];\nvar arr2 = [3, 4, 5];\n// Append all items from arr2 onto arr1\narr1 = arr1.concat(arr2);</pre> <p>With spread syntax this becomes:</p> <pre data-language=\"js\">var arr1 = [0, 1, 2];\nvar arr2 = [3, 4, 5];\narr1 = [...arr1, ...arr2];\n</pre> <p><a href=\"../global_objects/array/unshift\"><code>Array.unshift</code></a> is often used to insert an array of values at the start of an existing array. Without spread syntax this is done as:</p> <pre data-language=\"js\">var arr1 = [0, 1, 2];\nvar arr2 = [3, 4, 5];\n// Prepend all items from arr2 onto arr1\nArray.prototype.unshift.apply(arr1, arr2) // arr1 is now [3, 4, 5, 0, 1, 2]</pre> <p>With spread syntax this becomes [Note, however, that this creates a new <code>arr1</code> array. Unlike <a href=\"../global_objects/array/unshift\"><code>Array.unshift</code></a>, it does not modify the original <code>arr1</code> array in-place]:</p> <pre data-language=\"js\">var arr1 = [0, 1, 2];\nvar arr2 = [3, 4, 5];\narr1 = [...arr2, ...arr1]; // arr1 is now [3, 4, 5, 0, 1, 2]\n</pre> <h3 id=\"Spread_in_object_literals\">Spread in object literals</h3> <p>The <a href=\"https://github.com/tc39/proposal-object-rest-spread\">Rest/Spread Properties for ECMAScript</a> proposal (stage 4) adds spread properties to <a href=\"object_initializer\">object literals</a>. It copies own enumerable properties from a provided object onto a new object.</p> <p>Shallow-cloning (excluding prototype) or merging of objects is now possible using a shorter syntax than <a href=\"../global_objects/object/assign\"><code>Object.assign()</code></a>.</p> <pre data-language=\"js\">var obj1 = { foo: 'bar', x: 42 };\nvar obj2 = { foo: 'baz', y: 13 };\n\nvar clonedObj = { ...obj1 };\n// Object { foo: \"bar\", x: 42 }\n\nvar mergedObj = { ...obj1, ...obj2 };\n// Object { foo: \"baz\", x: 42, y: 13 }</pre> <p>Note that <a href=\"../global_objects/object/assign\"><code>Object.assign()</code></a> triggers <a href=\"../functions/set\">setters</a> whereas spread syntax doesn't.</p> <p>Note that you cannot replace nor mimic the <a href=\"../global_objects/object/assign\"><code>Object.assign()</code></a> function:</p> <pre data-language=\"js\">var obj1 = { foo: 'bar', x: 42 };\nvar obj2 = { foo: 'baz', y: 13 };\nconst merge = ( ...objects ) =&gt; ( { ...objects } );\n\nvar mergedObj = merge ( obj1, obj2);\n// Object { 0: { foo: 'bar', x: 42 }, 1: { foo: 'baz', y: 13 } }\n\nvar mergedObj = merge ( {}, obj1, obj2);\n// Object { 0: {}, 1: { foo: 'bar', x: 42 }, 2: { foo: 'baz', y: 13 } }</pre> <p>In the above example, the spread syntax does not work as one might expect: it spreads an <em>array</em> of arguments into the object literal, due to the rest parameter.</p> <h3 id=\"Only_for_iterables\">Only for iterables</h3> <p>Spread syntax (other than in the case of spread properties) can be applied only to <a href=\"../global_objects/symbol/iterator\">iterable</a> objects:</p> <pre data-language=\"js\">var obj = {'key1': 'value1'};\nvar array = [...obj]; // TypeError: obj is not iterable\n</pre> <h3 id=\"Spread_with_many_values\">Spread with many values</h3> <p>When using spread syntax for function calls, be aware of the possibility of exceeding the JavaScript engine's argument length limit. See <a href=\"../global_objects/function/apply\"><code>apply()</code></a> for more details.</p> <h2 id=\"Rest_syntax_(parameters)\">Rest syntax (parameters)</h2> <p>Rest syntax looks exactly like spread syntax, but is used for destructuring arrays and objects. In a way, rest syntax is the opposite of spread syntax: spread 'expands' an array into its elements, while rest collects multiple elements and 'condenses' them into a single element. See <a href=\"../functions/rest_parameters\">rest parameters.</a></p> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <thead> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> </thead> <tbody> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-array-initializer\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)</a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Defined in several sections of the specification: <a href=\"http://www.ecma-international.org/ecma-262/6.0/#sec-array-initializer\">Array Initializer</a>, <a href=\"http://www.ecma-international.org/ecma-262/6.0/#sec-argument-lists\">Argument Lists</a>\n</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/9.0/#sec-object-initializer\" hreflang=\"en\">ECMAScript 2018 (ECMA-262)</a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Defined in <a href=\"http://www.ecma-international.org/ecma-262/9.0/#sec-object-initializer\">Object Initializer</a>\n</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-array-initializer\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)</a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td>No changes.</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-object-initializer\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)</a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td>No changes.</td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Operators/Spread_syntax#Spread_in_array_literals\">Spread in array literals</a></th>\n<td class=\"bc-supports-yes\"> 46</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 16</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 37</td>\n<td class=\"bc-supports-yes\"> 8</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Operators/Spread_syntax#Spread_in_function_calls\">Spread in function calls</a></th>\n<td class=\"bc-supports-yes\"> 46</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 27</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 37</td>\n<td class=\"bc-supports-yes\"> 8</td>\n</tr>\n<tr>\n<th scope=\"row\">Spread in destructuring</th>\n<td class=\"bc-supports-yes\"> 49</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 34</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 37</td>\n<td> ? </td>\n</tr>\n<tr>\n<th scope=\"row\">\n<a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Operators/Spread_syntax#Spread_in_object_literals\">Spread in object literals</a> \n</th>\n<td class=\"bc-supports-yes\"> 60</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 55</td>\n<td class=\"bc-supports-no\"> No</td>\n<td> ? </td>\n<td class=\"bc-supports-no\"> No</td>\n</tr>\n</tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Operators/Spread_syntax#Spread_in_array_literals\">Spread in array literals</a></th>\n<td class=\"bc-supports-yes\"> 46</td>\n<td class=\"bc-supports-yes\"> 46</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 16</td>\n<td class=\"bc-supports-yes\"> 37</td>\n<td class=\"bc-supports-yes\"> 8</td>\n<td class=\"bc-supports-yes\"> 5.0</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Operators/Spread_syntax#Spread_in_function_calls\">Spread in function calls</a></th>\n<td class=\"bc-supports-yes\"> 46</td>\n<td class=\"bc-supports-yes\"> 46</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 27</td>\n<td class=\"bc-supports-yes\"> 37</td>\n<td class=\"bc-supports-yes\"> 8</td>\n<td class=\"bc-supports-yes\"> 5.0</td>\n</tr>\n<tr>\n<th scope=\"row\">Spread in destructuring</th>\n<td class=\"bc-supports-yes\"> 49</td>\n<td class=\"bc-supports-yes\"> 49</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 34</td>\n<td class=\"bc-supports-yes\"> 37</td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 5.0</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Operators/Spread_syntax#Spread_in_object_literals\">Spread in object literals</a> \n</th>\n<td class=\"bc-supports-yes\"> 60</td>\n<td class=\"bc-supports-yes\"> 60</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 55</td>\n<td> ? </td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n</tr>\n</tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Operators/Spread_syntax#Spread_in_array_literals\">Spread in array literals</a></th>\n<td class=\"bc-supports-yes bc-has-history\"> 5.0.0\n<section class=\"bc-history\" id=\"sect1\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 5.0.0\n</dt>\n\n<dt class=\"bc-supports-yes bc-supports\"> 4.0.0<div class=\"bc-icons\">Disabled </div>\n</dt>\n<dd>Disabled From version 4.0.0: this feature is behind the <code>--harmony</code> runtime flag.</dd>\n</dl></section>\n</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Operators/Spread_syntax#Spread_in_function_calls\">Spread in function calls</a></th>\n<td class=\"bc-supports-yes bc-has-history\"> 5.0.0\n<section class=\"bc-history\" id=\"sect2\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 5.0.0\n</dt>\n\n<dt class=\"bc-supports-yes bc-supports\"> 4.0.0<div class=\"bc-icons\">Disabled </div>\n</dt>\n<dd>Disabled From version 4.0.0: this feature is behind the <code>--harmony</code> runtime flag.</dd>\n</dl></section>\n</td>\n</tr>\n<tr>\n<th scope=\"row\">Spread in destructuring</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Operators/Spread_syntax#Spread_in_object_literals\">Spread in object literals</a> \n</th>\n<td class=\"bc-supports-yes bc-has-history\"> 8.3.0\n<section class=\"bc-history\" id=\"sect3\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 8.3.0\n</dt>\n\n<dt class=\"bc-supports-yes bc-supports\"> 8.0.0<div class=\"bc-icons\">Disabled </div>\n</dt>\n<dd>Disabled From version 8.0.0: this feature is behind the <code>--harmony</code> runtime flag.</dd>\n</dl></section>\n</td>\n</tr>\n</tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li>\n<a href=\"../functions/rest_parameters\">Rest parameters</a> (also ‘<code>...</code>’)</li> <li>\n<a href=\"../global_objects/function/apply\">fn.apply</a> (also ‘<code>...</code>’)</li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Spread_syntax$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Spread_syntax\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Spread_syntax</a>\n  </p>\n</div>\n","operators/void":"<h1>void</h1> <p>The <code>void</code> evaluates the given <code><em>expression</em></code> and then returns <a href=\"../global_objects/undefined\"><code>undefined</code></a>.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/expressions-voidoperator.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\">void <em>expression</em></pre> <h2 id=\"Description\">Description</h2> <p>This operator allows evaluating expressions that produce a value into places where an expression that evaluates to <a href=\"../global_objects/undefined\"><code>undefined</code></a> is desired.</p> <p>The <code>void</code> operator is often used merely to obtain the <code>undefined</code> primitive value, usually using \"<code>void(0)</code>\" (which is equivalent to \"<code>void 0</code>\"). In these cases, the global variable <a href=\"../global_objects/undefined\"><code>undefined</code></a> can be used instead (assuming it has not been assigned to a non-default value).</p> <h2 id=\"Immediately_Invoked_Function_Expressions\">Immediately Invoked Function Expressions</h2> <p>When using an <a href=\"https://developer.mozilla.org/en-US/docs/Glossary/IIFE\">immediately-invoked function expression</a>, <code>void</code> can be used to force the <code>function</code> keyword to be treated as an expression instead of a declaration.</p> <pre data-language=\"js\">void function iife() {\n    var bar = function () {};\n    var baz = function () {};\n    var foo = function () {\n        bar();\n        baz();\n     };\n    var biz = function () {};\n\n    foo();\n    biz();\n}();\n</pre> <h2 id=\"JavaScript_URIs\">JavaScript URIs</h2> <p>When a browser follows a <code>javascript:</code> URI, it evaluates the code in the URI and then replaces the contents of the page with the returned value, unless the returned value is <a href=\"../global_objects/undefined\"><code>undefined</code></a>. The <code>void</code> operator can be used to return <a href=\"../global_objects/undefined\"><code>undefined</code></a>. For example:</p> <pre data-language=\"html\">&lt;a href=\"javascript:void(0);\"&gt;\n  Click here to do nothing\n&lt;/a&gt;\n\n&lt;a href=\"javascript:void(document.body.style.backgroundColor='green');\"&gt;\n  Click here for green background\n&lt;/a&gt;\n</pre> <p>Note, however, that the <code>javascript:</code> pseudo protocol is discouraged over other alternatives, such as unobtrusive event handlers.</p> <h2 id=\"Non-leaking_Arrow_Functions\">Non-leaking Arrow Functions</h2> <p>Arrow functions introduce a short-hand braceless syntax that returns an expression. This can cause unintended side effects by returning the result of a function call that previously returned nothing. To be safe, when the return value of a function is not intended to be used, it can be passed to the void operator to ensure that (for example) changing APIs do not cause arrow functions' behaviors to change.</p> <pre data-language=\"js\">button.onclick = () =&gt; void doSomething();</pre> <p>This ensures the return value of <code>doSomething</code> changing from <code>undefined</code> to <code>true</code> will not change the behavior of this code.</p> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-void-operator\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'The void Operator' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-void-operator\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'The void Operator' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/5.1/#sec-11.4.2\" hreflang=\"en\">ECMAScript 5.1 (ECMA-262)<br><small>The definition of 'The void Operator' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/publications/files/ECMA-ST-ARCH/ECMA-262,%203rd%20edition,%20December%201999.pdf#sec-11.4.2\" hreflang=\"en\">ECMAScript 3rd Edition (ECMA-262)<br><small>The definition of 'The void Operator' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/publications/files/ECMA-ST-ARCH/ECMA-262,%201st%20edition,%20June%201997.pdf#sec-11.4.2\" hreflang=\"en\">ECMAScript 1st Edition (ECMA-262)<br><small>The definition of 'The void Operator' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition. Implemented in JavaScript 1.1</td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><code><a href=\"../global_objects/undefined\">undefined</a></code></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/void$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/void\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/void</a>\n  </p>\n</div>\n","operators/new":"<h1>new</h1> <p>The<code>new</code> creates an instance of a user-defined object type or of one of the built-in object types that has a constructor function.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/expressions-newoperator.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\">new <em>constructor</em>[([<em>arguments</em>])]</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><code>constructor</code></dt> <dd>A class or function that specifies the type of the object instance.</dd> </dl> <dl> <dt><code>arguments</code></dt> <dd>A list of values that the <code>constructor</code> will be called with.</dd> </dl> <h2 id=\"Description\">Description</h2> <p>Creating a user-defined object requires two steps:</p> <ol> <li>Define the object type by writing a function.</li> <li>Create an instance of the object with <code>new</code>.</li> </ol> <p>To define an object type, create a function for the object type that specifies its name and properties. An object can have a property that is itself or another object. See the examples below.</p> <p>When the code <code>new <em>Foo</em>(...)</code> is executed, the following things happen:</p> <ol> <li>A new object is created, inheriting from <code><em>Foo</em>.prototype</code>.</li> <li>The constructor function <em><code>Foo</code></em> is called with the specified arguments, and with <code><a href=\"this\">this</a></code> bound to the newly created object. <code>new <em>Foo</em></code> is equivalent to <code>new </code><em><code>Foo</code></em><code>()</code>, i.e. if no argument list is specified, <em><code>Foo</code></em> is called without arguments.</li> <li>The object (not null, false, 3.1415 or other primitive types) returned by the constructor function becomes the result of the whole <code>new</code> expression. If the constructor function doesn't explicitly return an object, the object created in step 1 is used instead. (Normally constructors don't return a value, but they can choose to do so if they want to override the normal object creation process.)</li> </ol> <p>You can always add a property to a previously defined object. For example, the statement <code>car1.color = \"black\"</code> adds a property <code>color</code> to <code>car1</code>, and assigns it a value of \"<code>black</code>\". However, this does not affect any other objects. To add the new property to all objects of the same type, you must add the property to the definition of the <code>Car</code> object type.</p> <p>You can add a shared property to a previously defined object type by using the <code><a href=\"../global_objects/function/prototype\">Function.prototype</a></code> property. This defines a property that is shared by all objects created with that function, rather than by just one instance of the object type. The following code adds a color property with value <code>\"original color\"</code> to all objects of type <code>Car</code>, and then overwrites that value with the string \"<code>black</code>\" only in the instance object <code>car1</code>. For more information, see <a href=\"../global_objects/function/prototype\">prototype</a>.</p> <pre data-language=\"js\">function Car() {}\ncar1 = new Car();\ncar2 = new Car();\n \nconsole.log(car1.color);    // undefined\n \nCar.prototype.color = \"original color\";\nconsole.log(car1.color);    // original color\n \ncar1.color = 'black';\nconsole.log(car1.color);   // black\n\nconsole.log(car1.__proto__.color) //original color\nconsole.log(car2.__proto__.color) //original color\nconsole.log(car1.color)  // black\nconsole.log(car2.color) // original color\n</pre> <div class=\"note\"> <p>If you didn't write the <code>new</code> operator, <strong>the Constructor Function would be invoked like any Regular Function,</strong> <em>without creating an Object.</em>In this case, the value of <code>this</code> is also different.</p> </div> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Object_type_and_object_instance\">Object type and object instance</h3> <p>Suppose you want to create an object type for cars. You want this type of object to be called <code>Car</code>, and you want it to have properties for make, model, and year. To do this, you would write the following function:</p> <pre data-language=\"js\">function Car(make, model, year) {\n  this.make = make;\n  this.model = model;\n  this.year = year;\n}\n</pre> <p>Now you can create an object called <code>mycar</code> as follows:</p> <pre data-language=\"js\">var mycar = new Car('Eagle', 'Talon TSi', 1993);\n</pre> <p>This statement creates <code>mycar</code> and assigns it the specified values for its properties. Then the value of <code>mycar.make</code> is the string \"Eagle\", <code>mycar.year</code> is the integer 1993, and so on.</p> <p>You can create any number of <code>car</code> objects by calls to <code>new</code>. For example:</p> <pre data-language=\"js\">var kenscar = new Car('Nissan', '300ZX', 1992);\n</pre> <h3 id=\"Object_property_that_is_itself_another_object\">Object property that is itself another object</h3> <p>Suppose you define an object called <code>person</code> as follows:</p> <pre data-language=\"js\">function Person(name, age, sex) {\n  this.name = name;\n  this.age = age;\n  this.sex = sex;\n}\n</pre> <p>And then instantiate two new <code>person</code> objects as follows:</p> <pre data-language=\"js\">var rand = new Person('Rand McNally', 33, 'M');\nvar ken = new Person('Ken Jones', 39, 'M');\n</pre> <p>Then you can rewrite the definition of <code>car</code> to include an <code>owner</code> property that takes a person object, as follows:</p> <pre data-language=\"js\">function Car(make, model, year, owner) {\n  this.make = make;\n  this.model = model;\n  this.year = year;\n  this.owner = owner;\n}\n</pre> <p>To instantiate the new objects, you then use the following:</p> <pre data-language=\"js\">var car1 = new Car('Eagle', 'Talon TSi', 1993, rand);\nvar car2 = new Car('Nissan', '300ZX', 1992, ken);\n</pre> <p>Instead of passing a literal string or integer value when creating the new objects, the above statements pass the objects <code>rand</code> and <code>ken</code> as the parameters for the owners. To find out the name of the owner of <code>car2</code>, you can access the following property:</p> <pre data-language=\"js\">car2.owner.name\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-new-operator\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'The new Operator' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-new-operator\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'The new Operator' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/5.1/#sec-11.2.2\" hreflang=\"en\">ECMAScript 5.1 (ECMA-262)<br><small>The definition of 'The new Operator' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/publications/files/ECMA-ST-ARCH/ECMA-262,%203rd%20edition,%20December%201999.pdf#sec-11.2.2\" hreflang=\"en\">ECMAScript 3rd Edition (ECMA-262)<br><small>The definition of 'The new Operator' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/publications/files/ECMA-ST-ARCH/ECMA-262,%201st%20edition,%20June%201997.pdf#sec-11.2.2\" hreflang=\"en\">ECMAScript 1st Edition (ECMA-262)<br><small>The definition of 'The new Operator' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition. Implemented in JavaScript 1.0.</td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"../global_objects/function\"><code>Function</code></a></li> <li><a href=\"../global_objects/reflect/construct\"><code>Reflect.construct()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/new$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/new\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/new</a>\n  </p>\n</div>\n","operators/typeof":"<h1>typeof</h1> <p>The <code>typeof</code> operator returns a string indicating the type of the unevaluated operand.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/expressions-typeof.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <p>The <code>typeof</code> operator is followed by its operand:</p> <pre class=\"syntaxbox\">typeof <em>operand</em>\n</pre>  <h3 id=\"Parameters\">Parameters</h3> <p><code><em>operand</em></code> is an expression representing the object or <a href=\"https://developer.mozilla.org/en-US/docs/Glossary/Primitive\">primitive</a> whose type is to be returned.</p> <p>The parentheses are optional.</p> <h2 id=\"Description\">Description</h2> <p>The following table summarizes the possible return values of <code>typeof</code>. For more information about types and primitives, see also the <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures\">JavaScript data structure</a> page.</p> <div class=\"_table\"><table class=\"standard-table\"> <thead> <tr> <th scope=\"col\">Type</th> <th scope=\"col\">Result</th> </tr> </thead> <tbody> <tr> <td>Undefined</td> <td><code>\"undefined\"</code></td> </tr> <tr> <td>Null</td> <td>\n<code>\"object\"</code> (see below)</td> </tr> <tr> <td>Boolean</td> <td><code>\"boolean\"</code></td> </tr> <tr> <td>Number</td> <td><code>\"number\"</code></td> </tr> <tr> <td>String</td> <td><code>\"string\"</code></td> </tr> <tr> <td>Symbol (new in ECMAScript 2015)</td> <td><code>\"symbol\"</code></td> </tr> <tr> <td>Host object (provided by the JS environment)</td> <td><em>Implementation-dependent</em></td> </tr> <tr> <td>Function object (implements [[Call]] in ECMA-262 terms)</td> <td><code>\"function\"</code></td> </tr> <tr> <td>Any other object</td> <td><code>\"object\"</code></td> </tr> </tbody> </table></div> <h2 id=\"Examples\">Examples</h2> <pre data-language=\"js\">// Numbers\ntypeof 37 === 'number';\ntypeof 3.14 === 'number';\ntypeof(42) === 'number';\ntypeof Math.LN2 === 'number';\ntypeof Infinity === 'number';\ntypeof NaN === 'number'; // Despite being \"Not-A-Number\"\ntypeof Number('1') === 'number'; // Number tries to parse things into numbers\n\n\n// Strings\ntypeof '' === 'string';\ntypeof 'bla' === 'string';\ntypeof `template literal` === 'string';\ntypeof '1' === 'string'; // note that a number within a string is still typeof string\ntypeof (typeof 1) === 'string'; // typeof always returns a string\ntypeof String(1) === 'string'; // String converts anything into a string, safer than toString\n\n\n// Booleans\ntypeof true === 'boolean';\ntypeof false === 'boolean';\ntypeof Boolean(1) === 'boolean'; // Boolean() will convert values based on if they're truthy or falsy\ntypeof !!(1) === 'boolean'; // two calls of the ! (logical NOT) operator are equivalent to Boolean()\n\n\n// Symbols\ntypeof Symbol() === 'symbol'\ntypeof Symbol('foo') === 'symbol'\ntypeof Symbol.iterator === 'symbol'\n\n\n// Undefined\ntypeof undefined === 'undefined';\ntypeof declaredButUndefinedVariable === 'undefined';\ntypeof undeclaredVariable === 'undefined'; \n\n\n// Objects\ntypeof {a: 1} === 'object';\n\n// use <a href=\"../global_objects/array/isarray\">Array.isArray</a> or Object.prototype.toString.call\n// to differentiate regular objects from arrays\ntypeof [1, 2, 4] === 'object';\n\ntypeof new Date() === 'object';\ntypeof /regex/ === 'object'; // See Regular expressions section for historical results\n\n\n// The following are confusing, dangerous, and wasteful. Avoid them.\ntypeof new Boolean(true) === 'object'; \ntypeof new Number(1) === 'object'; \ntypeof new String('abc') === 'object';\n\n\n// Functions\ntypeof function() {} === 'function';\ntypeof class C {} === 'function';\ntypeof Math.sin === 'function';\n</pre> <h2 id=\"Additional_information\">Additional information</h2> <h3 id=\"null\"><code>null</code></h3> <pre data-language=\"js\">// This stands since the beginning of JavaScript\ntypeof null === 'object';\n</pre> <p>In the first implementation of JavaScript, JavaScript values were represented as a type tag and a value. The type tag for objects was 0. <code>null</code> was represented as the NULL pointer (0x00 in most platforms). Consequently, null had 0 as type tag, hence the bogus <code>typeof</code> return value. (<a href=\"http://www.2ality.com/2013/10/typeof-null.html\">reference</a>)</p> <p>A fix was proposed for ECMAScript (via an opt-in), but <a href=\"https://web.archive.org/web/20160331031419/http://wiki.ecmascript.org:80/doku.php?id=harmony:typeof_null\">was rejected</a>. It would have resulted in <code>typeof null === 'null'</code>.</p> <h3 id=\"Using_new_operator\">Using <code>new</code> operator</h3> <pre data-language=\"js\">// All constructor functions, with the exception of the Function constructor, will always be typeof 'object'\nvar str = new String('String');\nvar num = new Number(100);\n\ntypeof str; // It will return 'object'\ntypeof num; // It will return 'object'\n\nvar func = new Function();\n\ntypeof func; // It will return 'function'\n</pre> <h3 id=\"Need_for_parentheses_in_Syntax\">Need for parentheses in Syntax</h3> <pre data-language=\"js\">// Parentheses can be used for determining the data type of expressions.\nvar iData = 99;\n\ntypeof iData + ' Wisen'; // 'number Wisen'\ntypeof (iData + ' Wisen'); // 'string'\n\n\n</pre> <h3 id=\"Regular_expressions\">Regular expressions</h3> <p>Callable regular expressions were a non-standard addition in some browsers.</p> <pre data-language=\"js\">typeof /s/ === 'function'; // Chrome 1-12 Non-conform to ECMAScript 5.1\ntypeof /s/ === 'object';   // Firefox 5+  Conform to ECMAScript 5.1\n</pre> <h3 id=\"Errors\">Errors</h3> <p>Before ECMAScript 2015, <code>typeof</code> was always guaranteed to return a string for any operand it was supplied with. Even with undeclared identifiers, <code>typeof</code> will return <code>'undefined'</code>. Using <code>typeof</code> could never generate an error.</p> <p>But with the addition of non-hoisted, block-scoped <code><a href=\"../statements/let\">let</a></code> and <code><a href=\"../statements/const\">const</a></code>, using <code>typeof</code> on <code>let</code> and <code>const</code> variables (or using <code>typeof</code> on a <code>class)</code> in a block before they are declared will throw a <code><a href=\"../global_objects/referenceerror\">ReferenceError</a></code>. Block scoped variables are in a \"<a href=\"../statements/let#Temporal_Dead_Zone_and_errors_with_let\">temporal dead zone</a>\" from the start of the block until the initialization is processed, during which, it will throw an error if accessed.</p> <pre data-language=\"js\">typeof undeclaredVariable === 'undefined';\n\ntypeof newLetVariable; // ReferenceError\ntypeof newConstVariable; // ReferenceError\ntypeof newClass; // ReferenceError\n\nlet newLetVariable;\nconst newConstVariable = 'hello';\nclass newClass{};</pre> <h3 id=\"Exceptions\">Exceptions</h3> <p>All current browsers expose a non-standard host object <a href=\"https://developer.mozilla.org/en-US/docs/Web/API/Document/all\"><code>document.all</code></a> with type <code>undefined</code>.</p> <pre data-language=\"js\">typeof document.all === 'undefined';\n</pre> <p>Although the specification allows custom type tags for non-standard exotic objects, it requires those type tags to be different from the predefined ones. The case of <code>document.all</code> having type <code>'undefined'</code> is classified in the web standards as a \"willful violation\" of the original ECMA JavaScript standard.</p> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-typeof-operator\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'The typeof Operator' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-typeof-operator\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'The typeof Operator' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/5.1/#sec-11.4.3\" hreflang=\"en\">ECMAScript 5.1 (ECMA-262)<br><small>The definition of 'The typeof Operator' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/publications/files/ECMA-ST-ARCH/ECMA-262,%203rd%20edition,%20December%201999.pdf#sec-11.4.3\" hreflang=\"en\">ECMAScript 3rd Edition (ECMA-262)<br><small>The definition of 'The typeof Operator' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/publications/files/ECMA-ST-ARCH/ECMA-262,%201st%20edition,%20June%201997.pdf#sec-11.4.3\" hreflang=\"en\">ECMAScript 1st Edition (ECMA-262)<br><small>The definition of 'The typeof Operator' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition. Implemented in JavaScript 1.1.</td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"IE-specific_notes\">IE-specific notes</h2> <p>On IE 6, 7, and 8 a lot of host objects are objects and not functions. For example:</p> <pre data-language=\"js\">typeof alert === 'object'</pre> <h2 id=\"See_also\">See also</h2> <ul> <li><code><a href=\"instanceof\">instanceof</a></code></li> <li><a href=\"http://es-discourse.com/t/why-typeof-is-no-longer-safe/15\">Why typeof is no longer \"safe\"</a></li> <li><a href=\"https://github.com/tc39/ecma262/issues/668\">document.all willful violation of the standard</a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/typeof$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/typeof\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/typeof</a>\n  </p>\n</div>\n","statements/break":"<h1>break</h1> <p>The <strong>break statement</strong> terminates the current loop, <a href=\"switch\"><code>switch</code></a>, or <a href=\"label\"><code>label</code></a> statement and transfers program control to the statement following the terminated statement.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/statement-break.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\">break [<em>label</em>];</pre> <dl> <dt><code>label</code></dt> <dd>Optional. Identifier associated with the label of the statement. If the statement is not a loop or <a href=\"switch\"><code>switch</code></a>, this is required.</dd> </dl> <h2 id=\"Description\">Description</h2> <p>The <code>break</code> statement includes an optional label that allows the program to break out of a labeled statement. The <code>break</code> statement needs to be nested within the referenced label. The labeled statement can be any <a href=\"block\"><code>block</code></a> statement; it does not have to be preceded by a loop statement.</p> <p>A <code>break</code> statement, with or without a following label, cannot be used within the body of a function that is itself nested within the current loop, switch, or label statement that the <code>break</code> statement is intended to break out of.</p> <h2 id=\"Examples\">Examples</h2> <p>The following function has a <code>break</code> statement that terminates the <a href=\"while\"><code>while</code></a> loop when <code>i</code> is 3, and then returns the value 3 * <code>x</code>.</p> <pre data-language=\"js\">function testBreak(x) {\n  var i = 0;\n\n  while (i &lt; 6) {\n    if (i == 3) {\n      break;\n    }\n    i += 1;\n  }\n\n  return i * x;\n}</pre> <p>The following code uses <code>break</code> statements with labeled blocks. A <code>break</code> statement must be nested within any label it references. Notice that <code>inner_block</code> is nested within <code>outer_block</code>.</p> <pre data-language=\"js\">outer_block: {\n  inner_block: {\n    console.log('1');\n    break outer_block; // breaks out of both inner_block and outer_block\n    console.log(':-('); // skipped\n  }\n  console.log('2'); // skipped\n}\n</pre> <p>The following code also uses <code>break</code> statements with labeled blocks but generates a Syntax Error because its <code>break</code> statement is within <code>block_1</code> but references <code>block_2</code>. A <code>break</code> statement must always be nested within any label it references.</p> <pre data-language=\"js\">block_1: {\n  console.log('1');\n  break block_2; // SyntaxError: label not found\n}\n\nblock_2: {\n  console.log('2');\n}\n</pre> <p>Syntax Errors are also generated in the following code examples which use <code>break</code> statements within functions that are nested within a loop or labeled block that the <code>break</code> statements are intended to break out of.</p> <pre data-language=\"js\">function testBreak(x) {\n  var i = 0;\n\n  while (i &lt; 6) {\n    if (i == 3) {\n      (function() {\n        break;\n      })();\n    }\n    i += 1;\n  }\n\nreturn i * x;\n}\n\ntestBreak(1); // SyntaxError: Illegal break statement\n</pre> <pre data-language=\"js\">block_1: {\n  console.log('1');\n  ( function() {\n    break block_1; // SyntaxError: Undefined label 'block_1'\n  })();\n}\n</pre>  <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/publications/files/ECMA-ST-ARCH/ECMA-262,%201st%20edition,%20June%201997.pdf\" hreflang=\"en\">ECMAScript 1st Edition (ECMA-262)</a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition. Unlabeled version.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/publications/files/ECMA-ST-ARCH/ECMA-262,%203rd%20edition,%20December%201999.pdf\" hreflang=\"en\">ECMAScript 3rd Edition (ECMA-262)</a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Labeled version added.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/5.1/#sec-12.8\" hreflang=\"en\">ECMAScript 5.1 (ECMA-262)<br><small>The definition of 'Break statement' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-break-statement\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Break statement' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-break-statement\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Break statement' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"continue\"><code>continue</code></a></li> <li><a href=\"label\"><code>label</code></a></li> <li><a href=\"switch\"><code>switch</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/break$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/break\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/break</a>\n  </p>\n</div>\n","operators/yield":"<h1>yield</h1> <p>The <code>yield</code> keyword is used to pause and resume a generator function (<a href=\"../statements/function*\"><code>function*</code></a> or <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/Legacy_generator_function\">legacy generator function</a>).</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/expressions-yield.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\">[<em>rv</em>] = <strong>yield</strong> [<em>expression</em>];</pre> <dl> <dt><code>expression</code></dt> <dd>Defines the value to return from the generator function via <a href=\"../iteration_protocols#The_iterator_protocol\">the iterator protocol</a>. If omitted, <code>undefined</code> is returned instead.</dd> <dt><code>rv</code></dt> <dd> <p>Returns the optional value passed to the generator's <code>next()</code> method to resume its execution.</p> </dd> </dl> <h2 id=\"Description\">Description</h2> <p>The <code>yield</code> keyword pauses generator function execution and the value of the expression following the <code>yield</code> keyword is returned to the generator's caller. It can be thought of as a generator-based version of the <code>return</code> keyword.</p> <p>The <code>yield</code> keyword actually returns an <code>IteratorResult</code> object with two properties, <code>value</code> and <code>done</code>. The <code>value</code> property is the result of evaluating the <code>yield</code> expression, and <code>done</code> is <code>false</code>, indicating that the generator function has not fully completed.</p> <p>Once paused on a <code>yield</code> expression, the generator's code execution remains paused until the generator's <code>next()</code> method is called. Each time the generator's <code>next()</code> method is called, the generator resumes execution and runs until it reaches one of the following:</p> <ul> <li> A <code>yield</code>, which causes the generator to once again pause and return the generator's new value. The next time <code>next()</code> is called, execution resumes with the statement immediately after the <code>yield</code>.</li> <li>\n<a href=\"../statements/throw\"><code>throw</code></a> is used to throw an exception from the generator. This halts execution of the generator entirely, and execution resumes in the caller as is normally the case when an exception is thrown.</li> <li>The end of the generator function is reached; in this case, execution of the generator ends and an <code>IteratorResult</code> is returned to the caller in which the <code>value</code> is <a href=\"../global_objects/undefined\"><code>undefined</code></a> and <code>done</code> is <code>true</code>.</li> <li>A <a href=\"../statements/return\"><code>return</code></a> statement is reached. In this case, execution of the generator ends and an <code>IteratorResult</code> is returned to the caller in which the <code>value</code> is the value specified by the <code>return</code> statement and <code>done</code> is <code>true</code>.</li> </ul> <p>If an optional value is passed to the generator's <code>next()</code> method, that value becomes the value returned by the generator's current <code>yield</code> operation.</p> <p>Between the generator's code path, its <code>yield</code> operators, and the ability to specify a new starting value by passing it to <a href=\"../global_objects/generator/next\"><code>Generator.prototype.next()</code></a>, generators offer enormous power and control.</p> <h2 id=\"Examples\">Examples</h2> <p>The following code is the declaration of an example generator function.</p> <pre data-language=\"js\">function* countAppleSales () {\n  var saleList = [3, 7, 5];\n  for (var i = 0; i &lt; saleList.length; i++) {\n    yield saleList[i];\n  }\n}</pre> <p>Once a generator function is defined, it can be used by constructing an iterator as shown.</p> <pre data-language=\"js\">var appleStore = countAppleSales(); // Generator { }\nconsole.log(appleStore.next()); // { value: 3, done: false }\nconsole.log(appleStore.next()); // { value: 7, done: false }\nconsole.log(appleStore.next()); // { value: 5, done: false }\nconsole.log(appleStore.next()); // { value: undefined, done: true }</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <thead> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> </thead> <tbody> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#prod-YieldExpression\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Yield' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#prod-YieldExpression\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Yield' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 39</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes bc-has-history\"> 26\n<section class=\"bc-history\" id=\"sect1\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 26\n</dt>\n<dd> Starting with Firefox 33, the parsing of the <code>yield</code> expression has been updated to conform with the ES2015 specification.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 10</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<code>IteratorResult</code> object instead of throwing</th>\n<td> ? </td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 29</td>\n<td class=\"bc-supports-no\"> No</td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 10</td>\n</tr>\n</tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 39</td>\n<td class=\"bc-supports-yes\"> 39</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes bc-has-history\"> 26\n<section class=\"bc-history\" id=\"sect2\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 26\n</dt>\n<dd> Starting with Firefox 33, the parsing of the <code>yield</code> expression has been updated to conform with the ES2015 specification.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 10</td>\n<td class=\"bc-supports-yes\"> 4.0</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<code>IteratorResult</code> object instead of throwing</th>\n<td> ? </td>\n<td> ? </td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 29</td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 10</td>\n<td> ? </td>\n</tr>\n</tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes bc-has-history\"> 4.0.0\n<section class=\"bc-history\" id=\"sect3\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 4.0.0\n</dt>\n\n<dt class=\"bc-supports-yes bc-supports\"> 0.12<div class=\"bc-icons\">Disabled </div>\n</dt>\n<dd>Disabled From version 0.12: this feature is behind the <code>--harmony</code> runtime flag.</dd>\n</dl></section>\n</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<code>IteratorResult</code> object instead of throwing</th>\n<td> ? </td>\n</tr>\n</tbody>\n</table>\n</div> <h2 id=\"Firefox-specific_notes\">Firefox-specific notes</h2> <ul> <li>Starting with Gecko 29 (Firefox 29 / Thunderbird 29 / SeaMonkey 2.26), the completed generator function no longer throws a <a href=\"../global_objects/typeerror\"><code>TypeError</code></a> \"generator has already finished\". Instead, it returns an <code>IteratorResult</code> object like <code>{ value: undefined, done: true }</code> (<a href=\"https://bugzilla.mozilla.org/show_bug.cgi?id=958951\">bug 958951</a>).</li> <li>Starting with Gecko 33 (Firefox 33 / Thunderbird 33 / SeaMonkey 2.30), the parsing of the <code>yield</code> expression has been updated to conform with the ES2015 specification (<a href=\"https://bugzilla.mozilla.org/show_bug.cgi?id=981599\">bug 981599</a>): <ul> <li>The expression after the <code>yield</code> keyword is optional and omitting it no longer throws a <a href=\"../global_objects/syntaxerror\"><code>SyntaxError</code></a>: <code>function* countAppleSales() { yield; }</code>\n</li> </ul> </li> </ul> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/The_Iterator_protocol\">The Iterator protocol</a></li> <li><a href=\"../statements/function*\"><code>function*</code></a></li> <li><a href=\"function*\"><code>function* expression</code></a></li> <li><a href=\"yield*\"><code>yield*</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/yield$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/yield\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/yield</a>\n  </p>\n</div>\n","operators/new.target":"<h1>new.target</h1> <p>The<code>new.target</code> property lets you detect whether a function or constructor was called using the <a href=\"new\">new</a> operator. In constructors and functions instantiated with the <a href=\"new\">new</a> operator, <code>new.target</code> returns a reference to the constructor or function. In normal function calls, <code>new.target</code> is <a href=\"../global_objects/undefined\"><code>undefined</code></a>.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/expressions-newtarget.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\">new.target</pre> <h2 id=\"Description\">Description</h2> <p>The <code>new.target</code> syntax consists of the keyword <code>\"new</code>\", a dot, and a property name <code>\"target\"</code>. Normally \"<code>new.\"</code> serves as the context for a property access, but here <code>\"new.\"</code> is not really an object. In constructor calls, however, <code>new.target</code> refers to the constructor invoked by <code>new</code> and so \"<code>new.</code>\" becomes a virtual context.</p> <p>The <code>new.target</code> property is a meta property that is available to all functions. In <a href=\"../functions/arrow_functions\">arrow functions</a>, <code>new.target</code> refers to the <code>new.target</code> of the surrounding function.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"new.target_in_function_calls\">new.target in function calls</h3> <p>In normal function calls (as opposed to constructor function calls), <code>new.target</code> is <a href=\"../global_objects/undefined\"><code>undefined</code></a>. This lets you detect if a function was called with <a href=\"new\">new</a> as a constructor.</p> <pre data-language=\"js\">function Foo() {\n  if (!new.target) throw 'Foo() must be called with new';\n  console.log('Foo instantiated with new');\n}\n\nFoo(); // throws \"Foo() must be called with new\"\nnew Foo(); // logs \"Foo instantiated with new\"\n</pre> <h3 id=\"new.target_in_constructors\">new.target in constructors</h3> <p>In class constructors, <code>new.target</code> refers to the constructor that was directly invoked by <code>new</code>. This is also the case if the constructor is in a parent class and was delegated from a child constructor.</p> <pre data-language=\"js\">class A {\n  constructor() {\n    console.log(new.target.name);\n  }\n}\n\nclass B extends A { constructor() { super(); } }\n\nvar a = new A(); // logs \"A\"\nvar b = new B(); // logs \"B\"\n\nclass C { constructor() { console.log(new.target); } }\nclass D extends C { constructor() { super(); } }\n \nvar c = new C(); // logs class C{constructor(){console.log(new.target);}}\nvar d = new D(); // logs class D extends C{constructor(){super();}}</pre> <p class=\"summary\">Thus from the above example of class C and D, it seems that new.target points to the class Definition of class which is initialized. For example, when D was initialized using new, the class definition of D was printed and similarly in case of c, class C was printed</p> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-built-in-function-objects\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Built-in Function Objects' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-built-in-function-objects\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Built-in Function Objects' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 46</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 41</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 46</td>\n<td class=\"bc-supports-yes\"> 46</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 41</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 5.0</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 5.0.0</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"../functions\">Functions</a></li> <li><a href=\"../classes\">Classes</a></li> <li><code><a href=\"new\">new</a></code></li> <li><code><a href=\"this\">this</a></code></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/new.target$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/new.target\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/new.target</a>\n  </p>\n</div>\n","statements/block":"<h1>block</h1> <p>A<strong> block statement</strong> (or <strong>compound statement</strong> in other languages) is used to group zero or more statements. The block is delimited by a pair of curly brackets and may optionally be <a href=\"label\"><code>labelled</code></a>:</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/statement-block.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <h3 id=\"Block_Statement\">Block Statement</h3> <pre class=\"syntaxbox\">{\n  <em>StatementList</em>\n}\n</pre> <h3 id=\"Labelled_Block_Statement\">Labelled Block Statement</h3> <pre class=\"syntaxbox\"><em>LabelIdentifier</em>: {\n  <em>StatementList</em>\n}\n</pre> <dl> <dt><code>StatementList</code></dt> <dd>Statements grouped within the block statement.</dd> <dt><code>LabelIdentifier</code></dt> <dd>An optional <a href=\"label\"><code>label</code></a> for visual identification or as a target for <a href=\"break\"><code>break</code></a>.</dd> </dl> <h2 id=\"Description\">Description</h2> <p>The block statement is often called <strong>compound statement</strong> in other languages. It allows you to use multiple statements where JavaScript expects only one statement. Combining statements into blocks is a common practice in JavaScript. The opposite behavior is possible using an <a href=\"empty\">empty statement</a>, where you provide no statement, although one is required.</p> <h3 id=\"Block_Scoping_Rules\">Block Scoping Rules</h3> <h4 id=\"With_var\">With <code>var</code>\n</h4> <p>Variables declared with <code>var</code> <strong>do not</strong> have block scope. Variables introduced with a block are scoped to the containing function or script, and the effects of setting them persist beyond the block itself. In other words, block statements do not introduce a scope. Although \"standalone\" blocks are valid syntax, you do not want to use standalone blocks in JavaScript, because they don't do what you think they do, if you think they do anything like such blocks in C or Java. For example:</p> <pre data-language=\"js\">var x = 1;\n{\n  var x = 2;\n}\nconsole.log(x); // logs 2\n</pre> <p>This logs 2 because the <code>var x</code> statement within the block is in the same scope as the <code>var x</code> statement before the block. In C or Java, the equivalent code would have outputted 1.</p> <h4 id=\"With_let_and_const\">With <code>let </code>and <code>const</code>\n</h4> <p>By contrast, identifiers declared with <a href=\"let\"><code>let</code></a> and <a href=\"const\"><code>const</code></a> <strong>do have </strong>block scope:</p> <pre data-language=\"js\">let x = 1;\n{\n  let x = 2;\n}\nconsole.log(x); // logs 1</pre> <p>The <code>x = 2</code> is limited in scope to the block in which it was defined.</p> <p>The same is true of <code>const</code>:</p> <pre data-language=\"js\">const c = 1;\n{\n  const c = 2;\n}\nconsole.log(c); // logs 1 and does not throw SyntaxError...</pre> <p>Note that the block-scoped <code>const c = 2</code> <em>does not</em> throw a <code>SyntaxError: Identifier 'c' has already been declared</code> because it can be declared uniquely within the block.</p> <h4 id=\"With_function\">With <code>function</code>\n</h4> <p>A <a href=\"function\">function declaration</a> is also limited in scope inside the block where the declaration occurs:</p> <pre data-language=\"js\">foo('outside');  // TypeError: foo is not a function\n{\n  function foo(location) {\n   console.log('foo is called ' + location);\n  }\n  foo('inside'); // works correctly and logs 'foo is called inside'\n}</pre> <p>To be more precise, the block statement is preventing the function declaration from being <a href=\"https://developer.mozilla.org/en-US/docs/Glossary/Hoisting\">hoisted</a> to the top of the scope. The function is behaving as if it were defined as a function expression and, as such, it is only the implicit variable declaration that gets hoisted to the top of the scope:</p> <pre>foo;  // returns undefined\n{\n  function foo(location) {\n   console.log('foo is called ' + location);\n  }\n  foo('inside'); // works correctly and logs 'foo is called inside'\n}</pre> <p>Consequently, this means that if we move the call to <code>foo</code> below the block statement that there will be no error:</p> <pre>{\n  function foo(location) {\n   console.log('foo is called ' + location);\n  }\n  foo('inside'); // works correctly and logs 'foo is called inside'\n}\nfoo('outside');  // works correctly and logs 'foo is called outside'</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-block\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Block statement' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-block\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Block statement' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/5.1/#sec-12.1\" hreflang=\"en\">ECMAScript 5.1 (ECMA-262)<br><small>The definition of 'Block statement' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/publications/files/ECMA-ST-ARCH/ECMA-262,%203rd%20edition,%20December%201999.pdf#sec-12.1\" hreflang=\"en\">ECMAScript 3rd Edition (ECMA-262)<br><small>The definition of 'Block statement' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/publications/files/ECMA-ST-ARCH/ECMA-262,%201st%20edition,%20June%201997.pdf#sec-12.1\" hreflang=\"en\">ECMAScript 1st Edition (ECMA-262)<br><small>The definition of 'Block statement' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition. Implemented in JavaScript 1.0.</td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"while\"><code>while</code></a></li> <li><a href=\"if...else\"><code>if...else</code></a></li> <li><a href=\"let\"><code>let</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/block$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/block\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/block</a>\n  </p>\n</div>\n","statements/const":"<h1>const</h1> Constants are block-scoped, much like variables defined using the <code><a href=\"let\">let</a></code> statement. The value of a constant cannot change through reassignment, and it can't be redeclared. <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/statement-const.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\">const <em>name1 = <em>value1 [</em>, <em>name2</em> = <em>value2</em><em> [</em>, ... [</em>, <em>nameN</em> = <em>valueN]]]</em>;</pre> <dl> <dt><code>nameN</code></dt> <dd>The constant's name, which can be any legal <a href=\"https://developer.mozilla.org/en-US/docs/Glossary/identifier\">identifier</a>.</dd> <dt><code>valueN</code></dt> <dd>The constant's value; this can be any legal <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Expressions_and_Operators#Expressions\">expression</a>, including a function expression.</dd> </dl> <h2 id=\"Description\">Description</h2> <p>This declaration creates a constant whose scope can be either global or local to the block in which it is declared. Global constants do not become properties of the window object, unlike <code><a href=\"var\">var</a></code> variables. An initializer for a constant is required; that is, you must specify its value in the same statement in which it's declared (which makes sense, given that it can't be changed later).</p> <p>The<code>const</code> creates a read-only reference to a value. It does <strong>not</strong> mean the value it holds is immutable, just that the variable identifier cannot be reassigned. For instance, in the case where the content is an object, this means the object's contents (e.g., its properties) can be altered.</p> <p>All the considerations about the \"<a href=\"let#Temporal_dead_zone\">temporal dead zone</a>\" apply to both <code><a href=\"let\">let</a></code> and <code>const</code>.</p> <p>A constant cannot share its name with a function or a variable in the same scope.</p> <h2 id=\"Examples\">Examples</h2> <p>The following example demonstrates how constants behave. Try this in your browser console.</p> <pre data-language=\"js\">// NOTE: Constants can be declared with uppercase or lowercase, but a common\n// convention is to use all-uppercase letters.\n\n// define MY_FAV as a constant and give it the value 7\nconst MY_FAV = 7;\n\n// this will throw an error - Uncaught TypeError: Assignment to constant variable.\nMY_FAV = 20;\n\n// MY_FAV is 7\nconsole.log('my favorite number is: ' + MY_FAV);\n\n// trying to redeclare a constant throws an error -  Uncaught SyntaxError: Identifier 'MY_FAV' has already been declared\nconst MY_FAV = 20;\n\n// the name MY_FAV is reserved for constant above, so this will fail too\nvar MY_FAV = 20;\n\n// this throws an error too\nlet MY_FAV = 20;\n\n// it's important to note the nature of block scoping\nif (MY_FAV === 7) { \n    // this is fine and creates a block scoped MY_FAV variable \n    // (works equally well with let to declare a block scoped non const variable)\n    let MY_FAV = 20;\n\n    // MY_FAV is now 20\n    console.log('my favorite number is ' + MY_FAV);\n\n    // this gets hoisted into the global context and throws an error\n    var MY_FAV = 20;\n}\n\n// MY_FAV is still 7\nconsole.log('my favorite number is ' + MY_FAV);\n\n// throws an error - Uncaught SyntaxError: Missing initializer in const declaration\nconst FOO; \n\n// const also works on objects\nconst MY_OBJECT = {'key': 'value'};\n\n// Attempting to overwrite the object throws an error - Uncaught TypeError: Assignment to constant variable.\nMY_OBJECT = {'OTHER_KEY': 'value'};\n\n// However, object keys are not protected,\n// so the following statement is executed without problem\nMY_OBJECT.key = 'otherValue'; // Use Object.freeze() to make object immutable\n\n// The same applies to arrays\nconst MY_ARRAY = [];\n// It's possible to push items into the array\nMY_ARRAY.push('A'); // [\"A\"]\n// However, assigning a new array to the variable throws an error - Uncaught TypeError: Assignment to constant variable.\nMY_ARRAY = ['B'];</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <thead> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> </thead> <tbody> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-let-and-const-declarations\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Let and Const Declarations' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-let-and-const-declarations\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Let and Const Declarations' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td>No changes.</td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 21</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes bc-has-history\"> 36\n<section class=\"bc-history\" id=\"sect1\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 36\n</dt>\n<dd> Prior to Firefox 13, <code>const</code> is implemented, but re-assignment is not failing.</dd>\n<dd> Prior to Firefox 46, a <code>TypeError</code> was thrown on redeclaration instead of a <code>SyntaxError</code>.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-yes\"> 11</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 5.1</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes bc-has-history\"> 36\n<section class=\"bc-history\" id=\"sect2\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 36\n</dt>\n<dd> Prior to Firefox 13, <code>const</code> is implemented, but re-assignment is not failing.</dd>\n<dd> Prior to Firefox 46, a <code>TypeError</code> was thrown on redeclaration instead of a <code>SyntaxError</code>.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"var\"><code>var</code></a></li> <li><a href=\"let\"><code>let</code></a></li> <li><a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Grammar_and_types#Constants\">Constants in the JavaScript Guide</a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/const$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/const\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/const</a>\n  </p>\n</div>\n","operators/yield*":"<h1>yield*</h1> <p>The <code>yield*</code> is used to delegate to another <a href=\"../statements/function*\"><code>generator</code></a> or iterable object.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/expressions-yieldasterisk.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\"> yield* [[expression]];</pre> <dl> <dt><code>expression</code></dt> <dd>The expression which returns an iterable object.</dd> </dl> <h2 id=\"Description\">Description</h2> <p>The <code>yield*</code> expression iterates over the operand and yields each value returned by it.</p> <p>The value of <code>yield*</code> expression itself is the value returned by that iterator when it's closed (i.e., when <code>done</code> is <code>true</code>).</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Delegating_to_another_generator\">Delegating to another generator</h3> <p>In following code, values yielded by <code>g1()</code> are returned from <code>next()</code> calls just like those which are yielded by <code>g2()</code>.</p> <pre data-language=\"js\">function* g1() {\n  yield 2;\n  yield 3;\n  yield 4;\n}\n\nfunction* g2() {\n  yield 1;\n  yield* g1();\n  yield 5;\n}\n\nvar iterator = g2();\n\nconsole.log(iterator.next()); // {value: 1, done: false}\nconsole.log(iterator.next()); // {value: 2, done: false}\nconsole.log(iterator.next()); // {value: 3, done: false}\nconsole.log(iterator.next()); // {value: 4, done: false}\nconsole.log(iterator.next()); // {value: 5, done: false}\nconsole.log(iterator.next()); // {value: undefined, done: true}\n</pre> <h3 id=\"Other_Iterable_objects\">Other Iterable objects</h3> <p>Besides generator objects, <code>yield*</code> can also <code>yield</code> other kinds of iterables, e.g. arrays, strings or arguments objects.</p> <pre data-language=\"js\">function* g3() {\n  yield* [1, 2];\n  yield* '34';\n  yield* Array.from(arguments);\n}\n\nvar iterator = g3(5, 6);\n\nconsole.log(iterator.next()); // {value: 1, done: false}\nconsole.log(iterator.next()); // {value: 2, done: false}\nconsole.log(iterator.next()); // {value: \"3\", done: false}\nconsole.log(iterator.next()); // {value: \"4\", done: false}\nconsole.log(iterator.next()); // {value: 5, done: false}\nconsole.log(iterator.next()); // {value: 6, done: false}\nconsole.log(iterator.next()); // {value: undefined, done: true}\n</pre> <h3 id=\"The_value_of_yield*_expression_itself\">The value of <code>yield*</code> expression itself</h3> <p><code>yield*</code> is an expression, not a statement, so it evaluates to a value.</p> <pre data-language=\"js\">function* g4() {\n  yield* [1, 2, 3];\n  return 'foo';\n}\n\nvar result;\n\nfunction* g5() {\n  result = yield* g4();\n}\n\nvar iterator = g5();\n\nconsole.log(iterator.next()); // {value: 1, done: false}\nconsole.log(iterator.next()); // {value: 2, done: false}\nconsole.log(iterator.next()); // {value: 3, done: false}\nconsole.log(iterator.next()); // {value: undefined, done: true}, \n                              // g4() returned {value: 'foo', done: true} at this point\n\nconsole.log(result);          // \"foo\"\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <thead> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> </thead> <tbody> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-generator-function-definitions-runtime-semantics-evaluation\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Yield' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-generator-function-definitions-runtime-semantics-evaluation\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Yield' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes bc-has-history\"> 27\n<section class=\"bc-history\" id=\"sect1\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 27\n</dt>\n<dd> Starting with Firefox 33, the parsing of the <code>yield</code> expression has been updated to conform with the ES2015 specification.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 10</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes bc-has-history\"> 27\n<section class=\"bc-history\" id=\"sect2\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 27\n</dt>\n<dd> Starting with Firefox 33, the parsing of the <code>yield</code> expression has been updated to conform with the ES2015 specification.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 10</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes bc-has-history\"> 4.0.0\n<section class=\"bc-history\" id=\"sect3\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 4.0.0\n</dt>\n\n<dt class=\"bc-supports-yes bc-supports\"> 0.12<div class=\"bc-icons\">Disabled </div>\n</dt>\n<dd>Disabled From version 0.12: this feature is behind the <code>--harmony</code> runtime flag.</dd>\n</dl></section>\n</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"Firefox-specific_notes\">Firefox-specific notes</h2> <ul> <li>Starting with Gecko 33 (Firefox 33 / Thunderbird 33 / SeaMonkey 2.30), the parsing of the yield expression has been updated to conform with the ES2015 specification (<a href=\"https://bugzilla.mozilla.org/show_bug.cgi?id=981599\">bug 981599</a>): <ul> <li>The line terminator restriction is now implemented. No line terminator between \"yield\" and \"*\" is allowed. Code like the following will throw a <a href=\"../global_objects/syntaxerror\"><code>SyntaxError</code></a>: <pre data-language=\"js\">function* foo() {\n  yield\n  *[];\n}</pre> </li> </ul> </li> </ul> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/The_Iterator_protocol\">The Iterator protocol</a></li> <li><a href=\"../statements/function*\"><code>function*</code></a></li> <li><a href=\"function*\"><code>function* expression</code></a></li> <li><a href=\"yield\"><code>yield</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/yield*$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/yield*\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/yield*</a>\n  </p>\n</div>\n","statements/continue":"<h1>continue</h1> <p>The <strong>continue statement</strong> terminates execution of the statements in the current iteration of the current or labeled loop, and continues execution of the loop with the next iteration.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/statement-continue.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\">continue [<em>label</em>];</pre> <dl> <dt><code>label</code></dt> <dd>Identifier associated with the label of the statement.</dd> </dl> <h2 id=\"Description\">Description</h2> <p>In contrast to the <a href=\"break\"><code>break</code></a> statement, <code>continue</code> does not terminate the execution of the loop entirely: instead,</p> <ul> <li>In a <a href=\"while\"><code>while</code></a> loop, it jumps back to the condition.</li> </ul> <ul> <li>In a <a href=\"for\"><code>for</code></a> loop, it jumps to the update expression.</li> </ul> <p>The <code>continue</code> statement can include an optional label that allows the program to jump to the next iteration of a labeled loop statement instead of the current loop. In this case, the <code>continue</code> statement needs to be nested within this labeled statement.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Using_continue_with_while\">Using continue with while</h3> <p>The following example shows a <a href=\"while\"><code>while</code></a> loop that has a <code>continue</code> statement that executes when the value of <code>i</code> is 3. Thus, <code>n</code> takes on the values 1, 3, 7, and 12.</p> <pre data-language=\"js\">var i = 0;\nvar n = 0;\n\nwhile (i &lt; 5) {\n  i++;\n\n  if (i === 3) {\n    continue;\n  }\n\n  n += i;\n}\n</pre> <h3 id=\"Using_continue_with_a_label\">Using continue with a label</h3> <p>In the following example, a statement labeled <code>checkiandj</code> contains a statement labeled <code>checkj</code>. If <code>continue</code> is encountered, the program continues at the top of the <code>checkj</code> statement. Each time <code>continue</code> is encountered, <code>checkj</code> reiterates until its condition returns false. When false is returned, the remainder of the <code>checkiandj</code> statement is completed.</p> <p>If <code>continue</code> had a label of <code>checkiandj</code>, the program would continue at the top of the <code>checkiandj</code> statement.</p> <p>See also <a href=\"label\"><code>label</code></a>.</p> <pre data-language=\"js\">var i = 0;\nvar j = 8;\n\ncheckiandj: while (i &lt; 4) {\n  console.log('i: ' + i);\n  i += 1;\n\n  checkj: while (j &gt; 4) {\n    console.log('j: ' + j);\n    j -= 1;\n\n    if ((j % 2) == 0)\n      continue checkj;\n    console.log(j + ' is odd.');\n  }\n  console.log('i = ' + i);\n  console.log('j = ' + j);\n}\n</pre> <p>Output:</p> <pre data-language=\"js\">i: 0\n\n// start checkj\nj: 8\n7 is odd.\nj: 7\nj: 6\n5 is odd.\nj: 5\n// end checkj\n\ni = 1 \nj = 4 \n\ni: 1\ni = 2 \nj = 4\n\ni: 2\ni = 3\nj = 4\n\ni: 3\ni = 4\nj = 4\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/publications/files/ECMA-ST-ARCH/ECMA-262,%201st%20edition,%20June%201997.pdf\" hreflang=\"en\">ECMAScript 1st Edition (ECMA-262)</a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition. Unlabeled version.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/publications/files/ECMA-ST-ARCH/ECMA-262,%203rd%20edition,%20December%201999.pdf\" hreflang=\"en\">ECMAScript 3rd Edition (ECMA-262)</a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Labeled version added.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/5.1/#sec-12.7\" hreflang=\"en\">ECMAScript 5.1 (ECMA-262)<br><small>The definition of 'Continue statement' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-continue-statement\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Continue statement' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-continue-statement\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Continue statement' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"break\"><code>break</code></a></li> <li><a href=\"label\"><code>label</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/continue$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/continue\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/continue</a>\n  </p>\n</div>\n","statements/async_function":"<h1>async function</h1>  <p>The <code><strong>async function</strong></code> declaration defines an <strong>asynchronous function</strong>, which returns an <a href=\"../global_objects/asyncfunction\"><code>AsyncFunction</code></a> object. An asynchronous function is a function which operates asynchronously via the event loop, using an implicit <a href=\"../global_objects/promise\"><code>Promise</code></a> to return its result. But the syntax and structure of your code using async functions is much more like using standard synchronous functions.</p> <div class=\"noinclude\"> <p>You can also define async functions using an <a href=\"../operators/async_function\">async function expression</a>.</p> </div>  <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/statement-async.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js taller\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\">async function <em>name</em>([<em>param</em>[, <em>param</em>[, ... <em>param</em>]]]) {\n   <em>statements</em>\n}\n</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><code>name</code></dt> <dd>The function name.</dd> </dl> <dl> <dt><code>param</code></dt> <dd>The name of an argument to be passed to the function.</dd> </dl> <dl> <dt><code>statements</code></dt> <dd>The statements comprising the body of the function.</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p>A <code><a href=\"https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Promise\">Promise</a></code> which will be resolved with the value returned by the async function, or rejected with an uncaught exception thrown from within the async function.</p> <h2 id=\"Description\">Description</h2> <p>An <code>async</code> function can contain an <a href=\"../operators/await\"><code>await</code></a> expression that pauses the execution of the async function and waits for the passed <code>Promise</code>'s resolution, and then resumes the <code>async</code> function's execution and returns the resolved value.<br> <br> Remember, the <code>await</code> keyword is only valid inside <code>async</code> functions. If you use it outside of an <code>async</code> function's body, you will get a <code><a href=\"../global_objects/syntaxerror\">SyntaxError</a></code>.</p> <div class=\"note\"> <p>The purpose of <code>async</code>/<code>await</code> functions is to simplify the behavior of using promises synchronously and to perform some behavior on a group of <code>Promises</code>. Just as <code>Promises</code> are similar to structured callbacks, <code>async</code>/<code>await</code> is similar to combining generators and promises.</p> </div> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Simple_example\">Simple example</h3> <pre data-language=\"js\">var resolveAfter2Seconds = function() {\n  console.log(\"starting slow promise\");\n  return new Promise(resolve =&gt; {\n    setTimeout(function() {\n      resolve(20);\n      console.log(\"slow promise is done\");\n    }, 2000);\n  });\n};\n\nvar resolveAfter1Second = function() {\n  console.log(\"starting fast promise\");\n  return new Promise(resolve =&gt; {\n    setTimeout(function() {\n      resolve(10);\n      console.log(\"fast promise is done\");\n    }, 1000);\n  });\n};\n\nvar sequentialStart = async function() {\n  console.log('==SEQUENTIAL START==');\n\n  // If the value of the expression following the await operator is not a Promise, it's converted to a resolved Promise.\n  const slow = await resolveAfter2Seconds();\n\n  const fast = await resolveAfter1Second();\n  console.log(slow);\n  console.log(fast);\n}\n\nvar concurrentStart = async function() {\n  console.log('==CONCURRENT START with await==');\n  const slow = resolveAfter2Seconds(); // starts timer immediately\n  const fast = resolveAfter1Second();\n\n  console.log(await slow);\n  console.log(await fast); // waits for slow to finish, even though fast is already done!\n}\n\nvar stillConcurrent = function() {\n  console.log('==CONCURRENT START with Promise.all==');\n  Promise.all([resolveAfter2Seconds(), resolveAfter1Second()]).then((messages) =&gt; {\n    console.log(messages[0]); // slow\n    console.log(messages[1]); // fast\n  });\n}\n\nvar parallel = function() {\n  console.log('==PARALLEL with Promise.then==');\n  resolveAfter2Seconds().then((message)=&gt;console.log(message));\n  resolveAfter1Second().then((message)=&gt;console.log(message));\n}\n\nsequentialStart(); // after 2 seconds, logs \"slow\", then after 1 more second, \"fast\"\n// wait above to finish\nsetTimeout(concurrentStart, 4000); // after 2 seconds, logs \"slow\" and then \"fast\"\n// wait again\nsetTimeout(stillConcurrent, 7000); // same as concurrentStart\n// wait again\nsetTimeout(parallel, 10000); // trully parallel: after 1 second, logs \"fast\", then after 1 more second, \"slow\"\n</pre> <div class=\"warning\"> <h4 id=\"Do_not_confuse_await_for_Promisethen\">Do not confuse <code>await</code> for <code>Promise#then</code>\n</h4> <p>In <code>sequentialStart</code>, execution suspends 2 seconds for the first <code>await</code>, and then again another 1 second for the second <code>await</code>. The second timer is not created until the first has already fired.</p> <p>In <code>concurrentStart</code>, both timers are created and then <code>await</code>ed. The timers are running concurrently but the <code>await</code> calls are still running in series, meaning the second <code>await</code> will wait for the first one to finish. This leads the code to finish in 2 rather than 3 seconds, which is the time the slowest timer needs. The same happens in <code>stillConcurrent</code> using <code>Promise.all</code> this time.</p> <p>If you wish to await two or more promises in parallel, you must still use <code>Promise#then</code>, as <code>parallel</code> does in the example.</p> </div> <h3 id=\"Rewriting_a_promise_chain_with_an_async_function\">Rewriting a promise chain with an <code>async</code> function</h3> <p>An API that returns a <a href=\"../global_objects/promise\"><code>Promise</code></a> will result in a promise chain, and it splits the function into many parts. Consider the following code:</p> <pre data-language=\"js\">function getProcessedData(url) {\n  return downloadData(url) // returns a promise\n    .catch(e =&gt; {\n      return downloadFallbackData(url)  // returns a promise\n    })\n    .then(v =&gt; {\n      return processDataInWorker(v); // returns a promise\n    });\n}\n</pre> <p>it can be rewritten with a single <code>async</code> function as follows:</p> <pre data-language=\"js\">async function getProcessedData(url) {\n  let v;\n  try {\n    v = await downloadData(url); \n  } catch(e) {\n    v = await downloadFallbackData(url);\n  }\n  return processDataInWorker(v);\n}\n</pre> <p>Note that in the above example, there is no <code>await</code> statement on the <code>return</code> statement, because the return value of an <code>async function</code> is implicitly wrapped in <a href=\"../global_objects/promise/resolve\"><code>Promise.resolve</code></a>.</p> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <thead> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> </thead> <tbody> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-async-function-definitions\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'async function' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td>Initial definition in ES2017.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/8.0/#sec-async-function-definitions\" hreflang=\"en\">ECMAScript 2017 (ECMA-262)<br><small>The definition of 'async function' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>   <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 55</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 52</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 42</td>\n<td class=\"bc-supports-yes\"> 10.1</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 55</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 52</td>\n<td class=\"bc-supports-yes\"> 42</td>\n<td class=\"bc-supports-yes\"> 10.1</td>\n<td class=\"bc-supports-yes\"> 6.0</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes bc-has-history\"> 7.6.0\n<section class=\"bc-history\" id=\"sect1\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 7.6.0\n</dt>\n\n<dt class=\"bc-supports-yes bc-supports\"> 7.0.0<div class=\"bc-icons\">Disabled </div>\n</dt>\n<dd>Disabled From version 7.0.0: this feature is behind the <code>--harmony</code> runtime flag.</dd>\n</dl></section>\n</td>\n</tr></tbody>\n</table>\n</div>  <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"../operators/async_function\"><code>async function expression</code></a></li> <li>\n<a href=\"../global_objects/asyncfunction\"><code>AsyncFunction</code></a> object</li> <li><a href=\"../operators/await\"><code>await</code></a></li> <li><a href=\"http://innolitics.com/10x/javascript-decorators-for-promise-returning-functions/\">\"Decorating Async Javascript Functions\" on \"innolitics.com\"</a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/async_function$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/async_function\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/async_function</a>\n  </p>\n</div>\n","operators/delete":"<h1>delete</h1> <p>The JavaScript <code>delete</code> removes a property from an object; if no more references to the same property are held, it is eventually released automatically.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/expressions-deleteoperator.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\">delete <em>expression</em> </pre> <p>where <em>expression</em> should evaluate to a <a href=\"https://developer.mozilla.org/en-US/docs/Glossary/property/JavaScript\">property</a> reference, e.g.:</p> <pre class=\"syntaxbox\">delete <em>object.property</em>\ndelete <em>object</em>['<em>property</em>']\n</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><code>object</code></dt> <dd>The name of an object, or an expression evaluating to an object.</dd> <dt><code>property</code></dt> <dd>The property to delete.</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p><code>true</code> for all cases except when the property is an <a href=\"../global_objects/object/hasownproperty\">own</a> <a href=\"../errors/cant_delete\">non-configurable</a> property, in which case, <code>false</code> is returned in non-strict mode.</p> <h3 id=\"Exceptions\">Exceptions</h3> <p>Throws <a href=\"../global_objects/syntaxerror\"><code>Global_objects/SyntaxError</code></a> in <a href=\"../strict_mode\">strict mode</a> if the property is an own non-configurable property.</p> <h2 id=\"Description\">Description</h2> <p>Unlike what common belief suggests, the <code>delete</code> operator has <strong>nothing</strong> to do with directly freeing memory. Memory management is done indirectly via breaking references. See the <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Memory_Management\">memory management</a> page for more details.</p> <p>The <code><strong>delete</strong></code> operator removes a given property from an object. On successful deletion, it will return <code>true</code>, else <code>false</code> will be returned. However, it is important to consider the following scenarios:</p> <ul> <li>If the property which you are trying to delete does not exist, <code>delete</code> will not have any effect and will return <code>true</code>\n</li> <li>If a property with the same name exists on the object's prototype chain, then, after deletion, the object will use the property from the prototype chain (in other words, <code>delete</code> only has an effect on own properties).</li> <li>Any property declared with <a href=\"../statements/var\"><code>var</code></a> cannot be deleted from the global scope or from a function's scope. <ul> <li>As such, <code>delete</code> cannot delete any functions in the global scope (whether this is part from a function definition or a function expression).</li> <li>Functions which are part of an object (apart from the global scope) can be deleted with <code>delete</code>.</li> </ul> </li> <li>Any property declared with <a href=\"../statements/let\"><code>let</code></a> or <a href=\"../statements/const\"><code>const</code></a> cannot be deleted from the scope within which they were defined.</li> <li>Non-configurable properties cannot be removed. This includes properties of built-in objects like <a href=\"../global_objects/math\"><code>Math</code></a>, <a href=\"../global_objects/array\"><code>Array</code></a>, <a href=\"../global_objects/object\"><code>Object</code></a> and properties that are created as non-configurable with methods like <a href=\"../global_objects/object/defineproperty\"><code>Object.defineProperty()</code></a>.</li> </ul> <p>The following snippet gives a simple example:</p> <pre data-language=\"js\">var Employee = {\n  age: 28,\n  name: 'abc',\n  designation: 'developer'\n}\n\nconsole.log(delete Employee.name);   // returns true\nconsole.log(delete Employee.age);    // returns true\n\n// When trying to delete a property that does \n// not exist, true is returned \nconsole.log(delete Employee.salary); // returns true\n</pre> <h3 id=\"Non-configurable_properties\"><strong>Non-configurable properties</strong></h3> <p>When a property is marked as non-configurable, <code>delete</code> won't have any effect, and will return <code>false</code>. In strict mode this will raise a <code>SyntaxError</code>.</p> <pre data-language=\"js\">var Employee = {};\nObject.defineProperty(Employee, 'name', {configurable: false});\n\nconsole.log(delete Employee.name);  // returns false\n</pre> <p><a href=\"../statements/var\"><code>var</code></a>, <a href=\"../statements/let\"><code>let</code></a> and <a href=\"../statements/const\"><code>const</code></a> create non-configurable properties that cannot be deleted with the <code>delete</code> operator:</p> <pre data-language=\"js\">var nameOther = 'XYZ';\n\n// We can access this global property using:\nObject.getOwnPropertyDescriptor(window, 'nameOther');  \n\n// output: Object {value: \"XYZ\", \n//                  writable: true, \n//                  enumerable: true,\n//                  <strong>configurable: false</strong>}\n\n// Since \"nameOther\" is added using with the\n// var keyword, it is marked as \"non-configurable\"\n\ndelete nameOther;   // return false</pre> <p>In strict mode, this would have raised an exception.</p> <h3 id=\"Strict_vs._non-strict_mode\"><strong>Strict vs. non-strict mode</strong></h3> <p>When in strict mode, if <code>delete</code> is used on a direct reference to a variable, a function argument or a function name, it will throw a <a href=\"../global_objects/syntaxerror\"><code>SyntaxError</code></a><strong>.</strong></p> <p>Any variable defined with <code>var</code> is marked as non-configurable. In the following example, <code>salary</code> is non-configurable and cannot be deleted. In non-strict mode, the <code>delete</code> operation will return <code>false</code>.</p> <pre data-language=\"js\">function Employee() { \n  delete salary;\n  var salary;\n}\n\nEmployee();\n</pre> <p>Let's see how the same code behaves in strict mode. Instead of returning <code>false</code>, the statement raises a <code>SyntaxError</code>.</p> <pre data-language=\"js\">\"use strict\";\n\nfunction Employee() {\n  delete salary;  // SyntaxError\n  var salary;        \n}\n\n// Similarly, any direct access to a function\n// with delete will raise a SyntaxError\n\nfunction DemoFunction() {\n  //some code\n}\n\ndelete DemoFunction; // SyntaxError\n</pre> <h2 id=\"Examples\">Examples</h2> <pre data-language=\"js\">// Creates the property adminName on the global scope.\nadminName = 'xyz';            \n\n// Creates the property empCount on the global scope.\n// Since we are using var, this is marked as non-configurable. The same is true of let and const.\nvar empCount = 43;\n\nEmployeeDetails = {\n  name: 'xyz',\n  age: 5,\n  designation: 'Developer'\n};\n\n// adminName is a property of the global scope.\n// It can be deleted since it is created without var,\n// and is therefore configurable.\ndelete adminName;       // returns true\n\n// On the contrary, empCount is not configurable\n// since var was used.\ndelete empCount;       // returns false \n\n// delete can be used to remove properties from objects.\ndelete EmployeeDetails.name; // returns true \n\n<strong>// </strong>Even when the property does not exist, delete returns \"true\".\ndelete EmployeeDetails.salary; // returns true \n\n// delete does not affect built-in static properties.\ndelete Math.PI; // returns false \n\n// EmployeeDetails is a property of the global scope.\n// Since it was defined without \"var\", it is marked configurable.\ndelete EmployeeDetails;   // returns true\n\nfunction f() {\n  var z = 44;\n\n  // delete doesn't affect local variable names\n  delete z;     // returns false\n}\n</pre> <h3 id=\"delete_and_the_prototype_chain\">\n<code>delete</code> and the prototype chain</h3> <p>In the following example, we delete an own property of an object while a property with the same name is available on the prototype chain:</p> <pre data-language=\"js\">function Foo() {\n  this.bar = 10;\n}\n\nFoo.prototype.bar = 42;\n\nvar foo = new Foo();\n\n// foo.bar is associated with the \n// own property. \nconsole.log(foo.bar); // 10 \n\n// Delete the own property within the \n// foo object. \ndelete foo.bar; // returns true \n\n// foo.bar is still available in the \n// prototype chain. \nconsole.log(foo.bar); // 42 \n\n// Delete the property on the prototype.\ndelete Foo.prototype.bar; // returns true \n\n// The \"bar\" property can no longer be \n// inherited from Foo since it has been \n// deleted. \nconsole.log(foo.bar); // undefined</pre> <h3 id=\"Deleting_array_elements\"><strong>Deleting array elements</strong></h3> <p>When you delete an array element, the array length is not affected. This holds even if you delete the last element of the array.</p> <p>When the <code>delete</code> operator removes an array element, that element is no longer in the array. In the following example, <code>trees[3]</code> is removed with <code>delete</code>.</p> <pre data-language=\"js\">var trees = ['redwood', 'bay', 'cedar', 'oak', 'maple'];\ndelete trees[3];\nif (3 in trees) {\n    // this is not executed\n}</pre> <p>If you want an array element to exist but have an undefined value, use the <code>undefined</code> value instead of the <code>delete</code> operator. In the following example, <code>trees[3]</code> is assigned the value undefined, but the array element still exists:</p> <pre data-language=\"js\">var trees = ['redwood', 'bay', 'cedar', 'oak', 'maple'];\ntrees[3] = undefined;\nif (3 in trees) {\n    // this is executed\n}</pre> <p>If instead, you want to remove an array element by changing the contents of the array, use the <code><a href=\"../global_objects/array/splice\"><code>splice</code></a></code> method. In the following example, <code>trees[3]</code> is removed from the array completely using <code><a href=\"../global_objects/array/splice\"><code>splice</code></a></code>:</p> <pre data-language=\"js\">var trees = ['redwood', 'bay', 'cedar', 'oak', 'maple'];\ntrees.splice(3,1);\nconsole.log(trees); // [\"redwood\", \"bay\", \"cedar\", \"maple\"]\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-delete-operator\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'The delete Operator' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-delete-operator\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'The delete Operator' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/5.1/#sec-11.4.1\" hreflang=\"en\">ECMAScript 5.1 (ECMA-262)<br><small>The definition of 'The delete Operator' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/publications/files/ECMA-ST-ARCH/ECMA-262,%201st%20edition,%20June%201997.pdf#sec-11.4.1\" hreflang=\"en\">ECMAScript 1st Edition (ECMA-262)<br><small>The definition of 'The delete Operator' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition. Implemented in JavaScript 1.2.</td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">Temporal dead zone</th>\n<td> ? </td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 36</td>\n<td> ? </td>\n<td> ? </td>\n<td> ? </td>\n</tr>\n</tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">Temporal dead zone</th>\n<td> ? </td>\n<td> ? </td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 36</td>\n<td> ? </td>\n<td> ? </td>\n<td> ? </td>\n</tr>\n</tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">Temporal dead zone</th>\n<td> ? </td>\n</tr>\n</tbody>\n</table>\n</div> <h2 id=\"Cross-browser_notes\">Cross-browser notes</h2> <p>Although ECMAScript makes iteration order of objects implementation-dependent, it may appear that all major browsers support an iteration order based on the earliest added property coming first (at least for properties not on the prototype). However, in the case of Internet Explorer, when one uses <code>delete</code> on a property, some confusing behavior results, preventing other browsers from using simple objects like object literals as ordered associative arrays. In Explorer, while the property <em>value</em> is indeed set to undefined, if one later adds back a property with the same name, the property will be iterated in its <em>old</em> position--not at the end of the iteration sequence as one might expect after having deleted the property and then added it back.</p> <p>If you want to use an ordered associative array in a cross-browser environment, use a <a href=\"../global_objects/map\"><code>Map</code></a> object if available, or simulate this structure with two separate arrays (one for the keys and the other for the values), or build an array of single-property objects, etc.</p> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"http://perfectionkills.com/understanding-delete/\">In depth analysis on delete</a></li> <li><a href=\"../global_objects/reflect/deleteproperty\"><code>Reflect.deleteProperty()</code></a></li> <li><a href=\"../global_objects/map/delete\"><code>Map.prototype.delete()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/delete$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/delete\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/delete</a>\n  </p>\n</div>\n","global_objects/string":"<h1>String</h1> <p>The <code>String</code> global object is a constructor for strings or a sequence of characters.</p> <h2 id=\"Syntax\">Syntax</h2> <p>String literals take the forms:</p> <pre class=\"syntaxbox\">'string text'\n\"string text\"\n\"中文 español Deutsch English देवनागरी العربية português বাংলা русский 日本語 ਪੰਜਾਬੀ 한국어 தமிழ் עברית\"</pre> <p>Strings can also be created using the <code>String</code> global object directly:</p> <pre class=\"syntaxbox\">String(thing)</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><code>thing</code></dt> <dd>Anything to be converted to a string.</dd> </dl> <h3 id=\"Template_literals\">Template literals</h3> <p>Starting with ECMAScript 2015, string literals can also be so-called <a href=\"../template_literals\">Template literals</a>:</p> <pre class=\"syntaxbox\">`hello world`\n`hello!\n world!`\n`hello ${who}`\ntag `&lt;a&gt;${who}&lt;/a&gt;`</pre>  <h3 id=\"Escape_notation\">Escape notation</h3> <p>Besides regular, printable characters, special characters can be encoded using escape notation:</p> <div class=\"_table\"><table class=\"standard-table\"> <thead> <tr> <th scope=\"col\">Code</th> <th scope=\"col\">Output</th> </tr> </thead> <tbody> <tr> <td><code>\\XXX</code></td> <td>an octal Latin-1 character.</td> </tr> <tr> <td><code>\\'</code></td> <td>single quote</td> </tr> <tr> <td><code>\\\"</code></td> <td>double quote</td> </tr> <tr> <td><code>\\\\</code></td> <td>backslash</td> </tr> <tr> <td><code>\\n</code></td> <td>new line</td> </tr> <tr> <td><code>\\r</code></td> <td>carriage return</td> </tr> <tr> <td><code>\\v</code></td> <td>vertical tab</td> </tr> <tr> <td><code>\\t</code></td> <td>tab</td> </tr> <tr> <td><code>\\b</code></td> <td>backspace</td> </tr> <tr> <td><code>\\f</code></td> <td>form feed</td> </tr> <tr> <td><code>\\uXXXX</code></td> <td>unicode codepoint</td> </tr> <tr> <td>\n<code>\\u{X}</code> ... <code>\\u{XXXXXX}</code>\n</td> <td>unicode codepoint \n</td> </tr> <tr> <td><code>\\xXX</code></td> <td>the Latin-1 character</td> </tr> </tbody> </table></div> <div class=\"note\"> <p>Unlike some other languages, JavaScript makes no distinction between single-quoted strings and double-quoted strings; therefore, the escape sequences above work in strings created with either single or double quotes.</p> </div>  <h3 id=\"Long_literal_strings\">Long literal strings</h3> <p>Sometimes, your code will include strings which are very long. Rather than having lines that go on endlessly, or wrap at the whim of your editor, you may wish to specifically break the string into multiple lines in the source code without affecting the actual string contents. There are two ways you can do this.</p> <p>You can use the <a href=\"../operators/arithmetic_operators#Addition_()\">+</a> operator to append multiple strings together, like this:</p> <pre data-language=\"js\">let longString = \"This is a very long string which needs \" +\n                 \"to wrap across multiple lines because \" +\n                 \"otherwise my code is unreadable.\";\n</pre> <p>Or you can use the backslash character (\"\\\") at the end of each line to indicate that the string will continue on the next line. Make sure there is no space or any other character after the backslash (except for a line break), or as an indent; otherwise it will not work. That form looks like this:</p> <pre data-language=\"js\">let longString = \"This is a very long string which needs \\\nto wrap across multiple lines because \\\notherwise my code is unreadable.\";\n</pre> <p>Both of these result in identical strings being created.</p> <h2 id=\"Description\">Description</h2> <p>Strings are useful for holding data that can be represented in text form. Some of the most-used operations on strings are to check their <a href=\"string/length\"><code>length</code></a>, to build and concatenate them using the <a href=\"../operators/arithmetic_operators\">+ and += string operators</a>, checking for the existence or location of substrings with the <a href=\"string/indexof\"><code>indexOf()</code></a> method, or extracting substrings with the <a href=\"string/substring\"><code>substring()</code></a> method.</p> <h3 id=\"Character_access\">Character access</h3> <p>There are two ways to access an individual character in a string. The first is the <a href=\"string/charat\"><code>charAt()</code></a> method:</p> <pre data-language=\"js\">return 'cat'.charAt(1); // returns \"a\"\n</pre> <p>The other way (introduced in ECMAScript 5) is to treat the string as an array-like object, where individual characters correspond to a numerical index:</p> <pre data-language=\"js\">return 'cat'[1]; // returns \"a\"\n</pre> <p>For character access using bracket notation, attempting to delete or assign a value to these properties will not succeed. The properties involved are neither writable nor configurable. (See <a href=\"object/defineproperty\"><code>Object.defineProperty()</code></a> for more information.)</p> <h3 id=\"Comparing_strings\">Comparing strings</h3> <p>C developers have the <code>strcmp()</code> function for comparing strings. In JavaScript, you just use the <a href=\"../operators/comparison_operators\">less-than and greater-than operators</a>:</p> <pre data-language=\"js\">var a = 'a';\nvar b = 'b';\nif (a &lt; b) { // true\n  console.log(a + ' is less than ' + b);\n} else if (a &gt; b) {\n  console.log(a + ' is greater than ' + b);\n} else {\n  console.log(a + ' and ' + b + ' are equal.');\n}\n</pre> <p>A similar result can be achieved using the <a href=\"string/localecompare\"><code>localeCompare()</code></a> method inherited by <code>String</code> instances.</p> <h3 id=\"Distinction_between_string_primitives_and_String_objects\">Distinction between string primitives and <code>String</code> objects</h3> <p>Note that JavaScript distinguishes between <code>String</code> objects and primitive string values. (The same is true of <a href=\"boolean\"><code>Boolean</code></a> and <a href=\"number\"><code>Numbers</code></a>.)</p> <p>String literals (denoted by double or single quotes) and strings returned from <code>String</code> calls in a non-constructor context (i.e., without using the <a href=\"../operators/new\"><code>new</code></a> keyword) are primitive strings. JavaScript automatically converts primitives to <code>String</code> objects, so that it's possible to use <code>String</code> object methods for primitive strings. In contexts where a method is to be invoked on a primitive string or a property lookup occurs, JavaScript will automatically wrap the string primitive and call the method or perform the property lookup.</p> <pre data-language=\"js\">var s_prim = 'foo';\nvar s_obj = new String(s_prim);\n\nconsole.log(typeof s_prim); // Logs \"string\"\nconsole.log(typeof s_obj);  // Logs \"object\"\n</pre> <p>String primitives and <code>String</code> objects also give different results when using <a href=\"eval\"><code>eval()</code></a>. Primitives passed to <code>eval</code> are treated as source code; <code>String</code> objects are treated as all other objects are, by returning the object. For example:</p> <pre data-language=\"js\">var s1 = '2 + 2';             // creates a string primitive\nvar s2 = new String('2 + 2'); // creates a String object\nconsole.log(eval(s1));        // returns the number 4\nconsole.log(eval(s2));        // returns the string \"2 + 2\"\n</pre> <p>For these reasons, the code may break when it encounters <code>String</code> objects when it expects a primitive string instead, although generally, authors need not worry about the distinction.</p> <p>A <code>String</code> object can always be converted to its primitive counterpart with the <a href=\"string/valueof\"><code>valueOf()</code></a> method.</p> <pre data-language=\"js\">console.log(eval(s2.valueOf())); // returns the number 4\n</pre> <div class=\"note\">\n<strong>Note:</strong> For another possible approach to strings in JavaScript, please read the article about <a href=\"https://developer.mozilla.org/en-US/Add-ons/Code_snippets/StringView\"><code>StringView</code> — a C-like representation of strings based on typed arrays</a>.</div> <h2 id=\"Properties\">Properties</h2> <dl> <dt><a href=\"string/prototype\"><code>String.prototype</code></a></dt> <dd>Allows the addition of properties to a <code>String</code> object.</dd> </dl> <h2 id=\"Methods\">Methods</h2> <dl> <dt><a href=\"string/fromcharcode\"><code>String.fromCharCode()</code></a></dt> <dd>Returns a string created by using the specified sequence of Unicode values.</dd> <dt><a href=\"string/fromcodepoint\"><code>String.fromCodePoint()</code></a></dt> <dd>Returns a string created by using the specified sequence of code points.</dd> <dt>\n<a href=\"string/raw\"><code>String.raw()</code></a> \n</dt> <dd>Returns a string created from a raw template string.</dd> </dl> <h2 id=\"String_generic_methods\">\n<code>String</code> generic methods</h2> <div class=\"warning\"> <p><strong>String generics are non-standard, deprecated and will get removed in the near future</strong>.</p> </div> <p>The <code>String</code> instance methods are also available in Firefox as of JavaScript 1.6 (<strong>not</strong> part of the ECMAScript standard) on the <code>String</code> object for applying <code>String</code> methods to any object:</p> <pre data-language=\"js\">var num = 15;\nconsole.log(String.replace(num, \"5\", \"2\"));\n</pre> <p>For migrating away from String generics, see also <a href=\"../errors/deprecated_string_generics\">Warning: String.x is deprecated; use String.prototype.x instead</a>.</p> <p><a href=\"array#Array_generic_methods\">Generics</a> are also available on <a href=\"array\"><code>Array</code></a> methods.</p> <h2 id=\"String_instances\">\n<code>String</code> instances</h2> <h3 id=\"Properties_2\">Properties</h3> <dl> <dt><code>String.prototype.constructor</code></dt> <dd>Specifies the function that creates an object's prototype.</dd> <dt><a href=\"string/length\"><code>String.prototype.length</code></a></dt> <dd>Reflects the length of the string.</dd> <dt><code><em>N</em></code></dt> <dd>Used to access the character in the <em>N</em>th position where <em>N</em> is an integer between 0 and one less than the value of <a href=\"string/length\"><code>length</code></a>. These properties are read-only.</dd> </dl> <h3 id=\"Methods_2\">Methods</h3> <h4 id=\"Methods_unrelated_to_HTML\">Methods unrelated to HTML</h4> <dl> <dt><a href=\"string/charat\"><code>String.prototype.charAt()</code></a></dt> <dd>Returns the character (exactly one UTF-16 code unit) at the specified index.</dd> <dt><a href=\"string/charcodeat\"><code>String.prototype.charCodeAt()</code></a></dt> <dd>Returns a number that is the UTF-16 code unit value at the given index.</dd> <dt><a href=\"string/codepointat\"><code>String.prototype.codePointAt()</code></a></dt> <dd>Returns a nonnegative integer Number that is the code point value of the UTF-16 encoded code point starting at the specified index.</dd> <dt><a href=\"string/concat\"><code>String.prototype.concat()</code></a></dt> <dd>Combines the text of two strings and returns a new string.</dd> <dt><a href=\"string/includes\"><code>String.prototype.includes()</code></a></dt> <dd>Determines whether one string may be found within another string.</dd> <dt><a href=\"string/endswith\"><code>String.prototype.endsWith()</code></a></dt> <dd>Determines whether a string ends with the characters of another string.</dd> <dt><a href=\"string/indexof\"><code>String.prototype.indexOf()</code></a></dt> <dd>Returns the index within the calling <a href=\"string\"><code>String</code></a> object of the first occurrence of the specified value, or -1 if not found.</dd> <dt><a href=\"string/lastindexof\"><code>String.prototype.lastIndexOf()</code></a></dt> <dd>Returns the index within the calling <a href=\"string\"><code>String</code></a> object of the last occurrence of the specified value, or -1 if not found.</dd> <dt><a href=\"string/localecompare\"><code>String.prototype.localeCompare()</code></a></dt> <dd>Returns a number indicating whether a reference string comes before or after or is the same as the given string in sort order.</dd> <dt><a href=\"string/match\"><code>String.prototype.match()</code></a></dt> <dd>Used to match a regular expression against a string.</dd> <dt><a href=\"string/normalize\"><code>String.prototype.normalize()</code></a></dt> <dd>Returns the Unicode Normalization Form of the calling string value.</dd> <dt><a href=\"string/padend\"><code>String.prototype.padEnd()</code></a></dt> <dd>Pads the current string from the end with a given string to create a new string from a given length.</dd> <dt><a href=\"string/padstart\"><code>String.prototype.padStart()</code></a></dt> <dd>Pads the current string from the start with a given string to create a new string from a given length.</dd> <dt><s class=\"obsoleteElement\"><a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/quote\"><code>String.prototype.quote()</code></a> </s></dt> <dd><s class=\"obsoleteElement\">Wraps the string in double quotes (\"<code>\"</code>\").</s></dd> <dt><a href=\"string/repeat\"><code>String.prototype.repeat()</code></a></dt> <dd>Returns a string consisting of the elements of the object repeated the given times.</dd> <dt><a href=\"string/replace\"><code>String.prototype.replace()</code></a></dt> <dd>Used to find a match between a regular expression and a string, and to replace the matched substring with a new substring.</dd> <dt><a href=\"string/search\"><code>String.prototype.search()</code></a></dt> <dd>Executes the search for a match between a regular expression and a specified string.</dd> <dt><a href=\"string/slice\"><code>String.prototype.slice()</code></a></dt> <dd>Extracts a section of a string and returns a new string.</dd> <dt><a href=\"string/split\"><code>String.prototype.split()</code></a></dt> <dd>Splits a <a href=\"string\"><code>String</code></a> object into an array of strings by separating the string into substrings.</dd> <dt><a href=\"string/startswith\"><code>String.prototype.startsWith()</code></a></dt> <dd>Determines whether a string begins with the characters of another string.</dd> <dt>\n<a href=\"string/substr\"><code>String.prototype.substr()</code></a> \n</dt> <dd>Returns the characters in a string beginning at the specified location through the specified number of characters.</dd> <dt><a href=\"string/substring\"><code>String.prototype.substring()</code></a></dt> <dd>Returns the characters in a string between two indexes into the string.</dd> <dt><a href=\"string/tolocalelowercase\"><code>String.prototype.toLocaleLowerCase()</code></a></dt> <dd>The characters within a string are converted to lower case while respecting the current locale. For most languages, this will return the same as <a href=\"string/tolowercase\"><code>toLowerCase()</code></a>.</dd> <dt><a href=\"string/tolocaleuppercase\"><code>String.prototype.toLocaleUpperCase()</code></a></dt> <dd>The characters within a string are converted to upper case while respecting the current locale. For most languages, this will return the same as <a href=\"string/touppercase\"><code>toUpperCase()</code></a>.</dd> <dt><a href=\"string/tolowercase\"><code>String.prototype.toLowerCase()</code></a></dt> <dd>Returns the calling string value converted to lower case.</dd> <dt>\n<a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/toSource\"><code>String.prototype.toSource()</code></a> \n</dt> <dd>Returns an object literal representing the specified object; you can use this value to create a new object. Overrides the <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/toSource\"><code>Object.prototype.toSource()</code></a> method.</dd> <dt><a href=\"string/tostring\"><code>String.prototype.toString()</code></a></dt> <dd>Returns a string representing the specified object. Overrides the <a href=\"object/tostring\"><code>Object.prototype.toString()</code></a> method.</dd> <dt><a href=\"string/touppercase\"><code>String.prototype.toUpperCase()</code></a></dt> <dd>Returns the calling string value converted to uppercase.</dd> <dt><a href=\"string/trim\"><code>String.prototype.trim()</code></a></dt> <dd>Trims whitespace from the beginning and end of the string. Part of the ECMAScript 5 standard.</dd> <dt>\n<a href=\"string/trimstart\"><code>String.prototype.trimStart()</code></a><br> <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/trimLeft\"><code>String.prototype.trimLeft()</code></a>\n</dt> <dd>Trims whitespace from the beginning of the string.</dd> <dt>\n<a href=\"string/trimend\"><code>String.prototype.trimEnd()</code></a><br> <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/trimRight\"><code>String.prototype.trimRight()</code></a>\n</dt> <dd>Trims whitespace from the end of the string.</dd> <dt><a href=\"string/valueof\"><code>String.prototype.valueOf()</code></a></dt> <dd>Returns the primitive value of the specified object. Overrides the <a href=\"object/valueof\"><code>Object.prototype.valueOf()</code></a> method.</dd> <dt><a href=\"string/@@iterator\"><code>String.prototype[@@iterator]()</code></a></dt> <dd>Returns a new <code>Iterator</code> object that iterates over the code points of a String value, returning each code point as a String value.</dd> </dl> <h4 id=\"HTML_wrapper_methods\">HTML wrapper methods</h4> <p>These methods are of limited use, as they provide only a subset of the available HTML tags and attributes.</p> <dl> <dt>\n<a href=\"string/anchor\"><code>String.prototype.anchor()</code></a> \n</dt> <dd>\n<code><a href=\"https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a#attr-name\">&lt;a name=\"name\"&gt;</a></code> (hypertext target)</dd> <dt>\n<a href=\"string/big\"><code>String.prototype.big()</code></a> \n</dt> <dd><a href=\"https://developer.mozilla.org/en-US/docs/Web/HTML/Element/big\"><code>&lt;big&gt;</code></a></dd> <dt>\n<a href=\"string/blink\"><code>String.prototype.blink()</code></a> \n</dt> <dd><a href=\"https://developer.mozilla.org/en-US/docs/Web/HTML/Element/blink\"><code>&lt;blink&gt;</code></a></dd> <dt>\n<a href=\"string/bold\"><code>String.prototype.bold()</code></a> \n</dt> <dd><a href=\"https://developer.mozilla.org/en-US/docs/Web/HTML/Element/b\"><code>&lt;b&gt;</code></a></dd> <dt>\n<a href=\"string/fixed\"><code>String.prototype.fixed()</code></a> \n</dt> <dd><a href=\"https://developer.mozilla.org/en-US/docs/Web/HTML/Element/tt\"><code>&lt;tt&gt;</code></a></dd> <dt>\n<a href=\"string/fontcolor\"><code>String.prototype.fontcolor()</code></a> \n</dt> <dd><code><a href=\"https://developer.mozilla.org/en-US/docs/Web/HTML/Element/font#attr-color\">&lt;font color=\"color\"&gt;</a></code></dd> <dt>\n<a href=\"string/fontsize\"><code>String.prototype.fontsize()</code></a> \n</dt> <dd><code><a href=\"https://developer.mozilla.org/en-US/docs/Web/HTML/Element/font#attr-size\">&lt;font size=\"size\"&gt;</a></code></dd> <dt>\n<a href=\"string/italics\"><code>String.prototype.italics()</code></a> \n</dt> <dd><a href=\"https://developer.mozilla.org/en-US/docs/Web/HTML/Element/i\"><code>&lt;i&gt;</code></a></dd> <dt>\n<a href=\"string/link\"><code>String.prototype.link()</code></a> \n</dt> <dd>\n<code><a href=\"https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a#attr-href\">&lt;a href=\"url\"&gt;</a></code> (link to URL)</dd> <dt>\n<a href=\"string/small\"><code>String.prototype.small()</code></a> \n</dt> <dd><a href=\"https://developer.mozilla.org/en-US/docs/Web/HTML/Element/small\"><code>&lt;small&gt;</code></a></dd> <dt>\n<a href=\"string/strike\"><code>String.prototype.strike()</code></a> \n</dt> <dd><a href=\"https://developer.mozilla.org/en-US/docs/Web/HTML/Element/strike\"><code>&lt;strike&gt;</code></a></dd> <dt>\n<a href=\"string/sub\"><code>String.prototype.sub()</code></a> \n</dt> <dd><a href=\"https://developer.mozilla.org/en-US/docs/Web/HTML/Element/sub\"><code>&lt;sub&gt;</code></a></dd> <dt>\n<a href=\"string/sup\"><code>String.prototype.sup()</code></a> \n</dt> <dd><a href=\"https://developer.mozilla.org/en-US/docs/Web/HTML/Element/sup\"><code>&lt;sup&gt;</code></a></dd> </dl> <h2 id=\"Examples\">Examples</h2> <h3 id=\"String_conversion\">String conversion</h3> <p>It's possible to use <code>String</code> as a more reliable <a href=\"string/tostring\"><code>toString()</code></a> alternative, as it works when used on <a href=\"null\"><code>null</code></a>, <a href=\"undefined\"><code>undefined</code></a>, and on <a href=\"symbol\"><code>symbols</code></a>. For example:</p> <pre data-language=\"js\">var outputStrings = [];\nfor (var i = 0, n = inputValues.length; i &lt; n; ++i) {\n  outputStrings.push(String(inputValues[i]));\n}\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/publications/files/ECMA-ST-ARCH/ECMA-262,%201st%20edition,%20June%201997.pdf\" hreflang=\"en\">ECMAScript 1st Edition (ECMA-262)</a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/5.1/#sec-15.5\" hreflang=\"en\">ECMAScript 5.1 (ECMA-262)<br><small>The definition of 'String' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-string-objects\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'String' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-string-objects\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'String' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String/@@iterator\"><code>@@iterator</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes bc-has-history\"> 36\n<section class=\"bc-history\" id=\"sect1\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 36\n</dt>\n\n<dt class=\"bc-supports-no bc-supports\">27 — 36\n</dt>\n<dd> A placeholder property named <code>@@iterator</code> is used.</dd>\n<dd> Uses the non-standard name: <code>@@iterator</code>\n</dd>\n<dt class=\"bc-supports-no bc-supports\">17 — 27\n</dt>\n<dd> A placeholder property named <code>iterator</code> is used.</dd>\n<dd> Uses the non-standard name: <code>iterator</code>\n</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n</tr>\n<tr>\n<th scope=\"row\">Unicode code point escapes \\u{xxxxxx}</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 40</td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String/anchor\"><code>anchor</code></a> \n</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes bc-has-history\"> 1\n<section class=\"bc-history\" id=\"sect3\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 1\n</dt>\n<dd> Starting with version 17, the quotation mark (\") is replaced by its HTML reference character (<code>\"</code>) in strings supplied for the <code>name</code> parameter.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String/big\"><code>big</code></a> \n</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String/blink\"><code>blink</code></a> \n</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String/bold\"><code>bold</code></a> \n</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String/charAt\"><code>charAt</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String/charCodeAt\"><code>charCodeAt</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String/codePointAt\"><code>codePointAt</code></a></th>\n<td class=\"bc-supports-yes\"> 41</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 29</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 28</td>\n<td class=\"bc-supports-yes\"> 10</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String/concat\"><code>concat</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String/endsWith\"><code>endsWith</code></a></th>\n<td class=\"bc-supports-yes\"> 41</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 17</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 28</td>\n<td class=\"bc-supports-yes\"> 9</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String/fixed\"><code>fixed</code></a> \n</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String/fontcolor\"><code>fontcolor</code></a> \n</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String/fontsize\"><code>fontsize</code></a> \n</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String/fromCharCode\"><code>fromCharCode</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String/fromCodePoint\"><code>fromCodePoint</code></a></th>\n<td class=\"bc-supports-yes\"> 41</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 29</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 28</td>\n<td class=\"bc-supports-yes\"> 10</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String/includes\"><code>includes</code></a></th>\n<td class=\"bc-supports-yes\"> 41</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes bc-has-history\"> 40\n<section class=\"bc-history\" id=\"sect7\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 40\n</dt>\n\n<dt class=\"bc-supports-no bc-supports\">18 — 48\n</dt>\n<dd> Uses the non-standard name: <code>contains</code>\n</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 9</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String/indexOf\"><code>indexOf</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String/italics\"><code>italics</code></a> \n</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String/lastIndexOf\"><code>lastIndexOf</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> 6</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String/length\"><code>length</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String/link\"><code>link</code></a> \n</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String/localeCompare\"><code>localeCompare</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><code>localeCompare.locales</code></th>\n<td class=\"bc-supports-yes\"> 24</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 29</td>\n<td class=\"bc-supports-yes\"> 11</td>\n<td class=\"bc-supports-yes\"> 15</td>\n<td class=\"bc-supports-yes\"> 10</td>\n</tr>\n<tr>\n<th scope=\"row\"><code>localeCompare.options</code></th>\n<td class=\"bc-supports-yes\"> 24</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 29</td>\n<td class=\"bc-supports-yes\"> 11</td>\n<td class=\"bc-supports-yes\"> 15</td>\n<td class=\"bc-supports-yes\"> 10</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String/match\"><code>match</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<code>match.flags</code> \n</th>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\">1 — 49</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String/normalize\"><code>normalize</code></a></th>\n<td class=\"bc-supports-yes\"> 34</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 31</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 10</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String/padEnd\"><code>padEnd</code></a></th>\n<td class=\"bc-supports-yes\"> 57</td>\n<td class=\"bc-supports-yes\"> 15</td>\n<td class=\"bc-supports-yes\"> 48</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 44</td>\n<td class=\"bc-supports-yes\"> 10</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String/padStart\"><code>padStart</code></a></th>\n<td class=\"bc-supports-yes\"> 57</td>\n<td class=\"bc-supports-yes\"> 15</td>\n<td class=\"bc-supports-yes\"> 48</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 44</td>\n<td class=\"bc-supports-yes\"> 10</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String/prototype\"><code>prototype</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String/quote\"><code>quote</code></a> \n</th>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\">1 — 37</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String/raw\"><code>raw</code></a></th>\n<td class=\"bc-supports-yes\"> 41</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 34</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 10</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String/repeat\"><code>repeat</code></a></th>\n<td class=\"bc-supports-yes\"> 41</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 24</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 9</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String/replace\"><code>replace</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<code>replace.flags</code> \n</th>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\">1 — 49</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String/search\"><code>search</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<code>search.flags</code> \n</th>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\">1 — 49</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String/slice\"><code>slice</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String/small\"><code>small</code></a> \n</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String/split\"><code>split</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String/startsWith\"><code>startsWith</code></a></th>\n<td class=\"bc-supports-yes\"> 41</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 17</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 28</td>\n<td class=\"bc-supports-yes\"> 9</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String/strike\"><code>strike</code></a> \n</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String/sub\"><code>sub</code></a> \n</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String/substr\"><code>substr</code></a> \n</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String/substring\"><code>substring</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String/sup\"><code>sup</code></a> \n</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String/toLocaleLowerCase\"><code>toLocaleLowerCase</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><code>toLocaleLowerCase.locale</code></th>\n<td> ? </td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 55</td>\n<td> ? </td>\n<td> ? </td>\n<td> ? </td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String/toLocaleUpperCase\"><code>toLocaleUpperCase</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><code>toLocaleUpperCase.locale</code></th>\n<td> ? </td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 55</td>\n<td> ? </td>\n<td> ? </td>\n<td> ? </td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String/toLowerCase\"><code>toLowerCase</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String/toSource\"><code>toSource</code></a> \n</th>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String/toString\"><code>toString</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String/toUpperCase\"><code>toUpperCase</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String/trim\"><code>trim</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 3.5</td>\n<td class=\"bc-supports-yes\"> 9</td>\n<td class=\"bc-supports-yes\"> 10.5</td>\n<td class=\"bc-supports-yes\"> 5</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String/trimEnd\"><code>trimEnd</code></a></th>\n<td class=\"bc-supports-yes bc-has-history\"> 66\n<section class=\"bc-history\" id=\"sect13\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 66\n</dt>\n\n<dt class=\"bc-supports-yes bc-supports\"> Yes\n</dt>\n<dd> Uses the non-standard name: <code>trimRight</code>\n</dd>\n</dl></section>\n</td>\n<td> ? </td>\n<td class=\"bc-supports-yes bc-has-history\"> 61\n<section class=\"bc-history\" id=\"sect14\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 61\n</dt>\n\n<dt class=\"bc-supports-yes bc-supports\"> 3.5\n</dt>\n<dd> Uses the non-standard name: <code>trimRight</code>\n</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 53</td>\n<td> ? </td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String/trimStart\"><code>trimStart</code></a></th>\n<td class=\"bc-supports-yes bc-has-history\"> 66\n<section class=\"bc-history\" id=\"sect18\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 66\n</dt>\n\n<dt class=\"bc-supports-yes bc-supports\"> Yes\n</dt>\n<dd> Uses the non-standard name: <code>trimLeft</code>\n</dd>\n</dl></section>\n</td>\n<td> ? </td>\n<td class=\"bc-supports-yes bc-has-history\"> 61\n<section class=\"bc-history\" id=\"sect19\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 61\n</dt>\n\n<dt class=\"bc-supports-yes bc-supports\"> 3.5\n</dt>\n<dd> Uses the non-standard name: <code>trimLeft</code>\n</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 53</td>\n<td> ? </td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String/valueOf\"><code>valueOf</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n</tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String/@@iterator\"><code>@@iterator</code></a></th>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td> ? </td>\n<td class=\"bc-supports-yes bc-has-history\"> 36\n<section class=\"bc-history\" id=\"sect2\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 36\n</dt>\n\n<dt class=\"bc-supports-no bc-supports\">27 — 36\n</dt>\n<dd> A placeholder property named <code>@@iterator</code> is used.</dd>\n<dd> Uses the non-standard name: <code>@@iterator</code>\n</dd>\n<dt class=\"bc-supports-no bc-supports\">17 — 27\n</dt>\n<dd> A placeholder property named <code>iterator</code> is used.</dd>\n<dd> Uses the non-standard name: <code>iterator</code>\n</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n</tr>\n<tr>\n<th scope=\"row\">Unicode code point escapes \\u{xxxxxx}</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 40</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String/anchor\"><code>anchor</code></a> \n</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String/big\"><code>big</code></a> \n</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String/blink\"><code>blink</code></a> \n</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String/bold\"><code>bold</code></a> \n</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String/charAt\"><code>charAt</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String/charCodeAt\"><code>charCodeAt</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String/codePointAt\"><code>codePointAt</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 29</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 10</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String/concat\"><code>concat</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String/endsWith\"><code>endsWith</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 36</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 17</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 9</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String/fixed\"><code>fixed</code></a> \n</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String/fontcolor\"><code>fontcolor</code></a> \n</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String/fontsize\"><code>fontsize</code></a> \n</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String/fromCharCode\"><code>fromCharCode</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String/fromCodePoint\"><code>fromCodePoint</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 29</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 10</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String/includes\"><code>includes</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes bc-has-history\"> 40\n<section class=\"bc-history\" id=\"sect8\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 40\n</dt>\n\n<dt class=\"bc-supports-no bc-supports\">18 — 48\n</dt>\n<dd> Uses the non-standard name: <code>contains</code>\n</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 9</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String/indexOf\"><code>indexOf</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String/italics\"><code>italics</code></a> \n</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String/lastIndexOf\"><code>lastIndexOf</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String/length\"><code>length</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String/link\"><code>link</code></a> \n</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String/localeCompare\"><code>localeCompare</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><code>localeCompare.locales</code></th>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 26</td>\n<td> ? </td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 10</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><code>localeCompare.options</code></th>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 26</td>\n<td> ? </td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 10</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String/match\"><code>match</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<code>match.flags</code> \n</th>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\">4 — 49</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String/normalize\"><code>normalize</code></a></th>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 34</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 31</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 10</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String/padEnd\"><code>padEnd</code></a></th>\n<td class=\"bc-supports-yes\"> 57</td>\n<td class=\"bc-supports-yes\"> 57</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 48</td>\n<td class=\"bc-supports-yes\"> 44</td>\n<td class=\"bc-supports-yes\"> 10</td>\n<td class=\"bc-supports-yes\"> 7.0</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String/padStart\"><code>padStart</code></a></th>\n<td class=\"bc-supports-yes\"> 57</td>\n<td class=\"bc-supports-yes\"> 57</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 48</td>\n<td class=\"bc-supports-yes\"> 44</td>\n<td class=\"bc-supports-yes\"> 10</td>\n<td class=\"bc-supports-yes\"> 7.0</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String/prototype\"><code>prototype</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String/quote\"><code>quote</code></a> \n</th>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\">4 — 37</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String/raw\"><code>raw</code></a></th>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 41</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 34</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 10</td>\n<td class=\"bc-supports-yes\"> 4.0</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String/repeat\"><code>repeat</code></a></th>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 36</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 24</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 9</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String/replace\"><code>replace</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<code>replace.flags</code> \n</th>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\">4 — 49</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String/search\"><code>search</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<code>search.flags</code> \n</th>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\">4 — 49</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String/slice\"><code>slice</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String/small\"><code>small</code></a> \n</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String/split\"><code>split</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String/startsWith\"><code>startsWith</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 36</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 17</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 9</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String/strike\"><code>strike</code></a> \n</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String/sub\"><code>sub</code></a> \n</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String/substr\"><code>substr</code></a> \n</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String/substring\"><code>substring</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String/sup\"><code>sup</code></a> \n</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String/toLocaleLowerCase\"><code>toLocaleLowerCase</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><code>toLocaleLowerCase.locale</code></th>\n<td> ? </td>\n<td> ? </td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 55</td>\n<td> ? </td>\n<td> ? </td>\n<td> ? </td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String/toLocaleUpperCase\"><code>toLocaleUpperCase</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><code>toLocaleUpperCase.locale</code></th>\n<td> ? </td>\n<td> ? </td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 55</td>\n<td> ? </td>\n<td> ? </td>\n<td> ? </td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String/toLowerCase\"><code>toLowerCase</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String/toSource\"><code>toSource</code></a> \n</th>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String/toString\"><code>toString</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String/toUpperCase\"><code>toUpperCase</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String/trim\"><code>trim</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String/trimEnd\"><code>trimEnd</code></a></th>\n<td class=\"bc-supports-yes bc-has-history\"> 66\n<section class=\"bc-history\" id=\"sect15\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 66\n</dt>\n\n<dt class=\"bc-supports-yes bc-supports\"> Yes\n</dt>\n<dd> Uses the non-standard name: <code>trimRight</code>\n</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-yes bc-has-history\"> 66\n<section class=\"bc-history\" id=\"sect16\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 66\n</dt>\n\n<dt class=\"bc-supports-yes bc-supports\"> Yes\n</dt>\n<dd> Uses the non-standard name: <code>trimRight</code>\n</dd>\n</dl></section>\n</td>\n<td> ? </td>\n<td class=\"bc-supports-yes bc-has-history\"> 61\n<section class=\"bc-history\" id=\"sect17\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 61\n</dt>\n\n<dt class=\"bc-supports-yes bc-supports\"> 4\n</dt>\n<dd> Uses the non-standard name: <code>trimRight</code>\n</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-yes\"> 53</td>\n<td> ? </td>\n<td> ? </td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String/trimStart\"><code>trimStart</code></a></th>\n<td class=\"bc-supports-yes bc-has-history\"> 66\n<section class=\"bc-history\" id=\"sect20\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 66\n</dt>\n\n<dt class=\"bc-supports-yes bc-supports\"> Yes\n</dt>\n<dd> Uses the non-standard name: <code>trimLeft</code>\n</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-yes bc-has-history\"> 66\n<section class=\"bc-history\" id=\"sect21\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 66\n</dt>\n\n<dt class=\"bc-supports-yes bc-supports\"> Yes\n</dt>\n<dd> Uses the non-standard name: <code>trimLeft</code>\n</dd>\n</dl></section>\n</td>\n<td> ? </td>\n<td class=\"bc-supports-yes bc-has-history\"> 61\n<section class=\"bc-history\" id=\"sect22\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 61\n</dt>\n\n<dt class=\"bc-supports-yes bc-supports\"> 4\n</dt>\n<dd> Uses the non-standard name: <code>trimLeft</code>\n</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-yes\"> 53</td>\n<td> ? </td>\n<td> ? </td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String/valueOf\"><code>valueOf</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n</tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String/@@iterator\"><code>@@iterator</code></a></th>\n<td class=\"bc-supports-yes\"> 0.12</td>\n</tr>\n<tr>\n<th scope=\"row\">Unicode code point escapes \\u{xxxxxx}</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String/anchor\"><code>anchor</code></a> \n</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String/big\"><code>big</code></a> \n</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String/blink\"><code>blink</code></a> \n</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String/bold\"><code>bold</code></a> \n</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String/charAt\"><code>charAt</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String/charCodeAt\"><code>charCodeAt</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String/codePointAt\"><code>codePointAt</code></a></th>\n<td class=\"bc-supports-yes bc-has-history\"> 4.0.0\n<section class=\"bc-history\" id=\"sect4\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 4.0.0\n</dt>\n\n<dt class=\"bc-supports-yes bc-supports\"> 0.12<div class=\"bc-icons\">Disabled </div>\n</dt>\n<dd>Disabled From version 0.12: this feature is behind the <code>--harmony</code> runtime flag.</dd>\n</dl></section>\n</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String/concat\"><code>concat</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String/endsWith\"><code>endsWith</code></a></th>\n<td class=\"bc-supports-yes bc-has-history\"> 4.0.0\n<section class=\"bc-history\" id=\"sect5\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 4.0.0\n</dt>\n\n<dt class=\"bc-supports-yes bc-supports\"> 0.12<div class=\"bc-icons\">Disabled </div>\n</dt>\n<dd>Disabled From version 0.12: this feature is behind the <code>--harmony</code> runtime flag.</dd>\n</dl></section>\n</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String/fixed\"><code>fixed</code></a> \n</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String/fontcolor\"><code>fontcolor</code></a> \n</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String/fontsize\"><code>fontsize</code></a> \n</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String/fromCharCode\"><code>fromCharCode</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String/fromCodePoint\"><code>fromCodePoint</code></a></th>\n<td class=\"bc-supports-yes bc-has-history\"> 4.0.0\n<section class=\"bc-history\" id=\"sect6\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 4.0.0\n</dt>\n\n<dt class=\"bc-supports-yes bc-supports\"> 0.12<div class=\"bc-icons\">Disabled </div>\n</dt>\n<dd>Disabled From version 0.12: this feature is behind the <code>--harmony</code> runtime flag.</dd>\n</dl></section>\n</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String/includes\"><code>includes</code></a></th>\n<td class=\"bc-supports-yes\"> 4.0.0</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String/indexOf\"><code>indexOf</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String/italics\"><code>italics</code></a> \n</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String/lastIndexOf\"><code>lastIndexOf</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String/length\"><code>length</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String/link\"><code>link</code></a> \n</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String/localeCompare\"><code>localeCompare</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><code>localeCompare.locales</code></th>\n<td> ? </td>\n</tr>\n<tr>\n<th scope=\"row\"><code>localeCompare.options</code></th>\n<td> ? </td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String/match\"><code>match</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<code>match.flags</code> \n</th>\n<td class=\"bc-supports-no\"> No</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String/normalize\"><code>normalize</code></a></th>\n<td class=\"bc-supports-yes\"> 0.12</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String/padEnd\"><code>padEnd</code></a></th>\n<td class=\"bc-supports-yes bc-has-history\"> 8.0.0\n<section class=\"bc-history\" id=\"sect9\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 8.0.0\n</dt>\n\n<dt class=\"bc-supports-yes bc-supports\"> 7.0.0<div class=\"bc-icons\">Disabled </div>\n</dt>\n<dd>Disabled From version 7.0.0: this feature is behind the <code>--harmony</code> runtime flag.</dd>\n</dl></section>\n</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String/padStart\"><code>padStart</code></a></th>\n<td class=\"bc-supports-yes bc-has-history\"> 8.0.0\n<section class=\"bc-history\" id=\"sect10\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 8.0.0\n</dt>\n\n<dt class=\"bc-supports-yes bc-supports\"> 7.0.0<div class=\"bc-icons\">Disabled </div>\n</dt>\n<dd>Disabled From version 7.0.0: this feature is behind the <code>--harmony</code> runtime flag.</dd>\n</dl></section>\n</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String/prototype\"><code>prototype</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String/quote\"><code>quote</code></a> \n</th>\n<td class=\"bc-supports-no\"> No</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String/raw\"><code>raw</code></a></th>\n<td class=\"bc-supports-yes\"> 4.0.0</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String/repeat\"><code>repeat</code></a></th>\n<td class=\"bc-supports-yes bc-has-history\"> 4.0.0\n<section class=\"bc-history\" id=\"sect11\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 4.0.0\n</dt>\n\n<dt class=\"bc-supports-yes bc-supports\"> 0.12<div class=\"bc-icons\">Disabled </div>\n</dt>\n<dd>Disabled From version 0.12: this feature is behind the <code>--harmony</code> runtime flag.</dd>\n</dl></section>\n</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String/replace\"><code>replace</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<code>replace.flags</code> \n</th>\n<td class=\"bc-supports-no\"> No</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String/search\"><code>search</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<code>search.flags</code> \n</th>\n<td class=\"bc-supports-no\"> No</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String/slice\"><code>slice</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String/small\"><code>small</code></a> \n</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String/split\"><code>split</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String/startsWith\"><code>startsWith</code></a></th>\n<td class=\"bc-supports-yes bc-has-history\"> 4.0.0\n<section class=\"bc-history\" id=\"sect12\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 4.0.0\n</dt>\n\n<dt class=\"bc-supports-yes bc-supports\"> 0.12<div class=\"bc-icons\">Disabled </div>\n</dt>\n<dd>Disabled From version 0.12: this feature is behind the <code>--harmony</code> runtime flag.</dd>\n</dl></section>\n</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String/strike\"><code>strike</code></a> \n</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String/sub\"><code>sub</code></a> \n</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String/substr\"><code>substr</code></a> \n</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String/substring\"><code>substring</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String/sup\"><code>sup</code></a> \n</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String/toLocaleLowerCase\"><code>toLocaleLowerCase</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><code>toLocaleLowerCase.locale</code></th>\n<td> ? </td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String/toLocaleUpperCase\"><code>toLocaleUpperCase</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><code>toLocaleUpperCase.locale</code></th>\n<td> ? </td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String/toLowerCase\"><code>toLowerCase</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String/toSource\"><code>toSource</code></a> \n</th>\n<td class=\"bc-supports-no\"> No</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String/toString\"><code>toString</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String/toUpperCase\"><code>toUpperCase</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String/trim\"><code>trim</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String/trimEnd\"><code>trimEnd</code></a></th>\n<td class=\"bc-supports-yes\"> 10.0.0</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String/trimStart\"><code>trimStart</code></a></th>\n<td class=\"bc-supports-yes\"> 10.0.0</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String/valueOf\"><code>valueOf</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n</tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"https://developer.mozilla.org/en-US/docs/Web/API/DOMString\"><code>DOMString</code></a></li> <li><a href=\"https://developer.mozilla.org/en-US/Add-ons/Code_snippets/StringView\"><code>StringView</code> — a C-like representation of strings based on typed arrays</a></li> <li><a href=\"https://developer.mozilla.org/en-US/docs/Web/API/DOMString/Binary\">Binary strings</a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String</a>\n  </p>\n</div>\n","operators/this":"<h1>this</h1> <p>A <code>this</code> behaves a little differently in JavaScript compared to other languages. It also has some differences between <a href=\"../strict_mode\">strict mode</a> and non-strict mode.</p> <p>In most cases, the value of <code>this</code> is determined by how a function is called. It can't be set by assignment during execution, and it may be different each time the function is called. ES5 introduced the <a href=\"../global_objects/function/bind\"><code>bind()</code></a> method to <a href=\"#The_bind_method\">set the value of a function's <code>this</code> regardless of how it's called</a>, and ES2015 introduced <a href=\"../functions/arrow_functions\">arrow functions</a> which don't provide their own <code>this</code> binding (it retains the <code>this</code> value of the enclosing lexical context).</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/expressions-this.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\">this</pre> <h2 id=\"Global_Context\">Global Context</h2> <p>In the global execution context (outside of any function), <code>this</code> refers to the global object whether in strict mode or not.</p> <pre data-language=\"js\">// In web browsers, the window object is also the global object:\nconsole.log(this === window); // true\n\na = 37;\nconsole.log(window.a); // 37\n\nthis.b = \"MDN\";\nconsole.log(window.b)  // \"MDN\"\nconsole.log(b)         // \"MDN\"\n</pre> <h2 id=\"Function_context\">Function context</h2> <p>Inside a function, the value of <code>this</code> depends on how the function is called.</p> <h3 id=\"Simple_call\">Simple call</h3> <p>Since the following code is not in <a href=\"../strict_mode\">strict mode</a>, and because the value of <code>this</code> is not set by the call, <code>this</code> will default to the global object, which is <a href=\"https://developer.mozilla.org/en-US/docs/Web/API/Window\"><code>window</code></a> in a browser. </p> <pre data-language=\"js\">function f1() {\n  return this;\n}\n\n// In a browser:\nf1() === window; // true \n\n// In Node:\nf1() === global; // true</pre> <p>In strict mode, however, the value of <code>this</code> remains at whatever it was set to when entering the execution context, so, in the following case, <code>this</code>will default to <code>undefined</code><strong>:</strong></p> <pre data-language=\"js\">function f2() {\n  'use strict'; // see strict mode\n  return this;\n}\n\nf2() === undefined; // true\n</pre> <p>So, in <strong>strict mode,</strong> if <code>this</code> was not defined by the execution context, it remains undefined.</p> <div class=\"note\">In the second example, <code>this</code> should be <a href=\"../global_objects/undefined\"><code>undefined</code></a>, because <code>f2</code> was called directly and not as a method or property of an object (e.g. <code>window.f2()</code>). This feature wasn't implemented in some browsers when they first started to support <a href=\"../strict_mode\">strict mode</a>. As a result, they incorrectly returned the <code>window</code> object.</div> <p>To pass the value of <code>this</code> from one context to another, use <a href=\"../global_objects/function/call\"><code>call()</code></a>, or <a href=\"../global_objects/function/apply\"><code>apply()</code></a><strong>:</strong></p> <pre dir=\"rtl\" data-language=\"js\">// An object can be passed as the first argument to call or apply and this will be bound to it.\nvar obj = {a: 'Custom'};\n\n// This property is set on the global object\nvar a = 'Global';\n\nfunction whatsThis() {\n  return this.a;  // The value of this is dependent on how the function is called\n}\n\nwhatsThis();          // 'Global'\nwhatsThis.call(obj);  // 'Custom'\nwhatsThis.apply(obj); // 'Custom'\n</pre> <p>Where a function uses the <code>this</code> keyword in its body, its value can be bound to a particular object in the call using the <code>call()</code> or <font face=\"consolas, Liberation Mono, courier, monospace\"><span style=\"background-color: rgba(220, 220, 220, 0.5);\">apply()</span></font> methods which all functions inherit from <a href=\"../global_objects/function/prototype\"><code>Function.prototype</code></a>.</p> <pre data-language=\"js\">function add(c, d) {\n  return this.a + this.b + c + d;\n}\n\nvar o = {a: 1, b: 3};\n\n// The first parameter is the object to use as\n// 'this', subsequent parameters are passed as \n// arguments in the function call\nadd.call(o, 5, 7); // 16\n\n// The first parameter is the object to use as\n// 'this', the second is an array whose\n// members are used as the arguments in the function call\nadd.apply(o, [10, 20]); // 34\n</pre> <p>Note that with <code>call</code> and <code>apply</code>, if the value passed as <code>this</code> is not an object, an attempt will be made to convert it to an object using the internal <code>ToObject</code> operation. So if the value passed is a primitive like <code>7</code> or <code>'foo'</code>, it will be converted to an Object using the related constructor, so the primitive number <code>7</code> is converted to an object as if by <code>new Number(7)</code> and the string <code>'foo'</code> to an object as if by <code>new String('foo')</code>, e.g.</p> <pre data-language=\"js\">function bar() {\n  console.log(Object.prototype.toString.call(this));\n}\n\nbar.call(7);     // [object Number]\nbar.call('foo'); // [object String]\n</pre> <h3 id=\"The_bind_method\">The <code>bind</code> method</h3> <p>ECMAScript 5 introduced <a href=\"../global_objects/function/bind\"><code>Function.prototype.bind()</code></a>. Calling <code>f.bind(someObject)</code> creates a new function with the same body and scope as <code>f</code>, but where <code>this</code> occurs in the original function, in the new function it is permanently bound to the first argument of <code>bind</code>, regardless of how the function is being used.</p> <pre data-language=\"js\">function f() {\n  return this.a;\n}\n\nvar g = f.bind({a: 'azerty'});\nconsole.log(g()); // azerty\n\nvar h = g.bind({a: 'yoo'}); // bind only works once!\nconsole.log(h()); // azerty\n\nvar o = {a: 37, f: f, g: g, h: h};\nconsole.log(o.a, o.f(), o.g(), o.h()); // 37,37, azerty, azerty\n</pre> <h3 id=\"Arrow_functions\">Arrow functions</h3> <p>In <a href=\"../functions/arrow_functions\">arrow functions</a>, <code>this</code> retains the value of the enclosing lexical context's <code>this</code>. In global code, it will be set to the global object:</p> <pre data-language=\"js\">var globalObject = this;\nvar foo = (() =&gt; this);\nconsole.log(foo() === globalObject); // true</pre> <div class=\"note\"> <p>Note: if this arg is passed to call, bind, or apply on invocation of an arrow function it will be ignored. You can still prepend arguments to the call, but the first argument (thisArg) should be set to null.</p> </div> <pre data-language=\"js\">// Call as a method of an object\nvar obj = {func: foo};\nconsole.log(obj.func() === globalObject); // true\n\n// Attempt to set this using call\nconsole.log(foo.call(obj) === globalObject); // true\n\n// Attempt to set this using bind\nfoo = foo.bind(obj);\nconsole.log(foo() === globalObject); // true</pre> <p>No matter what, <code>foo</code>'s <code>this</code> is set to what it was when it was created (in the example above, the global object). The same applies to arrow functions created inside other functions: their <code>this</code> remains that of the enclosing lexical context.</p> <pre data-language=\"js\">// Create obj with a method bar that returns a function that\n// returns its this. The returned function is created as \n// an arrow function, so its this is permanently bound to the\n// this of its enclosing function. The value of bar can be set\n// in the call, which in turn sets the value of the \n// returned function.\nvar obj = {\n  bar: function() {\n    var x = (() =&gt; this);\n    return x;\n  }\n};\n\n// Call bar as a method of obj, setting its this to obj\n// Assign a reference to the returned function to fn\nvar fn = obj.bar();\n\n// Call fn without setting this, would normally default\n// to the global object or undefined in strict mode\nconsole.log(fn() === obj); // true\n\n// But caution if you reference the method of obj without calling it\nvar fn2 = obj.bar;\n// Then calling the arrow function this is equals to window because it follows the this from bar.\nconsole.log(fn2()() == window); // true\n</pre> <p>In the above, the function(call it anonymous function A) assigned to <code>obj.bar</code> returns another function(call it anonymous function B) that is created as an arrow function. As a result, function B's <code>this</code> is permanently set to the <code>this</code> of <code>obj.bar</code> (function A)when called. When the returned function(function B) is called, its <code>this</code> will always be what it was set to initially. In the above code example, function B's <code>this</code> is set to function A's <code>this</code> which is obj, so it remains set to <code>obj</code> even when called in a manner that would normally set its <code>this</code> to <code>undefined</code> or the global object (or any other method as in the previous example in the global execution context).</p> <h3 id=\"As_an_object_method\">As an object method</h3> <p>When a function is called as a method of an object, its <code>this</code> is set to the object the method is called on.</p> <p>In the following example, when <code>o.f()</code> is invoked, inside the function <code>this</code> is bound to the <code>o</code> object.</p> <pre data-language=\"js\">var o = {\n  prop: 37,\n  f: function() {\n    return this.prop;\n  }\n};\n\nconsole.log(o.f()); // 37\n</pre> <p>Note that this behavior is not at all affected by how or where the function was defined. In the previous example, we defined the function inline as the <code>f</code> member during the definition of <code>o</code>. However, we could have just as easily defined the function first and later attached it to <code>o.f</code>. Doing so results in the same behavior:</p> <pre data-language=\"js\">var o = {prop: 37};\n\nfunction independent() {\n  return this.prop;\n}\n\no.f = independent;\n\nconsole.log(o.f()); // 37\n</pre> <p>This demonstrates that it matters only that the function was invoked from the <code>f</code> member of <code>o</code>.</p> <p>Similarly, the <code>this</code> binding is only affected by the most immediate member reference. In the following example, when we invoke the function, we call it as a method <code>g</code> of the object <code>o.b</code>. This time during execution, <code>this</code> inside the function will refer to <code>o.b</code>. The fact that the object is itself a member of <code>o</code> has no consequence; the most immediate reference is all that matters.</p> <pre data-language=\"js\">o.b = {g: independent, prop: 42};\nconsole.log(o.b.g()); // 42\n</pre> <h4 id=\"this_on_the_object's_prototype_chain\">\n<code>this</code> on the object's prototype chain</h4> <p>The same notion holds true for methods defined somewhere on the object's prototype chain. If the method is on an object's prototype chain, <code>this</code> refers to the object the method was called on, as if the method were on the object.</p> <pre data-language=\"js\">var o = {f: function() { return this.a + this.b; }};\nvar p = Object.create(o);\np.a = 1;\np.b = 4;\n\nconsole.log(p.f()); // 5\n</pre> <p>In this example, the object assigned to the variable <code>p</code> doesn't have its own <code>f</code> property, it inherits it from its prototype. But it doesn't matter that the lookup for <code>f</code> eventually finds a member with that name on <code>o</code>; the lookup began as a reference to <code>p.f</code>, so <code>this</code> inside the function takes the value of the object referred to as <code>p</code>. That is, since <code>f</code> is called as a method of <code>p</code>, its <code>this</code> refers to <code>p</code>. This is an interesting feature of JavaScript's prototype inheritance.</p> <h4 id=\"this_with_a_getter_or_setter\">\n<code>this</code> with a getter or setter</h4> <p>Again, the same notion holds true when a function is invoked from a getter or a setter. A function used as getter or setter has its <code>this</code> bound to the object from which the property is being set or gotten.</p> <pre data-language=\"js\">function sum() {\n  return this.a + this.b + this.c;\n}\n\nvar o = {\n  a: 1,\n  b: 2,\n  c: 3,\n  get average() {\n    return (this.a + this.b + this.c) / 3;\n  }\n};\n\nObject.defineProperty(o, 'sum', {\n    get: sum, enumerable: true, configurable: true});\n\nconsole.log(o.average, o.sum); // 2, 6\n</pre> <h3 id=\"As_a_constructor\">As a constructor</h3> <p>When a function is used as a constructor (with the <a href=\"new\"><code>new</code></a> keyword), its <code>this</code> is bound to the new object being constructed.</p> <div class=\"note\"> <p>While the default for a constructor is to return the object referenced by <code>this</code>, it can instead return some other object (if the return value isn't an object, then the <code>this</code> object is returned).</p> </div> <pre data-language=\"js\">/*\n * Constructors work like this:\n *\n * function MyConstructor(){\n *   // Actual function body code goes here.  \n *   // Create properties on |this| as\n *   // desired by assigning to them.  E.g.,\n *   this.fum = \"nom\";\n *   // et cetera...\n *\n *   // If the function has a return statement that\n *   // returns an object, that object will be the\n *   // result of the |new| expression.  Otherwise,\n *   // the result of the expression is the object\n *   // currently bound to |this|\n *   // (i.e., the common case most usually seen).\n * }\n */\n\nfunction C() {\n  this.a = 37;\n}\n\nvar o = new C();\nconsole.log(o.a); // 37\n\n\nfunction C2() {\n  this.a = 37;\n  return {a: 38};\n}\n\no = new C2();\nconsole.log(o.a); // 38\n</pre> <p>In the last example (<code>C2</code>), because an object was returned during construction, the new object that <code>this</code> was bound to simply gets discarded. (This essentially makes the statement \"<code>this.a = 37;</code>\" dead code. It's not exactly dead because it gets executed, but it can be eliminated with no outside effects.)</p> <h3 id=\"As_a_DOM_event_handler\">As a DOM event handler</h3> <p>When a function is used as an event handler, its <code>this</code> is set to the element the event fired from (some browsers do not follow this convention for listeners added dynamically with methods other than <a href=\"https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/addEventListener\"><code>addEventListener()</code></a>).</p> <pre data-language=\"js\">// When called as a listener, turns the related element blue\nfunction bluify(e) {\n  // Always true\n  console.log(this === e.currentTarget); \n  // true when currentTarget and target are the same object\n  console.log(this === e.target);\n  this.style.backgroundColor = '#A5D9F3';\n}\n\n// Get a list of every element in the document\nvar elements = document.getElementsByTagName('*');\n\n// Add bluify as a click listener so when the\n// element is clicked on, it turns blue\nfor (var i = 0; i &lt; elements.length; i++) {\n  elements[i].addEventListener('click', bluify, false);\n}</pre> <h3 id=\"In_an_inline_event_handler\">In an inline event handler</h3> <p>When the code is called from an inline <a href=\"https://developer.mozilla.org/en-US/docs/Web/Guide/Events/Event_handlers\">on-event handler</a>, its <code>this</code> is set to the DOM element on which the listener is placed:</p> <pre data-language=\"js\">&lt;button onclick=\"alert(this.tagName.toLowerCase());\"&gt;\n  Show this\n&lt;/button&gt;\n</pre> <p>The above alert shows <code>button</code>. Note however that only the outer code has its <code>this</code> set this way:</p> <pre data-language=\"js\">&lt;button onclick=\"alert((function() { return this; })());\"&gt;\n  Show inner this\n&lt;/button&gt;\n</pre> <p>In this case, the inner function's <code>this</code> isn't set so it returns the global/window object (i.e. the default object in non–strict mode where <code>this</code> isn't set by the call).</p> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-this-keyword\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'The this keyword' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-this-keyword\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'The this keyword' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/5.1/#sec-11.1.1\" hreflang=\"en\">ECMAScript 5.1 (ECMA-262)<br><small>The definition of 'The this keyword' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/publications/files/ECMA-ST-ARCH/ECMA-262,%203rd%20edition,%20December%201999.pdf#sec-11.1.1\" hreflang=\"en\">ECMAScript 3rd Edition (ECMA-262)<br><small>The definition of 'The this keyword' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/publications/files/ECMA-ST-ARCH/ECMA-262,%201st%20edition,%20June%201997.pdf#sec-11.1.1\" hreflang=\"en\">ECMAScript 1st Edition (ECMA-262)<br><small>The definition of 'The this keyword' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition. Implemented in JavaScript 1.0.</td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"../strict_mode\">Strict mode</a></li> <li><a href=\"https://dmitripavlutin.com/gentle-explanation-of-this-in-javascript/\">Gentle explanation of 'this' keyword in JavaScript</a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/this$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/this\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/this</a>\n  </p>\n</div>\n","statements/empty":"<h1>Empty</h1> <p>An <strong>empty statement</strong> is used to provide no statement, although the JavaScript syntax would expect one.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/statement-empty.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\">;\n</pre> <h2 id=\"Description\">Description</h2> <p>The empty statement is a semicolon (;) indicating that no statement will be executed, even if JavaScript syntax requires one. The opposite behavior, where you want multiple statements, but JavaScript only allows a single one, is possible using a<a href=\"block\"> block statement</a>; it combines several statements into a single one.</p> <h2 id=\"Examples\">Examples</h2> <p>The empty statement is sometimes used with loop statements. See the following example with an empty loop body:</p> <pre data-language=\"js\">var arr = [1, 2, 3];\n\n// Assign all array values to 0\nfor (i = 0; i &lt; arr.length; arr[i++] = 0) /* empty statement */ ;\n\nconsole.log(arr)\n// [0, 0, 0]\n</pre> <p><strong>Note:</strong> It is a good idea to comment the intentional use of the empty statement, as it is not really obvious to distinguish between a normal semicolon. In the following example the usage is probably not intentional:</p> <pre data-language=\"js\">if (condition);       // Caution, this \"if\" does nothing!\n   killTheUniverse()  // So this always gets executed!!!\n</pre> <p>Another Example: An <a href=\"if...else\"><code>if...else</code></a> statement without curly braces (<code>{}</code>). If <code>three</code> is <code>true</code>, nothing will happen, <code>four</code> does not matter, and also the <code>launchRocket()</code> function in the <code>else</code> case will not be executed.</p> <pre data-language=\"js\">if (one)\n  doOne();\nelse if (two)\n  doTwo();\nelse if (three)\n  ; // nothing here\nelse if (four)\n  doFour();\nelse\n  launchRocket();</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-empty-statement\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Empty statement' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-empty-statement\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Empty statement' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/5.1/#sec-12.3\" hreflang=\"en\">ECMAScript 5.1 (ECMA-262)<br><small>The definition of 'Empty statement' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/publications/files/ECMA-ST-ARCH/ECMA-262,%203rd%20edition,%20December%201999.pdf#sec-12.3\" hreflang=\"en\">ECMAScript 3rd Edition (ECMA-262)<br><small>The definition of 'Empty statement' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/publications/files/ECMA-ST-ARCH/ECMA-262,%201st%20edition,%20June%201997.pdf#sec-12.3\" hreflang=\"en\">ECMAScript 1st Edition (ECMA-262)<br><small>The definition of 'Empty statement' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"block\"><code>Block statement</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/Empty$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/Empty\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/Empty</a>\n  </p>\n</div>\n","statements/class":"<h1>class</h1> <p>The <strong>class declaration</strong> creates a new class with a given name using prototype-based inheritance.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/statement-class.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <div class=\"noinclude\"> <p>You can also define a class using a <a href=\"../operators/class\">class expression</a>. But unlike the class expression, the class declaration doesn't allow an existing class to be declared again and will throw a type error if attempted. </p> </div> <h2 id=\"Syntax\">Syntax</h2> <pre data-language=\"js\">class <em>name</em> [extends] {\n  // class body\n}\n</pre> <h2 id=\"Description\">Description</h2> <p>The class body of a class declaration is executed in <a href=\"../strict_mode\">strict mode</a>. The constructor property is optional.</p> <p>Class declarations are not <a href=\"https://developer.mozilla.org/en-US/docs/Glossary/Hoisting\">hoisted</a> (unlike <a href=\"function\">function declarations</a>).</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"A_simple_class_declaration\">A simple class declaration</h3> <p>In the following example, we first define a class named Polygon, then extend it to create a class named Square. Note that super(), used in the constructor, can only be used in constructors and must be called before the <code>this</code> keyword can be used.</p> <pre data-language=\"js\">class Polygon {\n  constructor(height, width) {\n    this.name = 'Polygon';\n    this.height = height;\n    this.width = width;\n  }\n}\n\nclass Square extends Polygon {\n  constructor(length) {\n    super(length, length);\n    this.name = 'Square';\n  }\n}</pre> <div class=\"warning\"> <h3 id=\"Attempting_to_declare_a_class_twice\">Attempting to declare a class twice</h3> <p>Re-declaring a class using the class declaration throws a type error.</p> <pre data-language=\"js\">class Foo {};\nclass Foo {}; // Uncaught TypeError: Identifier 'Foo' has already been declared\n</pre> <p>The same error is thrown when a class has been defined before using the class expression.</p> <pre data-language=\"js\">var Foo = class {};\nclass Foo {}; // Uncaught TypeError: Identifier 'Foo' has already been declared\n\n</pre> </div> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-class-definitions\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Class definitions' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/7.0/#sec-class-definitions\" hreflang=\"en\">ECMAScript 2016 (ECMA-262)<br><small>The definition of 'Class definitions' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/8.0/#sec-class-definitions\" hreflang=\"en\">ECMAScript 2017 (ECMA-262)<br><small>The definition of 'Class definitions' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-class-definitions\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Class definitions' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 42</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 45</td>\n<td class=\"bc-supports-no\"> No</td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 10.1</td>\n</tr>\n<tr>\n<th scope=\"row\">Array subclassing</th>\n<td class=\"bc-supports-yes\"> 43</td>\n<td> ? </td>\n<td> ? </td>\n<td class=\"bc-supports-no\"> No</td>\n<td> ? </td>\n<td> ? </td>\n</tr>\n<tr>\n<th scope=\"row\">Allowed in sloppy mode</th>\n<td class=\"bc-supports-yes\"> 49</td>\n<td> ? </td>\n<td> ? </td>\n<td class=\"bc-supports-no\"> No</td>\n<td> ? </td>\n<td> ? </td>\n</tr>\n</tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 42</td>\n<td class=\"bc-supports-yes\"> 42</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 45</td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 10.1</td>\n<td class=\"bc-supports-yes\"> 4.0</td>\n</tr>\n<tr>\n<th scope=\"row\">Array subclassing</th>\n<td class=\"bc-supports-yes\"> 43</td>\n<td class=\"bc-supports-yes\"> 43</td>\n<td> ? </td>\n<td> ? </td>\n<td> ? </td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 4.0</td>\n</tr>\n<tr>\n<th scope=\"row\">Allowed in sloppy mode</th>\n<td class=\"bc-supports-yes\"> 49</td>\n<td class=\"bc-supports-yes\"> 49</td>\n<td> ? </td>\n<td> ? </td>\n<td> ? </td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 5.0</td>\n</tr>\n</tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 6.0.0</td>\n</tr>\n<tr>\n<th scope=\"row\">Array subclassing</th>\n<td> ? </td>\n</tr>\n<tr>\n<th scope=\"row\">Allowed in sloppy mode</th>\n<td> ? </td>\n</tr>\n</tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"function\"><code>function</code> declaration</a></li> <li><a href=\"../operators/class\"><code>class</code> expression</a></li> <li><a href=\"../classes\">Classes</a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/class$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/class\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/class</a>\n  </p>\n</div>\n","statements/default":"<h1>default</h1> <p>The <strong>default keyword </strong>can be used in two situations in JavaScript: within a <a href=\"switch\"><code>switch</code></a> statement, or with an <a href=\"export\"><code>export</code></a> statement.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/statement-default.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <p>Within a <a href=\"switch\"><code>switch</code></a> statement:</p> <pre class=\"syntaxbox\">switch (expression) {\n  case value1:\n    //Statements executed when the result of expression matches value1\n    [break;]\n  default:\n    //Statements executed when none of the values match the value of the expression\n    [break;]\n}</pre> <p>With <a href=\"export\"><code>export</code></a> statement:</p> <pre class=\"syntaxbox\">export default <em>nameN</em> </pre> <h2 id=\"Description\">Description</h2> <p>For more details see the</p> <ul> <li>\n<a href=\"switch\"><code>switch</code></a> statement and</li> <li>\n<a href=\"export\"><code>export</code></a> statement pages.</li> </ul> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Using_default_in_switch_statements\">Using <code>default</code> in <code>switch</code> statements</h3> <p>In the following example, if <code>expr</code> evaluates to \"Oranges\" or \"Apples\", the program matches the values with either the case \"Oranges\" or \"Apples\" and executes the corresponding statement. The <code>default</code> keyword will help in any other case and executes the associated statement.</p> <pre data-language=\"js\">switch (expr) {\n  case 'Oranges':\n    console.log('Oranges are $0.59 a pound.');\n    break;\n  case 'Apples':\n    console.log('Apples are $0.32 a pound.');\n    break;\n  default:\n    console.log('Sorry, we are out of ' + expr + '.');\n}</pre> <h3 id=\"Using_default_with_export\">Using <code>default</code> with <code>export</code>\n</h3> <p>If you want to export a single value or need a fallback value for a module, a default export can be used:</p> <pre data-language=\"js\">// module \"my-module.js\"\nlet cube = function cube(x) {\n  return x * x * x;\n};\nexport default cube;</pre> <p>Then, in another script, it will be straightforward to import the default export:</p> <pre data-language=\"js\">// module \"my-module.js\"\nimport cube from 'my-module';  //default export gave us the liberty to say import cube, instead of import cube from 'my-module'\nconsole.log(cube(3)); // 27\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-switch-statement\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'switch statement' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-exports\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Exports' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-switch-statement\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'switch statement' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-exports\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Exports' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">\n<code>default</code> keyword in <code>switch</code>\n</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<code>default</code> keyword with <code>export</code>\n</th>\n<td class=\"bc-supports-yes\"> 61</td>\n<td class=\"bc-supports-yes bc-has-history\"> 16\n<section class=\"bc-history\" id=\"sect1\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 16\n</dt>\n\n<dt class=\"bc-supports-yes bc-supports\"> 15<div class=\"bc-icons\">Disabled </div>\n</dt>\n<dd>Disabled From version 15: this feature is behind the <code>Experimental JavaScript Features</code> preference.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-yes bc-has-history\"> 60\n<section class=\"bc-history\" id=\"sect2\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 60\n</dt>\n\n<dt class=\"bc-supports-no bc-supports\">54 — 60<div class=\"bc-icons\">Disabled </div>\n</dt>\n<dd>Disabled From version 54 until version 60 (exclusive): this feature is behind the <code>dom.moduleScripts.enabled</code> preference. To change preferences in Firefox, visit about:config.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 47</td>\n<td class=\"bc-supports-yes\"> 10.1</td>\n</tr>\n</tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">\n<code>default</code> keyword in <code>switch</code>\n</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<code>default</code> keyword with <code>export</code>\n</th>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 61</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes bc-has-history\"> 60\n<section class=\"bc-history\" id=\"sect3\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 60\n</dt>\n\n<dt class=\"bc-supports-no bc-supports\">54 — 60<div class=\"bc-icons\">Disabled </div>\n</dt>\n<dd>Disabled From version 54 until version 60 (exclusive): this feature is behind the <code>dom.moduleScripts.enabled</code> preference. To change preferences in Firefox, visit about:config.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-yes\"> 47</td>\n<td class=\"bc-supports-yes\"> 10.1</td>\n<td class=\"bc-supports-no\"> No</td>\n</tr>\n</tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">\n<code>default</code> keyword in <code>switch</code>\n</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<code>default</code> keyword with <code>export</code>\n</th>\n<td> ? </td>\n</tr>\n</tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"export\"><code>export</code></a></li> <li><a href=\"switch\"><code>switch</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/default$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/default\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/default</a>\n  </p>\n</div>\n","statements/debugger":"<h1>debugger</h1> <p>The <strong>debugger statement</strong> invokes any available debugging functionality, such as setting a breakpoint. If no debugging functionality is available, this statement has no effect.</p> <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\">debugger;</pre> <h2 id=\"Examples\">Examples</h2> <p>The following example shows code where a debugger statement has been inserted, to invoke a debugger (if one exists) when the function is called.</p> <pre data-language=\"js\">function potentiallyBuggyCode() {\n    debugger;\n    // do potentially buggy stuff to examine, step through, etc.\n}</pre> <p>When the debugger is invoked, execution is paused at the debugger statement. It is like a breakpoint in the script source.</p> <p><a href=\"https://mdn.mozillademos.org/files/6963/Screen%20Shot%202014-02-07%20at%209.14.35%20AM.png\"><img src=\"https://mdn.mozillademos.org/files/6963/Screen%20Shot%202014-02-07%20at%209.14.35%20AM.png\" alt=\"Paused at a debugger statement.\" style=\"height: 371px; width: 700px;\"></a></p> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-debugger-statement\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Debugger statement' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-debugger-statement\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Debugger statement' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/5.1/#sec-12.15\" hreflang=\"en\">ECMAScript 5.1 (ECMA-262)<br><small>The definition of 'Debugger statement' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/publications/files/ECMA-ST-ARCH/ECMA-262,%203rd%20edition,%20December%201999.pdf#sec-7.5.3\" hreflang=\"en\">ECMAScript 3rd Edition (ECMA-262)<br><small>The definition of 'Debugger statement' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/publications/files/ECMA-ST-ARCH/ECMA-262,%201st%20edition,%20June%201997.pdf#sec-7.4.3\" hreflang=\"en\">ECMAScript 1st Edition (ECMA-262)<br><small>The definition of 'Debugger statement' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Only mentioned as reserved word.</td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"https://developer.mozilla.org/en-US/docs/Debugging_JavaScript\">Debugging JavaScript</a></li> <li><a href=\"https://developer.mozilla.org/en-US/docs/Tools/Debugger\">The Debugger in the Firefox Developer Tools</a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/debugger$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/debugger\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/debugger</a>\n  </p>\n</div>\n","statements/export":"<h1>export</h1> <p>The <code>export</code> statement is used when creating JavaScript modules to export functions, objects, or primitive values from the module so they can be used by other programs with the <a href=\"import\"><code>import</code></a> statement.</p> <p>Exported modules are in <a href=\"../strict_mode\"><code>strict mode</code></a> whether you declare them as such or not. The export statement cannot be used in embedded scripts.</p> <h2 id=\"Syntax\">Syntax</h2> <pre data-language=\"js\">export { <var>name1</var>, <var>name2</var>, …, <var>nameN</var> };\nexport { <var>variable1</var> as <var>name1</var>, <var>variable2</var> as <var>name2</var>, …, <var>nameN</var> };\nexport let <var>name1</var>, <var>name2</var>, …, <var>nameN</var>; // also var, const\nexport let <var>name1</var> = …, <var>name2</var> = …, …, <var>nameN</var>; // also var, const\nexport function FunctionName(){...}\nexport class ClassName {...}\n\nexport default <em>expression</em>;\nexport default function (…) { … } // also class, function*\nexport default function name1(…) { … } // also class, function*\nexport { <var>name1</var> as default, … };\n\nexport * from …;\nexport { <var>name1</var>, <var>name2</var>, …, <var>nameN</var> } from …;\nexport { <var>import1</var> as <var>name1</var>, <var>import2</var> as <var>name2</var>, …, <var>nameN</var> } from …;\nexport { default } from …;</pre> <dl> <dt><code>nameN</code></dt> <dd>Identifier to be exported (so that it can be imported via <a href=\"import\"><code>import</code></a> in another script).</dd> </dl> <h2 id=\"Description\">Description</h2> <p>There are two different types of export, <strong>named</strong> and <strong>default</strong>. You can have multiple named exports per module but only one default export. Each type corresponds to one of the above syntax:</p> <ul> <li>Named exports: <pre data-language=\"js\">// exports a function declared earlier\nexport { myFunction }; \n\n// exports a constant\nexport const foo = Math.sqrt(2);</pre> </li> <li>Default exports (function): <pre data-language=\"js\">export default function() {} </pre> </li> <li>Default exports (class): <pre data-language=\"js\">export default class {} </pre> </li> </ul> <p>Named exports are useful to export several values. During the import, it is mandatory to use the same name of the corresponding object.</p> <p>But a default export can be imported with any name for example:</p> <pre data-language=\"js\">let k; export default k = 12; // in file test.js\n\nimport m from './test' // note that we have the freedom to use import m instead of import k, because k was default export\n\nconsole.log(m);        // will log 12\n</pre> <p>The following syntax does not export a default export from the imported module:</p> <pre data-language=\"js\">export * from …;</pre> <p>If you need to export the default, write the following instead:</p> <pre data-language=\"js\">export {default} from 'mod';\n</pre> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Using_named_exports\">Using named exports</h3> <p>In the module, we could use the following code:</p> <pre data-language=\"js\">// module \"my-module.js\"\nfunction cube(x) {\n  return x * x * x;\n}\nconst foo = Math.PI + Math.SQRT2;\nvar graph = {\n    options:{\n        color:'white',\n        thickness:'2px'\n    },\n    draw: function(){\n        console.log('From graph draw function');\n    }\n}\nexport { cube, foo, graph };\n</pre> <p>This way, in another script, we could have:</p> <pre data-language=\"js\">//You should use this script in html with the type module ,\n//eg ''&lt;script type=\"module\" src=\"demo.js\"&gt;&lt;/script&gt;\",\n//open the page in a httpserver,otherwise there will be a CORS policy error.\n//script demo.js\n\nimport { cube, foo, graph } from 'my-module';\ngraph.options = {\n    color:'blue',\n    thickness:'3px'\n}; \ngraph.draw();\nconsole.log(cube(3)); // 27\nconsole.log(foo);    // 4.555806215962888</pre> <h3 id=\"Using_the_default_export\">Using the default export</h3> <p>If we want to export a single value or to have a fallback value for our module, we could use a default export:</p> <pre data-language=\"js\">// module \"my-module.js\"\nexport default function cube(x) {\n  return x * x * x;\n}\n</pre> <p>Then, in another script, it will be straightforward to import the default export:</p> <pre data-language=\"js\">import cube from 'my-module';\nconsole.log(cube(3)); // 27\n</pre> <p>Note that it is not possible to use <code>var</code>, <code>let</code> or <code>const</code> with <code>export default</code>.</p> <h3 id=\"Module_Redirects\">Module Redirects</h3> <p>If we want to export default, and star from another module (effectively creating a \"redirect\"):</p> <pre data-language=\"js\">// module \"redirect-module.js\"\nexport {default} from './other-module';\nexport * from './other-module';</pre>  <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-exports\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Exports' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-exports\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Exports' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 61</td>\n<td class=\"bc-supports-yes bc-has-history\"> 16\n<section class=\"bc-history\" id=\"sect1\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 16\n</dt>\n\n<dt class=\"bc-supports-yes bc-supports\"> 15<div class=\"bc-icons\">Disabled </div>\n</dt>\n<dd>Disabled From version 15: this feature is behind the <code>Experimental JavaScript Features</code> preference.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-yes bc-has-history\"> 60\n<section class=\"bc-history\" id=\"sect2\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 60\n</dt>\n\n<dt class=\"bc-supports-no bc-supports\">54 — 60<div class=\"bc-icons\">Disabled </div>\n</dt>\n<dd>Disabled From version 54 until version 60 (exclusive): this feature is behind the <code>dom.moduleScripts.enabled</code> preference. To change preferences in Firefox, visit about:config.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 47</td>\n<td class=\"bc-supports-yes\"> 10.1</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 61</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes bc-has-history\"> 60\n<section class=\"bc-history\" id=\"sect3\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 60\n</dt>\n\n<dt class=\"bc-supports-no bc-supports\">54 — 60<div class=\"bc-icons\">Disabled </div>\n</dt>\n<dd>Disabled From version 54 until version 60 (exclusive): this feature is behind the <code>dom.moduleScripts.enabled</code> preference. To change preferences in Firefox, visit about:config.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-yes\"> 47</td>\n<td class=\"bc-supports-yes\"> 10.1</td>\n<td class=\"bc-supports-no\"> No</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td> ? </td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"import\"><code>import</code></a></li> <li>\n<a href=\"https://hacks.mozilla.org/2015/08/es6-in-depth-modules/\">ES6 in Depth: Modules</a>, Hacks blog post by Jason Orendorff</li> <li>\n<a href=\"https://hacks.mozilla.org/2018/03/es-modules-a-cartoon-deep-dive/\">ES modules: A cartoon deep-dive</a>, Hacks blog post by Lin Clark</li> <li><a href=\"http://exploringjs.com/es6/ch_modules.html\">Axel Rauschmayer's book: \"Exploring JS: Modules\"</a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/export$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/export\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/export</a>\n  </p>\n</div>\n","statements/do...while":"<h1>do...while</h1> <p>The <code>do...while</code> creates a loop that executes a specified statement until the test condition evaluates to false. The condition is evaluated after executing the statement, resulting in the specified statement executing at least once.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/statement-dowhile.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\">do\n   <em>statement</em>\nwhile (<em>condition</em>);\n</pre> <dl> <dt><code>statement</code></dt> <dd>A statement that is executed at least once and is re-executed each time the condition evaluates to true. To execute multiple statements within the loop, use a <a href=\"block\"><code>block</code></a> statement (<code>{ ... }</code>) to group those statements.</dd> </dl> <dl> <dt><code>condition</code></dt> <dd>An expression evaluated after each pass through the loop. If <code>condition</code> evaluates to true, the <code>statement</code> is re-executed. When <code>condition</code> evaluates to false, control passes to the statement following the <code>do...while</code>.</dd> </dl> <h2 name=\"Examples\" id=\"Examples\">Examples</h2> <h3 id=\"Using_do...while\">Using <code>do...while</code>\n</h3> <p>In the following example, the <code>do...while</code> loop iterates at least once and reiterates until <code>i</code> is no longer less than 5.</p> <h3 id=\"HTML_content\">HTML content</h3> <pre data-language=\"html\">&lt;div id=\"example\"&gt;&lt;/div&gt;</pre> <h3 id=\"JavaScript_content\">JavaScript content</h3> <pre data-language=\"js\">var result = '';\nvar i = 0;\ndo {\n   i += 1;\n   result += i + ' ';\n} while (i &lt; 5);\ndocument.getElementById('example').innerHTML = result;</pre> <h3 id=\"Result\">Result</h3> <p><iframe src=\"https://mdn.mozillademos.org/en-US/docs/Web/JavaScript/Reference/Statements/do...while%24samples/Examples?revision=1426425\" frameborder=\"0\" class=\"live-sample-frame sample-code-frame\" id=\"frame_Examples\"></iframe></p> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/publications/files/ECMA-ST-ARCH/ECMA-262,%203rd%20edition,%20December%201999.pdf\" hreflang=\"en\">ECMAScript 3rd Edition (ECMA-262)</a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition. Implemented in JavaScript 1.2</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/5.1/#sec-12.6.1\" hreflang=\"en\">ECMAScript 5.1 (ECMA-262)<br><small>The definition of 'do-while statement' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-do-while-statement\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'do-while statement' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Trailing ; is now optional.</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-do-while-statement\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'do-while statement' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> 6</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"while\"><code>while</code></a></li> <li><a href=\"for\"><code>for</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/do...while$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/do...while\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/do...while</a>\n  </p>\n</div>\n","statements/for":"<h1>for</h1> <p>The <strong>for statement</strong> creates a loop that consists of three optional expressions, enclosed in parentheses and separated by semicolons, followed by a statement (usually a <a href=\"block\">block statement</a>) to be executed in the loop.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/statement-for.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\">for ([<em>initialization</em>]; [<em>condition</em>]; [<em>final-expression</em>])\n   <em>statement</em></pre> <dl> <dt><code>initialization</code></dt> <dd>An expression (including assignment expressions) or variable declaration. Typically used to initialize a counter variable. This expression may optionally declare new variables with <code>var</code> or let keywords. Variables declared with <code>var</code> are not local to the loop, i.e. they are in the same scope the <code>for</code> loop is in. Variables declared with let are local to the statement.</dd> <dd>The result of this expression is discarded.</dd> <dt><code>condition</code></dt> <dd>An expression to be evaluated before each loop iteration. If this expression evaluates to true, <code>statement</code> is executed. This conditional test is optional. If omitted, the condition always evaluates to true. If the expression evaluates to false, execution skips to the first expression following the <code>for</code> construct.</dd> <dt><code>final-expression</code></dt> <dd>An expression to be evaluated at the end of each loop iteration. This occurs before the next evaluation of <code>condition</code>. Generally used to update or increment the counter variable.</dd> <dt><code>statement</code></dt> <dd>A statement that is executed as long as the condition evaluates to true. To execute multiple statements within the loop, use a <a href=\"block\">block</a> statement (<code>{ ... }</code>) to group those statements. To execute no statement within the loop, use an <a href=\"empty\">empty</a> statement (<code>;</code>).</dd> </dl> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Using_for\">Using <code>for</code>\n</h3> <p>The following <code>for</code> statement starts by declaring the variable <code>i</code> and initializing it to <code>0</code>. It checks that <code>i</code> is less than nine, performs the two succeeding statements, and increments <code>i</code> by 1 after each pass through the loop.</p> <pre data-language=\"js\">for (var i = 0; i &lt; 9; i++) {\n   console.log(i);\n   // more statements\n}\n</pre> <h3 id=\"Optional_for_expressions\">Optional <code>for</code> expressions</h3> <p>All three expressions in the head of the <code>for</code> loop are optional.</p> <p>For example, in the <em>initialization</em> block it is not required to initialize variables:</p> <pre data-language=\"js\">var i = 0;\nfor (; i &lt; 9; i++) {\n    console.log(i);\n    // more statements\n}\n</pre> <p>Like the <em>initialization</em> block, the <em>condition</em> block is also optional. If you are omitting this expression, you must make sure to break the loop in the body in order to not create an infinite loop.</p> <pre data-language=\"js\">for (var i = 0;; i++) {\n   console.log(i);\n   if (i &gt; 3) break;\n   // more statements\n}</pre> <p>You can also omit all three blocks. Again, make sure to use a <code><a href=\"break\">break</a></code> statement to end the loop and also modify (increase) a variable, so that the condition for the break statement is true at some point.</p> <pre data-language=\"js\">var i = 0;\n\nfor (;;) {\n  if (i &gt; 3) break;\n  console.log(i);\n  i++;\n}\n</pre> <h3 id=\"Using_for_without_a_statement\">Using <code>for</code> without a statement</h3> <p>The following <code>for</code> cycle calculates the offset position of a node in the <em>[final-expression]</em> section, and therefore it does not require the use of a <code>statement</code> or <code><a href=\"block\">block</a> statement</code> section, a semicolon is used instead.</p> <pre data-language=\"js\">function showOffsetPos(sId) {\n\n  var nLeft = 0, nTop = 0;\n\n  for (\n\n    var oItNode = document.getElementById(sId); /* initialization */\n\n      oItNode; /* condition */\n\n    nLeft += oItNode.offsetLeft, nTop += oItNode.offsetTop, oItNode = oItNode.offsetParent /* final-expression */\n\n  ); /* semicolon */ \n\n  console.log('Offset position of \\'' + sId + '\\' element:\\n left: ' + nLeft + 'px;\\n top: ' + nTop + 'px;');\n\n}\n\n/* Example call: */\n\nshowOffsetPos('content');\n\n// Output:\n// \"Offset position of \"content\" element:\n// left: 0px;\n// top: 153px;\"</pre> <div class=\"note\">\n<strong>Note:</strong> This is one of the few cases in JavaScript where <strong>the semicolon is mandatory</strong>. Indeed, without the semicolon the line that follows the cycle declaration will be considered a statement.</div> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-for-statement\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'for statement' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-for-statement\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'for statement' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/5.1/#sec-12.6.3\" hreflang=\"en\">ECMAScript 5.1 (ECMA-262)<br><small>The definition of 'for statement' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/publications/files/ECMA-ST-ARCH/ECMA-262,%203rd%20edition,%20December%201999.pdf#sec-12.6.3\" hreflang=\"en\">ECMAScript 3rd Edition (ECMA-262)<br><small>The definition of 'for statement' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/publications/files/ECMA-ST-ARCH/ECMA-262,%201st%20edition,%20June%201997.pdf#sec-12.6.2\" hreflang=\"en\">ECMAScript 1st Edition (ECMA-262)<br><small>The definition of 'for statement' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition</td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"break\"><code>break</code></a></li> <li><a href=\"continue\"><code>continue</code></a></li> <li><a href=\"empty\"><code>empty</code></a></li> <li><a href=\"while\"><code>while</code></a></li> <li><a href=\"do...while\"><code>do...while</code></a></li> <li><a href=\"for...in\"><code>for...in</code></a></li> <li><a href=\"for...of\"><code>for...of</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/for$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/for\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/for</a>\n  </p>\n</div>\n","statements/for_each...in":"<h1>for each...in</h1> <div class=\"warning\"> <p>The <code>for each...in</code> statement is deprecated as the part of ECMA-357 (<a href=\"https://developer.mozilla.org/en-US/docs/Archive/Web/E4X\">E4X</a>) standard. E4X support has been removed. Consider using <a href=\"for...of\">for...of</a> instead.<br> <br> <strong>Firefox now warns about the usage of <code>for each...in</code> and it no longer works starting with Firefox 57.<br> Please see <a href=\"../errors/for-each-in_loops_are_deprecated\">Warning: JavaScript 1.6's for-each-in loops are deprecated</a> for migration help.</strong></p> </div> <p>The<code> <strong>for each...in</strong></code><strong> statement</strong> iterates a specified variable over all values of object's properties. For each distinct property, a specified statement is executed.</p> <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\">for each (<em>variable</em> in <em>object</em>) {\n  <em>statement</em>\n}</pre> <dl> <dt><code>variable</code></dt> <dd>Variable to iterate over property values, optionally declared with the <code>var</code> keyword. This variable is local to the function, not to the loop.</dd> </dl> <dl> <dt><code>object</code></dt> <dd>Object for which the properties are iterated.</dd> </dl> <dl> <dt><code>statement</code></dt> <dd>A statement to execute for each property. To execute multiple statements within the loop, use a <a href=\"block\">block</a> statement (<code>{ ... }</code>) to group those statements.</dd> </dl> <h2 id=\"Description\">Description</h2> <p>Some built-in properties are not iterated over. These include all built-in methods of objects, e.g. <code>String</code>'s <code>indexOf</code> method. However, all user-defined properties are iterated over.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Using_for_each...in\">Using <code>for each...in</code>\n</h3> <p><strong>Warning:</strong> Never use a loop like this on arrays. Only use it on objects. See <a href=\"for...in\"><code>for...in</code></a> for more details.</p> <p>The following snippet iterates over an object's properties, calculating their sum:</p> <pre data-language=\"js\">var sum = 0;\nvar obj = {prop1: 5, prop2: 13, prop3: 8};\n\nfor each (var item in obj) {\n  sum += item;\n}\n\nconsole.log(sum); // logs \"26\", which is 5+13+8</pre> <h2 id=\"Specifications\">Specifications</h2> <p>Not part of a current ECMA-262 specification. Implemented in JavaScript 1.6 and deprecated.</p> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support \n</th>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\">1.5 — 57</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support \n</th>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\">4 — 57</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support \n</th>\n<td class=\"bc-supports-no\"> No</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li>\n<code><a href=\"for...in\">for...in</a></code> - a similar statement that iterates over the property <em>names</em>.</li> <li>\n<code><a href=\"for...of\">for...of</a></code> - a similar statement that iterates over the property <em>values</em> but can only be used for iteratable types, so not for generic objects</li> <li><code><a href=\"for\">for</a></code></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/for_each...in$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/for_each...in\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/for_each...in</a>\n  </p>\n</div>\n","statements/for...in":"<h1>for...in</h1> <p>The <code>for...in</code> iterates over all non-<a href=\"../global_objects/symbol\">Symbol</a>, <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Enumerability_and_ownership_of_properties\">enumerable properties</a> of an object.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/statement-forin.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\">for (<var>variable</var> in <var>object</var>) { <em>...</em>\n}</pre> <dl> <dt><code>variable</code></dt> <dd>A different property name is assigned to <em>variable</em> on each iteration.</dd> <dt><code>object</code></dt> <dd>Object whose non-Symbol enumerable properties are iterated over.</dd> </dl> <h2 id=\"Description\">Description</h2> <p>A <code>for...in</code> loop only iterates over enumerable, non-Symbol properties. Objects created from built–in constructors like <code>Array</code> and <code>Object</code> have inherited non–enumerable properties from <code>Object.prototype</code> and <code>String.prototype</code>, such as <a href=\"../global_objects/string\"><code>String</code></a>'s <a href=\"../global_objects/string/indexof\"><code>indexOf()</code></a> method or <a href=\"../global_objects/object\"><code>Object</code></a>'s <a href=\"../global_objects/object/tostring\"><code>toString()</code></a> method. The loop will iterate over all enumerable properties of the object itself and those the object inherits from its constructor's prototype (properties closer to the object in the prototype chain override prototypes' properties).</p> <h3 id=\"Deleted_added_or_modified_properties\">Deleted, added, or modified properties</h3> <p>A <code>for...in</code> loop iterates over the properties of an object in an arbitrary order (see the <a href=\"../operators/delete\"><code>delete</code></a> operator for more on why one cannot depend on the seeming orderliness of iteration, at least in a cross-browser setting).</p> <p>If a property is modified in one iteration and then visited at a later time, its value in the loop is its value at that later time. A property that is deleted before it has been visited will not be visited later. Properties added to the object over which iteration is occurring may either be visited or omitted from iteration.</p> <p>In general, it is best not to add, modify, or remove properties from the object during iteration, other than the property currently being visited. There is no guarantee whether an added property will be visited, whether a modified property (other than the current one) will be visited before or after it is modified, or whether a deleted property will be visited before it is deleted.</p> <h3 id=\"Array_iteration_and_for...in\">Array iteration and for...in</h3> <div class=\"note\"> <p><strong>Note:</strong> <code>for...in</code> should not be used to iterate over an <a href=\"../global_objects/array\"><code>Array</code></a> where the index order is important.</p> </div> <p>Array indexes are just enumerable properties with integer names and are otherwise identical to general object properties. There is no guarantee that <code>for...in</code> will return the indexes in any particular order. The <code>for...in</code> loop statement will return all enumerable properties, including those with non–integer names and those that are inherited.</p> <p>Because the order of iteration is implementation-dependent, iterating over an array may not visit elements in a consistent order. Therefore, it is better to use a <a href=\"for\"><code>for</code></a> loop with a numeric index (or <a href=\"../global_objects/array/foreach\"><code>Array.prototype.forEach()</code></a> or the <a href=\"for...of\"><code>for...of</code></a> loop) when iterating over arrays where the order of access is important.</p> <h3 id=\"Iterating_over_own_properties_only\">Iterating over own properties only</h3> <p>If you only want to consider properties attached to the object itself, and not its prototypes, use <a href=\"../global_objects/object/getownpropertynames\"><code>getOwnPropertyNames()</code></a> or perform a <a href=\"../global_objects/object/hasownproperty\"><code>hasOwnProperty()</code></a> check (<a href=\"../global_objects/object/propertyisenumerable\"><code>propertyIsEnumerable</code></a> can also be used). Alternatively, if you know there won't be any outside code interference, you can extend built-in prototypes with a check method.</p> <h2 id=\"Examples\">Examples</h2> <p>The <code>for...in</code> loop below iterates over all of the object's enumerable, non-Symbol properties and logs a string of the property names and their values.</p> <pre data-language=\"js\">var obj = {a: 1, b: 2, c: 3};\n    \nfor (const prop in obj) {\n  console.log(`obj.${prop} = ${obj[prop]}`);\n}\n\n// Output:\n// \"obj.a = 1\"\n// \"obj.b = 2\"\n// \"obj.c = 3\"</pre> <p>The following function illustrates the use of <a href=\"../global_objects/object/hasownproperty\"><code>hasOwnProperty()</code></a>: the inherited properties are not displayed.</p> <pre data-language=\"js\">var triangle = {a: 1, b: 2, c: 3};\n\nfunction ColoredTriangle() {\n  this.color = 'red';\n}\n\nColoredTriangle.prototype = triangle;\n\nvar obj = new ColoredTriangle();\n\nfor (const prop in obj) {\n  if (obj.hasOwnProperty(prop)) {\n    console.log(`obj.${prop} = ${obj[prop]}`);\n  } \n}\n\n// Output:\n// \"obj.color = red\"\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-for-in-and-for-of-statements\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'for...in statement' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-for-in-and-for-of-statements\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'for...in statement' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/5.1/#sec-12.6.4\" hreflang=\"en\">ECMAScript 5.1 (ECMA-262)<br><small>The definition of 'for...in statement' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/publications/files/ECMA-ST-ARCH/ECMA-262,%203rd%20edition,%20December%201999.pdf#sec-12.6.4\" hreflang=\"en\">ECMAScript 3rd Edition (ECMA-262)<br><small>The definition of 'for...in statement' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/publications/files/ECMA-ST-ARCH/ECMA-262,%201st%20edition,%20June%201997.pdf#sec-12.6.3\" hreflang=\"en\">ECMAScript 1st Edition (ECMA-262)<br><small>The definition of 'for...in statement' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> 6</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"Compatibility_Initializer_expressions_in_strict_mode\">Compatibility: Initializer expressions in strict mode</h2> <p>Prior to SpiderMonkey 40 (Firefox 40 / Thunderbird 40 / SeaMonkey 2.37), it was possible to use an initializer expression (<code>i=0</code>) in a <code>for...in</code> loop:</p> <pre data-language=\"js\">var obj = {a: 1, b: 2, c: 3};\nfor (var i = 0 in obj) {\n  console.log(obj[i]);\n}\n// 1\n// 2\n// 3\n</pre> <p>This nonstandard behavior is now ignored in version 40 and later, and will present a <a href=\"../global_objects/syntaxerror\"><code>SyntaxError</code></a> (\"<a href=\"../errors/invalid_for-in_initializer\">for-in loop head declarations may not have initializers</a>\") error in <a href=\"../strict_mode\">strict mode</a> (<a href=\"https://bugzilla.mozilla.org/show_bug.cgi?id=748550\">bug 748550</a> and <a href=\"https://bugzilla.mozilla.org/show_bug.cgi?id=1164741\">bug 1164741</a>).</p> <p>Other engines such as v8 (Chrome), Chakra (IE/Edge), and JSC (WebKit/Safari) are investigating whether to remove the nonstandard behavior as well.</p> <h2 id=\"See_also\">See also</h2> <ul> <li>\n<a href=\"for...of\"><code>for...of</code></a> – a similar statement that iterates over the property <em>values</em>\n</li> <li>\n<a href=\"for_each...in\"><code>for each...in</code></a>  – a similar but deprecated statement that iterates over the values of an object's properties, rather than the property names themselves</li> <li><a href=\"for\"><code>for</code></a></li> <li>\n<a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Iterators_and_Generators\">Generator expressions</a> (uses the <code>for...in</code> syntax)</li> <li><a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Enumerability_and_ownership_of_properties\">Enumerability and ownership of properties</a></li> <li><a href=\"../global_objects/object/getownpropertynames\"><code>Object.getOwnPropertyNames()</code></a></li> <li><a href=\"../global_objects/object/hasownproperty\"><code>Object.prototype.hasOwnProperty()</code></a></li> <li><a href=\"../global_objects/array/foreach\"><code>Array.prototype.forEach()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/for...in$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/for...in\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/for...in</a>\n  </p>\n</div>\n","statements/if...else":"<h1>if...else</h1> <p>The <strong>if statement</strong> executes a statement if a specified condition is <a href=\"https://developer.mozilla.org/en-US/docs/Glossary/truthy\">truthy</a>. If the condition is <a href=\"https://developer.mozilla.org/en-US/docs/Glossary/falsy\">falsy</a>, another statement can be executed.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/statement-ifelse.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\">if (<var>condition</var>)\n   <var>statement1</var>\n[else\n   <var>statement2</var>]\n</pre> <dl> <dt><var>condition</var></dt> <dd>An <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Expressions_and_Operators#Expressions\">expression</a> that is considered to be either <a href=\"https://developer.mozilla.org/en-US/docs/Glossary/truthy\">truthy</a> or <a href=\"https://developer.mozilla.org/en-US/docs/Glossary/falsy\">falsy</a>.</dd> </dl> <dl> <dt><var>statement1</var></dt> <dd>Statement that is executed if <var>condition</var> is <a href=\"https://developer.mozilla.org/en-US/docs/Glossary/truthy\">truthy</a>. Can be any statement, including further nested <code>if</code> statements. To execute multiple statements, use a <a href=\"block\">block</a> statement ({ ... }) to group those statements. To execute no statements, use an <a href=\"empty\">empty</a> statement.</dd> </dl> <dl> <dt><var>statement2</var></dt> <dd>Statement that is executed if <var>condition</var> is <a href=\"https://developer.mozilla.org/en-US/docs/Glossary/falsy\">falsy</a> and the <code>else</code> clause exists. Can be any statement, including block statements and further nested <code>if</code> statements.</dd> </dl> <h2 id=\"Description\">Description</h2> <p>Multiple <code>if...else</code> statements can be nested to create an <code>else if</code> clause. Note that there is no <code>elseif</code> (in one word) keyword in JavaScript.</p> <pre data-language=\"js\">if (<var>condition1</var>)\n   <var>statement1</var>\nelse if (<var>condition2</var>)\n   <var>statement2</var>\nelse if (<var>condition3</var>)\n   <var>statement3</var>\n...\nelse\n   <var>statementN</var>\n</pre> <p>To see how this works, this is how it would look if the nesting were properly indented:</p> <pre data-language=\"js\">if (<var>condition1</var>)\n   <var>statement1</var>\nelse\n   if (<var>condition2</var>)\n      <var>statement2</var>\n   else\n      if (<var>condition3</var>)\n...\n</pre> <p>To execute multiple statements within a clause, use a block statement (<code>{ ... }</code>) to group those statements. In general, it is a good practice to always use block statements, especially in code involving nested <code>if</code> statements:</p> <pre data-language=\"js\">if (<var>condition</var>) {\n   <var>statements1</var>\n} else {\n   <var>statements2</var>\n}\n</pre> <p>Do not confuse the primitive boolean values <code>true</code> and <code>false</code> with truthiness or falsiness of the <a href=\"../global_objects/boolean\"><code>Boolean</code></a> object. Any value that is not <code>false</code>, <code>undefined</code>, <code>null</code>, <code>0</code>, <code>NaN</code>, or the empty string (<code>\"\"</code>), and any object, including a Boolean object whose value is false, is considered <a href=\"https://developer.mozilla.org/en-US/docs/Glossary/truthy\">truthy</a> when used as the condition. For example:</p> <pre data-language=\"js\">var b = new Boolean(false);\nif (b) // this condition is truthy\n</pre> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Using_if...else\">Using <code>if...else</code>\n</h3> <pre data-language=\"js\">if (cipher_char === from_char) {\n   result = result + to_char;\n   x++;\n} else {\n   result = result + clear_char;\n}\n</pre> <h3 id=\"Using_else_if\">Using <code>else if</code>\n</h3> <p>Note that there is no <code>elseif</code> syntax in JavaScript. However, you can write it with a space between <code>else</code> and <code>if</code>:</p> <pre data-language=\"js\">if (x &gt; 5) {\n /* do the right thing */\n} else if (x &gt; 50) {\n /* do the right thing */\n} else {\n /* do the right thing */\n}</pre> <h3 id=\"Assignment_within_the_conditional_expression\">Assignment within the conditional expression</h3> <p>It is advisable to not use simple assignments in a conditional expression, because the assignment can be confused with equality when glancing over the code. For example, do not use the following code:</p> <pre data-language=\"js\">if (x = y) {\n   /* do the right thing */\n}\n</pre> <p>If you need to use an assignment in a conditional expression, a common practice is to put additional parentheses around the assignment. For example:</p> <pre data-language=\"js\">if ((x = y)) {\n   /* do the right thing */\n}\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-if-statement\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'if statement' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-if-statement\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'if statement' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/5.1/#sec-12.5\" hreflang=\"en\">ECMAScript 5.1 (ECMA-262)<br><small>The definition of 'if statement' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/publications/files/ECMA-ST-ARCH/ECMA-262,%203rd%20edition,%20December%201999.pdf#sec-12.5\" hreflang=\"en\">ECMAScript 3rd Edition (ECMA-262)<br><small>The definition of 'if statement' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/publications/files/ECMA-ST-ARCH/ECMA-262,%201st%20edition,%20June%201997.pdf#sec-12.5\" hreflang=\"en\">ECMAScript 1st Edition (ECMA-262)<br><small>The definition of 'if statement' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition</td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"block\"><code>block</code></a></li> <li><a href=\"switch\"><code>switch</code></a></li> <li><a href=\"../operators/conditional_operator\">conditional operator</a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/if...else$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/if...else\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/if...else</a>\n  </p>\n</div>\n","statements/for-await...of":"<h1>for-await...of</h1> <p>The <code>for await...of</code>creates a loop iterating over async iterable objects as well as on sync iterables, including: built-in <a href=\"../global_objects/string\"><code>String</code></a>, <a href=\"../global_objects/array\"><code>Array</code></a>, <code>Array</code>-like objects (e.g., <a href=\"../functions/arguments\"><code>arguments</code></a> or <a href=\"https://developer.mozilla.org/en-US/docs/Web/API/NodeList\"><code>NodeList</code></a>), <a href=\"../global_objects/typedarray\"><code>TypedArray</code></a>, <a href=\"../global_objects/map\"><code>Map</code></a>, <a href=\"../global_objects/set\"><code>Set</code></a>, and user-defined async/sync iterables. It invokes a custom iteration hook with statements to be executed for the value of each distinct property of the object.</p>   <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\">for await (<em>variable</em> of <em>iterable</em>) {\n  <em>statement\n</em>}\n</pre> <dl> <dt><code>variable</code></dt> <dd>On each iteration a value of a different property is assigned to <em>variable</em>.</dd> <dt><code>iterable</code></dt> <dd>Object whose iterable properties are iterated.</dd>  </dl> <h3 id=\"Iterating_over_async_iterables\">Iterating over async iterables</h3> <p>You can also iterate over an object that explicitly implements async iterable protocol:</p> <pre data-language=\"js\">var asyncIterable = {\n  [Symbol.asyncIterator]() {\n    return {\n      i: 0,\n      next() {\n        if (this.i &lt; 3) {\n          return Promise.resolve({ value: this.i++, done: false });\n        }\n\n        return Promise.resolve({ done: true });\n      }\n    };\n  }\n};\n\n(async function() {\n   for await (num of asyncIterable) {\n     console.log(num);\n   }\n})();\n// 0\n// 1\n// 2\n</pre>  <h3 id=\"Iterating_over_async_generators\">Iterating over async generators</h3> <p>Since async generators implement async Iterator protocol, they can be looped using <code>for await...of</code></p> <pre>async function* asyncGenerator() {\n  var i = 0;\n  while (i &lt; 3) {\n    yield i++;\n  }\n}\n\n(async function() {\n  for await (num of asyncGenerator()) {\n    console.log(num);\n  }\n})();\n// 0\n// 1\n// 2</pre>  <h2 id=\"Specifications\">Specifications</h2>  <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-for-in-and-for-of-statements\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'ECMAScript Language: The for-in, for-of, and for-await-of Statements' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility</h2>   <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"for...of\"><code>Statements/for...of</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/for-await...of$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/for-await...of\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/for-await...of</a>\n  </p>\n</div>\n","statements/for...of":"<h1>for...of</h1> <p>The <code>for...of</code>creates a loop iterating over <a href=\"../iteration_protocols#The_iterable_protocol\">iterable objects</a>, including: built-in <a href=\"../global_objects/string\"><code>String</code></a>, <a href=\"../global_objects/array\"><code>Array</code></a>, <code>Array</code>-like objects (e.g., <a href=\"../functions/arguments\"><code>arguments</code></a> or <a href=\"https://developer.mozilla.org/en-US/docs/Web/API/NodeList\"><code>NodeList</code></a>), <a href=\"../global_objects/typedarray\"><code>TypedArray</code></a>, <a href=\"../global_objects/map\"><code>Map</code></a>, <a href=\"../global_objects/set\"><code>Set</code></a>, and user-defined iterables. It invokes a custom iteration hook with statements to be executed for the value of each distinct property of the object.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/statement-forof.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\">for (<em>variable</em> of <em>iterable</em>) {\n  <em>statement\n</em>}\n</pre> <dl> <dt><code>variable</code></dt> <dd>On each iteration a value of a different property is assigned to <em>variable</em>.</dd> <dt><code>iterable</code></dt> <dd>Object whose iterable properties are iterated.</dd> </dl> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Iterating_over_an_Array\">Iterating over an <a href=\"../global_objects/array\"><code>Array</code></a>\n</h3> <pre data-language=\"js\">let iterable = [10, 20, 30];\n\nfor (let value of iterable) {\n  value += 1;\n  console.log(value);\n}\n// 11\n// 21\n// 31\n</pre> <p>You can use <a href=\"const\"><code>const</code></a> instead of <a href=\"let\"><code>let</code></a> too, if you don't reassign the variable inside the block.</p> <pre data-language=\"js\">let iterable = [10, 20, 30];\n\nfor (const value of iterable) {\n  console.log(value);\n}\n// 10\n// 20\n// 30\n</pre> <h3 id=\"Iterating_over_a_String\">Iterating over a <a href=\"../global_objects/string\"><code>String</code></a>\n</h3> <pre data-language=\"js\">let iterable = 'boo';\n\nfor (let value of iterable) {\n  console.log(value);\n}\n// \"b\"\n// \"o\"\n// \"o\"\n</pre> <h3 id=\"Iterating_over_a_TypedArray\">Iterating over a <a href=\"../global_objects/typedarray\"><code>TypedArray</code></a>\n</h3> <pre data-language=\"js\">let iterable = new Uint8Array([0x00, 0xff]);\n\nfor (let value of iterable) {\n  console.log(value);\n}\n// 0\n// 255\n</pre> <h3 id=\"Iterating_over_a_Map\">Iterating over a <a href=\"../global_objects/map\"><code>Map</code></a>\n</h3> <pre data-language=\"js\">let iterable = new Map([['a', 1], ['b', 2], ['c', 3]]);\n\nfor (let entry of iterable) {\n  console.log(entry);\n}\n// ['a', 1]\n// ['b', 2]\n// ['c', 3]\n\nfor (let [key, value] of iterable) {\n  console.log(value);\n}\n// 1\n// 2\n// 3\n</pre> <h3 id=\"Iterating_over_a_Set\">Iterating over a <a href=\"../global_objects/set\"><code>Set</code></a>\n</h3> <pre data-language=\"js\">let iterable = new Set([1, 1, 2, 2, 3, 3]);\n\nfor (let value of iterable) {\n  console.log(value);\n}\n// 1\n// 2\n// 3\n</pre> <h3 id=\"Iterating_over_the_arguments_object\">Iterating over the arguments object</h3> <p>You can iterate over the <a href=\"../functions/arguments\"><code>arguments</code></a> object to examine all of the parameters passed into a JavaScript function:</p> <pre data-language=\"js\">(function() {\n  for (let argument of arguments) {\n    console.log(argument);\n  }\n})(1, 2, 3);\n\n// 1\n// 2\n// 3</pre> <h3 id=\"Iterating_over_a_DOM_collection\">Iterating over a DOM collection</h3> <p>Iterating over DOM collections like <a href=\"https://developer.mozilla.org/en-US/docs/Web/API/NodeList\"><code>NodeList</code></a>: the following example adds a <code>read</code> class to paragraphs that are direct descendants of an article:</p> <pre data-language=\"js\">// Note: This will only work in platforms that have\n// implemented NodeList.prototype[Symbol.iterator]\nlet articleParagraphs = document.querySelectorAll('article &gt; p');\n\nfor (let paragraph of articleParagraphs) {\n  paragraph.classList.add('read');\n}\n</pre> <h3 id=\"Closing_iterators\">Closing iterators</h3> <p>In <code>for...of</code> loops, abrupt iteration termination can be caused by <code>break</code>, <code>continue</code>, <code>throw</code> or <code>return</code>. In these cases, the iterator is closed.</p> <pre data-language=\"js\">function* foo(){ \n  yield 1; \n  yield 2; \n  yield 3; \n}; \n\nfor (let o of foo()) { \n  console.log(o); \n  break; // closes iterator, triggers return\n}</pre> <h3 id=\"Iterating_over_generators\">Iterating over generators</h3> <p>You can also iterate over <a href=\"function*\">generators</a>, i.e. functions generating an iterable object:</p> <pre data-language=\"js\">function* fibonacci() { // a generator function\n  let [prev, curr] = [0, 1];\n  while (true) {\n    [prev, curr] = [curr, prev + curr];\n    yield curr;\n  }\n}\n\nfor (let n of fibonacci()) {\n  console.log(n);\n  // truncate the sequence at 1000\n  if (n &gt;= 1000) {\n    break;\n  }\n}\n</pre> <h4 id=\"Do_not_reuse_generators\">Do not reuse generators</h4> <p>Generators should not be re-used, even if the <code>for...of</code> loop is terminated early, for example via the <a href=\"break\"><code>break</code></a> keyword. Upon exiting a loop, the generator is closed and trying to iterate over it again does not yield any further results.</p> <pre data-language=\"js\">var gen = (function *(){\n  yield 1;\n  yield 2;\n  yield 3;\n})();\nfor (let o of gen) {\n  console.log(o);\n  break;  // Closes iterator\n}\n\n// The generator should not be re-used, the following does not make sense!\nfor (let o of gen) {\n  console.log(o); // Never called.\n}\n</pre> <h3 id=\"Iterating_over_other_iterable_objects\">Iterating over other iterable objects</h3> <p>You can also iterate over an object that explicitly implements <a href=\"../iteration_protocols#iterable\">iterable</a> protocol:</p> <pre data-language=\"js\">var iterable = {\n  [Symbol.iterator]() {\n    return {\n      i: 0,\n      next() {\n        if (this.i &lt; 3) {\n          return { value: this.i++, done: false };\n        }\n        return { value: undefined, done: true };\n      }\n    };\n  }\n};\n\nfor (var value of iterable) {\n  console.log(value);\n}\n// 0\n// 1\n// 2\n</pre> <p>Difference between <code>for...of</code> and <code>for...in</code></p> <p>Both <code>for...in</code> and <code>for...of</code> statements iterate over something. The main difference between them is in what they iterate over.</p> <p>The <a href=\"for...in\"><code>for...in</code></a> statement iterates over the <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Enumerability_and_ownership_of_properties\">enumerable properties</a> of an object, in an arbitrary order.</p> <p>The <code>for...of</code> statement iterates over data that <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Iterators_and_Generators#Iterables\">iterable object</a> defines to be iterated over.</p> <p>The following example shows the difference between a <code>for...of</code> loop and a <code>for...in</code> loop when used with an <a href=\"../global_objects/array\"><code>Array</code></a>.</p> <pre data-language=\"js\">Object.prototype.objCustom = function() {}; \nArray.prototype.arrCustom = function() {};\n\nlet iterable = [3, 5, 7];\niterable.foo = 'hello';\n\nfor (let i in iterable) {\n  console.log(i); // logs 0, 1, 2, \"foo\", \"arrCustom\", \"objCustom\"\n}\n\nfor (let i in iterable) {\n  if (iterable.hasOwnProperty(i)) {\n    console.log(i); // logs 0, 1, 2, \"foo\"\n  }\n}\n\nfor (let i of iterable) {\n  console.log(i); // logs 3, 5, 7\n}\n</pre> <p>Let us look into the above code step by step.</p> <pre data-language=\"js\">Object.prototype.objCustom = function() {};\nArray.prototype.arrCustom = function() {}; \n\nlet iterable = [3, 5, 7]; \niterable.foo = 'hello';</pre> <p>Every object will inherit <code>objCustom</code> property and every object that is an <a href=\"../global_objects/array\"><code>Array</code></a> will inherit <code>arrCustom</code> property because of adding those properties to <a href=\"../global_objects/object/prototype\"><code>Object.prototype</code></a> and <a href=\"../global_objects/array/prototype\"><code>Array.prototype</code></a>. The object <code>iterable</code> inherits properties <code>objCustom</code> and <code>arrCustom</code> because of <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Inheritance_and_the_prototype_chain\">inheritance and the prototype chain</a>.</p> <pre data-language=\"js\">for (let i in iterable) {\n  console.log(i); // logs 0, 1, 2, \"foo\", \"arrCustom\", \"objCustom\" \n}</pre> <p>This loop logs only <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Enumerability_and_ownership_of_properties\">enumerable properties</a> of <code>iterable</code> object, in original insertion order. It doesn't log array <strong>elements</strong> <code>3</code>, <code>5</code>, <code>7</code> or <code>hello</code> because those are <strong>not</strong> enumerable properties. But it logs array <strong>indexes</strong> as well as <code>arrCustom</code> and <code>objCustom</code>, which are. If you're not sure why the properties are iterated over, there's a more thorough explanation of how <a href=\"for...in#Array_iteration_and_for...in\"><code>array iteration and for...in</code></a> work.</p> <pre data-language=\"js\">for (let i in iterable) {\n  if (iterable.hasOwnProperty(i)) {\n    console.log(i); // logs 0, 1, 2, \"foo\"\n  }\n}</pre> <p>This loop is similar to the first one, but it uses <a href=\"../global_objects/object/hasownproperty\"><code>hasOwnProperty()</code></a> to check, if the found enumerable property is object's own (not inherited). And if it is, the property is logged. Properties <code>0</code>, <code>1</code>, <code>2</code> and <code>foo</code> are logged because they are own properties (<strong>not inherited</strong>). Properties <code>arrCustom</code> and <code>objCustom</code> are not logged because they <strong>are inherited</strong>.</p> <pre data-language=\"js\">for (let i of iterable) {\n  console.log(i); // logs 3, 5, 7 \n}</pre> <p>This loop iterates and logs values that <code>iterable</code> as an <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Iterators_and_Generators#Iterables\">iterable object</a>defines to be iterated over, which are array elements <code>3</code>, <code>5</code>, <code>7</code> and not any of object's <strong>properties</strong>.</p> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-for-in-and-for-of-statements\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'for...of statement' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-for-in-and-for-of-statements\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'for...of statement' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 38</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes bc-has-history\"> 13\n<section class=\"bc-history\" id=\"sect1\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 13\n</dt>\n<dd> Prior to Firefox 51, using the <code>for...of</code> loop construct with the <code>const</code> keyword threw a <code>SyntaxError</code> (\"missing = in const declaration\").</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 25</td>\n<td class=\"bc-supports-yes\"> 8</td>\n</tr>\n<tr>\n<th scope=\"row\">async iterators</th>\n<td class=\"bc-supports-yes\"> 63</td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 57</td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 50</td>\n<td> ? </td>\n</tr>\n<tr>\n<th scope=\"row\">Closing iterators</th>\n<td class=\"bc-supports-yes\"> 51</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 53</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n</tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 38</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes bc-has-history\"> 14\n<section class=\"bc-history\" id=\"sect2\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 14\n</dt>\n<dd> Prior to Firefox 51, using the <code>for...of</code> loop construct with the <code>const</code> keyword threw a <code>SyntaxError</code> (\"missing = in const declaration\").</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-yes\"> 25</td>\n<td class=\"bc-supports-yes\"> 8</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">async iterators</th>\n<td class=\"bc-supports-yes\"> 63</td>\n<td class=\"bc-supports-yes\"> 63</td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 57</td>\n<td class=\"bc-supports-yes\"> 50</td>\n<td> ? </td>\n<td> ? </td>\n</tr>\n<tr>\n<th scope=\"row\">Closing iterators</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 53</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n</tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">async iterators</th>\n<td> ? </td>\n</tr>\n<tr>\n<th scope=\"row\">Closing iterators</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n</tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"../global_objects/array/foreach\"><code>Array.prototype.forEach()</code></a></li> <li><a href=\"../global_objects/map/foreach\"><code>Map.prototype.forEach()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/for...of$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/for...of\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/for...of</a>\n  </p>\n</div>\n","statements/import":"<h1>import</h1> <p>The static <code><strong>import</strong></code> statement is used to import bindings which are exported by another module. Imported modules are in <a href=\"../strict_mode\"><code>strict mode</code></a> whether you declare them as such or not. The <code>import</code> statement cannot be used in embedded scripts unless such script has a <code>type=\"module\"</code>.</p> <p>There is also a function-like dynamic <code><strong>import()</strong></code>, which does not require scripts of <code>type=\"module\"</code>.</p> <p>Dynamic import is useful in situations where you wish to load a module conditionally, or on demand. The static form is preferable for loading initial dependencies, and can benefit more readily from static analysis tools and <a href=\"https://developer.mozilla.org/en-US/docs/Glossary/Tree_shaking\">tree shaking</a>.</p> <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\">import <em>defaultExport</em> from \"<em>module-name</em>\";\nimport * as <em>name</em> from \"<em>module-name</em>\";\nimport { <em>export </em>} from \"<em>module-name</em>\";\nimport { <em>export</em> as <em>alias </em>} from \"<em>module-name</em>\";\nimport { <em>export1 , export2</em> } from \"<em>module-name</em>\";\nimport { <em>foo , bar</em> } from \"<em>module-name/path/to/specific/un-exported/file</em>\";\nimport { <em>export1 , export2</em> as <em>alias2</em> , <em>[...]</em> } from \"<em>module-name</em>\";\nimport <em>defaultExport</em>, { <em>export</em> [ , <em>[...]</em> ] } from \"<em>module-name</em>\";\nimport <em>defaultExport</em>, * as <em>name</em> from \"<em>module-name</em>\";\nimport \"<em>module-name</em>\";\nvar <em>promise</em> = import(\"module-name\");</pre> <dl> <dt><code>defaultExport</code></dt> <dd>Name that will refer to the default export from the module.</dd> <dt><code>module-name</code></dt> <dd>The module to import from. This is often a relative or absolute path name to the <code>.js</code> file containing the module. Certain bundlers may permit or require the use of the extension; check your environment. Only single quotes and double quotes Strings are allowed.</dd> <dt><code>name</code></dt> <dd>Name of the module object that will be used as a kind of namespace when referring to the imports.</dd> <dt><code>export, exportN</code></dt> <dd>Name of the exports to be imported.</dd> <dt><code>alias, aliasN</code></dt> <dd>Names that will refer to the named imports.</dd> </dl> <h2 id=\"Description\">Description</h2> <p>The <code>name</code> parameter is the name of the \"module object\" which will be used as a kind of namespace to refer to the exports. The <code>export</code> parameters specify individual named exports, while the <code>import * as name</code> syntax imports all of them. Below are examples to clarify the syntax.</p> <h3 id=\"Import_an_entire_module's_contents\">Import an entire module's contents</h3> <p>This inserts <code>myModule</code> into the current scope, containing all the exports from the module in the file located in <code>/modules/my-module.js</code>.</p> <pre data-language=\"js\">import * as <em>myModule</em> from '/modules/my-module.js';\n</pre> <p>Here, accessing the exports means using the module name (\"myModule\" in this case) as a namespace. For example, if the module imported above includes an export <code>doAllTheAmazingThings()</code>, you would call it like this:</p> <pre data-language=\"js\">myModule.doAllTheAmazingThings();</pre> <h3 id=\"Import_a_single_export_from_a_module\">Import a single export from a module</h3> <p>Given an object or value named <code>myExport</code> which has been exported from the module <code>my-module</code> either implicitly (because the entire module is exported) or explicitly (using the <a href=\"export\"><code>export</code></a> statement), this inserts <code>myExport</code> into the current scope.</p> <pre data-language=\"js\">import {myExport} from '/modules/my-module.js';</pre> <h3 id=\"Import_multiple_exports_from_module\">Import multiple exports from module</h3> <p>This inserts both <code>foo</code> and <code>bar</code> into the current scope.</p> <pre data-language=\"js\">import {foo, bar} from '/modules/my-module.js';</pre> <h3 id=\"Import_an_export_with_a_more_convenient_alias\">Import an export with a more convenient alias</h3> <p>You can rename an export when importing it. For example, this inserts <code>shortName</code> into the current scope.</p> <pre data-language=\"js\">import {reallyReallyLongModuleExportName as shortName}\n  from '/modules/my-module.js';</pre> <h3 id=\"Rename_multiple_exports_during_import\">Rename multiple exports during import</h3> <p>Import multiple exports from a module with convenient aliases.</p> <pre data-language=\"js\">import {\n  reallyReallyLongModuleExportName as shortName,\n  anotherLongModuleName as short\n} from '/modules/my-module.js';</pre> <h3 id=\"Import_a_module_for_its_side_effects_only\">Import a module for its side effects only</h3> <p>Import an entire module for side effects only, without importing anything. This runs the module's global code, but doesn't actually import any values.</p> <pre data-language=\"js\">import '/modules/my-module.js';\n</pre> <h3 id=\"Importing_defaults\">Importing defaults</h3> <p>It is possible to have a default <a href=\"export\"><code>export</code></a> (whether it is an object, a function, a class, etc.). The <code>import</code> statement may then be used to import such defaults.</p> <p>The simplest version directly imports the default:</p> <pre data-language=\"js\">import myDefault from '/modules/my-module.js';</pre> <p>It is also possible to use the default syntax with the ones seen above (namespace imports or named imports). In such cases, the default import will have to be declared first. For instance:</p> <pre data-language=\"js\">import myDefault, * as myModule from '/modules/my-module.js';\n// myModule used as a namespace</pre> <p>or</p> <pre data-language=\"js\">import myDefault, {foo, bar} from '/modules/my-module.js';\n// specific, named imports\n</pre> <h3 id=\"Dynamic_Imports\">Dynamic Imports</h3> <p>The <code>import</code> keyword may be called as a function to dynamically import a module. When used this way, it returns a promise.</p> <pre data-language=\"js\">import('/modules/my-module.js')\n  .then((module) =&gt; {\n    // Do something with the module.\n  });\n</pre> <p>This form also supports the await keyword.</p> <pre data-language=\"js\">let module = await import('/modules/my-module.js');</pre> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Standard_Import\">Standard Import</h3> <p>The code below shows how to import from a secondary module to assist in processing an AJAX JSON request.</p> <h4 id=\"The_module_file.js\">The module: file.js</h4> <pre data-language=\"js\">function getJSON(url, callback) {\n  let xhr = new XMLHttpRequest();\n  xhr.onload = function () { \n    callback(this.responseText) \n  };\n  xhr.open('GET', url, true);\n  xhr.send();\n}\n\nexport function getUsefulContents(url, callback) {\n  getJSON(url, data =&gt; callback(JSON.parse(data)));\n}</pre> <h4 id=\"The_main_program_main.js\">The main program: main.js</h4> <pre data-language=\"js\">import { getUsefulContents } from '/modules/file.js';\n\ngetUsefulContents('http://www.example.com',\n    data =&gt; { doSomethingUseful(data); });</pre> <h3 id=\"Dynamic_Import\">Dynamic Import</h3> <p>This example shows how to load functionality on to a page based on a user action, in this case a button click, and then call a function within that module. This is not the only way to implement this functionality. The <code>import()</code> function also supports <code>await</code>.</p> <pre data-language=\"js\">const main = document.querySelector(\"main\");\nfor (const link of document.querySelectorAll(\"nav &gt; a\")) {\n  link.addEventListener(\"click\", e =&gt; {\n    e.preventDefault();\n\n    import('/modules/my-module.js')\n      .then(module =&gt; {\n        module.loadPageInto(main);\n      })\n      .catch(err =&gt; {\n        main.textContent = err.message;\n      });\n  });\n}</pre>  <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <thead> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> </thead> <tbody> <tr> <td><a href=\"https://github.com/tc39/proposal-dynamic-import/#import\">\"function-like\" dynamic <code>import()</code> proposal</a></td> <td>Stage 3</td> <td> </td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-imports\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Imports' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/9.0/#sec-imports\" hreflang=\"en\">ECMAScript 2018 (ECMA-262)<br><small>The definition of 'Imports' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/8.0/#sec-imports\" hreflang=\"en\">ECMAScript 2017 (ECMA-262)<br><small>The definition of 'Imports' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/7.0/#sec-imports\" hreflang=\"en\">ECMAScript 2016 (ECMA-262)<br><small>The definition of 'Imports' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-imports\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Imports' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 61</td>\n<td class=\"bc-supports-yes bc-has-history\"> 16\n<section class=\"bc-history\" id=\"sect1\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 16\n</dt>\n\n<dt class=\"bc-supports-yes bc-supports\"> 15<div class=\"bc-icons\">Disabled </div>\n</dt>\n<dd>Disabled From version 15: this feature is behind the <code>Experimental JavaScript Features</code> preference.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-yes bc-has-history\"> 60\n<section class=\"bc-history\" id=\"sect2\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 60\n</dt>\n\n<dt class=\"bc-supports-no bc-supports\">54 — 60<div class=\"bc-icons\">Disabled </div>\n</dt>\n<dd>Disabled From version 54 until version 60 (exclusive): this feature is behind the <code>dom.moduleScripts.enabled</code> preference. To change preferences in Firefox, visit about:config.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 47</td>\n<td class=\"bc-supports-yes\"> 10.1</td>\n</tr>\n<tr>\n<th scope=\"row\">Dynamic import</th>\n<td class=\"bc-supports-yes\"> 63</td>\n<td class=\"bc-supports-no bc-has-history\"> No\n<section class=\"bc-history\" id=\"sect5\"><dl>\n<dt class=\"bc-supports-no bc-supports\"> No\n</dt>\n<dd> See <a href=\"https://developer.microsoft.com/en-us/microsoft-edge/platform/status/javascriptmoduleimport/\">development status</a>.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-no bc-has-history\"> No\n<section class=\"bc-history\" id=\"sect6\"><dl>\n<dt class=\"bc-supports-no bc-supports\"> No\n</dt>\n<dd> See <a href=\"https://bugzil.la/1342012\">bug 1342012</a>.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 50</td>\n<td class=\"bc-supports-yes\"> 11.1</td>\n</tr>\n</tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 61</td>\n<td class=\"bc-supports-yes\"> 61</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes bc-has-history\"> 60\n<section class=\"bc-history\" id=\"sect3\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 60\n</dt>\n\n<dt class=\"bc-supports-no bc-supports\">54 — 60<div class=\"bc-icons\">Disabled </div>\n</dt>\n<dd>Disabled From version 54 until version 60 (exclusive): this feature is behind the <code>dom.moduleScripts.enabled</code> preference. To change preferences in Firefox, visit about:config.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-yes\"> 47</td>\n<td class=\"bc-supports-yes\"> 10.1</td>\n<td class=\"bc-supports-no\"> No</td>\n</tr>\n<tr>\n<th scope=\"row\">Dynamic import</th>\n<td class=\"bc-supports-yes\"> 63</td>\n<td class=\"bc-supports-yes\"> 63</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no bc-has-history\"> No\n<section class=\"bc-history\" id=\"sect7\"><dl>\n<dt class=\"bc-supports-no bc-supports\"> No\n</dt>\n<dd> See <a href=\"https://bugzil.la/1342012\">bug 1342012</a>.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-yes\"> 50</td>\n<td class=\"bc-supports-yes\"> 11.1</td>\n<td> ? </td>\n</tr>\n</tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes bc-has-history\"> 8.5.0<div class=\"bc-icons\"> Disabled </div>\n<section class=\"bc-history\" id=\"sect4\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 8.5.0<div class=\"bc-icons\"> Disabled </div>\n</dt>\n<dd> files must have suffix .mjs, not .js</dd>\n<dd>Disabled From version 8.5.0: this feature is behind the <code>--experimental-modules</code> runtime flag.</dd>\n</dl></section>\n</td>\n</tr>\n<tr>\n<th scope=\"row\">Dynamic import</th>\n<td> ? </td>\n</tr>\n</tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"export\"><code>export</code></a></li> <li><a href=\"import.meta\"><code>import.meta</code></a></li> <li><a href=\"https://blogs.windows.com/msedgedev/2016/05/17/es6-modules-and-beyond/\">Previewing ES6 Modules and more from ES2015, ES2016 and beyond</a></li> <li>\n<a href=\"https://hacks.mozilla.org/2015/08/es6-in-depth-modules/\">ES6 in Depth: Modules</a>, Hacks blog post by Jason Orendorff</li> <li>\n<a href=\"https://hacks.mozilla.org/2018/03/es-modules-a-cartoon-deep-dive/\">ES modules: A cartoon deep-dive</a>, Hacks blog post by Lin Clark</li> <li><a href=\"http://exploringjs.com/es6/ch_modules.html\">Axel Rauschmayer's book: \"Exploring JS: Modules\"</a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/import$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/import\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/import</a>\n  </p>\n</div>\n","statements/function":"<h1>function</h1> <p>The <strong>function declaration</strong> (function statement) defines a function with the specified parameters.</p> <p>You can also define functions using the <a href=\"../global_objects/function\"><code>Function</code></a> constructor and a <a href=\"../operators/function\"><code>function expression</code></a>.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/statement-function.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\">function <em>name</em>([<em>param</em>[, <em>param</em>,[..., <em>param</em>]]]) {\n   [<em>statements</em>]\n}\n</pre> <dl> <dt><code>name</code></dt> <dd>The function name.</dd> </dl> <dl> <dt><code>param</code></dt> <dd>The name of an argument to be passed to the function. Maximum number of arguments varies in different engines.</dd> </dl> <dl> <dt><code>statements</code></dt> <dd>The statements which comprise the body of the function.</dd> </dl> <h2 id=\"Description\">Description</h2> <p>A function created with a function declaration is a <code>Function</code> object and has all the properties, methods and behavior of <code>Function</code> objects. See <a href=\"../global_objects/function\"><code>Function</code></a> for detailed information on functions.</p> <p>A function can also be created using an expression (see <a href=\"../operators/function\"><code>function expression</code></a>).</p> <p>By default, functions return <code>undefined</code>. To return any other value, the function must have a <a href=\"return\"><code>return</code></a> statement that specifies the value to return.</p> <h3 id=\"Conditionally_created_functions\">Conditionally created functions</h3> <p>Functions can be conditionally declared, that is, a function statement can be nested within an <code>if</code> statement, however the results are inconsistent across implementations and therefore this pattern should not be used in production code. For conditional function creation, use function expressions instead.</p> <pre data-language=\"js\">var hoisted = \"foo\" in this;\nconsole.log(`'foo' name ${hoisted ? \"is\" : \"is not\"} hoisted. typeof foo is ${typeof foo}`);\nif (false) {\n  function foo(){ return 1; }\n}\n\n// In Chrome: \n// 'foo' name is hoisted. typeof foo is undefined\n// \n// In Firefox:\n// 'foo' name is hoisted. typeof foo is undefined\n//\n// In Edge:\n// 'foo' name is not hoisted. typeof foo is undefined\n// \n// In Safari:\n// 'foo' name is hoisted. typeof foo is function\n</pre> <p>The results are exactly the same for a condition that evaluates to true</p> <pre data-language=\"js\">var hoisted = \"foo\" in this;\nconsole.log(`'foo' name ${hoisted ? \"is\" : \"is not\"} hoisted. typeof foo is ${typeof foo}`);\nif (true) {\n  function foo(){ return 1; }\n}\n\n// In Chrome: \n// 'foo' name is hoisted. typeof foo is undefined\n// \n// In Firefox:\n// 'foo' name is hoisted. typeof foo is undefined\n//\n// In Edge:\n// 'foo' name is not hoisted. typeof foo is undefined\n// \n// In Safari:\n// 'foo' name is hoisted. typeof foo is function\n</pre> <h3 id=\"Function_declaration_hoisting\">Function declaration hoisting</h3> <p>Function declarations in JavaScript are hoisted to the top of the enclosing function or global scope. You can use the function before you declared it:</p> <pre data-language=\"js\">hoisted(); // logs \"foo\"\n\nfunction hoisted() {\n  console.log('foo');\n}\n</pre> <p>Note that <a href=\"../operators/function\"><code>function expressions</code></a> are not hoisted:</p> <pre data-language=\"js\">notHoisted(); // TypeError: notHoisted is not a function\n\nvar notHoisted = function() {\n   console.log('bar');\n};\n</pre> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Using_function\">Using <code>function</code>\n</h3> <p>The following code declares a function that returns the total amount of sales, when given the number of units sold of products <code>a</code>, <code>b</code>, and <code>c</code>.</p> <pre data-language=\"js\">function calc_sales(units_a, units_b, units_c) {\n   return units_a * 79 + units_b * 129 + units_c * 699;\n}\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-function-definitions\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Function definitions' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-function-definitions\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Function definitions' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/5.1/#sec-13\" hreflang=\"en\">ECMAScript 5.1 (ECMA-262)<br><small>The definition of 'Function definition' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/publications/files/ECMA-ST-ARCH/ECMA-262,%203rd%20edition,%20December%201999.pdf#sec-13\" hreflang=\"en\">ECMAScript 3rd Edition (ECMA-262)<br><small>The definition of 'Function definition' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/publications/files/ECMA-ST-ARCH/ECMA-262,%201st%20edition,%20June%201997.pdf#sec-13\" hreflang=\"en\">ECMAScript 1st Edition (ECMA-262)<br><small>The definition of 'Function definition' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition. Implemented in JavaScript 1.0.</td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">Allowed in sloppy mode</th>\n<td class=\"bc-supports-yes\"> 49</td>\n<td> ? </td>\n<td> ? </td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td> ? </td>\n</tr>\n<tr>\n<th scope=\"row\">Trailing comma in parameters</th>\n<td class=\"bc-supports-yes\"> 58</td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 52</td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 45</td>\n<td> ? </td>\n</tr>\n</tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">Allowed in sloppy mode</th>\n<td> ? </td>\n<td> ? </td>\n<td> ? </td>\n<td> ? </td>\n<td> ? </td>\n<td> ? </td>\n<td> ? </td>\n</tr>\n<tr>\n<th scope=\"row\">Trailing comma in parameters</th>\n<td class=\"bc-supports-yes\"> 58</td>\n<td class=\"bc-supports-yes\"> 58</td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 52</td>\n<td class=\"bc-supports-yes\"> 45</td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 7.0</td>\n</tr>\n</tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">Allowed in sloppy mode</th>\n<td> ? </td>\n</tr>\n<tr>\n<th scope=\"row\">Trailing comma in parameters</th>\n<td class=\"bc-supports-yes\"> 8.0.0</td>\n</tr>\n</tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions\"><code>Functions and function scope</code></a></li> <li><a href=\"../global_objects/function\"><code>Function</code></a></li> <li><a href=\"../operators/function\"><code>function expression</code></a></li> <li><a href=\"function*\"><code>function* statement</code></a></li> <li><a href=\"../operators/function*\"><code>function* expression</code></a></li> <li><a href=\"../functions/arrow_functions\"><code>Arrow functions</code></a></li> <li><a href=\"../global_objects/generatorfunction\"><code>GeneratorFunction</code></a></li> <li><a href=\"async_function\"><code>async function</code></a></li> <li><a href=\"../operators/async_function\"><code>async function expression</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/function$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/function\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/function</a>\n  </p>\n</div>\n","statements/import.meta":"<h1>import.meta</h1> <p>The<code>import.meta</code> object is a meta-property exposing context-specific meta data to a JavaScript module. It contains information about the module, like the module's URL.</p> <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\">import.meta</pre> <h2 id=\"Description\">Description</h2> <p>The <code>import.meta</code> object consists of the keyword <a href=\"import\"><code>import</code></a>, a dot, and a property name <code>meta</code>. Normally <code>import.</code> serves as the context for a property access, but here <code>import.</code> is not really an object.</p> <p>The <code>import.meta</code> object is created by the ECMAScript implementation, with a <a href=\"../global_objects/null\"><code>null</code></a> prototype. The object is extensible, and its properties are writable, configurable, and enumerable.</p> <h2 id=\"Examples\">Examples</h2> <p>Given a module <code>my-module.js</code></p> <pre data-language=\"html\">&lt;script type=\"module\" src=\"my-module.js\"&gt;&lt;/script&gt;\n</pre> <p>you can can access meta information about the module using the <code>import.meta</code> object.</p> <pre data-language=\"js\">console.log(import.meta); // { url: \"file:///home/user/my-module.mjs\" }</pre> <p>It returns an object with a <code>url</code> property indicating the base URL of the module. This will either be the URL from which the script was obtained, for external scripts, or the document base URL of the containing document, for inline scripts.</p> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td>\n<code><a href=\"https://github.com/tc39/proposal-import-meta/#importmeta\">import.meta</a></code> proposal</td> <td>Stage 3</td> <td> </td> </tr> <tr> <td><a href=\"https://html.spec.whatwg.org/multipage/webappapis.html#hostgetimportmetaproperties\" hreflang=\"en\">HTML Living Standard<br><small>The definition of 'import.meta' in that specification.</small></a></td> <td><span class=\"spec-Living\">Living Standard</span></td> <td>Defines <code>import.meta</code> properties in HTML.</td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 64</td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 62</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 51</td>\n<td> ? </td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 64</td>\n<td class=\"bc-supports-yes\"> 64</td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 62</td>\n<td class=\"bc-supports-yes\"> 51</td>\n<td> ? </td>\n<td class=\"bc-supports-no\"> No</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td> ? </td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"import\"><code>import</code></a></li> <li><a href=\"export\"><code>export</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/import.meta$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/import.meta\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/import.meta</a>\n  </p>\n</div>\n","statements/switch":"<h1>switch</h1> <p>The <code>switch</code> evaluates an <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Expressions_and_Operators\">expression</a>, matching the expression's value to a <code>case</code> clause, and executes <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements\">statements</a> associated with that case, as well as statements in cases that follow the matching case.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/statement-switch.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre data-language=\"js\">switch (expression) {\n  case value1:\n    //Statements executed when the\n    //result of expression matches value1\n    [break;]\n  case value2:\n    //Statements executed when the\n    //result of expression matches value2\n    [break;]\n  ...\n  case valueN:\n    //Statements executed when the\n    //result of expression matches valueN\n    [break;]\n  [default:\n    //Statements executed when none of\n    //the values match the value of the expression\n    [break;]]\n}</pre> <dl> <dt><code>expression</code></dt> <dd>An expression whose result is matched against each case clause.</dd> <dt>\n<code>case valueN</code> <span class=\"inlineIndicator optional optionalInline\">Optional</span>\n</dt> <dd>A <code>case</code> clause used to match against <code>expression</code>. If the <code>expression</code> matches the specified <code>valueN</code>, the statements inside the case clause are executed until either the end of the <code>switch</code> statement or a <code>break</code>.</dd> <dt>\n<code>default</code> <span class=\"inlineIndicator optional optionalInline\">Optional</span>\n</dt> <dd>A <code>default</code> clause; if provided, this clause is executed if the value of <code>expression</code> doesn't match any of the <code>case</code> clauses.</dd> </dl> <h2 id=\"Description\">Description</h2> <p>A switch statement first evaluates its expression. It then looks for the first <code>case</code> clause whose expression evaluates to the same value as the result of the input expression (using the <a href=\"../operators/comparison_operators\">strict comparison</a>, <code>===</code>) and transfers control to that clause, executing the associated statements. (If multiple cases match the provided value, the first case that matches is selected, even if the cases are not equal to each other.)</p> <p>If no matching <code>case</code> clause is found, the program looks for the optional <code>default</code> clause, and if found, transfers control to that clause, executing the associated statements. If no <code>default</code> clause is found, the program continues execution at the statement following the end of <code>switch</code>. By convention, the <code>default</code> clause is the last clause, but it does not need to be so.</p> <p>The optional <code><a href=\"break\">break</a></code> statement associated with each case label ensures that the program breaks out of switch once the matched statement is executed and continues execution at the statement following switch. If <code>break</code> is omitted, the program continues execution at the next statement in the <code>switch</code> statement.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Using_switch\">Using <code>switch</code>\n</h3> <p>In the following example, if <code>expr</code> evaluates to \"Bananas\", the program matches the value with case \"Bananas\" and executes the associated statement. When <code>break</code> is encountered, the program breaks out of <code>switch</code> and executes the statement following <code>switch</code>. If <code>break</code> were omitted, the statement for case \"Cherries\" would also be executed.</p> <pre data-language=\"js\">switch (expr) {\n  case 'Oranges':\n    console.log('Oranges are $0.59 a pound.');\n    break;\n  case 'Apples':\n    console.log('Apples are $0.32 a pound.');\n    break;\n  case 'Bananas':\n    console.log('Bananas are $0.48 a pound.');\n    break;\n  case 'Cherries':\n    console.log('Cherries are $3.00 a pound.');\n    break;\n  case 'Mangoes':\n  case 'Papayas':\n    console.log('Mangoes and papayas are $2.79 a pound.');\n    break;\n  default:\n    console.log('Sorry, we are out of ' + expr + '.');\n}\n\nconsole.log(\"Is there anything else you'd like?\");\n</pre> <h3 id=\"What_happens_if_I_forgot_a_break\">What happens if I forgot a break?</h3> <p>If you forget a break then the script will run from the case where the criterion is met and will run the case after that regardless if criterion was met. See example here:</p> <pre data-language=\"js\">var foo = 0;\nswitch (foo) {\n  case -1:\n    console.log('negative 1');\n    break;\n  case 0: // foo is 0 so criteria met here so this block will run\n    console.log(0);\n    // NOTE: the forgotten break would have been here\n  case 1: // no break statement in 'case 0:' so this case will run as well\n    console.log(1);\n    break; // it encounters this break so will not continue into 'case 2:'\n  case 2:\n    console.log(2);\n    break;\n  default:\n    console.log('default');\n}</pre> <h3 id=\"Can_I_put_a_default_between_cases\">Can I put a default between cases?</h3> <p>Yes, you can! JavaScript will drop you back to the default if it can't find a match:</p> <pre data-language=\"js\">var foo = 5;\nswitch (foo) {\n  case 2:\n    console.log(2);\n    break; // it encounters this break so will not continue into 'default:'\n  default:\n    console.log('default')\n    // fall-through\n  case 1:  \n    console.log('1');\n}\n</pre> <p>It also works when you put default before all other cases.</p> <h3 id=\"Methods_for_multi-criteria_case\">Methods for multi-criteria case</h3> <p>Source for this technique is here:</p> <p><a href=\"http://stackoverflow.com/questions/13207927/switch-statement-multiple-cases-in-javascript\">Switch statement multiple cases in JavaScript (Stack Overflow)</a></p> <h4 id=\"Multi-case_-_single_operation\">Multi-case - single operation</h4> <p>This method takes advantage of the fact that if there is no break below a case statement it will continue to execute the next case statement regardless if the case meets the criteria. See the section titled \"What happens if I forgot a break?\"</p> <p>This is an example of a single operation sequential switch statement, where four different values perform exactly the same.</p> <pre data-language=\"js\">var Animal = 'Giraffe';\nswitch (Animal) {\n  case 'Cow':\n  case 'Giraffe':\n  case 'Dog':\n  case 'Pig':\n    console.log('This animal will go on Noah\\'s Ark.');\n    break;\n  case 'Dinosaur':\n  default:\n    console.log('This animal will not.');\n}</pre> <h4 id=\"Multi-case_-_chained_operations\">Multi-case - chained operations</h4> <p>This is an example of a multiple-operation sequential switch statement, where, depending on the provided integer, you can receive different output. This shows you that it will traverse in the order that you put the case statements, and it does not have to be numerically sequential. In JavaScript, you can even mix in definitions of strings into these case statements as well.</p> <pre data-language=\"js\">var foo = 1;\nvar output = 'Output: ';\nswitch (foo) {\n  case 0:\n    output += 'So ';\n  case 1:\n    output += 'What ';\n    output += 'Is ';\n  case 2:\n    output += 'Your ';\n  case 3:\n    output += 'Name';\n  case 4:\n    output += '?';\n    console.log(output);\n    break;\n  case 5:\n    output += '!';\n    console.log(output);\n    break;\n  default:\n    console.log('Please pick a number from 0 to 5!');\n}</pre> <p>The output from this example:</p> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Value</th> <th scope=\"col\">Log text</th> </tr> <tr> <td>foo is NaN or not 1, 2, 3, 4, 5 or 0</td> <td>Please pick a number from 0 to 5!</td> </tr> <tr> <td>0</td> <td>Output: So What Is Your Name?</td> </tr> <tr> <td>1</td> <td>Output: What Is Your Name?</td> </tr> <tr> <td>2</td> <td>Output: Your Name?</td> </tr> <tr> <td>3</td> <td>Output: Name?</td> </tr> <tr> <td>4</td> <td>Output: ?</td> </tr> <tr> <td>5</td> <td>Output: !</td> </tr> </tbody> </table></div> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/publications/files/ECMA-ST-ARCH/ECMA-262,%203rd%20edition,%20December%201999.pdf\" hreflang=\"en\">ECMAScript 3rd Edition (ECMA-262)</a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition. Implemented in JavaScript 1.2</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/5.1/#sec-12.11\" hreflang=\"en\">ECMAScript 5.1 (ECMA-262)<br><small>The definition of 'switch statement' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-switch-statement\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'switch statement' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-switch-statement\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'switch statement' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"if...else\"><code>if...else</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/switch$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/switch\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/switch</a>\n  </p>\n</div>\n","statements/var":"<h1>var</h1> <p>The <code>var</code> declares a variable, optionally initializing it to a value.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/statement-var.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\">var <em>varname1 [</em>= <em>value1] [</em>, <em>varname2 [</em>= <em>value2] </em><em>... [</em>, <em>varnameN [</em>= <em>valueN]]]</em>;</pre> <dl> <dt><code>varnameN</code></dt> <dd>Variable name. It can be any legal identifier.</dd> </dl> <dl> <dt><code>valueN</code></dt> <dd>Initial value of the variable. It can be any legal expression. Default value is <em>undefined</em>.</dd> </dl> <h2 id=\"Description\">Description</h2> <p><code>var</code> declarations, wherever they occur, are processed before any code is executed. This is called hoisting, and is discussed further below.</p> <p>The scope of a variable declared with <code>var</code> is its current <em>execution context</em>, which is either the enclosing function or, for variables declared outside any function, global. If you re-declare a JavaScript variable, it will not lose its value.</p> <p>Assigning a value to an undeclared variable implicitly creates it as a global variable (it becomes a property of the global object) when the assignment is executed. The differences between declared and undeclared variables are:</p> <p>1. Declared variables are constrained in the execution context in which they are declared. Undeclared variables are always global.</p> <pre data-language=\"js\">function x() {\n  y = 1;   // Throws a ReferenceError in strict mode\n  var z = 2;\n}\n\nx();\n\nconsole.log(y); // logs \"1\" \nconsole.log(z); // Throws a ReferenceError: z is not defined outside x\n</pre> <p>2. Declared variables are created before any code is executed. Undeclared variables do not exist until the code assigning to them is executed.</p> <pre data-language=\"js\">console.log(a);                // Throws a ReferenceError.\nconsole.log('still going...'); // Never executes.</pre> <pre data-language=\"js\">var a;\nconsole.log(a);                // logs \"undefined\" or \"\" depending on browser.\nconsole.log('still going...'); // logs \"still going...\".</pre> <p>3. Declared variables are a non-configurable property of their execution context (function or global). Undeclared variables are configurable (e.g. can be deleted).</p> <pre data-language=\"js\">var a = 1;\nb = 2;\n\ndelete this.a; // Throws a TypeError in strict mode. Fails silently otherwise.\ndelete this.b;\n\nconsole.log(a, b); // Throws a ReferenceError. \n// The 'b' property was deleted and no longer exists.</pre> <p>Because of these three differences, failure to declare variables will very likely lead to unexpected results. Thus <strong>it is recommended to always declare variables, regardless of whether they are in a function or global scope.</strong> And in ECMAScript 5 <a href=\"../strict_mode\">strict mode</a>, assigning to an undeclared variable throws an error.</p> <h3 id=\"var_hoisting\">var hoisting</h3> <p>Because variable declarations (and declarations in general) are processed before any code is executed, declaring a variable anywhere in the code is equivalent to declaring it at the top. This also means that a variable can appear to be used before it's declared. This behavior is called \"hoisting\", as it appears that the variable declaration is moved to the top of the function or global code.</p> <pre data-language=\"js\">bla = 2;\nvar bla;\n// ...\n\n// is implicitly understood as:\n\nvar bla;\nbla = 2;\n</pre> <p>For that reason, it is recommended to always declare variables at the top of their scope (the top of global code and the top of function code) so it's clear which variables are function scoped (local) and which are resolved on the scope chain.</p> <p>It's important to point out that the hoisting will affect the variable declaration, but not its value's initialization. The value will be indeed assigned when the assignment statement is reached:</p> <pre data-language=\"js\">function do_something() {\n  console.log(bar); // undefined\n  var bar = 111;\n  console.log(bar); // 111\n}\n\n// is implicitly understood as: \nfunction do_something() {\n  var bar;\n  console.log(bar); // undefined\n  bar = 111;\n  console.log(bar); // 111\n}\n</pre>  <h2 id=\"Examples\">Examples</h2> <h3 id=\"Declaring_and_initializing_two_variables\">Declaring and initializing two variables</h3> <pre data-language=\"js\">var a = 0, b = 0;\n</pre> <h3 id=\"Assigning_two_variables_with_single_string_value\">Assigning two variables with single string value</h3> <pre data-language=\"js\">var a = 'A';\nvar b = a;\n\n// Equivalent to:\n\nvar a, b = a = 'A';\n</pre> <p>Be mindful of the order:</p> <pre data-language=\"js\">var x = y, y = 'A';\nconsole.log(x + y); // undefinedA\n</pre> <p>Here, <code>x</code> and <code>y</code> are declared before any code is executed, but the assignments occur later. At the time \"<code>x = y</code>\" is evaluated, <code>y</code> exists so no <code>ReferenceError</code> is thrown and its value is <code>undefined</code>. So, <code>x</code> is assigned the undefined value. Then, <code>y</code> is assigned the value <code>'A'</code>. Consequently, after the first line, <code>x === undefined &amp;&amp; y === 'A'</code>, hence the result.</p> <h3 id=\"Initialization_of_several_variables\">Initialization of several variables</h3> <pre data-language=\"js\">var x = 0;\n\nfunction f() {\n  var x = y = 1; // x is declared locally. y is not!\n}\nf();\n\nconsole.log(x, y); // Throws a ReferenceError in strict mode (y is not defined). 0, 1 otherwise. \n// In non-strict mode:\n// x is the global one as expected\n// y leaked outside of the function, though!</pre> <h3 id=\"Implicit_globals_and_outer_function_scope\">Implicit globals and outer function scope</h3> <p>Variables that appear to be implicit globals may be references to variables in an outer function scope:</p> <pre data-language=\"js\">var x = 0;  // x is declared within file scope, then assigned a value of 0\n\nconsole.log(typeof z); // undefined, since z doesn't exist yet\n\nfunction a() { // when a is called,\n  var y = 2;   // y is declared within scope of function a, then assigned a value of 2\n\n  console.log(x, y);   // 0 2 \n\n  function b() {       // when b is called\n    x = 3;  // assigns 3 to existing file scoped x, doesn't create a new global var\n    y = 4;  // assigns 4 to existing outer y, doesn't create a new global var\n    z = 5;  // creates a new global variable z and assigns a value of 5. \n  }         // (Throws a ReferenceError in strict mode.)\n\n  b();     // calling b creates z as a global variable\n  console.log(x, y, z);  // 3 4 5\n}\n\na();                   // calling a also calls b\nconsole.log(x, z);     // 3 5\nconsole.log(typeof y); // undefined as y is local to function a</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/publications/files/ECMA-ST-ARCH/ECMA-262,%201st%20edition,%20June%201997.pdf\" hreflang=\"en\">ECMAScript 1st Edition (ECMA-262)</a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition. Implemented in JavaScript 1.0</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/5.1/#sec-12.2\" hreflang=\"en\">ECMAScript 5.1 (ECMA-262)<br><small>The definition of 'var statement' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-variable-statement\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'variable statement' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-variable-statement\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'variable statement' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"let\"><code>let</code></a></li> <li><a href=\"const\"><code>const</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/var$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/var\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/var</a>\n  </p>\n</div>\n","statements/label":"<h1>label</h1> <p>The <strong>labeled statement</strong> can be used with <a href=\"break\"><code>break</code></a> or <a href=\"continue\"><code>continue</code></a> statements. It is prefixing a statement with an identifier which you can refer to.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/statement-label.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <div class=\"note\"> <p><strong>Note:</strong> Labeled loops or blocks are very uncommon. Usually function calls can be used instead of loop jumps.</p> </div> <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\"><em>label</em> :\n   <em>statement</em>\n</pre> <dl> <dt><code>label</code></dt> <dd>Any JavaScript identifier that is not a reserved word.</dd> <dt><code>statement</code></dt> <dd>A JavaScript statement. <code>break</code> can be used with any labeled statement, and <code>continue</code> can be used with looping labeled statements.</dd> </dl> <h2 id=\"Description\">Description</h2> <p>You can use a label to identify a loop, and then use the <code>break</code> or <code>continue</code> statements to indicate whether a program should interrupt the loop or continue its execution.</p> <p>Note that JavaScript has <em>no</em> <code>goto</code> statement, you can only use labels with <code>break</code> or <code>continue</code>.</p> <p>In <a href=\"../strict_mode\">strict mode</a> code, you can't use \"<code>let</code>\" as a label name. It will throw a <a href=\"../global_objects/syntaxerror\"><code>SyntaxError</code></a> (let is a reserved identifier).</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Using_a_labeled_continue_with_for_loops\">Using a labeled <code>continue</code> with <code>for</code> loops</h3> <pre data-language=\"js\">var i, j;\n\nloop1:\nfor (i = 0; i &lt; 3; i++) {      //The first for statement is labeled \"loop1\"\n   loop2:\n   for (j = 0; j &lt; 3; j++) {   //The second for statement is labeled \"loop2\"\n      if (i === 1 &amp;&amp; j === 1) {\n         continue loop1;\n      }\n      console.log('i = ' + i + ', j = ' + j);\n   }\n}\n\n// Output is:\n//   \"i = 0, j = 0\"\n//   \"i = 0, j = 1\"\n//   \"i = 0, j = 2\"\n//   \"i = 1, j = 0\"\n//   \"i = 2, j = 0\"\n//   \"i = 2, j = 1\"\n//   \"i = 2, j = 2\"\n// Notice how it skips both \"i = 1, j = 1\" and \"i = 1, j = 2\"\n</pre> <h3 id=\"Using_a_labeled_continue_statement\">Using a labeled <code>continue</code> statement</h3> <p>Given an array of items and an array of tests, this example counts the number of items that passes all the tests.</p> <pre data-language=\"js\">var itemsPassed = 0;\nvar i, j;\n\ntop:\nfor (i = 0; i &lt; items.length; i++) {\n  for (j = 0; j &lt; tests.length; j++) {\n    if (!tests[j].pass(items[i])) {\n      continue top;\n    }\n  }\n\n  itemsPassed++;\n}</pre> <h3 id=\"Using_a_labeled_break_with_for_loops\">Using a labeled <code>break</code> with <code>for</code> loops</h3> <pre data-language=\"js\">var i, j;\n\nloop1:\nfor (i = 0; i &lt; 3; i++) {      //The first for statement is labeled \"loop1\"\n   loop2:\n   for (j = 0; j &lt; 3; j++) {   //The second for statement is labeled \"loop2\"\n      if (i === 1 &amp;&amp; j === 1) {\n         break loop1;\n      }\n      console.log('i = ' + i + ', j = ' + j);\n   }\n}\n\n// Output is:\n//   \"i = 0, j = 0\"\n//   \"i = 0, j = 1\"\n//   \"i = 0, j = 2\"\n//   \"i = 1, j = 0\"\n// Notice the difference with the previous continue example</pre> <h3 id=\"Using_a_labeled_break_statement\">Using a labeled <code>break</code> statement</h3> <p>Given an array of items and an array of tests, this example determines whether all items pass all tests.</p> <pre data-language=\"js\">var allPass = true;\nvar i, j;\n\ntop:\nfor (i = 0; items.length; i++)\n  for (j = 0; j &lt; tests.length; i++)\n    if (!tests[j].pass(items[i])) {\n      allPass = false;\n      break top;\n    }</pre> <h3 id=\"Using_a_labeled_block_with_break\">Using a labeled block with <code>break</code>\n</h3> <p>You can use labels within simple blocks, but only <code>break</code> statements can make use of non-loop labels.</p> <pre data-language=\"js\">foo: {\n  console.log('face');\n  break foo;\n  console.log('this will not be executed');\n}\nconsole.log('swap');\n\n// this will log:\n\n// \"face\"\n// \"swap </pre> <h3 id=\"Labeled_function_declarations\">Labeled function declarations</h3> <p>Starting with ECMAScript 2015, labeled function declarations are now standardized for non-strict code in the <a href=\"http://www.ecma-international.org/ecma-262/6.0/#sec-labelled-function-declarations\">web compatibility annex of the specification</a>.</p> <pre data-language=\"js\">L: function F() {}</pre> <p>In <a href=\"../strict_mode\">strict mode</a> code, however, this will throw a <a href=\"../global_objects/syntaxerror\"><code>SyntaxError</code></a>:</p> <pre data-language=\"js\">'use strict';\nL: function F() {}\n// SyntaxError: functions cannot be labelled</pre> <p><a href=\"function*\">Generator functions</a> can neither be labeled in strict code, nor in non-strict code:</p> <pre data-language=\"js\">L: function* F() {}\n// SyntaxError: generator functions cannot be labelled\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/publications/files/ECMA-ST-ARCH/ECMA-262,%203rd%20edition,%20December%201999.pdf\" hreflang=\"en\">ECMAScript 3rd Edition (ECMA-262)</a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition. Implemented in JavaScript 1.2</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/5.1/#sec-12.12\" hreflang=\"en\">ECMAScript 5.1 (ECMA-262)<br><small>The definition of 'Labelled statement' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-labelled-statements\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Labelled statement' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-labelled-statements\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Labelled statement' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"break\"><code>break</code></a></li> <li><a href=\"continue\"><code>continue</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/label$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/label\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/label</a>\n  </p>\n</div>\n","statements/function*":"<h1>function*</h1> <p>The <code><strong>function*</strong></code> declaration (<code>function</code> keyword followed by an asterisk) defines a <em>generator function</em>, which returns a <a href=\"../global_objects/generator\"><code>Generator</code></a> object.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/statement-functionasterisk.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <div class=\"noinclude\"> <p>You can also define generator functions using the <a href=\"../global_objects/generatorfunction\"><code>GeneratorFunction</code></a> constructor, or the function expression syntax.</p> </div> <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\">function* <em>name</em>([<em>param</em>[, <em>param</em>[, ... <em>param</em>]]]) {\n   <em>statements</em>\n}\n</pre> <dl> <dt><code>name</code></dt> <dd>The function name.</dd> </dl> <dl> <dt><code>param</code></dt> <dd>The name of a formal parameter for the function.</dd> </dl> <dl> <dt><code>statements</code></dt> <dd>The statements comprising the body of the function.</dd> </dl> <h2 id=\"Description\">Description</h2> <p>Generators are functions which can be exited and later re-entered. Their context (variable bindings) will be saved across re-entrances.<br> <br> Generators in JavaScript -- especially when combined with Promises -- are a very powerful tool for asynchronous programming as they mitigate -- if not entirely eliminate -- the problems with callbacks, such as <a href=\"http://callbackhell.com/\">Callback Hell</a> and <a href=\"https://frontendmasters.com/courses/rethinking-async-js/callback-problems-inversion-of-control/\">Inversion of Control</a>. <br> This pattern is what <code><a href=\"async_function\">async</a></code> functions are built on top of.</p> <p>Calling a generator function does not execute its body immediately; an <a href=\"../iteration_protocols#iterator\">iterator</a> object for the function is returned instead. When the iterator's <code>next()</code> method is called, the generator function's body is executed until the first <a href=\"../operators/yield\"><code>yield</code></a> expression, which specifies the value to be returned from the iterator or, with <a href=\"../operators/yield*\"><code>yield*</code></a>, delegates to another generator function. The <code>next()</code> method returns an object with a <code>value</code> property containing the yielded value and a <code>done</code> property which indicates whether the generator has yielded its last value as a boolean. Calling the <code>next()</code> method with an argument will resume the generator function execution, replacing the <code>yield</code> expression where execution was paused with the argument from <code>next()</code>. </p> <p>A <code>return</code> statement in a generator, when executed, will make the generator finished (i.e the <code>done</code> property of the object returned by it will be set to <code>true</code>). If a value is returned, it will be set as the <code>value</code> property of the object returned by the generator.<br> Much like a <code>return</code> statement, an error thrown inside the generator will make the generator finished -- unless caught within the generator's body.<br> When a generator is finished, subsequent <code>next</code> calls will not execute any of that generator's code, they will just return an object of this form: <code>{value: undefined, done: true}</code>.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Simple_example\">Simple example</h3> <pre data-language=\"js\">function* idMaker() {\n  var index = 0;\n  while (index &lt; index+1)\n    yield index++;\n}\n\nvar gen = idMaker();\n\nconsole.log(gen.next().value); // 0\nconsole.log(gen.next().value); // 1\nconsole.log(gen.next().value); // 2\nconsole.log(gen.next().value); // 3\n// ...</pre> <h3 id=\"Example_with_yield*\">Example with yield*</h3> <pre data-language=\"js\">function* anotherGenerator(i) {\n  yield i + 1;\n  yield i + 2;\n  yield i + 3;\n}\n\nfunction* generator(i) {\n  yield i;\n  yield* anotherGenerator(i);\n  yield i + 10;\n}\n\nvar gen = generator(10);\n\nconsole.log(gen.next().value); // 10\nconsole.log(gen.next().value); // 11\nconsole.log(gen.next().value); // 12\nconsole.log(gen.next().value); // 13\nconsole.log(gen.next().value); // 20\n</pre> <h3 id=\"Passing_arguments_into_Generators\">Passing arguments into Generators</h3> <pre data-language=\"js\">function* logGenerator() {\n  console.log(0);\n  console.log(1, yield);\n  console.log(2, yield);\n  console.log(3, yield);\n}\n\nvar gen = logGenerator();\n\n// the first call of next executes from the start of the function\n// until the first yield statement\ngen.next();             // 0\ngen.next('pretzel');    // 1 pretzel\ngen.next('california'); // 2 california\ngen.next('mayonnaise'); // 3 mayonnaise\n</pre> <h3 id=\"Return_statement_in_a_generator\">Return statement in a generator</h3> <pre data-language=\"js\">function* yieldAndReturn() {\n  yield \"Y\";\n  return \"R\";\n  yield \"unreachable\";\n}\n\nvar gen = yieldAndReturn()\nconsole.log(gen.next()); // { value: \"Y\", done: false }\nconsole.log(gen.next()); // { value: \"R\", done: true }\nconsole.log(gen.next()); // { value: undefined, done: true }\n</pre> <h3 id=\"Generators_are_not_constructable\">Generators are not constructable</h3> <pre data-language=\"js\">function* f() {}\nvar obj = new f; // throws \"TypeError: f is not a constructor\n</pre> <h3 id=\"Generator_defined_in_an_expression\">Generator defined in an expression</h3> <pre data-language=\"js\">const foo = function* () {\n  yield 10;\n  yield 20;\n};\n\nconst bar = foo();\nconsole.log(bar.next()); // {value: 10, done: false}</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <thead> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> </thead> <tbody> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-generator-function-definitions\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'function*' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/7.0/#sec-generator-function-definitions\" hreflang=\"en\">ECMAScript 2016 (ECMA-262)<br><small>The definition of 'function*' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Changed that generators should not have [[Construct]] trap and will throw when used with <code>new</code>.</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-generator-function-definitions\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'function*' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>   <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 39</td>\n<td class=\"bc-supports-yes\"> 13</td>\n<td class=\"bc-supports-yes\"> 26</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 26</td>\n<td class=\"bc-supports-yes\"> 10</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<code>IteratorResult</code> object instead of throwing</th>\n<td class=\"bc-supports-yes\"> 49</td>\n<td class=\"bc-supports-yes\"> 13</td>\n<td class=\"bc-supports-yes\"> 29</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">Not constructable with <code>new</code> (ES2016)</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 43</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 10</td>\n</tr>\n<tr>\n<th scope=\"row\">Trailing comma in parameters</th>\n<td> ? </td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 52</td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td> ? </td>\n</tr>\n</tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 39</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 26</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 10</td>\n<td class=\"bc-supports-yes\"> 4.0</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<code>IteratorResult</code> object instead of throwing</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 29</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">Not constructable with <code>new</code> (ES2016)</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 43</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 10</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">Trailing comma in parameters</th>\n<td> ? </td>\n<td> ? </td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 52</td>\n<td> ? </td>\n<td> ? </td>\n<td> ? </td>\n</tr>\n</tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes bc-has-history\"> 4.0.0\n<section class=\"bc-history\" id=\"sect1\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 4.0.0\n</dt>\n\n<dt class=\"bc-supports-yes bc-supports\"> 0.12<div class=\"bc-icons\">Disabled </div>\n</dt>\n<dd>Disabled From version 0.12: this feature is behind the <code>--harmony</code> runtime flag.</dd>\n</dl></section>\n</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<code>IteratorResult</code> object instead of throwing</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">Not constructable with <code>new</code> (ES2016)</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">Trailing comma in parameters</th>\n<td class=\"bc-supports-yes\"> 8.0.0</td>\n</tr>\n</tbody>\n</table>\n</div>  <h2 id=\"Firefox-specific_notes\">Firefox-specific notes</h2> <h4 id=\"Generators_and_iterators_in_Firefox_versions_before_26\">Generators and iterators in Firefox versions before 26</h4> <p>Older Firefox versions implement an older version of the generators proposal. In the older version, generators were defined using a regular <code>function</code> keyword (without an asterisk) among other differences. See <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/Legacy_generator_function\">Legacy generator function </a>for further information.</p> <h4 id=\"IteratorResult_object_returned_instead_of_throwing\">\n<code>IteratorResult</code> object returned instead of throwing</h4> <p>Starting with Gecko 29 (Firefox 29 / Thunderbird 29 / SeaMonkey 2.26), the completed generator function no longer throws a <a href=\"../global_objects/typeerror\"><code>TypeError</code></a> \"generator has already finished\". Instead, it returns an <code>IteratorResult</code> object like <code>{ value: undefined, done: true }</code> (<a href=\"https://bugzilla.mozilla.org/show_bug.cgi?id=958951\">bug 958951</a>).</p> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"../operators/function*\"><code>function* expression</code></a></li> <li>\n<a href=\"../global_objects/generatorfunction\"><code>GeneratorFunction</code></a> object</li> <li><a href=\"../iteration_protocols\">Iteration protocols</a></li> <li><a href=\"../operators/yield\"><code>yield</code></a></li> <li><a href=\"../operators/yield*\"><code>yield*</code></a></li> <li>\n<a href=\"../global_objects/function\"><code>Function</code></a> object</li> <li><a href=\"function\"><code>function declaration</code></a></li> <li><a href=\"../operators/function\"><code>function expression</code></a></li> <li><a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions\"><code>Functions and function scope</code></a></li> <li>Other web resources: <ul> <li>\n<a href=\"http://facebook.github.io/regenerator/\">Regenerator</a> an ES2015 generator compiler to ES5</li> <li><a href=\"http://www.youtube.com/watch?v=qbKWsbJ76-s\">Forbes Lindesay: Promises and Generators: control flow utopia -- JSConf EU 2013</a></li> <li><a href=\"https://github.com/mozilla/task.js\">Task.js</a></li> <li><a href=\"https://github.com/getify/You-Dont-Know-JS/blob/master/async%20%26%20performance/ch4.md#iterating-generators-asynchronously\">Iterating generators asynchronously</a></li> </ul> </li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/function*$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/function*\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/function*</a>\n  </p>\n</div>\n","statements/while":"<h1>while</h1> <p>The <strong>while statement</strong> creates a loop that executes a specified statement as long as the test condition evaluates to true. The condition is evaluated before executing the statement.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/statement-while.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\">while (<em>condition</em>)\n  <em>statement</em>\n</pre> <dl> <dt><code>condition</code></dt> <dd>An expression evaluated before each pass through the loop. If this condition evaluates to true, <code>statement</code> is executed. When condition evaluates to false, execution continues with the statement after the <code>while</code> loop.</dd> <dt><code>statement</code></dt> <dd>An optional statement that is executed as long as the condition evaluates to true. To execute multiple statements within the loop, use a <a href=\"block\">block</a> statement (<code>{ ... }</code>) to group those statements.<br> <br> Note: Use the break statement to stop a loop before condition evaluates to true.</dd> </dl> <h2 id=\"Examples\">Examples</h2> <p>The following <code>while</code> loop iterates as long as <code>n</code> is less than three.</p> <pre data-language=\"js\">var n = 0;\nvar x = 0;\n\nwhile (n &lt; 3) {\n  n++;\n  x += n;\n}</pre> <p>Each iteration, the loop increments <code>n</code> and adds it to <code>x</code>. Therefore, <code>x</code> and <code>n</code> take on the following values:</p> <ul> <li>After the first pass: <code>n</code> = 1 and <code>x</code> = 1</li> <li>After the second pass: <code>n</code> = 2 and <code>x</code> = 3</li> <li>After the third pass: <code>n</code> = 3 and <code>x</code> = 6</li> </ul> <p>After completing the third pass, the condition <code>n</code> &lt; 3 is no longer true, so the loop terminates.</p> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-while-statement\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'while statement' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-while-statement\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'while statement' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/5.1/#sec-12.6.2\" hreflang=\"en\">ECMAScript 5.1 (ECMA-262)<br><small>The definition of 'while statement' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/publications/files/ECMA-ST-ARCH/ECMA-262,%203rd%20edition,%20December%201999.pdf#sec-12.6.2\" hreflang=\"en\">ECMAScript 3rd Edition (ECMA-262)<br><small>The definition of 'while statement' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/publications/files/ECMA-ST-ARCH/ECMA-262,%201st%20edition,%20June%201997.pdf#sec-12.6.1\" hreflang=\"en\">ECMAScript 1st Edition (ECMA-262)<br><small>The definition of 'while statement' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition</td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"do...while\"><code>do...while</code></a></li> <li><a href=\"for\"><code>for</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/while$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/while\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/while</a>\n  </p>\n</div>\n","statements/with":"<h1>with</h1><div class=\"warning\">Use of the <code>with</code> statement is not recommended, as it may be the source of confusing bugs and compatibility issues. See the \"Ambiguity Contra\" paragraph in the \"Description\" section below for details.</div>  <p>The <strong>with statement</strong> extends the scope chain for a statement.</p> <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\">with (expression)\n  <em>statement</em>\n</pre> <dl> <dt><code>expression</code></dt> <dd>Adds the given expression to the scope chain used when evaluating the statement. The parentheses around the expression are required.</dd> <dt><code>statement</code></dt> <dd>Any statement. To execute multiple statements, use a <a href=\"block\">block</a> statement ({ ... }) to group those statements.</dd> </dl> <h2 id=\"Description\">Description</h2> <p>JavaScript looks up an unqualified name by searching a scope chain associated with the execution context of the script or function containing that unqualified name. The 'with' statement adds the given object to the head of this scope chain during the evaluation of its statement body. If an unqualified name used in the body matches a property in the scope chain, then the name is bound to the property and the object containing the property. Otherwise a <a href=\"../global_objects/referenceerror\"><code>ReferenceError</code></a> is thrown.</p> <div class=\"note\">Using <code>with</code> is not recommended, and is forbidden in ECMAScript 5 <a href=\"../strict_mode\">strict mode</a>. The recommended alternative is to assign the object whose properties you want to access to a temporary variable.</div> <h3 id=\"Performance_pro_contra\">Performance pro &amp; contra</h3> <p><strong>Pro:</strong> The <code>with</code> statement can help reduce file size by reducing the need to repeat a lengthy object reference without performance penalty. The scope chain change required by 'with' is not computationally expensive. Use of 'with' will relieve the interpreter of parsing repeated object references. Note, however, that in many cases this benefit can be achieved by using a temporary variable to store a reference to the desired object.</p> <p><strong>Contra:</strong> The <code>with</code> statement forces the specified object to be searched first for all name lookups. Therefore all identifiers that aren't members of the specified object will be found more slowly in a 'with' block. Where performance is important, 'with' should only be used to encompass code blocks that access members of the specified object.</p> <h3 id=\"Ambiguity_contra\">Ambiguity contra</h3> <p><strong>Contra:</strong> The <code>with</code> statement makes it hard for a human reader or JavaScript compiler to decide whether an unqualified name will be found along the scope chain, and if so, in which object. So given this example:</p> <pre data-language=\"js\">function f(x, o) {\n  with (o) {\n    console.log(x);\n  }\n}</pre> <p>Only when <code>f</code> is called is <code>x</code> either found or not, and if found, either in <code>o</code> or (if no such property exists) in <code>f</code>'s activation object, where <code>x</code> names the first formal argument. If you forget to define <code>x</code> in the object you pass as the second argument, or if there's some similar bug or confusion, you won't get an error -- just unexpected results.</p> <p><strong>Contra: </strong>Code using <code>with</code> may not be forward compatible, especially when used with something other than a plain object. Consider this example:</p>  <pre data-language=\"js\">function f(foo, values) {\n  with (foo) {\n    console.log(values);\n  }\n}\n</pre> <p>If you call <code>f([1,2,3], obj)</code> in an ECMAScript 5 environment, then the <code>values</code> reference inside the <code>with</code> statement will resolve to <code>obj</code>. However, ECMAScript 6 introduces a <code>values</code> property on <a href=\"../global_objects/array/prototype\"><code>Array.prototype</code></a> (so that it will be available on every array). So, in a JavaScript environment that supports ECMAScript 6, the <code>values</code> reference inside the <code>with</code> statement could resolve to <code>[1,2,3].values</code>. However, in this particular example, <a href=\"../global_objects/array/prototype\"><code>Array.prototype</code></a> has been defined with <code>values</code> in its <a href=\"../global_objects/symbol/unscopables\"><code>Symbol.unscopables</code></a> object. If it were not, one can see how this would be a difficult issue to debug.</p>  <h2 id=\"Examples\">Examples</h2> <h3 id=\"Using_with\">Using <code>with</code>\n</h3> <p>The following <code>with</code> statement specifies that the <a href=\"../global_objects/math\"><code>Math</code></a> object is the default object. The statements following the <code>with</code> statement refer to the <a href=\"../global_objects/math/pi\"><code>PI</code></a> property and the <a href=\"../global_objects/math/cos\"><code>cos</code></a> and <a href=\"../global_objects/math/sin\"><code>sin</code></a> methods, without specifying an object. JavaScript assumes the <code>Math</code> object for these references.</p> <pre data-language=\"js\">var a, x, y;\nvar r = 10;\n\nwith (Math) {\n  a = PI * r * r;\n  x = r * cos(PI);\n  y = r * sin(PI / 2);\n}</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-with-statement\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'with statement' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-with-statement\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'with statement' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/5.1/#sec-12.10\" hreflang=\"en\">ECMAScript 5.1 (ECMA-262)<br><small>The definition of 'with statement' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Now forbidden in strict mode.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/publications/files/ECMA-ST-ARCH/ECMA-262,%203rd%20edition,%20December%201999.pdf#sec-12.10\" hreflang=\"en\">ECMAScript 3rd Edition (ECMA-262)<br><small>The definition of 'with statement' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/publications/files/ECMA-ST-ARCH/ECMA-262,%201st%20edition,%20June%201997.pdf#sec-12.10\" hreflang=\"en\">ECMAScript 1st Edition (ECMA-262)<br><small>The definition of 'with statement' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition</td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support \n</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support \n</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support \n</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"block\"><code>block</code></a></li> <li><a href=\"../strict_mode\">Strict mode</a></li> <li><a href=\"../global_objects/symbol/unscopables\"><code>Symbol.unscopables</code></a></li> <li><a href=\"../global_objects/array/@@unscopables\"><code>Array.prototype[@@unscopables]</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/with$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/with\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/with</a>\n  </p>\n</div>\n","statements/let":"<h1>let</h1> <p>The <code>let</code> statement declares a block scope local variable, optionally initializing it to a value.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/statement-let.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\">let <em>var1</em> [= <em>value1</em>] [, <em>var2</em> [= <em>value2</em>]] [, ..., <em>varN</em> [= <em>valueN</em>];</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt>\n<code>var1</code>, <code>var2</code>, …, <code>varN</code>\n</dt> <dd>The names of the variable or variables to declare. Each must be a legal JavaScript identifier.</dd> <dt>\n<code>value1</code>, <code>value2</code>, …, <code>valueN</code> <span class=\"inlineIndicator optional optionalInline\">Optional</span>\n</dt> <dd>For each variable declared, you may optionally specify its initial value to any legal JavaScript expression.</dd> </dl> <h2 id=\"Description\">Description</h2> <p><code>let</code> allows you to declare variables that are limited in scope to the block, statement, or expression on which it is used. This is unlike the <a href=\"var\"><code>var</code></a> keyword, which defines a variable globally, or locally to an entire function regardless of block scope.</p> <p>An explanation of why the name \"<strong>let</strong>\" was chosen can be found <a href=\"https://stackoverflow.com/questions/37916940/why-was-the-name-let-chosen-for-block-scoped-variable-declarations-in-javascri\">here</a>.</p> <h3 id=\"Scoping_rules_2\">Scoping rules</h3> <p>Variables declared by <code>let</code> have their scope in the block for which they are defined, as well as in any contained sub-blocks. In this way, <code>let</code> works very much like <code>var</code>. The main difference is that the scope of a <code>var</code> variable is the entire enclosing function:</p> <pre data-language=\"js\">function varTest() {\n  var x = 1;\n  if (true) {\n    var x = 2;  // same variable!\n    console.log(x);  // 2\n  }\n  console.log(x);  // 2\n}\n\nfunction letTest() {\n  let x = 1;\n  if (true) {\n    let x = 2;  // different variable\n    console.log(x);  // 2\n  }\n  console.log(x);  // 1\n}\n</pre> <p id=\"Scoping_rules\">At the top level of programs and functions, <code>let</code>, unlike <code>var</code>, does not create a property on the global object. For example:</p> <pre data-language=\"js\">var x = 'global';\nlet y = 'global';\nconsole.log(this.x); // \"global\"\nconsole.log(this.y); // undefined\n</pre> <h3 id=\"Emulating_private_members\">Emulating private members</h3> <p>In dealing with <a href=\"https://developer.mozilla.org/en-US/docs/Glossary/Constructor\">constructors</a> it is possible to use the <code>let</code> bindings to share one or more private members without using <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Closures\">closures</a>:</p> <pre data-language=\"js\">var Thing;\n\n{\n  let privateScope = new WeakMap();\n  let counter = 0;\n\n  Thing = function() {\n    this.someProperty = 'foo';\n    \n    privateScope.set(this, {\n      hidden: ++counter,\n    });\n  };\n\n  Thing.prototype.showPublic = function() {\n    return this.someProperty;\n  };\n\n  Thing.prototype.showPrivate = function() {\n    return privateScope.get(this).hidden;\n  };\n}\n\nconsole.log(typeof privateScope);\n// \"undefined\"\n\nvar thing = new Thing();\n\nconsole.log(thing);\n// Thing {someProperty: \"foo\"}\n\nthing.showPublic();\n// \"foo\"\n\nthing.showPrivate();\n// 1\n</pre> <p>The same privacy pattern with closures over local variables can be created with <code>var</code>, but those need a function scope (typically an IIFE in the module pattern) instead of just a block scope like in the example above.</p> <h3 id=\"Redeclarations\">Redeclarations</h3> <p>Redeclaring the same variable within the same function or block scope raises a <a href=\"../global_objects/syntaxerror\"><code>SyntaxError</code></a>.</p> <pre data-language=\"js\">if (x) {\n  let foo;\n  let foo; // SyntaxError thrown.\n}\n</pre> <p>You may encounter errors in <a href=\"switch\"><code>switch</code></a> statements because there is only one block.</p> <pre data-language=\"js\">let x = 1;\nswitch(x) {\n  case 0:\n    let foo;\n    break;\n    \n  case 1:\n    let foo; // SyntaxError for redeclaration.\n    break;\n}</pre> <p>However, it's important to point out that a block nested inside a case clause will create a new block scoped lexical environment, which will not produce the redeclaration errors shown above.</p> <pre data-language=\"js\">let x = 1;\n\nswitch(x) {\n  case 0: {\n    let foo;\n    break;\n  }  \n  case 1: {\n    let foo;\n    break;\n  }\n}</pre> <h3 id=\"Temporal_dead_zone\">Temporal dead zone</h3> <p><code>let</code> bindings are created at the top of the (block) scope containing the declaration, commonly referred to as \"hoisting\". Unlike variables declared with <code><a href=\"var#var_hoisting\">var</a></code>, which will start with the value <code>undefined</code>, <code>let</code> variables are <em>not</em> initialized until their definition is evaluated. Accessing the variable before the initialization results in a <code><a href=\"../global_objects/referenceerror\">ReferenceError</a></code>. The variable is in a \"temporal dead zone\" from the start of the block until the initialization is processed.</p> <pre data-language=\"js\">function do_something() {\n  console.log(bar); // undefined\n  console.log(foo); // ReferenceError\n  var bar = 1;\n  let foo = 2;\n}</pre> <h3 id=\"The_temporal_dead_zone_and_typeof\">The temporal dead zone and <code>typeof</code>\n</h3> <p>Unlike with simply undeclared variables and variables that hold a value of <code>undefined</code>, using the <code>typeof</code> operator to check for the type of a variable in that variable's TDZ will throw a <code>ReferenceError</code>:</p> <pre data-language=\"js\">// prints out 'undefined'\nconsole.log(typeof undeclaredVariable);\n// results in a 'ReferenceError'\nconsole.log(typeof i);\nlet i = 10;</pre> <h3 id=\"Another_example_of_temporal_dead_zone_combined_with_lexical_scoping\">Another example of temporal dead zone combined with lexical scoping</h3> <p>Due to lexical scoping, the identifier<strong> \"foo\"</strong> inside the expression <code>(foo + 55)</code> evaluates to the <u>if block's foo</u>, and <strong>not</strong> the <u>overlying variable foo</u> with the value of 33.<br> In that very line, the <u>if block's \"foo\"</u> has already been created in the lexical environment, but has not yet reached (and <strong>terminated</strong>) its initialization (which is part of the statement itself): it's still in the temporal dead zone.</p> <pre data-language=\"js\">function test(){\n   var foo = 33;\n   if (true) {\n      let foo = (foo + 55); // ReferenceError\n   }\n}\ntest();</pre> <p>This phenomenon may confuse you in a situation like the following. The instruction <code>let n of n.a</code> is already inside the private scope of the <u>for loop's block</u>, hence the identifier<strong> \"n.a\"</strong> is resolved to the property 'a' of the <u>'n' object located in the first part of the instruction itself</u> (\"let n\"), which is still in the temporal dead zone since its declaration statement has not been reached and <strong>terminated</strong>.</p> <pre data-language=\"js\">function go(n) {\n  // n here is defined!\n  console.log(n); // Object {a: [1,2,3]}\n\n  for (let n of n.a) { // ReferenceError\n    console.log(n);\n  }\n}\n\ngo({a: [1, 2, 3]});\n</pre> <h2 id=\"Other_situations\">Other situations</h2> <p>When used inside a block, <code>let</code> limits the variable's scope to that block. Note the difference between <code><strong>var</strong></code>whose scope is inside the function where it is declared.</p> <pre data-language=\"js\">var a = 1;\nvar b = 2;\n\nif (a === 1) {\n  var a = 11; // the scope is global\n  let b = 22; // the scope is inside the if-block\n\n  console.log(a);  // 11\n  console.log(b);  // 22\n} \n\nconsole.log(a); // 11\nconsole.log(b); // 2</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-let-and-const-declarations\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Let and Const Declarations' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition. Does not specify let expressions or let blocks.</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-let-and-const-declarations\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Let and Const Declarations' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes bc-has-history\"> 49\n<section class=\"bc-history\" id=\"sect1\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 49\n</dt>\n\n<dt class=\"bc-supports-no bc-supports\">48 — 49<div class=\"bc-icons\"> Disabled </div>\n</dt>\n<dd> Support outside of <a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Strict_mode\">strict mode</a>.</dd>\n<dd>Disabled From version 48 until version 49 (exclusive): this feature is behind the <code>Enable Experimental JavaScript Features</code> preference. To change preferences in Chrome, visit chrome://flags.</dd>\n<dt class=\"bc-supports-no bc-supports\">41 — 49\n</dt>\n<dd> <a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Strict_mode\">Strict mode</a> is required.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes bc-has-history\"> 44\n<section class=\"bc-history\" id=\"sect2\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 44\n</dt>\n<dd> Prior to Firefox 44, <code>let</code> is only available to code blocks in HTML wrapped in a <code>&lt;script type=\"application/javascript;version=1.7\"&gt;</code> block (or higher version) and has different semantics (e.g. no temporal dead zone).</dd>\n<dd> Prior to Firefox 46, a <code>TypeError</code> is thrown on redeclaration instead of a <code>SyntaxError</code>.</dd>\n<dd> Firefox 54 adds support of <code>let</code> in workers.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-yes\"> 11</td>\n<td class=\"bc-supports-yes\"> 17</td>\n<td class=\"bc-supports-yes\"> 10</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes bc-has-history\"> 49\n<section class=\"bc-history\" id=\"sect3\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 49\n</dt>\n\n<dt class=\"bc-supports-no bc-supports\">41 — 49\n</dt>\n<dd> <a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Strict_mode\">Strict mode</a> is required.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-yes bc-has-history\"> 49\n<section class=\"bc-history\" id=\"sect4\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 49\n</dt>\n\n<dt class=\"bc-supports-no bc-supports\">48 — 49<div class=\"bc-icons\"> Disabled </div>\n</dt>\n<dd> Support outside of <a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Strict_mode\">strict mode</a>.</dd>\n<dd>Disabled From version 48 until version 49 (exclusive): this feature is behind the <code>Enable Experimental JavaScript Features</code> preference. To change preferences in Chrome, visit chrome://flags.</dd>\n<dt class=\"bc-supports-no bc-supports\">41 — 49\n</dt>\n<dd> <a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Strict_mode\">Strict mode</a> is required.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes bc-has-history\"> 44\n<section class=\"bc-history\" id=\"sect5\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 44\n</dt>\n<dd> Prior to Firefox 44, <code>let</code> is only available to code blocks in HTML wrapped in a <code>&lt;script type=\"application/javascript;version=1.7\"&gt;</code> block (or higher version) and has different semantics (e.g. no temporal dead zone).</dd>\n<dd> Prior to Firefox 46, a <code>TypeError</code> is thrown on redeclaration instead of a <code>SyntaxError</code>.</dd>\n<dd> Firefox 54 adds support of <code>let</code> in workers.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-yes\"> 17</td>\n<td class=\"bc-supports-yes\"> 10</td>\n<td class=\"bc-supports-yes\"> 4.0</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 6.0.0</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"var\"><code>var</code></a></li> <li><a href=\"const\"><code>const</code></a></li> <li><a href=\"https://hacks.mozilla.org/2015/07/es6-in-depth-let-and-const/\">ES6 In Depth: <code>let</code> and <code>const</code></a></li> <li><a href=\"https://blog.mozilla.org/addons/2015/10/14/breaking-changes-let-const-firefox-nightly-44/\">Breaking changes in <code>let</code> and <code>const</code> in Firefox 44</a></li> <li><a href=\"https://github.com/getify/You-Dont-Know-JS/blob/master/scope%20%26%20closures/ch3.md\">You Don't Know JS: Scope &amp; Closures: Chapter 3: Function vs. Block Scope</a></li> <li><a href=\"https://stackoverflow.com/a/33198850/1125029\">StackOverflow: What is the Temporal Dead Zone. </a></li> <li><a href=\"https://stackoverflow.com/questions/762011/whats-the-difference-between-using-let-and-var-to-declare-a-variable\">StackOverflow: What is the difference between using let and var?</a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/let$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/let\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/let</a>\n  </p>\n</div>\n","statements/throw":"<h1>throw</h1> <p>The <code>throw</code> throws a user-defined exception. Execution of the current function will stop (the statements after <code>throw</code> won't be executed), and control will be passed to the first <a href=\"try...catch\"><code>catch</code></a> block in the call stack. If no <code>catch</code> block exists among caller functions, the program will terminate.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/statement-throw.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\">throw <em>expression</em>; </pre> <dl> <dt><code>expression</code></dt> <dd>The expression to throw.</dd> </dl> <h2 id=\"Description\">Description</h2> <p>Use the <code>throw</code> statement to throw an exception. When you throw an exception, <code>expression</code> specifies the value of the exception. Each of the following throws an exception:</p> <pre data-language=\"js\">throw 'Error2'; // generates an exception with a string value\nthrow 42;       // generates an exception with the value 42\nthrow true;     // generates an exception with the value true\nthrow new Error('Required');  // generates an error object with the message of Required\n</pre> <p>Also note that the <code>throw</code> statement is affected by <a href=\"../lexical_grammar#Automatic_semicolon_insertion\">automatic semicolon insertion (ASI)</a> as no line terminator between the <code>throw</code> keyword and the expression is allowed.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Throw_an_object\">Throw an object</h3> <p>You can specify an object when you throw an exception. You can then reference the object's properties in the <code>catch</code> block. The following example creates an object of type <code>UserException</code> and uses it in a <code>throw</code> statement.</p> <pre data-language=\"js\">function UserException(message) {\n   this.message = message;\n   this.name = 'UserException';\n}\nfunction getMonthName(mo) {\n   mo = mo - 1; // Adjust month number for array index (1 = Jan, 12 = Dec)\n   var months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul',\n      'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];\n   if (months[mo] !== undefined) {\n      return months[mo];\n   } else {\n      throw new UserException('InvalidMonthNo');\n   }\n}\n\ntry {\n   // statements to try\n   var myMonth = 15; // 15 is out of bound to raise the exception\n   var monthName = getMonthName(myMonth);\n} catch (e) {\n   monthName = 'unknown';\n   console.log(e.message, e.name); // pass exception object to err handler\n}\n</pre> <h3 id=\"Another_example_of_throwing_an_object\">Another example of throwing an object</h3> <p>The following example tests an input string for a U.S. zip code. If the zip code uses an invalid format, the throw statement throws an exception by creating an object of type <code>ZipCodeFormatException</code>.</p> <pre data-language=\"js\">/*\n * Creates a ZipCode object.\n *\n * Accepted formats for a zip code are:\n *    12345\n *    12345-6789\n *    123456789\n *    12345 6789\n *\n * If the argument passed to the ZipCode constructor does not\n * conform to one of these patterns, an exception is thrown.\n */\n\nfunction ZipCode(zip) {\n   zip = new String(zip);\n   pattern = /[0-9]{5}([- ]?[0-9]{4})?/;\n   if (pattern.test(zip)) {\n      // zip code value will be the first match in the string\n      this.value = zip.match(pattern)[0];\n      this.valueOf = function() {\n         return this.value\n      };\n      this.toString = function() {\n         return String(this.value)\n      };\n   } else {\n      throw new ZipCodeFormatException(zip);\n   }\n}\n\nfunction ZipCodeFormatException(value) {\n   this.value = value;\n   this.message = 'does not conform to the expected format for a zip code';\n   this.toString = function() {\n      return this.value + this.message;\n   };\n}\n\n/*\n * This could be in a script that validates address data\n * for US addresses.\n */\n\nconst ZIPCODE_INVALID = -1;\nconst ZIPCODE_UNKNOWN_ERROR = -2;\n\nfunction verifyZipCode(z) {\n   try {\n      z = new ZipCode(z);\n   } catch (e) {\n      if (e instanceof ZipCodeFormatException) {\n         return ZIPCODE_INVALID;\n      } else {\n         return ZIPCODE_UNKNOWN_ERROR;\n      }\n   }\n   return z;\n}\n\na = verifyZipCode(95060);         // returns 95060\nb = verifyZipCode(9560);          // returns -1\nc = verifyZipCode('a');           // returns -1\nd = verifyZipCode('95060');       // returns 95060\ne = verifyZipCode('95060 1234');  // returns 95060 1234\n</pre> <h3 id=\"Rethrow_an_exception\">Rethrow an exception</h3> <p>You can use <code>throw</code> to rethrow an exception after you catch it. The following example catches an exception with a numeric value and rethrows it if the value is over 50. The rethrown exception propagates up to the enclosing function or to the top level so that the user sees it.</p> <pre data-language=\"js\">try {\n   throw n; // throws an exception with a numeric value\n} catch (e) {\n   if (e &lt;= 50) {\n      // statements to handle exceptions 1-50\n   } else {\n      // cannot handle this exception, so rethrow\n      throw e;\n   }\n}\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/publications/files/ECMA-ST-ARCH/ECMA-262,%203rd%20edition,%20December%201999.pdf\" hreflang=\"en\">ECMAScript 3rd Edition (ECMA-262)</a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition. Implemented in JavaScript 1.4</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/5.1/#sec-12.13\" hreflang=\"en\">ECMAScript 5.1 (ECMA-262)<br><small>The definition of 'throw statement' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-throw-statement\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'throw statement' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-throw-statement\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'throw statement' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"try...catch\"><code>try...catch</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/throw$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/throw\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/throw</a>\n  </p>\n</div>\n","statements/return":"<h1>return</h1> <p>The <code>return</code> ends function execution and specifies a value to be returned to the function caller.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/statement-return.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\">return [[expression]]; </pre> <dl> <dt><code>expression</code></dt> <dd>The expression whose value is to be returned. If omitted, <code>undefined</code> is returned instead.</dd> </dl> <h2 id=\"Description\">Description</h2> <p>When a <code>return</code> statement is used in a function body, the execution of the function is stopped. If specified, a given value is returned to the function caller. For example, the following function returns the square of its argument, <code>x</code>, where <code>x</code> is a number.</p> <pre data-language=\"js\">function square(x) {\n   return x * x;\n}\nvar demo = square(3);\n// demo will equal 9\n</pre> <p>If the value is omitted, <code>undefined</code> is returned instead.</p> <p>The following return statements all break the function execution:</p> <pre data-language=\"js\">return;\nreturn true;\nreturn false;\nreturn x;\nreturn x + y / 3;\n</pre> <h3 id=\"Automatic_Semicolon_Insertion\">Automatic Semicolon Insertion</h3> <p>The <code>return</code> statement is affected by <a href=\"../lexical_grammar#Automatic_semicolon_insertion\">automatic semicolon insertion (ASI)</a>. No line terminator is allowed between the <code>return</code> keyword and the expression.</p> <pre data-language=\"js\">return\na + b;\n</pre> <p>is transformed by ASI into:</p> <pre data-language=\"js\">return; \na + b;\n</pre> <p>The console will warn \"unreachable code after return statement\".</p> <div class=\"note\">Starting with Gecko 40 (Firefox 40 / Thunderbird 40 / SeaMonkey 2.37), a warning is shown in the console if unreachable code is found after a return statement.</div> <p>To avoid this problem (to prevent ASI), you could use parentheses:</p> <pre data-language=\"js\">return (\n  a + b\n);\n</pre> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Interrupt_a_function\">Interrupt a function</h3> <p>A function immediately stops at the point where <code>return</code> is called.</p> <pre data-language=\"js\">function counter() {\n  for (var count = 1; ; count++) {  // infinite loop\n    console.log(count + 'A'); // until 5\n      if (count === 5) {          \n        return;\n      }\n      console.log(count + 'B');  // until 4\n    }\n  console.log(count + 'C');  // never appears\n}\n\ncounter();\n\n// Output:\n// 1A\n// 1B\n// 2A\n// 2B\n// 3A\n// 3B\n// 4A\n// 4B\n// 5A\n</pre> <h3 id=\"Returning_a_function\">Returning a function</h3> <p>See also the article about <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Closures\">Closures</a>.</p> <pre data-language=\"js\">function magic() {\n  return function calc(x) { return x * 42; };\n}\n\nvar answer = magic();\nanswer(1337); // 56154\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/publications/files/ECMA-ST-ARCH/ECMA-262,%201st%20edition,%20June%201997.pdf\" hreflang=\"en\">ECMAScript 1st Edition (ECMA-262)</a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/5.1/#sec-12.9\" hreflang=\"en\">ECMAScript 5.1 (ECMA-262)<br><small>The definition of 'Return statement' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-return-statement\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Return statement' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-return-statement\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Return statement' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"../functions\">Functions</a></li> <li><a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Closures\">Closures</a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/return$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/return\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/return</a>\n  </p>\n</div>\n","functions/arrow_functions":"<h1>Arrow functions</h1> <p>An <strong>arrow function expression</strong> has a shorter syntax than a <a href=\"../operators/function\">function expression</a> and does not have its own <code><a href=\"../operators/this\">this</a></code>, <code><a href=\"arguments\">arguments</a></code>, <code><a href=\"../operators/super\">super</a></code>, or <code><a href=\"../operators/new.target\">new.target</a></code>. These function expressions are best suited for non-method functions, and they cannot be used as constructors.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/functions-arrow.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe> <h2 id=\"Syntax\">Syntax</h2> <h3 id=\"Basic_syntax\">Basic syntax</h3> <pre class=\"syntaxbox\">(param1, param2, …, paramN) =&gt; { statements } \n(param1, param2, …, paramN) =&gt; expression\n// equivalent to: =&gt; { return expression; } \n\n// Parentheses are optional when there's only one parameter name:\n(singleParam) =&gt; { statements }\nsingleParam =&gt; { statements }\n\n// The parameter list for a function with no parameters should be written with a pair of parentheses.\n() =&gt; { statements }\n</pre> <h3 id=\"Advanced_syntax\">Advanced syntax</h3> <pre class=\"syntaxbox\">// Parenthesize the body of function to return an object literal expression:\nparams =&gt; ({foo: bar}) \n\n// <a href=\"rest_parameters\">Rest parameters</a> and <a href=\"default_parameters\">default parameters</a> are supported\n(param1, param2, ...rest) =&gt; { statements } \n(param1 = defaultValue1, param2, …, paramN = defaultValueN) =&gt; { \nstatements } \n\n// <a href=\"../operators/destructuring_assignment\">Destructuring</a> within the parameter list is also supported\nvar f = ([a, b] = [1, 2], {x: c} = {x: a + b}) =&gt; a + b + c;\nf(); // 6\n</pre> <h2 id=\"Description\">Description</h2> <p>See also <a href=\"https://hacks.mozilla.org/2015/06/es6-in-depth-arrow-functions/\">\"ES6 In Depth: Arrow functions\" on hacks.mozilla.org</a>.</p> <p>Two factors influenced the introduction of arrow functions: shorter functions and no existence of <code>this</code> keyword.</p> <h3 id=\"Shorter_functions\">Shorter functions</h3> <pre data-language=\"js\">var elements = [\n  'Hydrogen',\n  'Helium',\n  'Lithium',\n  'Beryllium'\n];\n\nelements.<a href=\"../global_objects/array/map\">map</a>(function(element) { \n  return element.length; \n}); // [8, 6, 7, 9]\n\nelements.<a href=\"../global_objects/array/map\">map</a>(element =&gt; {\n  return element.length;\n}); // [8, 6, 7, 9]\n\nelements.map(element =&gt; element.length); // [8, 6, 7, 9]\n\nelements.<a href=\"../global_objects/array/map\">map</a>(({ length }) =&gt; length); // [8, 6, 7, 9]\n</pre> <h3 id=\"No_separate_this\">No separate <code>this</code>\n</h3> <p>Until arrow functions, every new function defined its own <code><a href=\"../operators/this\">this</a></code> value (based on how function was called, a new object in the case of a constructor, undefined in <a href=\"../strict_mode\">strict mode</a> function calls, the base object if the function is called as an \"object method\", etc.). This proved to be less than ideal with an object-oriented style of programming.</p> <pre data-language=\"js\">function Person() {\n  // The Person() constructor defines `this` as an instance of itself.\n  this.age = 0;\n\n  setInterval(function growUp() {\n    // In non-strict mode, the growUp() function defines `this` \n    // as the global object (because it's where growUp() is executed.), \n    // which is different from the `this`\n    // defined by the Person() constructor. \n    this.age++;\n  }, 1000);\n}\n\nvar p = new Person();</pre> <p>In ECMAScript 3/5, the <code>this</code> issue was fixable by assigning the value in <code>this</code> to a variable that could be closed over.</p> <pre data-language=\"js\">function Person() {\n  var that = this;\n  that.age = 0;\n\n  setInterval(function growUp() {\n    // The callback refers to the `that` variable of which\n    // the value is the expected object.\n    that.age++;\n  }, 1000);\n}</pre> <p>Alternatively, a <a href=\"../global_objects/function/bind\">bound function</a> could be created so that a preassigned <code>this</code> value would be passed to the bound target function (the <code>growUp()</code> function in the example above).</p> <p>An arrow function does not have its own <code>this;</code> the <code>this</code> value of the enclosing lexical context is used i.e. Arrow functions follow the normal variable lookup rules. So while searching for <code>this</code> which is not present in current scope they end up finding <code>this</code> from its enclosing scope . Thus, in the following code, the <code>this</code> within the function that is passed to <code>setInterval</code> has the same value as <code>this</code> in the lexically enclosing function:</p> <pre data-language=\"js\">function Person(){\n  this.age = 0;\n\n  setInterval(() =&gt; {\n    this.age++; // |this| properly refers to the Person object\n  }, 1000);\n}\n\nvar p = new Person();</pre> <h4 id=\"Relation_with_strict_mode\">Relation with strict mode</h4> <p>Given that <code>this</code> comes from the surrounding lexical context, <a href=\"../strict_mode\">strict mode</a> rules with regard to <code>this</code> are ignored.</p> <pre data-language=\"js\">var f = () =&gt; { 'use strict'; return this; };\nf() === window; // or the global object</pre> <p>All other strict mode rules apply normally.</p> <h4 id=\"Invoked_through_call_or_apply\">Invoked through call or apply</h4> <p>Since arrow functions do not have their own <code>this</code>, the methods <code>call()</code> or <code>apply()</code> can only pass in parameters. <code>thisArg</code> is ignored.</p> <pre data-language=\"js\">var adder = {\n  base: 1,\n\n  add: function(a) {\n    var f = v =&gt; v + this.base;\n    return f(a);\n  },\n\n  addThruCall: function(a) {\n    var f = v =&gt; v + this.base;\n    var b = {\n      base: 2\n    };\n\n    return f.call(b, a);\n  }\n};\n\nconsole.log(adder.add(1));         // This would log to 2\nconsole.log(adder.addThruCall(1)); // This would log to 2 still</pre> <h3 id=\"No_binding_of_arguments\">No binding of <code>arguments</code>\n</h3> <p>Arrow functions do not have their own <a href=\"arguments\"><code>arguments</code> object</a>. Thus, in this example, <code>arguments</code> is simply a reference to the arguments of the enclosing scope:</p> <pre data-language=\"js\">var arguments = [1, 2, 3];\nvar arr = () =&gt; arguments[0];\n\narr(); // 1\n\nfunction foo(n) {\n  var f = () =&gt; arguments[0] + n; // <em>foo</em>'s implicit arguments binding. arguments[0] is n\n  return f();\n}\n\nfoo(3); // 6</pre> <p>In most cases, using <a href=\"rest_parameters\">rest parameters</a> is a good alternative to using an <code>arguments</code> object.</p> <pre data-language=\"js\">function foo(n) { \n  var f = (...args) =&gt; args[0] + n; \n  return f(10); \n}\n\nfoo(1); // 11</pre> <h3 id=\"Arrow_functions_used_as_methods\">Arrow functions used as methods</h3> <p>As stated previously, arrow function expressions are best suited for non-method functions. Let's see what happens when we try to use them as methods:</p> <pre data-language=\"js\">'use strict';\n\nvar obj = {\n  i: 10,\n  b: () =&gt; console.log(this.i, this),\n  c: function() {\n    console.log(this.i, this);\n  }\n}\n\nobj.b(); // prints undefined, Window {...} (or the global object)\nobj.c(); // prints 10, Object {...}</pre> <p>Arrow functions do not have their own <code>this</code>. Another example involving <a href=\"../global_objects/object/defineproperty\"><code>Object.defineProperty()</code></a>:</p> <pre data-language=\"js\">'use strict';\n\nvar obj = {\n  a: 10\n};\n\nObject.defineProperty(obj, 'b', {\n  get: () =&gt; {\n    console.log(this.a, typeof this.a, this); // undefined 'undefined' Window {...} (or the global object)\n    return this.a + 10; // represents global object 'Window', therefore 'this.a' returns 'undefined'\n  }\n});\n</pre> <h3 id=\"Use_of_the_new_operator\">Use of the <code>new</code> operator</h3> <p>Arrow functions cannot be used as constructors and will throw an error when used with <code>new</code>.</p> <pre data-language=\"js\">var Foo = () =&gt; {};\nvar foo = new Foo(); // TypeError: Foo is not a constructor</pre> <h3 id=\"Use_of_prototype_property\">Use of <code>prototype</code> property</h3> <p>Arrow functions do not have a <code>prototype</code> property.</p> <pre data-language=\"js\">var Foo = () =&gt; {};\nconsole.log(Foo.prototype); // undefined\n</pre> <h3 id=\"Use_of_the_yield_keyword\">Use of the <code>yield</code> keyword</h3> <p>The <code><a href=\"../operators/yield\">yield</a></code> keyword may not be used in an arrow function's body (except when permitted within functions further nested within it). As a consequence, arrow functions cannot be used as generators.</p> <h2 id=\"Function_body\">Function body</h2> <p>Arrow functions can have either a \"concise body\" or the usual \"block body\".</p> <p>In a concise body, only an expression is specified, which becomes the implicit return value. In a block body, you must use an explicit <code>return</code> statement.</p> <pre data-language=\"js\">var func = x =&gt; x * x;                  \n// concise body syntax, implied \"return\"\n\nvar func = (x, y) =&gt; { return x + y; }; \n// with block body, explicit \"return\" needed\n</pre> <h2 id=\"Returning_object_literals\">Returning object literals</h2> <p>Keep in mind that returning object literals using the concise body syntax <code>params =&gt; {object:literal}</code> will not work as expected.</p> <pre data-language=\"js\">var func = () =&gt; { foo: 1 };               \n// Calling func() returns undefined!\n\nvar func = () =&gt; { foo: function() {} };   \n// SyntaxError: function statement requires a name</pre> <p>This is because the code inside braces ({}) is parsed as a sequence of statements (i.e. <code>foo</code> is treated like a label, not a key in an object literal).</p> <p>Remember to wrap the object literal in parentheses.</p> <pre data-language=\"js\">var func = () =&gt; ({foo: 1});</pre> <h2 id=\"Line_breaks\">Line breaks</h2> <p>An arrow function cannot contain a line break between its parameters and its arrow.</p> <pre data-language=\"js\">var func = ()\n           =&gt; 1; \n// SyntaxError: expected expression, got '=&gt;'</pre> <h2 id=\"Parsing_order\">Parsing order</h2> <p>Although the arrow in an arrow function is not an operator, arrow functions have special parsing rules that interact differently with <a href=\"../operators/operator_precedence\">operator precedence</a> compared to regular functions.</p> <pre data-language=\"js\">let callback;\n\ncallback = callback || function() {}; // ok\n\ncallback = callback || () =&gt; {};      \n// SyntaxError: invalid arrow-function arguments\n\ncallback = callback || (() =&gt; {});    // ok\n</pre> <h2 id=\"More_examples\">More examples</h2> <pre data-language=\"js\">// An empty arrow function returns undefined\nlet empty = () =&gt; {};\n\n(() =&gt; 'foobar')(); \n// Returns \"foobar\"\n// (this is an Immediately Invoked Function Expression \n// see 'IIFE' in glossary)\n\nvar simple = a =&gt; a &gt; 15 ? 15 : a; \nsimple(16); // 15\nsimple(10); // 10\n\nlet max = (a, b) =&gt; a &gt; b ? a : b;\n\n// Easy array filtering, mapping, ...\n\nvar arr = [5, 6, 13, 0, 1, 18, 23];\n\nvar sum = arr.reduce((a, b) =&gt; a + b);  \n// 66\n\nvar even = arr.filter(v =&gt; v % 2 == 0); \n// [6, 0, 18]\n\nvar double = arr.map(v =&gt; v * 2);       \n// [10, 12, 26, 0, 2, 36, 46]\n\n// More concise promise chains\npromise.then(a =&gt; {\n  // ...\n}).then(b =&gt; {\n  // ...\n});\n\n// Parameterless arrow functions that are visually easier to parse\nsetTimeout( () =&gt; {\n  console.log('I happen sooner');\n  setTimeout( () =&gt; {\n    // deeper code\n    console.log('I happen later');\n  }, 1);\n}, 1);  \n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-arrow-function-definitions\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Arrow Function Definitions' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-arrow-function-definitions\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Arrow Function Definitions' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>   <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 45</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes bc-has-history\"> 22\n<section class=\"bc-history\" id=\"sect1\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 22\n</dt>\n<dd> The initial implementation of arrow functions in Firefox made them automatically strict. This has been changed as of Firefox 24. The use of <code>'use strict';</code> is now required.</dd>\n<dd> Prior to Firefox 39, a line terminator (<code>\\n</code>) was incorrectly allowed after arrow function arguments. This has been fixed to conform to the ES2015 specification and code like <code>() \\n =&gt; {}</code> will now throw a <code>SyntaxError</code> in this and later versions.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 32</td>\n<td class=\"bc-supports-yes\"> 10</td>\n</tr>\n<tr>\n<th scope=\"row\">Trailing comma in parameters</th>\n<td class=\"bc-supports-yes\"> 58</td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 52</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 45</td>\n<td> ? </td>\n</tr>\n</tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 45</td>\n<td class=\"bc-supports-yes\"> 45</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes bc-has-history\"> 22\n<section class=\"bc-history\" id=\"sect2\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 22\n</dt>\n<dd> The initial implementation of arrow functions in Firefox made them automatically strict. This has been changed as of Firefox 24. The use of <code>'use strict';</code> is now required.</dd>\n<dd> Prior to Firefox 39, a line terminator (<code>\\n</code>) was incorrectly allowed after arrow function arguments. This has been fixed to conform to the ES2015 specification and code like <code>() \\n =&gt; {}</code> will now throw a <code>SyntaxError</code> in this and later versions.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-yes\"> 32</td>\n<td class=\"bc-supports-yes\"> 10</td>\n<td class=\"bc-supports-yes\"> 5.0</td>\n</tr>\n<tr>\n<th scope=\"row\">Trailing comma in parameters</th>\n<td class=\"bc-supports-yes\"> 58</td>\n<td class=\"bc-supports-yes\"> 58</td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 52</td>\n<td class=\"bc-supports-yes\"> 45</td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 7.0</td>\n</tr>\n</tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">Trailing comma in parameters</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n</tbody>\n</table>\n</div>  <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"https://hacks.mozilla.org/2015/06/es6-in-depth-arrow-functions/\">\"ES6 In Depth: Arrow functions\" on hacks.mozilla.org</a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Arrow_functions$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Arrow_functions\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Arrow_functions</a>\n  </p>\n</div>\n","statements/try...catch":"<h1>try...catch</h1> <p>The <code>try...catch</code> statement marks a block of statements to try, and specifies a response, should an exception be thrown.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/statement-trycatch.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\">try {\n   <em>try_statements</em>\n}\n[catch (<em>exception_var_1</em> if <em>condition_1</em>) { // non-standard\n   <em>catch_statements_1</em>\n}]\n...\n[catch (<em>exception_var_2</em>) {\n   <em>catch_statements_2</em>\n}]\n[finally {\n   <em>finally_statements</em>\n}]\n</pre> <dl> <dt><code>try_statements</code></dt> <dd>The statements to be executed.</dd> </dl> <dl> <dt>\n<code>catch_statements_1</code>, <code>catch_statements_2</code>\n</dt> <dd>Statements that are executed if an exception is thrown in the <code>try</code> block.</dd> </dl> <dl> <dt>\n<code>exception_var_1</code>, <code>exception_var_2</code>\n</dt> <dd>An identifier to hold an exception object for the associated <code>catch</code> clause.</dd> </dl> <dl> <dt><code>condition_1</code></dt> <dd>A conditional expression.</dd> </dl> <dl> <dt><code>finally_statements</code></dt> <dd>Statements that are executed after the <code>try</code> statement completes. These statements execute regardless of whether an exception was thrown or caught.</dd> </dl> <h2 id=\"Description\">Description</h2> <p>The <code>try</code> statement consists of a <code>try</code> block, which contains one or more statements. <code>{}</code> must always be used, also for single statements. At least one <code>catch</code> clause, or a <code>finally</code> clause, must be present. This gives us three forms for the <code>try</code> statement:</p> <ol> <li><code>try...catch</code></li> <li><code>try...finally</code></li> <li><code>try...catch...finally</code></li> </ol> <p>A <code>catch</code> clause contains statements that specify what to do if an exception is thrown in the <code>try</code> block. That is, you want the <code>try</code> block to succeed, and if it does not succeed, you want to pass control to the <code>catch</code> block. If any statement within the <code>try</code> block (or in a function called from within the <code>try</code> block) throws an exception, control is immediately shifted to the <code>catch</code> clause. If no exception is thrown in the <code>try</code> block, the <code>catch</code> clause is skipped.</p> <p>The <code>finally</code> clause executes after the <code>try</code> block and <code>catch</code> clause(s) execute but before the statements following the <code>try</code> statement. It always executes, regardless of whether an exception was thrown or caught.</p> <p>You can nest one or more <code>try</code> statements. If an inner <code>try</code> statement does not have a <code>catch</code> clause, the enclosing <code>try</code> statement's <code>catch</code> clause is entered.</p> <p>You can also use the <code>try</code> statement to handle JavaScript exceptions. See the <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide\">JavaScript Guide</a> for more information on JavaScript exceptions.</p> <h3 id=\"Unconditional_catch_clause\">Unconditional <code>catch</code> clause</h3> <p>When a single, unconditional <code>catch</code> clause is used, the <code>catch</code> block is entered when any exception is thrown. For example, when the exception occurs in the following code, control transfers to the <code>catch</code> clause.</p> <pre data-language=\"js\">try {\n   throw 'myException'; // generates an exception\n}\ncatch (e) {\n   // statements to handle any exceptions\n   logMyErrors(e); // pass exception object to error handler\n}\n</pre> <p>The <code>catch</code> block specifies an identifier (<code>e</code> in the example above) that holds the value specified by the <code>throw</code> statement. The <code>catch</code> block is unique in that JavaScript creates this identifier when the <code>catch</code> block is entered and it adds it to the current scope; the identifier lasts only for the duration of the <code>catch</code> block; after the <code>catch</code> block finishes executing, the identifier is no longer available.</p> <h3 id=\"Conditional_catch_clauses\">Conditional <code>catch</code> clauses</h3> <div class=\"blockIndicator nonStandard nonStandardHeader\"> <p><strong> Non-standard</strong><br> This feature is non-standard and is not on a standards track. Do not use it on production sites facing the Web: it will not work for every user. There may also be large incompatibilities between implementations and the behavior may change in the future.</p> </div> <p>You can also use one or more conditional <code>catch</code> clauses to handle specific exceptions. In this case, the appropriate <code>catch</code> clause is entered when the specified exception is thrown. In the following example, code in the <code>try</code> block can potentially throw three exceptions: <a href=\"../global_objects/typeerror\"><code>TypeError</code></a>, <a href=\"../global_objects/rangeerror\"><code>RangeError</code></a>, and <a href=\"../global_objects/evalerror\"><code>EvalError</code></a>. When an exception occurs, control transfers to the appropriate <code>catch</code> clause. If the exception is not one of the specified exceptions and an unconditional <code>catch</code> clause is found, control transfers to that <code>catch</code> clause.</p> <p>If you use an unconditional <code>catch</code> clause with one or more conditional <code>catch</code> clauses, the unconditional <code>catch</code> clause must be specified last. Otherwise, the unconditional <code>catch</code> clause will intercept all types of exception before they can reach the conditional ones.</p> <p>Reminder: this functionality is not part of the ECMAScript specification and has been removed in Firefox 59. It's not supported in any current browser anymore.</p> <pre data-language=\"js\">try {\n    myroutine(); // may throw three types of exceptions\n} catch (e if e instanceof TypeError) {\n    // statements to handle TypeError exceptions\n} catch (e if e instanceof RangeError) {\n    // statements to handle RangeError exceptions\n} catch (e if e instanceof EvalError) {\n    // statements to handle EvalError exceptions\n} catch (e) {\n    // statements to handle any unspecified exceptions\n    logMyErrors(e); // pass exception object to error handler\n}\n</pre> <p>Here is the same \"Conditional catch clauses\" using code that conforms to ECMAScript specification (obviously it's verbose, but works everywhere):</p> <pre data-language=\"js\">try {\n    myroutine(); // may throw three types of exceptions\n} catch (e) {\n    if (e instanceof TypeError) {\n        // statements to handle TypeError exceptions\n    } else if (e instanceof RangeError) {\n        // statements to handle RangeError exceptions\n    } else if (e instanceof EvalError) {\n        // statements to handle EvalError exceptions\n    } else {\n       // statements to handle any unspecified exceptions\n       logMyErrors(e); // pass exception object to error handler\n    }\n}\n</pre> <h3 id=\"The_exception_identifier\">The exception identifier</h3> <p>When an exception is thrown in the <code>try</code> block, <em><code>exception_var</code></em> (e.g. the <code>e</code> in <code>catch (e)</code>) holds the value specified by the <code>throw</code> statement. You can use this identifier to get information about the exception that was thrown. This identifier is local to the <code>catch</code> clause. That is, it is created when the <code>catch</code> clause is entered, and after the <code>catch</code> clause finishes executing, the identifier is no longer available.</p> <div class=\"warning\"> <p>In Firefox 58, when the exception is unused, the identifier can be omitted, as in the code below. This is also <a href=\"https://www.typescriptlang.org/docs/handbook/release-notes/typescript-2-5.html\">allowed in TypeScript 2.5</a> and later. However, at the time of this writing (August 2018), <a href=\"https://github.com/tc39/proposal-optional-catch-binding\">the proposal to support this</a> has not yet been included into an ECMAScript standard, so this syntax may not work in other browsers.</p> </div> <pre data-language=\"js\">function isValidJSON(text) {\n    try {\n        JSON.parse(text);\n        return true;\n    } catch {\n        return false;\n    }\n}\n</pre>  <h3 id=\"The_finally_clause\">The <code>finally</code> clause</h3> <p>The <code>finally</code> clause contains statements to execute after the <code>try</code> block and <code>catch</code> clause(s) execute, but before the statements following the <code>try..catch..finally</code> block. Note that the <code>finally</code> clause executes regardless of whether an exception is thrown. Also, if an exception is thrown, the statements in the <code>finally</code> clause execute even if no <code>catch</code> clause handles the exception. </p> <p>You can use the <code>finally</code> clause to make your script fail gracefully when an exception occurs; for example, to do general cleanup, you may need to release a resource that your script has tied up.</p> <p>It may seem strange to have a special exception-related clause that executes <strong>regardless</strong> of whether there is an exception, but this construct actually does serve a purpose. The important point is not that the <code>finally</code>-clause always executes, but rather that ordinary code following a <code>try..catch</code> does not. </p> <p>For instance, if another exception occurs inside a try's catch-block, any remaining code in the same outer try-block enclosing that try..catch (or in the main flow, if not in an outer try-block) , will not get executed, since control is immediately transferred to the outer try's catch-block (or the internal error-generator, if not in a try-block). </p> <p>Thus, any routine cleanup code done in that enclosed (or the main) section before it exits, will be skipped. However, If the try-block has a finally-block, then that finally-block code will be executed first to permit any such cleanup, and THEN the other try's catch-block (or the error-generator) will get control to handle the second exception. </p> <p>Now, if that routine cleanup must be done whether or not the try..catch code succeeds, then if the finally-block only executed after an exception, the same cleanup code would have to be duplicated both inside and outside the finally-block, and therefore there is no reason not to have just the finally-block alone, and let it execute regardless of exceptions or not.</p> <p>The following example opens a file and then executes statements that use the file (server-side JavaScript allows you to access files). If an exception is thrown while the file is open, the <code>finally</code> clause closes the file before the script fails. The code in <code>finally</code> also executes upon explicitly returning from <code>try</code> or <code>catch</code> block.</p> <pre data-language=\"js\">openMyFile();\ntry {\n   // tie up a resource\n   writeMyFile(theData);\n}\nfinally {\n   closeMyFile(); // always close the resource\n}\n</pre> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Nested_try-blocks\">Nested try-blocks</h3> <p>First, let's see what happens with this:</p> <pre data-language=\"js\">try {\n  try {\n    throw new Error('oops');\n  }\n  finally {\n    console.log('finally');\n  }\n}\ncatch (ex) {\n  console.error('outer', ex.message);\n}\n\n// Output:\n// \"finally\"\n// \"outer\" \"oops\"\n</pre> <p>Now, if we already caught the exception in the inner try-block by adding a catch block</p> <pre data-language=\"js\">try {\n  try {\n    throw new Error('oops');\n  }\n  catch (ex) {\n    console.error('inner', ex.message);\n  }\n  finally {\n    console.log('finally');\n  }\n}\ncatch (ex) {\n  console.error('outer', ex.message);\n}\n\n// Output:\n// \"inner\" \"oops\"\n// \"finally\"\n</pre> <p>And now, let's re-throw the error.</p> <pre data-language=\"js\">try {\n  try {\n    throw new Error('oops');\n  }\n  catch (ex) {\n    console.error('inner', ex.message);\n    throw ex;\n  }\n  finally {\n    console.log('finally');\n  }\n}\ncatch (ex) {\n  console.error('outer', ex.message);\n}\n\n// Output:\n// \"inner\" \"oops\"\n// \"finally\"\n// \"outer\" \"oops\"\n</pre> <p>Any given exception will be caught only once by the nearest enclosing catch-block unless it is re-thrown. Of course, any new exceptions raised in the \"inner\" block (because the code in catch-block may do something that throws), will be caught by the \"outer\" block.</p> <h3 id=\"Returning_from_a_finally_block\">Returning from a finally block</h3> <p>If the <code>finally</code> block returns a value, this value becomes the return value of the entire <code>try-catch-finally</code> production, regardless of any <code>return</code> statements in the <code>try</code> and <code>catch</code> blocks. This includes exceptions thrown inside of the catch block:</p> <pre data-language=\"js\">(function() {\n  try {\n    try {\n      throw new Error('oops');\n    }\n    catch (ex) {\n      console.error('inner', ex.message);\n      throw ex;\n    }\n    finally {\n      console.log('finally');\n      return;\n    }\n  }\n  catch (ex) {\n    console.error('outer', ex.message);\n  }\n})();\n\n// Output:\n// \"inner\" \"oops\"\n// \"finally\"</pre> <p>The outer \"oops\" is not thrown because of the return in the finally block. The same would apply to any value returned from the catch block.</p> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/publications/files/ECMA-ST-ARCH/ECMA-262,%203rd%20edition,%20December%201999.pdf\" hreflang=\"en\">ECMAScript 3rd Edition (ECMA-262)</a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition. Implemented in JavaScript 1.4</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/5.1/#sec-12.14\" hreflang=\"en\">ECMAScript 5.1 (ECMA-262)<br><small>The definition of 'try statement' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-try-statement\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'try statement' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-try-statement\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'try statement' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td>Not part of the current ECMA-262 standard: Multiple catch clauses and conditional clauses (SpiderMonkey extension, JavaScript 1.5).</td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> 6</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">Conditional clauses \n</th>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\">1 — 59</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n</tr>\n<tr>\n<th scope=\"row\">Optional catch binding</th>\n<td class=\"bc-supports-yes\"> 66</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 58</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 53</td>\n<td class=\"bc-supports-no\"> No</td>\n</tr>\n</tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">Conditional clauses \n</th>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\">4 — 59</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n</tr>\n<tr>\n<th scope=\"row\">Optional catch binding</th>\n<td class=\"bc-supports-yes\"> 66</td>\n<td class=\"bc-supports-yes\"> 66</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 58</td>\n<td class=\"bc-supports-yes\"> 53</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n</tr>\n</tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">Conditional clauses \n</th>\n<td class=\"bc-supports-no\"> No</td>\n</tr>\n<tr>\n<th scope=\"row\">Optional catch binding</th>\n<td class=\"bc-supports-no\"> No</td>\n</tr>\n</tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"../global_objects/error\"><code>Error</code></a></li> <li><a href=\"throw\"><code>throw</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/try...catch$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/try...catch\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/try...catch</a>\n  </p>\n</div>\n","functions/rest_parameters":"<h1>rest parameters</h1> <p>The <strong>rest parameter</strong> syntax allows us to represent an indefinite number of arguments as an array.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/functions-restparameters.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre data-language=\"js\">function f(a, b, ...theArgs) {\n  // ...\n}\n</pre> <h2 id=\"Description\">Description</h2> <p>A function's last parameter can be prefixed with <code>...</code> which will cause all remaining (user supplied) arguments to be placed within a \"standard\" javascript array. Only the last parameter can be a \"rest parameter\".</p> <pre data-language=\"js\">function myFun(a, b, ...manyMoreArgs) {\n  console.log(\"a\", a); \n  console.log(\"b\", b);\n  console.log(\"manyMoreArgs\", manyMoreArgs); \n}\n\nmyFun(\"one\", \"two\", \"three\", \"four\", \"five\", \"six\");\n\n// Console Output:\n// a, one\n// b, two\n// manyMoreArgs, [three, four, five, six]\n\n</pre> <h3 id=\"Difference_between_rest_parameters_and_the_arguments_object\">Difference between rest parameters and the <code>arguments</code> object</h3> <p>There are three main differences between rest parameters and the <a href=\"arguments\"><code>arguments</code></a> object:</p> <ul> <li>rest parameters are only the ones that haven't been given a separate name (i.e. formally defined in function expression), while the <code>arguments</code> object contains all arguments passed to the function;</li> <li>the <code>arguments</code> object is not a real array, while rest parameters are <a href=\"../global_objects/array\"><code>Array</code></a> instances, meaning methods like <a href=\"../global_objects/array/sort\"><code>sort</code></a>, <a href=\"../global_objects/array/map\"><code>map</code></a>, <a href=\"../global_objects/array/foreach\"><code>forEach</code></a> or <a href=\"../global_objects/array/pop\"><code>pop</code></a> can be applied on it directly;</li> <li>the <code>arguments</code> object has additional functionality specific to itself (like the <code>callee</code> property).</li> </ul> <h3 id=\"From_arguments_to_an_array\">From arguments to an array</h3> <p>Rest parameters have been introduced to reduce the boilerplate code that was induced by the arguments</p> <pre data-language=\"js\">// Before rest parameters, \"arguments\" could be converted to a normal array using:\n\nfunction f(a, b) {\n\n  var normalArray = Array.prototype.slice.call(arguments);\n  // -- or --\n  var normalArray = [].slice.call(arguments);\n  // -- or --\n  var normalArray = Array.from(arguments);\n\n  var first = normalArray.shift(); // OK, gives the first argument\n  var first = arguments.shift(); // ERROR (arguments is not a normal array)\n\n}\n\n// Now we can easily gain access to a normal array using a rest parameter\n\nfunction f(...args) {\n  var normalArray = args;\n  var first = normalArray.shift(); // OK, gives the first argument\n}\n</pre> <h3 id=\"Destructuring_rest_parameters\">Destructuring rest parameters</h3> <p>Rest parameters can be destructured (arrays only), that means that their data can be unpacked into distinct variables. See <a href=\"../operators/destructuring_assignment\">Destructuring assignment</a>.</p> <pre data-language=\"js\">function f(...[a, b, c]) {\n  return a + b + c;\n}\n\nf(1)          // NaN (b and c are undefined)\nf(1, 2, 3)    // 6\nf(1, 2, 3, 4) // 6 (the fourth parameter is not destructured)</pre> <h2 id=\"Examples\">Examples</h2> <p>In this example, the first argument is mapped to <code>\"a\"</code> and the second to <code>\"b\"</code>, so these named arguments are used like normal. However the third argument <code>\"manyMoreArgs\"</code> will be an array that contains the 3rd, 4th, 5th, 6th ... nth -- as many arguments that the user includes.</p> <pre data-language=\"js\">function myFun(a, b, ...manyMoreArgs) {\n  console.log(\"a\", a); \n  console.log(\"b\", b);\n  console.log(\"manyMoreArgs\", manyMoreArgs); \n}\n\nmyFun(\"one\", \"two\", \"three\", \"four\", \"five\", \"six\");\n\n// a, one\n// b, two\n// manyMoreArgs, [three, four, five, six]\n</pre> <p>Below... even though there is just one value, the last argument still gets put into an array.</p> <pre data-language=\"js\">// using the same function definition from example above\n\nmyFun(\"one\", \"two\", \"three\");\n\n// a, one\n// b, two\n// manyMoreArgs, [three]</pre> <p>Below... the third argument wasn't provided, yet \"manyMoreArgs\" is still an array (although empty).</p> <pre data-language=\"js\">// using the same function definition from example above\n\nmyFun(\"one\", \"two\");\n\n// a, one\n// b, two\n// manyMoreArgs, []</pre> <p>Since <code>theArgs</code> is an array, a count of its elements is given by the <code>length</code> property:</p> <pre data-language=\"js\">function fun1(...theArgs) {\n  console.log(theArgs.length);\n}\n\nfun1();  // 0\nfun1(5); // 1\nfun1(5, 6, 7); // 3\n</pre> <p>In the next example, a rest parameter is used to collect all arguments after the first one in an array. Each one of them is then multiplied by the first parameter and the array is returned:</p> <pre data-language=\"js\">function multiply(multiplier, ...theArgs) {\n  return theArgs.map(function(element) {\n    return multiplier * element;\n  });\n}\n\nvar arr = multiply(2, 1, 2, 3); \nconsole.log(arr); // [2, 4, 6]\n</pre> <p><code>Array</code> methods can be used on rest parameters, but not on the <code>arguments</code> object:</p> <pre data-language=\"js\">function sortRestArgs(...theArgs) {\n  var sortedArgs = theArgs.sort();\n  return sortedArgs;\n}\n\nconsole.log(sortRestArgs(5, 3, 7, 1)); // 1, 3, 5, 7\n\nfunction sortArguments() {\n  var sortedArgs = arguments.sort(); \n  return sortedArgs; // this will never happen\n}\n\n\nconsole.log(sortArguments(5, 3, 7, 1)); // TypeError (arguments.sort is not a function)\n</pre> <p>To use <code>Array</code> methods on the <code>arguments</code> object, it must be converted to a real array first.</p> <pre data-language=\"js\">function sortArguments() {\n  var args = Array.from(arguments);\n  var sortedArgs = args.sort();\n  return sortedArgs;\n}\nconsole.log(sortArguments(5, 3, 7, 1)); // 1, 3, 5, 7\n</pre>  <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-function-definitions\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Function Definitions' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-function-definitions\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Function Definitions' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>   <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 47</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 15</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 34</td>\n<td class=\"bc-supports-yes\"> 10</td>\n</tr>\n<tr>\n<th scope=\"row\">Destructuring rest parameters</th>\n<td class=\"bc-supports-yes\"> 49</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 52</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 36</td>\n<td> ? </td>\n</tr>\n</tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 47</td>\n<td class=\"bc-supports-yes\"> 47</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 15</td>\n<td class=\"bc-supports-yes\"> 34</td>\n<td class=\"bc-supports-yes\"> 10</td>\n<td class=\"bc-supports-yes\"> 5.0</td>\n</tr>\n<tr>\n<th scope=\"row\">Destructuring rest parameters</th>\n<td class=\"bc-supports-yes\"> 49</td>\n<td class=\"bc-supports-yes\"> 49</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 52</td>\n<td class=\"bc-supports-yes\"> 36</td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 5.0</td>\n</tr>\n</tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes bc-has-history\"> 6.0.0\n<section class=\"bc-history\" id=\"sect1\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 6.0.0\n</dt>\n\n<dt class=\"bc-supports-yes bc-supports\"> 4.0.0<div class=\"bc-icons\">Disabled </div>\n</dt>\n<dd>Disabled From version 4.0.0: this feature is behind the <code>--harmony</code> runtime flag.</dd>\n</dl></section>\n</td>\n</tr>\n<tr>\n<th scope=\"row\">Destructuring rest parameters</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n</tbody>\n</table>\n</div>  <h2 id=\"See_also\">See also</h2> <ul> <li>\n<a href=\"../operators/spread_syntax\">Spread syntax</a> (also ‘<code>...</code>’)</li> <li><a href=\"arguments\">Arguments object</a></li> <li><a href=\"../global_objects/array\">Array</a></li> <li><a href=\"../functions\">Functions</a></li> <li><a href=\"http://wiki.ecmascript.org/doku.php?id=harmony:rest_parameters\">Original proposal at ecmascript.org</a></li> <li><a href=\"http://javascriptweblog.wordpress.com/2011/01/18/javascripts-arguments-object-and-beyond/\">JavaScript arguments object and beyond</a></li> <li><a href=\"../operators/destructuring_assignment\">Destructuring assignment</a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/rest_parameters$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/rest_parameters\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/rest_parameters</a>\n  </p>\n</div>\n","errors/not_a_codepoint":"<h1>Errors: Not a codepoint</h1> <h2 id=\"Message\">Message</h2> <pre class=\"syntaxbox\">RangeError: Invalid code point {0} (Edge)\nRangeError: {0} is not a valid code point (Firefox)\nRangeError: Invalid code point {0} (Chrome)\n</pre>  <h2 id=\"Error_type\">Error type</h2> <p><a href=\"../global_objects/rangeerror\"><code>RangeError</code></a></p> <h2 id=\"What_went_wrong\">What went wrong?</h2> <p>The <a href=\"../global_objects/string/fromcodepoint\"><code>String.fromCodePoint()</code></a> method accepts valid code points only.</p> <p>A <a href=\"https://en.wikipedia.org/wiki/Code_point\">code point</a> is a value in the Unicode codespace; that is, the range of integers from <code>0</code> to <code>0x10FFFF</code>.</p> <p>Using <a href=\"../global_objects/nan\"><code>NaN</code></a> values, negative Integers (<code>-1</code>), non-Integers (<code>3.14</code>), or values larger than <code>0x10FFFF</code> (<code>1114111</code>) won't work with this method.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Invalid_cases\">Invalid cases</h3> <pre data-language=\"js\">String.fromCodePoint('_');      // RangeError\nString.fromCodePoint(Infinity); // RangeError\nString.fromCodePoint(-1);       // RangeError\nString.fromCodePoint(3.14);     // RangeError\nString.fromCodePoint(3e-2);     // RangeError\nString.fromCodePoint(NaN);      // RangeError</pre> <h3 id=\"Valid_cases\">Valid cases</h3> <pre data-language=\"js\">String.fromCodePoint(42);       // \"*\"\nString.fromCodePoint(65, 90);   // \"AZ\"\nString.fromCodePoint(0x404);    // \"\\u0404\"\nString.fromCodePoint(0x2F804);  // \"\\uD87E\\uDC04\"\nString.fromCodePoint(194564);   // \"\\uD87E\\uDC04\"\nString.fromCodePoint(0x1D306, 0x61, 0x1D307) // \"\\uD834\\uDF06a\\uD834\\uDF07\"\n</pre> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"../global_objects/string/fromcodepoint\"><code>String.fromCodePoint()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Not_a_codepoint$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Not_a_codepoint\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Not_a_codepoint</a>\n  </p>\n</div>\n","functions/default_parameters":"<h1>Default parameters</h1> <p><strong>Default function parameters</strong> allow named parameters to be initialized with default values if no value or <code>undefined</code> is passed.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/functions-default.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\">function [<em>name</em>]([<em>param1</em>[ = defaultValue1 ][, ..., <em>paramN</em>[ = defaultValueN ]]]) {\n   <em>statements</em>\n}\n</pre> <h2 id=\"Description\">Description</h2> <p>In JavaScript, function parameters default to <code><a href=\"../global_objects/undefined\"><code>undefined</code></a></code>. However, it's often useful to set a different default value. This is where default parameters can help.</p> <p>In the past, the general strategy for setting defaults was to test parameter values in the function body and assign a value if they are <code>undefined</code>.</p> <p>In the following example, if no value is provided for <code>b</code> when <code>multiply</code> is called, <code>b</code>’s value would be <code>undefined</code> when evaluating <code>a * b</code> and <code>multiply</code> would return <code>NaN</code>.</p> <pre data-language=\"js\">function multiply(a, b) {\n  return a * b;\n}\n\nmultiply(5, 2); // 10\nmultiply(5);    // NaN !\n</pre> <p>To guard against this, something like the second line would be used, where <code>b</code> is set to <code>1</code> if <code>multiply</code> is called with only one argument:</p> <pre data-language=\"js\">function multiply(a, b) {\n  b = (typeof b !== 'undefined') ?  b : 1;\n  return a * b;\n}\n\nmultiply(5, 2); // 10\nmultiply(5);    // 5\n</pre> <p>With default parameters in ES2015, checks in the function body are no longer necessary. Now, you can assign <code>1</code> as the default value for <code>b</code> in the function head:</p> <pre data-language=\"js\">function multiply(a, b = 1) {\n  return a * b;\n}\n\nmultiply(5, 2); // 10\nmultiply(5);    // 5\n</pre> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Passing_undefined_vs._other_falsy_values\">Passing <code>undefined</code> vs. other falsy values</h3> <p>In the second call in this example, even if the first argument is set explicitly to <code>undefined</code> (though not <code>null</code> or other <em><a href=\"https://developer.mozilla.org/en-US/docs/Glossary/Falsy\">falsy</a> values</em>), the value of the <code>num</code> argument is still the default.</p> <pre data-language=\"js\">function test(num = 1) {\n  console.log(typeof num);\n}\n\ntest();          // 'number' (num is set to 1)\ntest(undefined); // 'number' (num is set to 1 too)\n\n// test with other falsy values:\ntest('');        // 'string' (num is set to '')\ntest(null);      // 'object' (num is set to null)\n</pre> <h3 id=\"Evaluated_at_call_time\">Evaluated at call time</h3> <p>The default argument is evaluated at call time, so unlike e.g. Python, a new object is created each time the function is called.</p> <pre data-language=\"js\">function append(value, array = []) {\n  array.push(value);\n  return array;\n}\n\nappend(1); //[1]\nappend(2); //[2], not [1, 2]\n</pre> <p>This even applies to functions and variables:</p> <pre data-language=\"js\">function callSomething(thing = something()) {\n return thing;\n}\n\nlet numberOfTimesCalled = 0;\nfunction something() {\n  numberOfTimesCalled += 1;\n  return numberOfTimesCalled;\n}\n\ncallSomething(); // 1\ncallSomething(); // 2</pre> <h3 id=\"Default_parameters_are_available_to_later_default_parameters\">Default parameters are available to later default parameters</h3> <p>Parameters defined beforehand (to the left) are available to later default parameters:</p> <pre data-language=\"js\">function greet(name, greeting, message = greeting + ' ' + name) {\n    return [name, greeting, message];\n}\n\ngreet('David', 'Hi');  // [\"David\", \"Hi\", \"Hi David\"]\ngreet('David', 'Hi', 'Happy Birthday!');  // [\"David\", \"Hi\", \"Happy Birthday!\"]\n</pre> <p>This functionality can be approximated like this, which demonstrates how many edge cases are handled:</p> <pre data-language=\"js\">function go() {\n  return ':P';\n}\n\nfunction withDefaults(a, b = 5, c = b, d = go(), e = this, \n                      f = arguments, g = this.value) {\n  return [a, b, c, d, e, f, g];\n}\n\nfunction withoutDefaults(a, b, c, d, e, f, g) {\n  switch (arguments.length) {\n    case 0:\n      a;\n    case 1:\n      b = 5;\n    case 2:\n      c = b;\n    case 3:\n      d = go();\n    case 4:\n      e = this;\n    case 5:\n      f = arguments;\n    case 6:\n      g = this.value;\n    default:\n  }\n  return [a, b, c, d, e, f, g];\n}\n\nwithDefaults.call({value: '=^_^='});\n// [undefined, 5, 5, \":P\", {value:\"=^_^=\"}, arguments, \"=^_^=\"]\n\nwithoutDefaults.call({value: '=^_^='});\n// [undefined, 5, 5, \":P\", {value:\"=^_^=\"}, arguments, \"=^_^=\"]\n</pre> <h3 id=\"Functions_defined_inside_function_body\">Functions defined inside function body</h3> <p>Introduced in Gecko 33 (Firefox 33 / Thunderbird 33 / SeaMonkey 2.30). Functions declared in the function body cannot be referred to inside the outer function]s default parameters. If attempted, a <a href=\"../global_objects/referenceerror\"><code>ReferenceError</code></a> is thrown. Default parameters are always executed first, so function declarations inside the function body evaluate afterwards.</p> <pre data-language=\"js\">// Doesn't work! Throws ReferenceError.\nfunction f(a = go()) {\n  function go() { return ':P'; }\n}\n</pre> <h3 id=\"Parameters_without_defaults_after_default_parameters\">Parameters without defaults after default parameters</h3> <p>Prior to Gecko 26 (Firefox 26 / Thunderbird 26 / SeaMonkey 2.23 / Firefox OS 1.2), the following code resulted in a <a href=\"../global_objects/syntaxerror\"><code>SyntaxError</code></a>. This was fixed in <a href=\"https://bugzilla.mozilla.org/show_bug.cgi?id=777060\">bug 777060</a>. Parameters are still set left-to-right, overwriting default parameters even if there are later parameters without defaults.</p> <pre data-language=\"js\">function f(x = 1, y) { \n  return [x, y]; \n}\n\nf(); // [1, undefined]\nf(2); // [2, undefined]\n</pre> <h3 id=\"Destructured_parameter_with_default_value_assignment\">Destructured parameter with default value assignment</h3> <p>You can use default value assignment with the <a href=\"../operators/destructuring_assignment\">destructuring assignment</a> notation:</p> <pre data-language=\"js\">function f([x, y] = [1, 2], {z: z} = {z: 3}) { \n  return x + y + z; \n}\n\nf(); // 6</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-function-definitions\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Function Definitions' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-function-definitions\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Function Definitions' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>   <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 49</td>\n<td class=\"bc-supports-yes\"> 14</td>\n<td class=\"bc-supports-yes\"> 15</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 36</td>\n<td class=\"bc-supports-yes\"> 10</td>\n</tr>\n<tr>\n<th scope=\"row\">Parameters without defaults after default parameters</th>\n<td class=\"bc-supports-yes\"> 49</td>\n<td class=\"bc-supports-yes\"> 14</td>\n<td class=\"bc-supports-yes\"> 26</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 36</td>\n<td class=\"bc-supports-yes\"> 10</td>\n</tr>\n<tr>\n<th scope=\"row\">Destructured parameter with default value assignment</th>\n<td class=\"bc-supports-yes\"> 49</td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 41</td>\n<td class=\"bc-supports-no\"> No</td>\n<td> ? </td>\n<td> ? </td>\n</tr>\n</tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 49</td>\n<td class=\"bc-supports-yes\"> 49</td>\n<td class=\"bc-supports-yes\"> 14</td>\n<td class=\"bc-supports-yes\"> 15</td>\n<td class=\"bc-supports-yes\"> 36</td>\n<td class=\"bc-supports-yes\"> 10</td>\n<td class=\"bc-supports-yes\"> 5.0</td>\n</tr>\n<tr>\n<th scope=\"row\">Parameters without defaults after default parameters</th>\n<td class=\"bc-supports-yes\"> 49</td>\n<td class=\"bc-supports-yes\"> 49</td>\n<td class=\"bc-supports-yes\"> 14</td>\n<td class=\"bc-supports-yes\"> 26</td>\n<td class=\"bc-supports-yes\"> 36</td>\n<td class=\"bc-supports-yes\"> 10</td>\n<td class=\"bc-supports-yes\"> 5.0</td>\n</tr>\n<tr>\n<th scope=\"row\">Destructured parameter with default value assignment</th>\n<td class=\"bc-supports-yes\"> 49</td>\n<td class=\"bc-supports-yes\"> 49</td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 41</td>\n<td> ? </td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 5.0</td>\n</tr>\n</tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 6.0.0</td>\n</tr>\n<tr>\n<th scope=\"row\">Parameters without defaults after default parameters</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">Destructured parameter with default value assignment</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n</tbody>\n</table>\n</div>  <h2 id=\"See_also\">See also</h2> <ul> <li><a rel=\"external\" href=\"http://wiki.ecmascript.org/doku.php?id=harmony:parameter_default_values\">Original proposal at ecmascript.org</a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Default_parameters$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Default_parameters\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Default_parameters</a>\n  </p>\n</div>\n","classes/constructor":"<h1>constructor</h1> <p>The <code>constructor</code> method is a special method for creating and initializing an object created within a <code><a href=\"../statements/class\">class</a></code>.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/classes-constructor.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\">constructor([<em>arguments</em>]) { ... }</pre> <h2 id=\"Description\">Description</h2> <p>There can be only one special method with the name \"constructor\" in a class. Having more than one occurrence of a <code>constructor</code> method in a class will throw a <a href=\"../global_objects/syntaxerror\"><code>SyntaxError</code></a> error.</p> <p>A constructor can use the <code>super</code> keyword to call the constructor of a parent class.</p> <p>If you do not specify a constructor method, a default constructor is used.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Using_the_constructor_method\">Using the <code>constructor</code> method</h3> <p>This code snippet is taken from the <a href=\"https://github.com/GoogleChrome/samples/blob/gh-pages/classes-es6/index.html\">classes sample</a> (<a href=\"https://googlechrome.github.io/samples/classes-es6/index.html\">live demo</a>).</p> <pre data-language=\"js\">class Square extends Polygon {\n  constructor(length) {\n    // Here, it calls the parent class' constructor with lengths\n    // provided for the Polygon's width and height\n    super(length, length);\n    // Note: In derived classes, super() must be called before you\n    // can use 'this'. Leaving this out will cause a reference error.\n    this.name = 'Square';\n  }\n\n  get area() {\n    return this.height * this.width;\n  }\n\n  set area(value) {\n    this.area = value;\n  } \n}</pre> <h3 id=\"Another_example\">Another example</h3> <p>Take a look at this code snippet</p> <pre data-language=\"js\">class Polygon {\n    constructor() {\n        this.name = \"Polygon\";\n    }\n}\n\nclass Square extends Polygon {\n    constructor() {\n        super();\n    }\n}\n\nclass Rectangle {}\n\nObject.setPrototypeOf(Square.prototype, Rectangle.prototype);\n\nconsole.log(Object.getPrototypeOf(Square.prototype) === Polygon.prototype); //false\nconsole.log(Object.getPrototypeOf(Square.prototype) === Rectangle.prototype); //true\n\nlet newInstance = new Square();\nconsole.log(newInstance.name); //Polygon</pre> <p>Here the prototype of <strong>Square</strong> class is changed but still the constructor of the previous base class <strong>Polygon </strong>is called when a new instance of a square is being created.</p> <h3 id=\"Default_constructors\">Default constructors</h3> <p>As stated, if you do not specify a constructor method a default constructor is used. For base classes the default constructor is:</p> <pre data-language=\"js\">constructor() {}\n</pre> <p>For derived classes, the default constructor is:</p> <pre data-language=\"js\">constructor(...args) {\n  super(...args);\n}</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-static-semantics-constructormethod\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Constructor Method' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-static-semantics-constructormethod\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Constructor Method' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes bc-has-history\"> 49\n<section class=\"bc-history\" id=\"sect1\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 49\n</dt>\n<dd> From Chrome 42 to 48 strict mode is required. Non-strict mode support can be enabled using the flag \"Enable Experimental JavaScript\".</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-yes\"> 13</td>\n<td class=\"bc-supports-yes\"> 45</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 36</td>\n<td class=\"bc-supports-yes\"> 9</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 13</td>\n<td class=\"bc-supports-yes\"> 45</td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 9</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes bc-has-history\"> 6.0.0\n<section class=\"bc-history\" id=\"sect2\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 6.0.0\n</dt>\n\n<dt class=\"bc-supports-yes bc-supports\"> 4.0.0<div class=\"bc-icons\">Disabled </div>\n</dt>\n<dd>Disabled From version 4.0.0: this feature is behind the <code>--use_strict</code> runtime flag.</dd>\n<dt class=\"bc-supports-yes bc-supports\"> 5.0.0<div class=\"bc-icons\">Disabled </div>\n</dt>\n<dd>Disabled From version 5.0.0: this feature is behind the <code>--harmony</code> runtime flag.</dd>\n</dl></section>\n</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"../operators/super\">super()</a></li> <li><a href=\"../operators/class\"><code>class</code> expression</a></li> <li><a href=\"../statements/class\"><code>class</code> declaration</a></li> <li><a href=\"../classes\">Classes</a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes/constructor$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes/constructor\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes/constructor</a>\n  </p>\n</div>\n","errors/property_access_denied":"<h1>Errors: Property access denied</h1> <h2 id=\"Message\">Message</h2> <pre class=\"syntaxbox\">Error: Permission denied to access property \"x\"\n</pre> <h2 id=\"Error_type\">Error type</h2> <p><a href=\"../global_objects/error\"><code>Error</code></a>.</p> <h2 id=\"What_went_wrong\">What went wrong?</h2> <p>There was attempt to access an object for which you have no permission. This is likely an <a href=\"https://developer.mozilla.org/en-US/docs/Web/HTML/Element/iframe\"><code>&lt;iframe&gt;</code></a> element loaded from a different domain for which you violated the <a href=\"https://developer.mozilla.org/en-US/docs/Web/Security/Same-origin_policy\">same-origin policy</a>.</p> <h2 id=\"Examples\">Examples</h2> <pre data-language=\"html\">&lt;!DOCTYPE html&gt;\n&lt;html&gt;\n  &lt;head&gt;\n    &lt;iframe id=\"myframe\" src=\"http://www1.w3c-test.org/common/blank.html\"&gt;&lt;/iframe&gt;\n    &lt;script&gt;\n      onload = function() {\n        console.log(frames[0].document);\n        // Error: Permission denied to access property \"document\"\n      }\n    &lt;/script&gt;\n  &lt;/head&gt;\n  &lt;body&gt;&lt;/body&gt;\n&lt;/html&gt;</pre> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"https://developer.mozilla.org/en-US/docs/Web/HTML/Element/iframe\"><code>&lt;iframe&gt;</code></a></li> <li><a href=\"https://developer.mozilla.org/en-US/docs/Web/Security/Same-origin_policy\">Same-origin policy</a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Property_access_denied$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Property_access_denied\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Property_access_denied</a>\n  </p>\n</div>\n","errors/precision_range":"<h1>Errors: Precision range</h1> <h2 id=\"Message\">Message</h2> <pre class=\"syntaxbox\">RangeError: The number of fractional digits is out of range (Edge)\nRangeError: The precision is out of range (Edge)\nRangeError: precision {0} out of range (Firefox)\nRangeError: toExponential() argument must be between 0 and 20 (Chrome)\nRangeError: toFixed() digits argument must be between 0 and 20 (Chrome)\nRangeError: toPrecision() argument must be between 1 and 21 (Chrome)\n</pre> <h2 id=\"Error_type\">Error type</h2> <p><a href=\"../global_objects/rangeerror\"><code>RangeError</code></a></p> <h2 id=\"What_went_wrong\">What went wrong?</h2> <p>There was an out of range precision argument in one of these methods:</p> <ul> <li><a href=\"../global_objects/number/toexponential\"><code>Number.prototype.toExponential()</code></a></li> <li><a href=\"../global_objects/number/tofixed\"><code>Number.prototype.toFixed()</code></a></li> <li><a href=\"../global_objects/number/toprecision\"><code>Number.prototype.toPrecision()</code></a></li> </ul> <p>The allowed range for these methods is usually between 0 and 20 (or 21). However, the ECMAScript specification allows to extend this range.</p> <div class=\"_table\"><table class=\"standard-table\"> <thead> <tr> <th scope=\"col\">Method</th> <th scope=\"col\">Firefox (SpiderMonkey)</th> <th scope=\"col\">Chrome, Opera (V8)</th> </tr> </thead> <tbody> <tr> <td><a href=\"../global_objects/number/toexponential\"><code>Number.prototype.toExponential()</code></a></td> <td>0 to 100</td> <td>0 to 20</td> </tr> <tr> <td><a href=\"../global_objects/number/tofixed\"><code>Number.prototype.toFixed()</code></a></td> <td>-20 to 100</td> <td>0 to 20</td> </tr> <tr> <td><a href=\"../global_objects/number/toprecision\"><code>Number.prototype.toPrecision()</code></a></td> <td>1 to 100</td> <td>1 to 21</td> </tr> </tbody> </table></div> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Invalid_cases\">Invalid cases</h3> <pre data-language=\"js\">77.1234.toExponential(-1);  // RangeError\n77.1234.toExponential(101); // RangeError\n\n2.34.toFixed(-100);         // RangeError \n2.34.toFixed(1001);         // RangeError \n\n1234.5.toPrecision(-1);     // RangeError\n1234.5.toPrecision(101);    // RangeError\n</pre> <h3 id=\"Valid_cases\">Valid cases</h3> <pre data-language=\"js\">77.1234.toExponential(4); // 7.7123e+1\n77.1234.toExponential(2); // 7.71e+1\n\n2.34.toFixed(1); // 2.3\n2.35.toFixed(1); // 2.4 (note that it rounds up in this case)\n\n5.123456.toPrecision(5); // 5.1235\n5.123456.toPrecision(2); // 5.1\n5.123456.toPrecision(1); // 5\n</pre> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"../global_objects/number/toexponential\"><code>Number.prototype.toExponential()</code></a></li> <li><a href=\"../global_objects/number/tofixed\"><code>Number.prototype.toFixed()</code></a></li> <li><a href=\"../global_objects/number/toprecision\"><code>Number.prototype.toPrecision()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Precision_range$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Precision_range\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Precision_range</a>\n  </p>\n</div>\n","functions/set":"<h1>set</h1> <p>The <code>set</code> syntax binds an object property to a function to be called when there is an attempt to set that property.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/functions-setter.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\">{set <em>prop</em>(<em>val</em>) { . . . }}\n{set [expression](<em>val</em>) { . . . }}</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><code>prop</code></dt> <dd>The name of the property to bind to the given function.</dd> </dl> <dl> <dt><code>val</code></dt> <dd>An alias for the variable that holds the value attempted to be assigned to <code>prop.</code>\n</dd> <dt>expression</dt> <dd>Starting with ECMAScript 2015, you can also use expressions for a computed property name to bind to the given function.</dd> </dl> <h2 id=\"Description\">Description</h2> <p>In JavaScript, a setter can be used to execute a function whenever a specified property is attempted to be changed. Setters are most often used in conjunction with getters to create a type of pseudo-property. It is not possible to simultaneously have a setter on a property that holds an actual value.</p> <p>Note the following when working with the <code>set</code> syntax:</p>  <ul> <li>It can have an identifier which is either a number or a string;</li> <li>It must have exactly one parameter (see <a rel=\"external nofollow\" href=\"http://whereswalden.com/2010/08/22/incompatible-es5-change-literal-getter-and-setter-functions-must-now-have-exactly-zero-or-one-arguments/\">Incompatible <abbr title=\"ECMAScript 5th edition\">ES5</abbr> change: literal getter and setter functions must now have exactly zero or one arguments</a> for more information);</li> <li>It must not appear in an object literal with another <code>set</code> or with a data entry for the same property.<br> ( <code>{ set x(v) { }, set x(v) { } }</code> and <code>{ x: ..., set x(v) { } }</code> are forbidden )</li> </ul>  <p>A setter can be removed using the <a href=\"../operators/delete\"><code>delete</code></a> operator.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Defining_a_setter_on_new_objects_in_object_initializers\">Defining a setter on new objects in object initializers</h3> <p>This will define a pseudo-property <code>current</code> of object <font face=\"consolas, Liberation Mono, courier, monospace\">language</font> that, when assigned a value, will update <code>log</code> with that value:</p> <pre data-language=\"js\">var language = {\n  set current(name) {\n    this.log.push(name);\n  },\n  log: []\n}\n\nlanguage.current = 'EN';\nconsole.log(language.log); // ['EN']\n\nlanguage.current = 'FA';\nconsole.log(language.log); // ['EN', 'FA']\n</pre> <p>Note that <code>current</code> is not defined and any attempts to access it will result in <code>undefined</code>.</p> <h3 id=\"Removing_a_setter_with_the_delete_operator\">Removing a setter with the <code>delete</code> operator</h3> <p>If you want to remove the setter, you can just <code><a href=\"../operators/delete\">delete</a></code> it:</p> <pre data-language=\"js\">delete o.current;\n</pre> <h3 id=\"Defining_a_setter_on_existing_objects_using_defineProperty\">Defining a setter on existing objects using <code>defineProperty</code>\n</h3> <p>To append a setter to an existing object later at any time, use <a href=\"../global_objects/object/defineproperty\"><code>Object.defineProperty()</code></a>.</p> <pre data-language=\"js\">var o = {a: 0};\n\nObject.defineProperty(o, 'b', { set: function(x) { this.a = x / 2; } });\n\no.b = 10; // Runs the setter, which assigns 10 / 2 (5) to the 'a' property\nconsole.log(o.a) // 5</pre> <h3 id=\"Using_a_computed_property_name\">Using a computed property name</h3> <pre data-language=\"js\">var expr = 'foo';\n\nvar obj = {\n  baz: 'bar',\n  set [expr](v) { this.baz = v; }\n};\n\nconsole.log(obj.baz); // \"bar\"\nobj.foo = 'baz';      // run the setter\nconsole.log(obj.baz); // \"baz\"\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/5.1/#sec-11.1.5\" hreflang=\"en\">ECMAScript 5.1 (ECMA-262)<br><small>The definition of 'Object Initializer' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-method-definitions\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Method definitions' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Added computed property names.</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-method-definitions\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Method definitions' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 2</td>\n<td class=\"bc-supports-yes\"> 9</td>\n<td class=\"bc-supports-yes\"> 9.5</td>\n<td class=\"bc-supports-yes\"> 3</td>\n</tr>\n<tr>\n<th scope=\"row\">Computed property names</th>\n<td class=\"bc-supports-yes\"> 46</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 34</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 47</td>\n<td class=\"bc-supports-no\"> No</td>\n</tr>\n</tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> 18</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">Computed property names</th>\n<td class=\"bc-supports-yes\"> 46</td>\n<td class=\"bc-supports-yes\"> 46</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 34</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 5.0</td>\n</tr>\n</tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">Computed property names</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n</tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"get\">getter</a></li> <li><a href=\"../operators/delete\"><code>delete</code></a></li> <li><a href=\"../global_objects/object/defineproperty\"><code>Object.defineProperty()</code></a></li> <li><a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/defineGetter\"><code>__defineGetter__</code></a></li> <li><a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/defineSetter\"><code>__defineSetter__</code></a></li> <li>\n<a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Working_with_Objects#Defining_getters_and_setters\">Defining Getters and Setters</a> in JavaScript Guide</li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/set$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/set\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/set</a>\n  </p>\n</div>\n","classes/extends":"<h1>extends</h1> <p>The <code>extends</code> keyword is used in <a href=\"../statements/class\">class declarations</a> or <a href=\"../operators/class\">class expressions</a> to create a class which is a child of another class.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/classes-extends.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js taller\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\">class ChildClass extends ParentClass { ... }</pre> <h2 id=\"Description\">Description</h2> <p>The <code>extends</code> keyword can be used to subclass custom classes as well as built-in objects.</p> <p>The <code>.prototype</code> of the extension must be an <a href=\"../global_objects/object\"><code>Object</code></a> or <a href=\"../global_objects/null\"><code>null</code></a>.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Using_extends\">Using <code>extends</code>\n</h3> <p>The first example creates a class called <code>Square</code> from a class called <code>Polygon</code>. This example is extracted from this <a href=\"https://googlechrome.github.io/samples/classes-es6/index.html\">live demo</a> <a href=\"https://github.com/GoogleChrome/samples/blob/gh-pages/classes-es6/index.html\">(source)</a>.</p> <pre data-language=\"js\">class Square extends Polygon {\n  constructor(length) {\n    // Here, it calls the parent class' constructor with lengths\n    // provided for the Polygon's width and height\n    super(length, length);\n    // Note: In derived classes, super() must be called before you\n    // can use 'this'. Leaving this out will cause a reference error.\n    this.name = 'Square';\n  }\n\n  get area() {\n    return this.height * this.width;\n  }\n}</pre> <h3 id=\"Using_extends_with_built-in_objects\">Using <code>extends</code> with built-in objects</h3> <p>This example extends the built-in <a href=\"../global_objects/date\"><code>Date</code></a> object. This example is extracted from this <a href=\"https://googlechrome.github.io/samples/classes-es6/index.html\">live demo</a> <a href=\"https://github.com/GoogleChrome/samples/blob/gh-pages/classes-es6/index.html\">(source)</a>.</p> <pre data-language=\"js\">class myDate extends Date {\n  constructor() {\n    super();\n  }\n\n  getFormattedDate() {\n    var months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];\n    return this.getDate() + '-' + months[this.getMonth()] + '-' + this.getFullYear();\n  }\n}</pre> <h3 id=\"Extending_null\">Extending <code>null</code>\n</h3> <p>Extending from <a href=\"../global_objects/null\"><code>null</code></a> works like with a normal class, except that the prototype object does not inherit from <a href=\"../global_objects/object/prototype\"><code>Object.prototype</code></a>.</p> <pre data-language=\"js\">class nullExtends extends null {\n  constructor() {}\n}\n\nObject.getPrototypeOf(nullExtends); // Function.prototype\nObject.getPrototypeOf(nullExtends.prototype) // null\n\nnew nullExtends(); //ReferenceError: this is not defined\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-class-definitions\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'extends' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-class-definitions\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'extends' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes bc-has-history\"> 49\n<section class=\"bc-history\" id=\"sect1\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 49\n</dt>\n<dd> From Chrome 42 to 48 strict mode is required. Non-strict mode support can be enabled using the flag \"Enable Experimental JavaScript\".</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-yes\"> 13</td>\n<td class=\"bc-supports-yes\"> 45</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 36</td>\n<td class=\"bc-supports-yes\"> 9</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 13</td>\n<td class=\"bc-supports-yes\"> 45</td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 9</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes bc-has-history\"> 6.0.0\n<section class=\"bc-history\" id=\"sect2\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 6.0.0\n</dt>\n\n<dt class=\"bc-supports-yes bc-supports\"> 4.0.0<div class=\"bc-icons\">Disabled </div>\n</dt>\n<dd>Disabled From version 4.0.0: this feature is behind the <code>--use_strict</code> runtime flag.</dd>\n<dt class=\"bc-supports-yes bc-supports\"> 5.0.0<div class=\"bc-icons\">Disabled </div>\n</dt>\n<dd>Disabled From version 5.0.0: this feature is behind the <code>--harmony</code> runtime flag.</dd>\n</dl></section>\n</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"../classes\">Classes</a></li> <li><a href=\"../operators/super\">super</a></li> <li><a href=\"https://medium.com/beginners-guide-to-mobile-web-development/super-and-extends-in-javascript-es6-understanding-the-tough-parts-6120372d3420\">Anurag Majumdar - Super &amp; Extends in JavaScript</a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes/extends$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes/extends\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes/extends</a>\n  </p>\n</div>\n","errors/invalid_array_length":"<h1>Errors: Invalid array length</h1> <h2 id=\"Message\">Message</h2> <pre class=\"syntaxbox\">RangeError: Array length must be a finite positive integer (Edge)\nRangeError: invalid array length (Firefox)\nRangeError: Invalid array length (Chrome)\nRangeError: Invalid array buffer length (Chrome)\n</pre> <h2 id=\"Error_type\">Error type</h2> <p><a href=\"../global_objects/rangeerror\"><code>RangeError</code></a></p> <h2 id=\"What_went_wrong\">What went wrong?</h2> <p>An invalid array length might appear in these situations:</p> <ul> <li>When creating an <a href=\"../global_objects/array\"><code>Array</code></a> or an <a href=\"../global_objects/arraybuffer\"><code>ArrayBuffer</code></a> which has a length which is either negative or larger or equal to 2<sup>32</sup>, or</li> <li>when setting the <a href=\"../global_objects/array/length\"><code>Array.length</code></a> property to a value which is either negative or larger or equal to 2<sup>32</sup>.</li> </ul> <p>Why are <code>Array</code> and <code>ArrayBuffer</code> length limited? The <code>length</code> property of an <code>Array</code> or an <code>ArrayBuffer</code> is represented with an unsigned 32-bit integer, that can only store values which are in the range from 0 to 2<sup>32</sup>-1.</p> <p>If you are creating an <code>Array</code>, using the constructor, you probably want to use the literal notation instead, as the first argument is interpreted as the length of the <code>Array</code>.</p> <p>Otherwise, you might want to clamp the length before setting the length property, or using it as argument of the constructor.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Invalid_cases\">Invalid cases</h3> <pre data-language=\"js\">new Array(Math.pow(2, 40))\nnew Array(-1)\nnew ArrayBuffer(Math.pow(2, 32))\nnew ArrayBuffer(-1)\n\nlet a = [];\na.length = a.length - 1;         // set -1 to the length property\n\nlet b = new Array(Math.pow(2, 32) - 1);\nb.length = b.length + 1;         // set 2^32 to the length property\n</pre> <h3 id=\"Valid_cases\">Valid cases</h3> <pre data-language=\"js\">[ Math.pow(2, 40) ]                     // [ 1099511627776 ]\n[ -1 ]                                  // [ -1 ]\nnew ArrayBuffer(Math.pow(2, 32) - 1)\nnew ArrayBuffer(0)\n\nlet a = [];\na.length = Math.max(0, a.length - 1);\n\nlet b = new Array(Math.pow(2, 32) - 1);\nb.length = Math.min(0xffffffff, b.length + 1);   \n\n// 0xffffffff is the hexadecimal notation for 2^32 - 1\n// which can also be written as (-1 &gt;&gt;&gt; 0)\n</pre> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"../global_objects/array\"><code>Array</code></a></li> <li><a href=\"../global_objects/array/length\"><code>Array.length</code></a></li> <li><a href=\"../global_objects/arraybuffer\"><code>ArrayBuffer</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Invalid_array_length$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Invalid_array_length\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Invalid_array_length</a>\n  </p>\n</div>\n","functions/method_definitions":"<h1>Method definitions</h1> <p>Starting with ECMAScript 2015, a shorter syntax for method definitions on objects initializers is introduced. It is a shorthand for a function assigned to the method's name.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/functions-definitions.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\">var obj = {\n  <var>property</var>( <var>parameters…</var> ) {},\n  *<var>generator</var>( <var>parameters…</var> ) {},\n  async property( <var>parameters…</var> ) {},\n  async* generator( <var>parameters…</var> ) {},\n\n  // with computed keys:\n  [property]( <var>parameters…</var> ) {},\n  *[generator]( <var>parameters…</var> ) {},\n  async [property]( <var>parameters…</var> ) {},\n\n  // compare getter/setter syntax:\n  get <var>property</var>() {},\n  set <var>property</var>(<var>value</var>) {}\n};\n</pre> <h2 id=\"Description\">Description</h2> <p>The shorthand syntax is similar to the <a href=\"get\">getter</a> and <a href=\"set\">setter</a> syntax introduced in ECMAScript 2015.</p> <p>Given the following code:</p> <pre data-language=\"js\">var obj = {\n  foo: function() {\n    /* code */\n  },\n  bar: function() {\n    /* code */\n  }\n};\n</pre> <p>You are now able to shorten this to:</p> <pre data-language=\"js\">var obj = {\n  foo() {\n    /* code */\n  },\n  bar() {\n    /* code */\n  }\n};\n\n</pre> <h3 id=\"Generator_methods\">Generator methods</h3> <p><a href=\"../statements/function*\">Generator methods</a> can be defined using the shorthand syntax as well. When using them,</p> <ul> <li>the asterisk (*) in the shorthand syntax must be before the generator property name. That is, <code>* g(){}</code> will work but <code>g *(){}</code> will not;</li> <li> <p>non-generator method definitions may not contain the <code>yield</code> keyword. This means that <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/Legacy_generator_function\">legacy generator functions</a> won't work either and will throw a <a href=\"../global_objects/syntaxerror\"><code>SyntaxError</code></a>. Always use <code>yield</code> in conjunction with the asterisk (*).</p> </li> </ul> <pre data-language=\"js\">// Using a named property\nvar obj2 = {\n  g: function* () {\n    var index = 0;\n    while (true)\n      yield index++;\n  }\n};\n\n// The same object using shorthand syntax\nvar obj2 = { \n  * g() {\n    var index = 0;\n    while (true)\n      yield index++;\n  }\n};\n\nvar it = obj2.g();\nconsole.log(it.next().value); // 0\nconsole.log(it.next().value); // 1</pre> <h3 id=\"Async_methods\">Async methods</h3> <p><a href=\"../statements/async_function\">Async methods</a> can also be defined using the shorthand syntax.</p> <pre data-language=\"js\">// Using a named property\nvar obj3 = {\n  f: async function () {\n    await some_promise;\n  }\n};\n\n// The same object using shorthand syntax\nvar obj3 = { \n  async f() {\n    await some_promise;\n  }\n};\n</pre> <h3 id=\"Async_generator_methods\">Async generator methods</h3> <p><a href=\"../statements/function*\">Generator methods</a> can also be <a href=\"../statements/async_function\">async</a>.</p> <pre data-language=\"js\">var obj4 = {\n  f: async function* () {\n    yield 1;\n    yield 2;\n    yield 3;\n  }\n};\n\n// The same object using shorthand syntax\nvar obj4 = {\n  async* f() {\n   yield 1;\n   yield 2;\n   yield 3;\n  }\n};</pre> <h3 id=\"Method_definitions_are_not_constructable\">Method definitions are not constructable</h3> <p>All method definitions are not constructors and will throw a <a href=\"../global_objects/typeerror\"><code>TypeError</code></a> if you try to instantiate them.</p> <pre data-language=\"js\">var obj = { \n  method() {}\n};\nnew obj.method; // TypeError: obj.method is not a constructor\n\nvar obj = { \n  * g() {} \n};\nnew obj.g; // TypeError: obj.g is not a constructor (changed in ES2016)\n</pre> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Simple_test_case\">Simple test case</h3> <pre data-language=\"js\">var obj = {\n  a: 'foo',\n  b() { return this.a; }\n};\nconsole.log(obj.b()); // \"foo\"\n</pre> <h3 id=\"Computed_property_names\">Computed property names</h3> <p>The shorthand syntax also supports computed property names.</p> <pre data-language=\"js\">var bar = {\n  foo0: function() { return 0; },\n  foo1() { return 1; },\n  ['foo' + 2]() { return 2; }\n};\n\nconsole.log(bar.foo0()); // 0\nconsole.log(bar.foo1()); // 1\nconsole.log(bar.foo2()); // 2</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-method-definitions\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Method definitions' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/7.0/#sec-method-definitions\" hreflang=\"en\">ECMAScript 2016 (ECMA-262)<br><small>The definition of 'Method definitions' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Changed that generator methods should also not have a [[Construct]] trap and will throw when used with <code>new</code>.</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-method-definitions\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Method definitions' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 39</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 34</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 26</td>\n<td class=\"bc-supports-no\"> No</td>\n</tr>\n<tr>\n<th scope=\"row\">Generator methods are not constructable (ES2016)</th>\n<td> ? </td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 43</td>\n<td class=\"bc-supports-no\"> No</td>\n<td> ? </td>\n<td> ? </td>\n</tr>\n<tr>\n<th scope=\"row\">Async methods</th>\n<td> ? </td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 52</td>\n<td class=\"bc-supports-no\"> No</td>\n<td> ? </td>\n<td> ? </td>\n</tr>\n<tr>\n<th scope=\"row\">Async generator methods</th>\n<td> ? </td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 55</td>\n<td class=\"bc-supports-no\"> No</td>\n<td> ? </td>\n<td> ? </td>\n</tr>\n</tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 39</td>\n<td class=\"bc-supports-yes\"> 39</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 34</td>\n<td class=\"bc-supports-yes\"> 26</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 4.0</td>\n</tr>\n<tr>\n<th scope=\"row\">Generator methods are not constructable (ES2016)</th>\n<td> ? </td>\n<td> ? </td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 43</td>\n<td> ? </td>\n<td> ? </td>\n<td> ? </td>\n</tr>\n<tr>\n<th scope=\"row\">Async methods</th>\n<td> ? </td>\n<td> ? </td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 52</td>\n<td> ? </td>\n<td> ? </td>\n<td> ? </td>\n</tr>\n<tr>\n<th scope=\"row\">Async generator methods</th>\n<td> ? </td>\n<td> ? </td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 55</td>\n<td> ? </td>\n<td> ? </td>\n<td> ? </td>\n</tr>\n</tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">Generator methods are not constructable (ES2016)</th>\n<td> ? </td>\n</tr>\n<tr>\n<th scope=\"row\">Async methods</th>\n<td class=\"bc-supports-yes bc-has-history\"> 7.6.0\n<section class=\"bc-history\" id=\"sect1\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 7.6.0\n</dt>\n\n<dt class=\"bc-supports-yes bc-supports\"> 7.0.0<div class=\"bc-icons\">Disabled </div>\n</dt>\n<dd>Disabled From version 7.0.0: this feature is behind the <code>--harmony</code> runtime flag.</dd>\n</dl></section>\n</td>\n</tr>\n<tr>\n<th scope=\"row\">Async generator methods</th>\n<td class=\"bc-supports-yes bc-has-history\"> 10.0.0\n<section class=\"bc-history\" id=\"sect2\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 10.0.0\n</dt>\n\n<dt class=\"bc-supports-yes bc-supports\"> 8.10.0<div class=\"bc-icons\">Disabled </div>\n</dt>\n<dd>Disabled From version 8.10.0: this feature is behind the <code>--harmony</code> runtime flag.</dd>\n</dl></section>\n</td>\n</tr>\n</tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><code><a href=\"get\">get</a></code></li> <li><code><a href=\"set\">set</a></code></li> <li><a href=\"../lexical_grammar\">Lexical grammar</a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Method_definitions$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Method_definitions\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Method_definitions</a>\n  </p>\n</div>\n","functions/get":"<h1>get</h1> <p>The <code>get</code> syntax binds an object property to a function that will be called when that property is looked up.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/functions-getter.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\">{get <em>prop</em>() { ... } }\n{get <em>[expression]</em>() { ... } }</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><code>prop</code></dt> <dd>The name of the property to bind to the given function.</dd> <dt>expression</dt> <dd>Starting with ECMAScript 2015, you can also use expressions for a computed property name to bind to the given function.</dd> </dl> <h2 id=\"Description\">Description</h2> <p>Sometimes it is desirable to allow access to a property that returns a dynamically computed value, or you may want to reflect the status of an internal variable without requiring the use of explicit method calls. In JavaScript, this can be accomplished with the use of a <em>getter</em>. It is not possible to simultaneously have a getter bound to a property and have that property actually hold a value, although it is possible to use a getter and a setter in conjunction to create a type of pseudo-property.</p> <p>Note the following when working with the <code>get</code> syntax:</p>  <ul> <li>It can have an identifier which is either a number or a string;</li> <li>It must have exactly zero parameters (see <a rel=\"external nofollow\" href=\"http://whereswalden.com/2010/08/22/incompatible-es5-change-literal-getter-and-setter-functions-must-now-have-exactly-zero-or-one-arguments/\">Incompatible <abbr title=\"ECMAScript 5th edition\">ES5</abbr> change: literal getter and setter functions must now have exactly zero or one arguments</a> for more information);</li> <li>It must not appear in an object literal with another <code>get</code> or with a data entry for the same property (<code>{ get x() { }, get x() { } }</code> and <code>{ x: ..., get x() { } }</code> are forbidden).</li> </ul>  <p>A getter can be removed using the <code><a href=\"../operators/delete\">delete</a></code> operator.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Defining_a_getter_on_new_objects_in_object_initializers\">Defining a getter on new objects in object initializers</h3> <p>This will create a pseudo-property <code>latest</code> for object <code>obj</code>, which will return the last array item in <code>log</code>.</p> <pre data-language=\"js\">var obj = {\n  log: ['example','test'],\n  get latest() {\n    if (this.log.length == 0) return undefined;\n    return this.log[this.log.length - 1];\n  }\n}\nconsole.log(obj.latest); // \"test\".\n</pre> <p>Note that attempting to assign a value to <code>latest</code> will not change it.</p> <h3 id=\"Deleting_a_getter_using_the_delete_operator\">Deleting a getter using the <code>delete</code> operator</h3> <p>If you want to remove the getter, you can just <code><a href=\"../operators/delete\">delete</a></code> it:</p> <pre data-language=\"js\">delete obj.latest;\n</pre> <h3 id=\"Defining_a_getter_on_existing_objects_using_defineProperty\">Defining a getter on existing objects using <code>defineProperty</code>\n</h3> <p>To append a getter to an existing object later at any time, use <a href=\"../global_objects/object/defineproperty\"><code>Object.defineProperty()</code></a>.</p> <pre data-language=\"js\">var o = {a: 0};\n\nObject.defineProperty(o, 'b', { get: function() { return this.a + 1; } });\n\nconsole.log(o.b) // Runs the getter, which yields a + 1 (which is 1)</pre> <h3 id=\"Using_a_computed_property_name\">Using a computed property name</h3> <pre data-language=\"js\">var expr = 'foo';\n\nvar obj = {\n  get [expr]() { return 'bar'; }\n};\n\nconsole.log(obj.foo); // \"bar\"</pre> <h3 id=\"Smart_self-overwriting_lazy_getters\">Smart / self-overwriting / lazy getters</h3> <p>Getters give you a way to define a property of an object, but they do not calculate the property's value until it is accessed. A getter defers the cost of calculating the value until the value is needed, and if it is never needed, you never pay the cost.</p> <p>An additional optimization technique to lazify or delay the calculation of a property value and cache it for later access are<strong> smart or <a href=\"https://en.wikipedia.org/wiki/Memoization\">memoized</a> getters</strong>. The value is calculated the first time the getter is called, and is then cached so subsequent accesses return the cached value without recalculating it. This is useful in the following situations:</p> <ul> <li>If the calculation of a property value is expensive (takes much RAM or CPU time, spawns worker thread, retrieves remote file, etc).</li> <li>If the value isn't needed just now. It will be used later, or in some case it's not used at all.</li> <li>If it's used, it will be accessed several times, and there is no need to re-calculate that value will never be changed, or shouldn't be re-calculated.</li> </ul> <p>This means that you shouldn't use a lazy getter for a property whose value you expect to change, because the getter will not recalculate the value.</p> <p>In the following example, the object has a getter as its own property. On getting the property, the property is removed from the object and re-added, but implicitly as a data property this time. Finally the value gets returned.</p> <pre data-language=\"js\">get notifier() {\n  delete this.notifier;\n  return this.notifier = document.getElementById('bookmarked-notification-anchor');\n},</pre> <p>For Firefox code, see also the XPCOMUtils.jsm code module, which defines the <code><a href=\"https://developer.mozilla.org/en-US/docs/Mozilla/JavaScript_code_modules/XPCOMUtils.jsm#defineLazyGetter()\">defineLazyGetter()</a></code> function.</p> <h3 id=\"get_Vs._defineProperty\">\n<code>get</code> Vs. <code>defineProperty</code>\n</h3> <p>While using the <code>get</code> keyword and <a href=\"../global_objects/object/defineproperty\"><code>Object.defineProperty()</code></a> have similar results there is a subtle difference between the two when used on <a href=\"../classes\"><code>classes</code></a>.</p> <p>When using <code>get</code> the property will be defined on the prototype of the object while using <a href=\"../global_objects/object/defineproperty\"><code>Object.defineProperty()</code></a> the property will be defined on the instance it is applied to.</p> <pre data-language=\"js\">class Example {\n  get hello() {\n    return 'world';\n  }\n}\n\nconst obj = new Example();\nconsole.log(obj.hello);\n// \"world\"\nconsole.log(Object.getOwnPropertyDescriptor(obj, 'hello'));\n// undefined\nconsole.log(Object.getOwnPropertyDescriptor(Object.getPrototypeOf(obj), 'hello'));\n// { configurable: true, enumerable: false, get: function get hello() { return 'world'; }, set: undefined }</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/5.1/#sec-11.1.5\" hreflang=\"en\">ECMAScript 5.1 (ECMA-262)<br><small>The definition of 'Object Initializer' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-method-definitions\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Method definitions' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Added computed property names.</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-method-definitions\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Method definitions' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 2</td>\n<td class=\"bc-supports-yes\"> 9</td>\n<td class=\"bc-supports-yes\"> 9.5</td>\n<td class=\"bc-supports-yes\"> 3</td>\n</tr>\n<tr>\n<th scope=\"row\">Computed property names</th>\n<td class=\"bc-supports-yes\"> 46</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 34</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 47</td>\n<td class=\"bc-supports-no\"> No</td>\n</tr>\n</tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> 18</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">Computed property names</th>\n<td class=\"bc-supports-yes\"> 46</td>\n<td class=\"bc-supports-yes\"> 46</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 34</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 5.0</td>\n</tr>\n</tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">Computed property names</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n</tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"set\">setter</a></li> <li><a href=\"../operators/delete\"><code>delete</code></a></li> <li><a href=\"../global_objects/object/defineproperty\"><code>Object.defineProperty()</code></a></li> <li><a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/defineGetter\"><code>__defineGetter__</code></a></li> <li><a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/defineSetter\"><code>__defineSetter__</code></a></li> <li>\n<a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Working_with_Objects#Defining_getters_and_setters\">Defining Getters and Setters</a> in JavaScript Guide</li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/get$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/get\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/get</a>\n  </p>\n</div>\n","errors/invalid_date":"<h1>Errors: Invalid date</h1> <h2 id=\"Message\">Message</h2> <pre class=\"syntaxbox\">RangeError: invalid date (Edge)\nRangeError: invalid date (Firefox)\nRangeError: invalid time value (Chrome)\nRangeError: Provided date is not in valid range (Chrome)\n</pre> <h2 id=\"Error_type\">Error type</h2> <p><a href=\"../global_objects/rangeerror\"><code>RangeError</code></a></p> <h2 id=\"What_went_wrong\">What went wrong?</h2> <p>A string leading to an invalid date has been provided to <a href=\"../global_objects/date\"><code>Date</code></a> or <a href=\"../global_objects/date/parse\"><code>Date.parse()</code></a>.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Invalid_cases\">Invalid cases</h3> <p>Unrecognizable strings or dates containing illegal element values in ISO formatted strings usually return <a href=\"../global_objects/nan\"><code>NaN</code></a>. However, depending on the implementation, non–conforming ISO format strings, may also throw <code>RangeError: invalid date</code>, like the following cases in Firefox:</p> <pre data-language=\"js\">new Date('foo-bar 2014');\nnew Date('2014-25-23').toISOString();\nnew Date('foo-bar 2014').toString();\n</pre> <p>This, however, returns <a href=\"../global_objects/nan\"><code>NaN</code></a> in Firefox:</p> <pre data-language=\"js\">Date.parse('foo-bar 2014'); // NaN</pre> <p>For more details, see the <a href=\"../global_objects/date/parse\"><code>Date.parse()</code></a> documentation.</p> <h3 id=\"Valid_cases\">Valid cases</h3> <pre data-language=\"js\">new Date('05 October 2011 14:48 UTC');</pre> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"../global_objects/date\"><code>Date</code></a></li> <li><a href=\"../global_objects/date/parse\"><code>Date.prototype.parse()</code></a></li> <li><a href=\"../global_objects/date/toisostring\"><code>Date.prototype.toISOString()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Invalid_date$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Invalid_date\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Invalid_date</a>\n  </p>\n</div>\n","errors/resulting_string_too_large":"<h1>Errors: Resulting string too large</h1> <h2 id=\"Message\">Message</h2> <pre class=\"syntaxbox\">RangeError: argument out of range (Edge)\nRangeError: repeat count must be less than infinity and not overflow maximum string size (Firefox)\n\nRangeError: Invalid count value (Chrome)\n</pre> <h2 id=\"Error_type\">Error type</h2> <p><a href=\"../global_objects/rangeerror\"><code>RangeError</code></a></p> <h2 id=\"What_went_wrong\">What went wrong?</h2> <p>The <a href=\"../global_objects/string/repeat\"><code>String.prototype.repeat()</code></a> method has been used. It has a <code>count</code> parameter indicating the number of times to repeat the string. It must be between 0 and less than positive <a href=\"../global_objects/infinity\"><code>Infinity</code></a> and cannot be a negative number. The range of allowed values can be described like this: [0, +∞).</p> <p>The resulting string can also not be larger than the maximum string size, which can differ in JavaScript engines. In Firefox (SpiderMonkey) the maximum string size is 2<sup>28</sup> -1 (<code>0xFFFFFFF</code>).</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Invalid_cases\">Invalid cases</h3> <pre data-language=\"js\">'abc'.repeat(Infinity); // RangeError\n'a'.repeat(2**28);      // RangeError\n</pre> <h3 id=\"Valid_cases\">Valid cases</h3> <pre data-language=\"js\">'abc'.repeat(0);    // ''\n'abc'.repeat(1);    // 'abc'\n'abc'.repeat(2);    // 'abcabc'\n'abc'.repeat(3.5);  // 'abcabcabc' (count will be converted to integer)\n</pre> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"../global_objects/string/repeat\"><code>String.prototype.repeat()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Resulting_string_too_large$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Resulting_string_too_large\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Resulting_string_too_large</a>\n  </p>\n</div>\n","errors/bad_radix":"<h1>Errors: Bad radix</h1> <h2 id=\"Message\">Message</h2> <pre class=\"syntaxbox\">RangeError: invalid argument (Edge)\nRangeError: radix must be an integer at least 2 and no greater than 36 (Firefox)\nRangeError: toString() radix argument must be between 2 and 36 (Chrome)\n</pre> <h2 id=\"Error_type\">Error type</h2> <p><a href=\"../global_objects/rangeerror\"><code>RangeError</code></a></p> <h2 id=\"What_went_wrong\">What went wrong?</h2> <p>The optional <code>radix</code> parameter of the <a href=\"../global_objects/number/tostring\"><code>Number.prototype.toString()</code></a> method was specified. Its value must be an integer (a number) between 2 and 36, specifying the base of the number system to be used for representing numeric values. For example, the decimal (base 10) number 169 is represented in hexadecimal (base 16) as A9.</p> <p>Why is this parameter's value limited to 36? A radix that is larger than 10 uses alphabetical characters as digits; therefore, the radix can't be larger than 36, since the Latin alphabet (used by English and many other languages) only has 26 characters.</p> <p>The most common radixes:</p> <ul> <li>2 for <a href=\"https://en.wikipedia.org/wiki/Binary_number\">binary numbers</a>,</li> <li>8 for <a href=\"https://en.wikipedia.org/wiki/Octal\">octal numbers</a>,</li> <li>10 for <a href=\"https://en.wikipedia.org/wiki/Decimal\">decimal numbers</a>,</li> <li>16 for <a href=\"https://en.wikipedia.org/wiki/Hexadecimal\">hexadecimal numbers</a>.</li> </ul> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Invalid_cases\">Invalid cases</h3> <pre data-language=\"js\">(42).toString(0);\n(42).toString(1);\n(42).toString(37);\n(42).toString(150);\n// You cannot use a string like this for formatting:\n(12071989).toString('MM-dd-yyyy');\n</pre> <h3 id=\"Valid_cases\">Valid cases</h3> <pre data-language=\"js\">(42).toString(2);     // \"101010\" (binary)\n(13).toString(8);     // \"15\"     (octal)\n(0x42).toString(10);  // \"66\"     (decimal)\n(100000).toString(16) // \"186a0\"  (hexadecimal)\n</pre> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"../global_objects/number/tostring\"><code>Number.prototype.toString()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Bad_radix$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Bad_radix\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Bad_radix</a>\n  </p>\n</div>\n","errors/not_defined":"<h1>Errors: Not defined</h1> <h2 id=\"Message\">Message</h2> <pre class=\"syntaxbox\">ReferenceError: \"x\" is not defined\n</pre> <h2 id=\"Error_type\">Error type</h2> <p><a href=\"../global_objects/referenceerror\"><code>ReferenceError</code></a>.</p> <h2 id=\"What_went_wrong\">What went wrong?</h2> <p>There is a non-existent variable referenced somewhere. This variable needs to be declared, or you need make sure it is available in your current script or <a href=\"https://developer.mozilla.org/en-US/docs/Glossary/scope\">scope</a>.</p> <div class=\"note\"> <p><strong>Note:</strong> When loading a library (such as jQuery), make sure it is loaded before you access library variables, such as \"$\". Put the <a href=\"https://developer.mozilla.org/en-US/docs/Web/HTML/Element/script\"><code>&lt;script&gt;</code></a> tag that loads the library before your code that uses it.</p> </div> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Variable_not_declared\">Variable not declared</h3> <pre data-language=\"js\">foo.substring(1); // ReferenceError: foo is not defined\n</pre> <p>The \"foo\" variable isn't defined anywhere. It needs to be some string, so that the <a href=\"../global_objects/string/substring\"><code>String.prototype.substring()</code></a> method will work.</p> <pre data-language=\"js\">var foo = 'bar';\nfoo.substring(1); // \"ar\"</pre> <h3 id=\"Wrong_scope\">Wrong scope</h3> <p>A variable needs to be available in the current context of execution. Variables defined inside a <a href=\"../functions\">function</a> cannot be accessed from anywhere outside the function, because the variable is defined only in the scope of the function</p> <pre data-language=\"js\">function numbers() { \n  var num1 = 2, \n      num2 = 3;\n  return num1 + num2;\n}\n\nconsole.log(num1); // ReferenceError num1 is not defined.</pre> <p>However, a function can access all variables and functions defined inside the scope in which it is defined. In other words, a function defined in the global scope can access all variables defined in the global scope.</p> <pre data-language=\"js\">var num1 = 2,\n    num2 = 3;\n\nfunction numbers() {\n  return num1 + num2; \n}\n\nconsole.log(numbers()); // 5</pre> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"https://developer.mozilla.org/en-US/docs/Glossary/Scope\">Scope</a></li> <li><a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Grammar_and_types#Declaring_variables\">Declaring variables in the JavaScript Guide</a></li> <li><a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Functions#Function_scope/en-US/docs/\">Function scope in the JavaScript Guide</a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Not_defined$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Not_defined\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Not_defined</a>\n  </p>\n</div>\n","errors/too_much_recursion":"<h1>Errors: Too much recursion</h1> <h2 id=\"Message\">Message</h2> <pre class=\"syntaxbox\">Error: Out of stack space (Edge)\nInternalError: too much recursion (Firefox)\nRangeError: Maximum call stack size exceeded (Chrome)\n</pre> <h2 id=\"Error_type\">Error type</h2> <p><a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/InternalError\"><code>InternalError</code></a>.</p> <h2 id=\"What_went_wrong\">What went wrong?</h2> <p>A function that calls itself is called a <em>recursive function</em>. In some ways, recursion is analogous to a loop. Both execute the same code multiple times, and both require a condition (to avoid an infinite loop, or rather, infinite recursion in this case). When there is too much or infinite recursion, JavaScript will throw this error.</p> <h2 id=\"Examples\">Examples</h2> <p>This recursive function runs 10 times, as per the exit condition.</p> <pre data-language=\"js\">function loop(x) {\n  if (x &gt;= 10) // \"x &gt;= 10\" is the exit condition\n    return;\n  // do stuff\n  loop(x + 1); // the recursive call\n}\nloop(0);</pre> <p>Setting this condition to an extremely high value, won't work:</p> <pre data-language=\"js\">function loop(x) {\n  if (x &gt;= 1000000000000)\n    return;\n  // do stuff\n  loop(x + 1);\n}\nloop(0);\n\n// InternalError: too much recursion</pre> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"https://developer.mozilla.org/en-US/docs/Glossary/Recursion\">Recursion</a></li> <li><a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Functions#Recursion\">Recursive functions</a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Too_much_recursion$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Too_much_recursion\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Too_much_recursion</a>\n  </p>\n</div>\n","classes/static":"<h1>static</h1> <p>The <code><strong>static</strong></code> keyword defines a static method for a class. Static methods aren't called on instances of the class. Instead, they're called on the class itself. These are often utility functions, such as functions to create or clone objects.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/classes-static.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\">static <em>methodName</em>() { ... }</pre> <h2 id=\"Description\">Description</h2> <p>Static method calls are made directly on the class and are not callable on instances of the class. Static methods are often used to create utility functions.</p> <h2 id=\"Calling_static_methods\">Calling static methods</h2> <h3 id=\"From_another_static_method\">From another static method</h3> <p>In order to call a static method within another static method of the same class, you can use the <code><a href=\"../operators/this\">this</a></code> keyword.</p> <pre data-language=\"js\">class StaticMethodCall {\n  static staticMethod() {\n    return 'Static method has been called';\n  }\n  static anotherStaticMethod() {\n    return this.staticMethod() + ' from another static method';\n  }\n}\nStaticMethodCall.staticMethod(); \n// 'Static method has been called'\n\nStaticMethodCall.anotherStaticMethod(); \n// 'Static method has been called from another static method'</pre> <h3 id=\"From_class_constructor_and_other_methods\">From class constructor and other methods</h3> <p>Static methods are not directly accessible using the <code><a href=\"../operators/this\">this</a></code> keyword from non-static methods. You need to call them using the class name: <code>CLASSNAME.STATIC_METHOD_NAME()</code> or by calling the method as a property of the <code>constructor</code>: <code>this.constructor.STATIC_METHOD_NAME()</code>.</p> <pre data-language=\"js\">class StaticMethodCall {\n  constructor() {\n    console.log(StaticMethodCall.staticMethod()); \n    // 'static method has been called.' \n\n    console.log(this.constructor.staticMethod()); \n    // 'static method has been called.' \n  }\n\n  static staticMethod() {\n    return 'static method has been called.';\n  }\n}</pre> <h2 id=\"Examples\">Examples</h2> <p>The following example demonstrates several things:</p> <ol> <li>How a static method is implemented on a class.</li> <li>That a class with a static member can be sub-classed.</li> <li>How a static method can and cannot be called.</li> </ol> <pre data-language=\"js\">class Triple {\n  static triple(n) {\n    if (n === undefined) {\n      n = 1;\n    }\n    return n * 3;\n  }\n}\n\nclass BiggerTriple extends Triple {\n  static triple(n) {\n    return super.triple(n) * super.triple(n);\n  }\n}\n\nconsole.log(Triple.triple());        // 3\nconsole.log(Triple.triple(6));       // 18\n\nvar tp = new Triple();\n\nconsole.log(BiggerTriple.triple(3));\n// 81 (not affected by parent's instantiation)\n\nconsole.log(tp.triple());\n// 'tp.triple is not a function'.\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-class-definitions\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Class definitions' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-class-definitions\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Class definitions' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes bc-has-history\"> 49\n<section class=\"bc-history\" id=\"sect1\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 49\n</dt>\n<dd> From Chrome 42 to 48 strict mode is required. Non-strict mode support can be enabled using the flag \"Enable Experimental JavaScript\".</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-yes\"> 13</td>\n<td class=\"bc-supports-yes\"> 45</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 36</td>\n<td class=\"bc-supports-yes\"> 9</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 13</td>\n<td class=\"bc-supports-yes\"> 45</td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 9</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes bc-has-history\"> 6.0.0\n<section class=\"bc-history\" id=\"sect2\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 6.0.0\n</dt>\n\n<dt class=\"bc-supports-yes bc-supports\"> 4.0.0<div class=\"bc-icons\">Disabled </div>\n</dt>\n<dd>Disabled From version 4.0.0: this feature is behind the <code>--use_strict</code> runtime flag.</dd>\n<dt class=\"bc-supports-yes bc-supports\"> 5.0.0<div class=\"bc-icons\">Disabled </div>\n</dt>\n<dd>Disabled From version 5.0.0: this feature is behind the <code>--harmony</code> runtime flag.</dd>\n</dl></section>\n</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"../operators/class\"><code>class</code> expression</a></li> <li><a href=\"../statements/class\"><code>class</code> declaration</a></li> <li><a href=\"../classes\">Classes</a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes/static$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes/static\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes/static</a>\n  </p>\n</div>\n","functions/arguments":"<h1>arguments</h1>   <p><code>arguments</code> is an <code>Array</code>-like object accessible inside <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Functions\">functions</a> that contains the values of the arguments passed to that function.</p> <div class=\"note\"> <p><strong>Note:</strong> “Array-like” means that <code>arguments</code> has a <code><a href=\"arguments/length\">length</a></code> property and properties indexed from zero, but it doesn't have <a href=\"../global_objects/array\"><code>Array</code></a>'s built-in methods like <code><a href=\"../global_objects/array/foreach\">forEach</a></code> and <code><a href=\"../global_objects/array/map\">map</a></code>. See <a href=\"#Description\">§Description</a> for details.</p> </div> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/functions-arguments.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\">arguments</pre> <h2 id=\"Description\">Description</h2> <p>The <code>arguments</code> object is a local variable available within all non-<a href=\"arrow_functions\">arrow</a> functions. You can refer to a function's arguments inside that function by using its <code>arguments</code> object. It has entries for each argument the function was called with, with the first entry's index at 0.</p> <p>For example, if a function is passed 3 arguments, you can access them as follows:</p> <pre data-language=\"js\">arguments[0] // first argument\narguments[1] // second argument\narguments[2] // third argument\n</pre> <p>Each argument can also be set or reassigned:</p> <pre data-language=\"js\">arguments[1] = 'new value';\n</pre> <p>The <code>arguments</code> object is not an <a href=\"../global_objects/array\"><code>Array</code></a>. It is similar, but does not have any <code>Array</code> properties except <code><a href=\"arguments/length\">length</a></code>. For example, it does not have the <code><a href=\"../global_objects/array/pop\">pop</a></code> method. However, it can be converted to a real <code>Array</code>:</p> <pre data-language=\"js\">var args = Array.prototype.slice.call(arguments);\n// Using an array literal is shorter than above but allocates an empty array\nvar args = [].slice.call(arguments); \n</pre> <p>As you can do with any Array-like object, you can use ES2015's <a href=\"../global_objects/array/from\"><code>Array.from()</code></a> method or <a href=\"../operators/spread_syntax\">spread operator</a> to convert <code>arguments</code> to a real Array:</p> <pre data-language=\"js\">var args = Array.from(arguments);\nvar args = [...arguments];\n</pre> <p>The <code>arguments</code> object is useful for functions called with more arguments than they are formally declared to accept. This technique is useful for functions that can be passed a variable number of arguments, such as <code><a href=\"../global_objects/math/min\">Math.min()</a></code>. This example function accepts any number of string arguments and returns the longest one:</p> <pre data-language=\"js\">function longestString() {\n  var longest = '';\n  for (var i=0; i &lt; arguments.length; i++) {\n    if (arguments[i].length &gt; longest.length) {\n      longest = arguments[i];\n    }\n  }\n  return longest;\n}\n</pre> <p>You can use <code><a href=\"arguments/length\">arguments.length</a></code> to count how many arguments the function was called with. If you instead want to count how many parameters a function is declared to accept, inspect that function's <code><a href=\"../global_objects/function/length\">length</a></code> property.</p> <h3 id=\"Using_typeof_with_Arguments\">Using <code>typeof</code> with Arguments</h3> <p>The <code><a href=\"../operators/typeof\">typeof</a></code> operator returns <code>'object'</code> when used with <code>arguments</code></p> <pre data-language=\"js\">console.log(typeof arguments); // 'object' </pre> <p>The type of individual arguments can be determined by indexing <code>arguments</code>:</p> <pre>console.log(typeof arguments[0]); // returns the type of the first argument</pre> <h2 id=\"Properties\">Properties</h2> <dl> <dt><code><a href=\"arguments/callee\">arguments.callee</a></code></dt> <dd>Reference to the currently executing function that the arguments belong to.</dd> <dt>\n<code><a href=\"arguments/caller\">arguments.caller</a></code> \n</dt> <dd>Reference to the function that invoked the currently executing function.</dd> <dt><code><a href=\"arguments/length\">arguments.length</a></code></dt> <dd>The number of arguments that were passed to the function.</dd> <dt><code><a href=\"arguments/@@iterator\">arguments[@@iterator]</a></code></dt> <dd>Returns a new <a href=\"../global_objects/array/@@iterator\">Array Iterator object</a> that contains the values for each index in the <code>arguments</code>.</dd> </dl> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Defining_a_function_that_concatenates_several_strings\">Defining a function that concatenates several strings</h3> <p>This example defines a function that concatenates several strings. The function's only formal argument is a string containing the characters that separate the items to concatenate.</p> <pre data-language=\"js\">function myConcat(separator) {\n  var args = Array.prototype.slice.call(arguments, 1);\n  return args.join(separator);\n}</pre> <p>You can pass as many arguments as you like to this function. It returns a string list using each argument in the list:</p> <pre data-language=\"js\">// returns \"red, orange, blue\"\nmyConcat(', ', 'red', 'orange', 'blue');\n\n// returns \"elephant; giraffe; lion; cheetah\"\nmyConcat('; ', 'elephant', 'giraffe', 'lion', 'cheetah');\n\n// returns \"sage. basil. oregano. pepper. parsley\"\nmyConcat('. ', 'sage', 'basil', 'oregano', 'pepper', 'parsley');</pre> <h3 id=\"Defining_a_function_that_creates_HTML_lists\">Defining a function that creates HTML lists</h3> <p>This example defines a function that creates a string containing HTML for a list. The only formal argument for the function is a string that is \"<code>u</code>\" if the list is to be unordered (bulleted), or \"<code>o</code>\" if the list is to be ordered (numbered). The function is defined as follows:</p> <pre data-language=\"js\">function list(type) {\n  var html = '&lt;' + type + 'l&gt;&lt;li&gt;';\n  var args = Array.prototype.slice.call(arguments, 1);\n  html += args.join('&lt;/li&gt;&lt;li&gt;');\n  html += '&lt;/li&gt;&lt;/' + type + 'l&gt;'; // end list\n\n  return html;\n}</pre> <p>You can pass any number of arguments to this function, and it adds each argument as a list item to a list of the type indicated. For example:</p> <pre data-language=\"js\">var listHTML = list('u', 'One', 'Two', 'Three');\n\n/* listHTML is:\n\"&lt;ul&gt;&lt;li&gt;One&lt;/li&gt;&lt;li&gt;Two&lt;/li&gt;&lt;li&gt;Three&lt;/li&gt;&lt;/ul&gt;\"\n*/</pre> <h3 id=\"Rest_default_and_destructured_parameters\">Rest, default, and destructured parameters</h3> <p>The <code>arguments</code> object can be used in conjunction with <a href=\"rest_parameters\">rest</a>, <a href=\"default_parameters\">default</a>, and <a href=\"../operators/destructuring_assignment\">destructured</a> parameters.</p> <pre data-language=\"js\">function foo(...args) {\n  return args;\n}\nfoo(1, 2, 3); // [1,2,3]\n</pre> <p>While the presence of rest, default, or destructured parameters does not alter the <a href=\"../strict_mode#Making_eval_and_arguments_simpler\">behavior of the <code>arguments</code> object in strict mode code</a>, there is a subtle difference for non-strict code.</p> <p>If a non-strict function <strong><strong>does </strong>not</strong> contain rest, default, or destructured parameters, then the values in the <code>arguments</code> object <strong>do</strong> change in sync with the values of the argument variables. See the code below:</p> <pre data-language=\"js\">function func(a) { \n  arguments[0] = 99; // updating arguments[0] also updates a\n  console.log(a);\n}\nfunc(10); // 99\n</pre> <p>and</p> <pre data-language=\"js\">function func(a) { \n  a = 99; // updating a also updates arguments[0]\n  console.log(arguments[0]);\n}\nfunc(10); // 99\n</pre> <p>When a non-strict function <strong>does</strong> contain rest, default, or destructured parameters, then the values in the <code>arguments</code> object <strong>do not</strong> track the values of the arguments. Instead, they reflect the arguments provided when the function was called:</p> <pre data-language=\"js\">function func(a = 55) { \n  arguments[0] = 99; // updating arguments[0] does not also update a\n  console.log(a);\n}\nfunc(10); // 10</pre> <p>and</p> <pre data-language=\"js\">function func(a = 55) { \n  a = 99; // updating a does not also update arguments[0]\n  console.log(arguments[0]);\n}\nfunc(10); // 10\n</pre> <p>and</p> <pre data-language=\"js\">// An untracked default parameter\nfunction func(a = 55) { \n  console.log(arguments[0]);\n}\nfunc(); // undefined</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/publications/files/ECMA-ST-ARCH/ECMA-262,%201st%20edition,%20June%201997.pdf\" hreflang=\"en\">ECMAScript 1st Edition (ECMA-262)</a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition. Implemented in JavaScript 1.1</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/5.1/#sec-10.6\" hreflang=\"en\">ECMAScript 5.1 (ECMA-262)<br><small>The definition of 'Arguments Object' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-arguments-exotic-objects\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Arguments Exotic Objects' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-arguments-exotic-objects\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Arguments Exotic Objects' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Functions/arguments/callee\"><code>callee</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> 6</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Functions/arguments/caller\"><code>caller</code></a> \n</th>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\">? — 9</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Functions/arguments/length\"><code>length</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Functions/arguments/@@iterator\"><code>@@iterator</code></a></th>\n<td class=\"bc-supports-yes\"> 52</td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 46</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 9</td>\n</tr>\n</tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Functions/arguments/callee\"><code>callee</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Functions/arguments/caller\"><code>caller</code></a> \n</th>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Functions/arguments/length\"><code>length</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Functions/arguments/@@iterator\"><code>@@iterator</code></a></th>\n<td class=\"bc-supports-yes\"> 52</td>\n<td class=\"bc-supports-yes\"> 52</td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 46</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 9</td>\n<td class=\"bc-supports-yes\"> 6.0</td>\n</tr>\n</tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Functions/arguments/callee\"><code>callee</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Functions/arguments/caller\"><code>caller</code></a> \n</th>\n<td class=\"bc-supports-no\"> No</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Functions/arguments/length\"><code>length</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Functions/arguments/@@iterator\"><code>@@iterator</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n</tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"../global_objects/function\"><code>Function</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/arguments$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/arguments\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/arguments</a>\n  </p>\n</div>\n","errors/negative_repetition_count":"<h1>Errors: Negative repetition count</h1> <h2 id=\"Message\">Message</h2> <pre class=\"syntaxbox\">RangeError: argument out of range\nRangeError: repeat count must be non-negative (Firefox)\nRangeError: Invalid count value (Chrome)\n</pre> <h2 id=\"Error_type\">Error type</h2> <p><a href=\"../global_objects/rangeerror\"><code>RangeError</code></a></p> <h2 id=\"What_went_wrong\">What went wrong?</h2> <p>The <a href=\"../global_objects/string/repeat\"><code>String.prototype.repeat()</code></a> method has been used. It has a <code>count</code> parameter indicating the number of times to repeat the string. It must be between 0 and less than positive <a href=\"../global_objects/infinity\"><code>Infinity</code></a> and cannot be a negative number. The range of allowed values can be described like this: [0, +∞).</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Invalid_cases\">Invalid cases</h3> <pre data-language=\"js\">'abc'.repeat(-1); // RangeError </pre> <h3 id=\"Valid_cases\">Valid cases</h3> <pre data-language=\"js\">'abc'.repeat(0);    // ''\n'abc'.repeat(1);    // 'abc'\n'abc'.repeat(2);    // 'abcabc'\n'abc'.repeat(3.5);  // 'abcabcabc' (count will be converted to integer)\n</pre> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"../global_objects/string/repeat\"><code>String.prototype.repeat()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Negative_repetition_count$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Negative_repetition_count\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Negative_repetition_count</a>\n  </p>\n</div>\n","errors/undeclared_var":"<h1>Errors: Undeclared var</h1> <h2 id=\"Message\">Message</h2> <pre class=\"syntaxbox\">ReferenceError: assignment to undeclared variable \"x\" (Firefox)\nReferenceError: \"x\" is not defined (Chrome)\nReferenceError: Variable undefined in strict mode (Edge)\n</pre> <h2 id=\"Error_type\">Error type</h2> <p><a href=\"../global_objects/referenceerror\"><code>ReferenceError</code></a> warning in <a href=\"../strict_mode\">strict mode</a> only.</p> <h2 id=\"What_went_wrong\">What went wrong?</h2> <p>A value has been assigned to an undeclared variable. In other words, there was an assignment without the var keyword. There are some differences between declared and undeclared variables, which might lead to unexpected results and that's why JavaScript presents an error in strict mode.</p> <p>Three things to note about declared and undeclared variables:</p> <ul> <li>Declared variables are constrained in the execution context in which they are declared. Undeclared variables are always global.</li> <li>Declared variables are created before any code is executed. Undeclared variables do not exist until the code assigning to them is executed.</li> <li>Declared variables are a non-configurable property of their execution context (function or global). Undeclared variables are configurable (e.g. can be deleted).</li> </ul> <p>For more details and examples, see the <code><a href=\"../statements/var\">var</a></code> reference page.</p> <p>Errors about undeclared variable assignments occur in <a href=\"../strict_mode\">strict mode code</a> only. In non-strict code, they are silently ignored.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Invalid_cases\">Invalid cases</h3> <p>In this case, the variable \"bar\" is an undeclared variable.</p> <pre data-language=\"js\">function foo() { \n  'use strict'; \n  bar = true; \n} \nfoo(); // ReferenceError: assignment to undeclared variable bar\n</pre> <h3 id=\"Valid_cases\">Valid cases</h3> <p>To make \"bar\" a declared variable, you can add the <code><a href=\"../statements/var\">var</a></code> keyword in front of it.</p> <pre data-language=\"js\">function foo() {\n  'use strict';\n  var bar = true;\n}\nfoo();</pre> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"../strict_mode\">Strict mode</a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Undeclared_var$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Undeclared_var\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Undeclared_var</a>\n  </p>\n</div>\n","errors/invalid_assignment_left-hand_side":"<h1>Errors: Invalid assignment left-hand side</h1> <h2 id=\"Message\">Message</h2> <pre class=\"syntaxbox\">ReferenceError: invalid assignment left-hand side\n</pre> <h2 id=\"Error_type\">Error type</h2> <p><a href=\"../global_objects/referenceerror\"><code>ReferenceError</code></a>.</p> <h2 id=\"What_went_wrong\">What went wrong?</h2> <p>There was an unexpected assignment somewhere. This might be due to a mismatch of a <a href=\"../operators/assignment_operators\">assignment operator</a> and a <a href=\"../operators/comparison_operators\">comparison operator</a>, for example. While a single \"<code>=</code>\" sign assigns a value to a variable, the \"<code>==</code>\" or \"<code>===</code>\" operators compare a value.</p> <h2 id=\"Examples\">Examples</h2> <pre data-language=\"js\">if (Math.PI = 3 || Math.PI = 4) { \n  console.log('no way!');\n}\n// ReferenceError: invalid assignment left-hand side\n\nvar str = 'Hello, '\n+= 'is it me '\n+= 'you\\'re looking for?';\n// ReferenceError: invalid assignment left-hand side\n</pre> <p>In the <code>if</code> statement, you want to use a comparison operator (\"==\"), and for the string concatenation, the plus (\"+\") operator is needed.</p> <pre data-language=\"js\">if (Math.PI == 3 || Math.PI == 4) { \n  console.log('no way!'); \n}\n\nvar str = 'Hello, ' \n+ 'from the ' \n+ 'other side!';\n</pre> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"../operators/assignment_operators\">Assignment operators</a></li> <li><a href=\"../operators/comparison_operators\">Comparison operators</a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Invalid_assignment_left-hand_side$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Invalid_assignment_left-hand_side\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Invalid_assignment_left-hand_side</a>\n  </p>\n</div>\n","errors/cant_access_lexical_declaration_before_init":"<h1>Errors: Cant access lexical declaration before init</h1> <h2 id=\"Message\">Message</h2> <pre class=\"syntaxbox\">ReferenceError: Use before delaration (Edge)\nReferenceError: can't access lexical declaration `X' before initialization (Firefox)\nReferenceError: 'x' is not defined (Chrome)\n</pre> <h2 id=\"Error_type\">Error type</h2> <p><a href=\"../global_objects/referenceerror\"><code>ReferenceError</code></a></p> <h2 id=\"What_went_wrong\">What went wrong?</h2> <p>A lexical variable was accessed before it was initialized. This happens within any block statement, when <code><a href=\"../statements/let\">let</a></code> or <code><a href=\"../statements/const\">const</a></code> declarations are accessed before they are defined.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Invalid_cases\">Invalid cases</h3> <p>In this case, the variable \"foo\" is redeclared in the block statement using <code>let</code>.</p> <pre data-language=\"js\">function test() {\n  let foo = 33;\n  if (true) {\n    let foo = (foo + 55); \n    // ReferenceError: can't access lexical \n    // declaration `foo' before initialization\n  }\n}\ntest();\n</pre> <h3 id=\"Valid_cases\">Valid cases</h3> <p>To change \"foo\" inside the if statement, you need to remove the <code>let</code> that causes the redeclaration.</p> <pre data-language=\"js\">function test(){\n   let foo = 33;\n   if (true) {\n      foo = (foo + 55);\n   }\n}\ntest();\n</pre> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"../statements/let#Temporal_Dead_Zone_and_errors_with_let\">Temporal Dead Zone and errors with let</a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Cant_access_lexical_declaration_before_init$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Cant_access_lexical_declaration_before_init\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Cant_access_lexical_declaration_before_init</a>\n  </p>\n</div>\n","errors/json_bad_parse":"<h1>Errors: JSON bad parse</h1> <h2 id=\"Message\">Message</h2> <pre class=\"syntaxbox\">SyntaxError: JSON.parse: unterminated string literal\nSyntaxError: JSON.parse: bad control character in string literal\nSyntaxError: JSON.parse: bad character in string literal\nSyntaxError: JSON.parse: bad Unicode escape\nSyntaxError: JSON.parse: bad escape character\nSyntaxError: JSON.parse: unterminated string\nSyntaxError: JSON.parse: no number after minus sign\nSyntaxError: JSON.parse: unexpected non-digit\nSyntaxError: JSON.parse: missing digits after decimal point\nSyntaxError: JSON.parse: unterminated fractional number\nSyntaxError: JSON.parse: missing digits after exponent indicator\nSyntaxError: JSON.parse: missing digits after exponent sign\nSyntaxError: JSON.parse: exponent part is missing a number\nSyntaxError: JSON.parse: unexpected end of data\nSyntaxError: JSON.parse: unexpected keyword\nSyntaxError: JSON.parse: unexpected character\nSyntaxError: JSON.parse: end of data while reading object contents\nSyntaxError: JSON.parse: expected property name or '}'\nSyntaxError: JSON.parse: end of data when ',' or ']' was expected\nSyntaxError: JSON.parse: expected ',' or ']' after array element\nSyntaxError: JSON.parse: end of data when property name was expected\nSyntaxError: JSON.parse: expected double-quoted property name\nSyntaxError: JSON.parse: end of data after property name when ':' was expected\nSyntaxError: JSON.parse: expected ':' after property name in object\nSyntaxError: JSON.parse: end of data after property value in object\nSyntaxError: JSON.parse: expected ',' or '}' after property value in object\nSyntaxError: JSON.parse: expected ',' or '}' after property-value pair in object literal\nSyntaxError: JSON.parse: property names must be double-quoted strings\nSyntaxError: JSON.parse: expected property name or '}'\nSyntaxError: JSON.parse: unexpected character\nSyntaxError: JSON.parse: unexpected non-whitespace character after JSON data\nSyntaxError: JSON.parse Error: Invalid character at position {0} (Edge)</pre> <h2 id=\"Error_type\">Error type</h2> <p><a href=\"../global_objects/syntaxerror\"><code>SyntaxError</code></a></p> <h2 id=\"What_went_wrong\">What went wrong?</h2> <p><a href=\"../global_objects/json/parse\"><code>JSON.parse()</code></a> parses a string as JSON. This string has to be valid JSON and will throw this error if incorrect syntax was encountered.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"JSON.parse()_does_not_allow_trailing_commas\">\n<code>JSON.parse()</code> does not allow trailing commas</h3> <p>Both lines will throw a SyntaxError:</p> <pre data-language=\"js\">JSON.parse('[1, 2, 3, 4,]');\nJSON.parse('{\"foo\": 1,}');\n// SyntaxError JSON.parse: unexpected character \n// at line 1 column 14 of the JSON data\n</pre> <p>Omit the trailing commas to parse the JSON correctly:</p> <pre data-language=\"js\">JSON.parse('[1, 2, 3, 4]');\nJSON.parse('{\"foo\": 1}');</pre> <h3 id=\"Property_names_must_be_double-quoted_strings\">Property names must be double-quoted strings</h3> <p>You cannot use single-quotes around properties, like 'foo'.</p> <pre data-language=\"js\">JSON.parse(\"{'foo': 1}\");\n// SyntaxError: JSON.parse: expected property name or '}' \n// at line 1 column 2 of the JSON data</pre> <p>Instead write \"foo\":</p> <pre data-language=\"js\">JSON.parse('{\"foo\": 1}');</pre> <h3 id=\"Leading_zeros_and_decimal_points\">Leading zeros and decimal points</h3> <p>You cannot use leading zeros, like 01, and decimal points must be followed by at least one digit.</p> <pre data-language=\"js\">JSON.parse('{\"foo\": 01}');\n// SyntaxError: JSON.parse: expected ',' or '}' after property value \n// in object at line 1 column 2 of the JSON data\n\nJSON.parse('{\"foo\": 1.}'); \n// SyntaxError: JSON.parse: unterminated fractional number \n// at line 1 column 2 of the JSON data\n</pre> <p>Instead write just 1 without a zero and use at least one digit after a decimal point:</p> <pre data-language=\"js\">JSON.parse('{\"foo\": 1}');\nJSON.parse('{\"foo\": 1.0}');\n</pre> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"../global_objects/json\"><code>JSON</code></a></li> <li><a href=\"../global_objects/json/parse\"><code>JSON.parse()</code></a></li> <li><a href=\"../global_objects/json/stringify\"><code>JSON.stringify()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/JSON_bad_parse$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/JSON_bad_parse\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/JSON_bad_parse</a>\n  </p>\n</div>\n","errors/deprecated_caller_or_arguments_usage":"<h1>Errors: Deprecated caller or arguments usage</h1> <h2 id=\"Message\">Message</h2> <pre class=\"syntaxbox\">TypeError: 'arguments', 'callee' and 'caller' are restricted function properties and cannot be accessed in this context (Edge)\nWarning: ReferenceError: deprecated caller usage (Firefox)\nWarning: ReferenceError: deprecated arguments usage (Firefox)\nTypeError: 'callee' and 'caller' cannot be accessed in strict mode. (Safari)\n</pre> <h2 id=\"Error_type\">Error type</h2> <p>A strict-mode-only warning that a <a href=\"../global_objects/referenceerror\"><code>ReferenceError</code></a> occurred. JavaScript execution won't be halted.</p> <h2 id=\"What_went_wrong\">What went wrong?</h2> <p>In <a href=\"../strict_mode\">strict mode</a>, the <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/caller\"><code>Function.caller</code></a> or <a href=\"../global_objects/function/arguments\"><code>Function.arguments</code></a> properties are used and shouldn't be. They are deprecated, because they leak the function caller, are non-standard, hard to optimize and potentially a performance-harmful feature.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Deprecated_function.caller_or_arguments.callee.caller\">Deprecated <code>function.caller</code> or <code>arguments.callee.caller</code>\n</h3> <p><a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/caller\"><code>Function.caller</code></a> and <code><a href=\"../functions/arguments/callee\">arguments.callee.caller</a></code> are deprecated (see the reference articles for more information).</p> <pre data-language=\"js\">'use strict';\n\nfunction myFunc() {\n  if (myFunc.caller == null) {\n    return 'The function was called from the top!';\n  } else {\n    return 'This function\\'s caller was ' + myFunc.caller;\n  }\n}\n\nmyFunc();\n// Warning: ReferenceError: deprecated caller usage\n// \"The function was called from the top!\"</pre> <h3 id=\"Function.arguments\"><code>Function.arguments</code></h3> <p><a href=\"../global_objects/function/arguments\"><code>Function.arguments</code></a> is deprecated (see the reference article for more information).</p> <pre data-language=\"js\">'use strict';\n\nfunction f(n) { g(n - 1); }\n\nfunction g(n) {\n  console.log('before: ' + g.arguments[0]);\n  if (n &gt; 0) { f(n); }\n  console.log('after: ' + g.arguments[0]);\n}\n\nf(2);\n\nconsole.log('returned: ' + g.arguments);\n// Warning: ReferenceError: deprecated arguments usage\n</pre> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Deprecated_and_obsolete_features\">Deprecated and obsolete features</a></li> <li><a href=\"../strict_mode\">Strict mode</a></li> <li><a href=\"../global_objects/function/arguments\"><code>Function.arguments</code></a></li> <li>\n<a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/caller\"><code>Function.caller</code></a> and <code><a href=\"../functions/arguments/callee\">arguments.callee.caller</a></code>\n</li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Deprecated_caller_or_arguments_usage$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Deprecated_caller_or_arguments_usage\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Deprecated_caller_or_arguments_usage</a>\n  </p>\n</div>\n","errors/malformed_formal_parameter":"<h1>Errors: Malformed formal parameter</h1> <h2 id=\"Message\">Message</h2> <pre class=\"syntaxbox\">SyntaxError: Expected {x} (Edge)\nSyntaxError: malformed formal parameter (Firefox)\n</pre> <h2 id=\"Error_type\">Error type</h2> <p><a href=\"../global_objects/syntaxerror\"><code>SyntaxError</code></a></p> <h2 id=\"What_went_wrong\">What went wrong?</h2> <p>There is a <code><a href=\"../global_objects/function\">Function()</a></code> constructor with at least two arguments passed in the code. The last argument is the source code for the new function you're creating. All the rest make up your new function's argument list.</p> <p>The argument list is invalid somehow. Perhaps you accidentally picked a keyword like <code>if</code> or <code>var</code> as an argument name, or perhaps there's some stray punctuation in your argument list. Or maybe you accidentally passed an invalid value, like a number or object.</p> <h2 id=\"OK_that_fixed_my_problem._But_why_didn't_you_say_that_in_the_first_place\">OK, that fixed my problem. But why didn't you say that in the first place?</h2> <p>Admittedly the wording in the error message is slightly strange. \"Formal parameter\" is a fancy way of saying \"function argument\". And we use the word \"malformed\" because all Firefox engineers are huge fans of 19th-century Gothic horror novels.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Invalid_cases\">Invalid cases</h3> <pre data-language=\"js\">var f = Function('x y', 'return x + y;');  \n// SyntaxError (missing a comma)\n\nvar f = Function('x,', 'return x;');  \n// SyntaxError (extraneous comma)\n\nvar f = Function(37, \"alert('OK')\");\n// SyntaxError (numbers can't be argument names)\n</pre> <h3 id=\"Valid_cases\">Valid cases</h3> <pre data-language=\"js\">var f = Function('x, y', 'return x + y;');  // correctly punctuated\n\nvar f = Function('x', 'return x;');\n\n// if you can, avoid using Function - this is much faster\nvar f = function(x) { return x; };\n</pre> <h2 id=\"See_also\">See also</h2> <ul> <li><code><a href=\"../global_objects/function\">Function()</a></code></li> <li><a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Functions\">About functions</a></li> <li>\n<a href=\"https://www.gutenberg.org/ebooks/84\"><em>Frankenstein</em> by Mary Wollstonecraft Shelley, full e-text</a> (\"Cursed (although I curse myself) be the hands that formed you! You have made me wretched beyond expression. You have left me no power to consider whether I am just to you or not. Begone! Relieve me from the sight of your detested form.\")</li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Malformed_formal_parameter$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Malformed_formal_parameter\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Malformed_formal_parameter</a>\n  </p>\n</div>\n","errors/invalid_for-of_initializer":"<h1>Errors: Invalid for-of initializer</h1> <h2 id=\"Message\">Message</h2> <pre class=\"syntaxbox\">SyntaxError: for-of loop head declarations cannot have an initializer (Edge)\nSyntaxError: a declaration in the head of a for-of loop can't have an initializer (Firefox)\nSyntaxError: for-of loop variable declaration may not have an initializer. (Chrome)\n</pre> <h2 id=\"Error_type\">Error type</h2> <p><a href=\"../global_objects/syntaxerror\"><code>SyntaxError</code></a></p> <h2 id=\"What_went_wrong\">What went wrong?</h2> <p>The head of a<a href=\"../statements/for...of\"> for...of</a> loop contains an initializer expression. That is, a variable is declared and assigned a value |<code>for (var i = 0 of iterable)</code>|. This is not allowed in for-of loops. You might want a <code><a href=\"../statements/for\">for</a></code> loop that does allow an initializer.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Invalid_for-of_loop\">Invalid <code>for-of</code> loop</h3> <pre data-language=\"js\">let iterable = [10, 20, 30]; \n\nfor (let value = 50 of iterable) { \n  console.log(value); \n} \n\n// SyntaxError: a declaration in the head of a for-of loop can't \n// have an initializer</pre> <h3 id=\"Valid_for-of_loop\">Valid <code>for-of</code> loop</h3> <p>You need to remove the initializer (<code>value = 50</code>) in the head of the <code>for-of</code> loop. Maybe you intended to make 50 an offset value, in that case you could add it to the loop body, for example.</p> <pre data-language=\"js\">let iterable = [10, 20, 30];\n\nfor (let value of iterable) {\n  value += 50;\n  console.log(value);\n}\n// 60\n// 70\n// 80\n</pre> <h2 id=\"See_also\">See also</h2> <ul> <li><code><a href=\"../statements/for...of\">for...of</a></code></li> <li>\n<code><a href=\"../statements/for...in\">for...in</a></code> – disallows an initializer in strict mode as well (<a href=\"invalid_for-in_initializer\">SyntaxError: for-in loop head declarations may not have initializers</a>)</li> <li>\n<code><a href=\"../statements/for\">for</a></code> – allows to define an initializer when iterating.</li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Invalid_for-of_initializer$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Invalid_for-of_initializer\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Invalid_for-of_initializer</a>\n  </p>\n</div>\n","errors/deprecated_octal":"<h1>Errors: Deprecated octal</h1> <h2 id=\"Message\">Message</h2> <pre class=\"syntaxbox\">SyntaxError: Octal numeric literals and escape characters not allowed in strict mode (Edge)\nSyntaxError: \n\"0\"-prefixed octal literals and octal escape sequences are deprecated; \nfor octal literals use the \"0o\" prefix instead\n</pre> <h2 id=\"Error_type\">Error type</h2> <p><a href=\"../global_objects/syntaxerror\"><code>SyntaxError</code></a> in <a href=\"../strict_mode\">strict mode</a> only.</p> <h2 id=\"What_went_wrong\">What went wrong?</h2> <p>Octal literals and octal escape sequences are deprecated and will throw a <a href=\"../global_objects/syntaxerror\"><code>SyntaxError</code></a> in strict mode. With ECMAScript 2015 and later, the standardized syntax uses a leading zero followed by a lowercase or uppercase Latin letter \"O\" (<code>0o</code> or <code>0O)</code>.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"0-prefixed_octal_literals\">\"0\"-prefixed octal literals</h3> <pre data-language=\"js\">\"use strict\";\n\n03;\n\n// SyntaxError: \"0\"-prefixed octal literals and octal escape sequences \n// are deprecated</pre> <h3 id=\"Octal_escape_sequences\">Octal escape sequences</h3> <pre data-language=\"js\">\"use strict\";\n\n\"\\251\";\n\n// SyntaxError: \"0\"-prefixed octal literals and octal escape sequences\n// are deprecated\n</pre> <h3 id=\"Valid_octal_numbers\">Valid octal numbers</h3> <p>Use a leading zero followed by the letter \"o\" or \"O\":</p> <pre data-language=\"js\">0o3;\n</pre> <p>For octal escape sequences, you can use hexadecimal escape sequences instead:</p> <pre data-language=\"js\">'\\xA9';</pre> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"../lexical_grammar#Octal\">Lexical grammar</a></li> <li> <p><a href=\"bad_octal\">Warning: 08/09 is not a legal ECMA-262 octal constant</a></p> </li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Deprecated_octal$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Deprecated_octal\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Deprecated_octal</a>\n  </p>\n</div>\n","errors/illegal_character":"<h1>Errors: Illegal character</h1> <h2 id=\"Message\">Message</h2> <pre class=\"syntaxbox\">SyntaxError: Invalid character (Edge)\nSyntaxError: illegal character (Firefox)\nSyntaxError: Invalid or unexpected token (Chrome)\n</pre> <h2 id=\"Error_type\">Error type</h2> <p><a href=\"../global_objects/syntaxerror\"><code>SyntaxError</code></a></p> <h2 id=\"What_went_wrong\">What went wrong?</h2> <p>There is an invalid or unexpected token that doesn't belong at this position in the code. Use an editor that supports syntax highlighting and carefully check your code against mismatches like a minus sign (<code> - </code>) versus a dash (<code> – </code>) or simple quotes (<code> \" </code>) vs non-standard quotation marks (<code> “ </code>).</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Mismatched_characters\">Mismatched characters</h3> <p>Some characters look similar, but will cause the parser to fail interpreting your code. Famous examples of this are quotes, the minus or semicolon (<a href=\"https://en.wikipedia.org/wiki/Question_mark#Greek_question_mark\">greek questionmark (U+37e)</a> looks same).</p> <pre data-language=\"js\">“This looks like a string”;  // SyntaxError: illegal character \n                             // “ and ” are not \" but look like this\n\n42 – 13;                     // SyntaxError: illegal character\n                             // – is not - but looks like this\n\nvar foo = 'bar';             // SyntaxError: illegal character\n                             // &lt;37e&gt; is not ; but looks like this\n</pre> <p>This should work:</p> <pre data-language=\"js\">\"This is actually a string\";\n42 - 13;\nvar foo = 'bar';\n</pre> <p><span class=\"message-body-wrapper\"><span class=\"message-flex-body\"><span class=\"devtools-monospace message-body\"><span class=\"objectBox objectBox-string\">Some editors and IDEs will notify you or at least use a slightly different highlighting for it, but not all. When something like this happens to your code and you're not able to find the source of the problem, it's often best to just delete the problematic line and retype it.</span></span></span></span></p> <h3 id=\"Forgotten_characters\">Forgotten characters</h3> <p>It's easy to forget a character here or there.</p> <pre data-language=\"js\">var colors = ['#000', #333', '#666'];\n// SyntaxError: illegal character\n</pre> <p>Add the missing quote for <code><strong>'</strong>#333'</code>.</p> <pre data-language=\"js\">var colors = ['#000', '#333', '#666'];</pre> <h3 id=\"Hidden_characters\">Hidden characters</h3> <p>When copy pasting code from external sources, there might be invalid characters. Watch out!</p> <pre data-language=\"js\">var foo = 'bar';​\n// SyntaxError: illegal character\n</pre> <p>When inspecting this code in an editor like Vim, you can see that there is actually a <a href=\"https://en.wikipedia.org/wiki/Zero-width_space\">zero-width space (ZWSP) (U+200B)</a> character.</p> <pre data-language=\"js\">var foo = 'bar';​&lt;200b&gt;</pre> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"../lexical_grammar\">Lexical grammar</a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Illegal_character$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Illegal_character\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Illegal_character</a>\n  </p>\n</div>\n","errors/undefined_prop":"<h1>Errors: Undefined prop</h1> <h2 id=\"Message\">Message</h2> <pre class=\"syntaxbox\">ReferenceError: reference to undefined property \"x\" (Firefox)\n</pre> <h2 id=\"Error_type\">Error type</h2> <p>(Firefox only) <a href=\"../global_objects/referenceerror\"><code>ReferenceError</code></a> warning which is reported only if <code>javascript.options.strict</code> preference is set to <code>true</code>.</p> <h2 id=\"What_went_wrong\">What went wrong?</h2> <p>The script attempted to access an object property which doesn't exist. There are two ways to access properties; see the <a href=\"../operators/property_accessors#0\">property accessors</a> reference page to learn more about them.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Invalid_cases\">Invalid cases</h3> <p>In this case, the property <code>bar</code> is an undefined property, so a <code>ReferenceError</code> will occur.</p> <pre data-language=\"js\">var foo = {};\nfoo.bar; // ReferenceError: reference to undefined property \"bar\"\n</pre> <h3 id=\"Valid_cases\">Valid cases</h3> <p>To avoid the error, you need to either add a definition for <code>bar</code> to the object or check for the existence of the <code>bar</code> property before trying to access it; one way to do that is to use the <a href=\"../global_objects/object/hasownproperty\"><code>Object.prototype.hasOwnProperty()</code></a> method), like this:</p> <pre data-language=\"js\">var foo = {};\n\n// Define the bar property\n\nfoo.bar = 'moon';\nconsole.log(foo.bar); // \"moon\"\n\n// Test to be sure bar exists before accessing it\n\nif (foo.hasOwnProperty('bar')) {\n  console.log(foo.bar);\n}</pre> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"../operators/property_accessors#0\">property accessors</a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Undefined_prop$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Undefined_prop\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Undefined_prop</a>\n  </p>\n</div>\n","errors/strict_non_simple_params":"<h1>Errors: Strict Non Simple Params</h1> <h2 id=\"Message\">Message</h2> <pre class=\"syntaxbox\">Edge:\nCannot apply strict mode on functions with non-simple parameter list\n\nFirefox:\nSyntaxError: \"use strict\" not allowed in function with default parameter\nSyntaxError: \"use strict\" not allowed in function with rest parameter\nSyntaxError: \"use strict\" not allowed in function with destructuring parameter\n\nChrome:\nSyntaxError: Illegal 'use strict' directive in function with non-simple parameter list\n</pre> <h2 id=\"Error_type\">Error type</h2> <p><a href=\"../global_objects/syntaxerror\"><code>SyntaxError</code></a>.</p> <h2 id=\"What_went_wrong\">What went wrong?</h2> <p>A <code>\"use strict\"</code> directive is written at the top of a function that has one of the following parameters:</p> <ul> <li><a href=\"../functions/default_parameters\">Default parameters</a></li> <li><a href=\"../functions/rest_parameters\">Rest parameters</a></li> <li><a href=\"../operators/destructuring_assignment\">Destructuring parameters</a></li> </ul> <p>A <code>\"use strict\"</code> directive is not allowed at the top of such functions per the ECMAScript specification.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Function_statement\">Function statement</h3> <p>In this case, the function <code>sum</code> has default parameters <code>a=1</code> and <code>b=2</code>:</p> <pre data-language=\"js\">function sum(a = 1, b = 2) {\n  // SyntaxError: \"use strict\" not allowed in function with default parameter\n  'use strict';\n  return a + b;\n}\n</pre> <p>If the function should be in <a href=\"../strict_mode\">strict mode</a>, and the entire script or enclosing function is also okay to be in strict mode, you can move the <code>\"use strict\"</code> directive outside of the function:</p> <pre data-language=\"js\">'use strict';\nfunction sum(a = 1, b = 2) {\n  return a + b;\n}\n</pre> <h3 id=\"Function_expression\">Function expression</h3> <p>A function expression can use yet another workaround:</p> <pre data-language=\"js\">var sum = function sum([a, b]) {\n  // SyntaxError: \"use strict\" not allowed in function with destructuring parameter\n  'use strict';\n  return a + b;\n};\n</pre> <p>This can be converted to the following expression:</p> <pre data-language=\"js\">var sum = (function() {\n  'use strict';\n  return function sum([a, b]) {\n    return a + b;\n  };\n})();\n</pre> <h3 id=\"Arrow_function\">Arrow function</h3> <p>If an arrow function needs to access the <code>this</code> variable, you can use the arrow function as the enclosing function:</p> <pre data-language=\"js\">var callback = (...args) =&gt; {\n  // SyntaxError: \"use strict\" not allowed in function with rest parameter\n  'use strict';\n  return this.run(args);\n};\n</pre> <p>This can be converted to the following expression:</p> <pre data-language=\"js\">var callback = (() =&gt; {\n  'use strict';\n  return (...args) =&gt; {\n    return this.run(args);\n  };\n})();\n</pre> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"../strict_mode\">Strict mode</a></li> <li><a href=\"../statements/function\">function statement</a></li> <li><a href=\"../operators/function\">function expression</a></li> <li><a href=\"../functions/default_parameters\">Default parameters</a></li> <li><a href=\"../functions/rest_parameters\">Rest parameters</a></li> <li><a href=\"../operators/destructuring_assignment\">Destructuring parameters</a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Strict_Non_Simple_Params$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Strict_Non_Simple_Params\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Strict_Non_Simple_Params</a>\n  </p>\n</div>\n","errors/unexpected_token":"<h1>Errors: Unexpected token</h1> <h2 id=\"Message\">Message</h2> <pre class=\"syntaxbox\">SyntaxError: expected expression, got \"x\"\nSyntaxError: expected property name, got \"x\" \nSyntaxError: expected target, got \"x\"\nSyntaxError: expected rest argument name, got \"x\"\nSyntaxError: expected closing parenthesis, got \"x\"\nSyntaxError: expected '=&gt;' after argument list, got \"x\"\n</pre> <h2 id=\"Error_type\">Error type</h2> <p><a href=\"../global_objects/syntaxerror\"><code>SyntaxError</code></a></p> <h2 id=\"What_went_wrong\">What went wrong?</h2> <p>A specific language construct was expected, but something else was provided. This might be a simple typo.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Expression_expected\">Expression expected</h3> <p>For example, when chaining expressions, trailing commas are not allowed.</p> <pre data-language=\"js\">for (let i = 0; i &lt; 5,; ++i) {\n  console.log(i);\n}\n// SyntaxError: expected expression, got ')'\n</pre> <p>Correct would be omitting the comma or adding another expression:</p> <pre data-language=\"js\">for (let i = 0; i &lt; 5; ++i) {\n  console.log(i);\n}\n</pre> <h3 id=\"Not_enough_brackets\">Not enough brackets</h3> <p>Sometimes, you leave out brackets around <code>if</code> statements:</p> <pre data-language=\"js\">function round(n, upperBound, lowerBound){\n  if(n &gt; upperBound) || (n &lt; lowerBound){\n    throw 'Number ' + String(n) + ' is more than ' + String(upperBound) + ' or less than ' + String(lowerBound);\n  }else if(n &lt; ((upperBound + lowerBound)/2)){\n    return lowerBound;\n  }else{\n    return upperBound;\n  }\n} // SyntaxError: expected expression, got '||'</pre> <p>The brackets may look correct at first, but note how the <code>||</code> is outside the brackets. Correct would be putting brackets around the <code>||</code>:</p> <pre data-language=\"js\">function round(n, upperBound, lowerBound){\n  if((n &gt; upperBound) || (n &lt; lowerBound)){\n    throw 'Number ' + String(n) + ' is more than ' + String(upperBound) + ' or less than ' + String(lowerBound);\n  }else if(n &lt; ((upperBound + lowerBound)/2)){\n    return lowerBound;\n  }else{\n    return upperBound;\n  }\n}\n</pre> <div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Unexpected_token$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Unexpected_token\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Unexpected_token</a>\n  </p>\n</div>\n","errors/reserved_identifier":"<h1>Errors: Reserved identifier</h1> <h2 id=\"Message\">Message</h2> <pre class=\"syntaxbox\">SyntaxError: The use of a future reserved word for an identifier is invalid (Edge)\nSyntaxError: \"x\" is a reserved identifier (Firefox)\nSyntaxError: Unexpected reserved word (Chrome)</pre> <h2 id=\"Error_type\">Error type</h2> <p><a href=\"../global_objects/syntaxerror\"><code>SyntaxError</code></a></p> <h2 id=\"What_went_wrong\">What went wrong?</h2> <p><a href=\"../lexical_grammar#Keywords\">Reserved keywords</a> will throw in if they are used as identifiers. These are reserved in strict mode and sloppy mode:</p> <ul> <li><code>enum</code></li> </ul> <p>The following are only reserved when they are found in strict mode code:</p> <ul class=\"threecolumns\"> <li><code>implements</code></li> <li><code>interface</code></li> <li><a href=\"../statements/let\"><code>let</code></a></li> <li><code>package</code></li> <li><code>private</code></li> <li><code>protected</code></li> <li><code>public</code></li> <li><code>static</code></li> </ul> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Strict_and_non-strict_reserved_keywords\">Strict and non-strict reserved keywords</h3> <p>The <code>enum</code> identifier is generally reserved.</p> <pre data-language=\"js\">var enum = { RED: 0, GREEN: 1, BLUE: 2 };\n// SyntaxError: enum is a reserved identifier\n</pre> <p>In strict mode code, more identifiers are reserved.</p> <pre data-language=\"js\">\"use strict\";\nvar package = [\"potatoes\", \"rice\", \"fries\"];\n// SyntaxError: package is a reserved identifier\n</pre> <p>You'll need to rename these variables.</p> <pre data-language=\"js\">var colorEnum = { RED: 0, GREEN: 1, BLUE: 2 };\nvar list = [\"potatoes\", \"rice\", \"fries\"];</pre> <h3 id=\"Update_older_browsers\">Update older browsers</h3> <p>If you are using an older browser that does not yet implement <code><a href=\"../statements/let\">let</a></code> or <code><a href=\"../statements/class\">class</a></code>, for example, you should update to a more recent browser version that does support these new language features.</p> <pre data-language=\"js\">\"use strict\"; \nclass DocArchiver {}\n\n// SyntaxError: class is a reserved identifier\n// (throws in older browsers only, e.g. Firefox 44 and older)\n</pre> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"http://wiki.c2.com/?GoodVariableNames\">Good variable names</a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Reserved_identifier$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Reserved_identifier\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Reserved_identifier</a>\n  </p>\n</div>\n","errors/invalid_for-in_initializer":"<h1>Errors: Invalid for-in initializer</h1> <h2 id=\"Message\">Message</h2> <pre class=\"syntaxbox\">SyntaxError: for-in loop head declarations cannot have an initializer (Edge)\nSyntaxError: for-in loop head declarations may not have initializers (Firefox)\nSyntaxError: for-in loop variable declaration may not have an initializer. (Chrome)\n</pre> <h2 id=\"Error_type\">Error type</h2> <p><a href=\"../global_objects/syntaxerror\"><code>SyntaxError</code></a> in <a href=\"../strict_mode\">strict mode</a> only.</p> <h2 id=\"What_went_wrong\">What went wrong?</h2> <p>The head of a<a href=\"../statements/for...in\"> for...in</a> loop contains an initializer expression. That is, a variable is declared and assigned a value |<code>for (var i = 0 in obj)</code>|. In non-strict mode, this head declaration is silently ignored and behaves like <code>|for (var i in obj)|</code>. In <a href=\"../strict_mode\">strict mode</a>, however, a <code>SyntaxError</code> is thrown.</p> <h2 id=\"Examples\">Examples</h2> <p>This example throws a <code>SyntaxError</code>:</p> <pre data-language=\"js\">\"use strict\";\n\nvar obj = {a: 1, b: 2, c: 3 }; \n\nfor (var i = 0 in obj) { \n  console.log(obj[i]);\n}\n\n// SyntaxError: for-in loop head declarations may not have initializers\n</pre> <h3 id=\"Valid_for-in_loop\">Valid for-in loop</h3> <p>You can remove the initializer (<code>i = 0</code>) in the head of the for-in loop.</p> <pre data-language=\"js\">\"use strict\";\n\nvar obj = {a: 1, b: 2, c: 3 };\n\nfor (var i in obj) {\n  console.log(obj[i]);\n}\n</pre> <h3 id=\"Array_iteration\">Array iteration</h3> <p>The for...in loop <a href=\"../statements/for...in#Array_iteration_and_for...in\">shouldn't be used for Array iteration</a>. Did you intend to use a <code><a href=\"../statements/for\">for</a></code> loop instead of a <code>for-in</code> loop to iterate an <a href=\"../global_objects/array\"><code>Array</code></a>? The <code>for</code> loop allows you to set an initializer then as well:</p> <pre data-language=\"js\">var arr = [ \"a\", \"b\", \"c\" ] \n\nfor (var i = 2; i &lt; arr.length; i++) { \n  console.log(arr[i]); \n}\n\n// \"c\"</pre> <h2 id=\"See_also\">See also</h2> <ul> <li><code><a href=\"../statements/for...in\">for...in</a></code></li> <li>\n<code><a href=\"../statements/for...of\">for...of</a></code> – also disallows an initializer in both strict and non-strict mode.</li> <li>\n<code><a href=\"../statements/for\">for</a></code> – preferred for array iteration, allows to define an initializer.</li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Invalid_for-in_initializer$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Invalid_for-in_initializer\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Invalid_for-in_initializer</a>\n  </p>\n</div>\n","errors/deprecated_source_map_pragma":"<h1>Errors: Deprecated source map pragma</h1> <h2 id=\"Message\">Message</h2> <pre class=\"syntaxbox\">Warning: SyntaxError: Using //@ to indicate sourceURL pragmas is deprecated. Use //# instead\n\nWarning: SyntaxError: Using //@ to indicate sourceMappingURL pragmas is deprecated. Use //# instead\n</pre> <h2 id=\"Error_type\">Error type</h2> <p>A warning that a <a href=\"../global_objects/syntaxerror\"><code>SyntaxError</code></a> occurred. JavaScript execution won't be halted.</p> <h2 id=\"What_went_wrong\">What went wrong?</h2> <p>There is a deprecated source map syntax in a JavaScript source.</p> <p>JavaScript sources are often combined and minified to make delivering them from the server more efficient. With <a href=\"http://www.html5rocks.com/en/tutorials/developertools/sourcemaps/\">source maps</a>, the debugger can map the code being executed to the original source files.</p> <p>The source map specification changed the syntax due to a conflict with IE whenever it was found in the page after <code>//@cc_on</code> was interpreted to turn on conditional compilation in the IE JScript engine. The <a href=\"https://msdn.microsoft.com/en-us/library/8ka90k2e%28v=vs.94%29.aspx\">conditional compilation comment</a> in IE is a little known feature, but it broke source maps with <a href=\"https://bugs.jquery.com/ticket/13274\">jQuery</a> and other libraries.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Deprecated_syntax\">Deprecated syntax</h3> <p>Syntax with the \"@\" sign is deprecated.</p> <pre data-language=\"js\">//@ sourceMappingURL=http://example.com/path/to/your/sourcemap.map\n</pre> <h3 id=\"Standard_syntax\">Standard syntax</h3> <p>Use the \"#\" sign instead.</p> <pre data-language=\"js\">//# sourceMappingURL=http://example.com/path/to/your/sourcemap.map</pre> <p>Or, alternatively, you can set a <a href=\"https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/SourceMap\"><code>SourceMap</code></a> header to your JavaScript file to avoid having a comment at all:</p> <pre data-language=\"js\">SourceMap: /path/to/file.js.map</pre> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"https://developer.mozilla.org/en-US/docs/Tools/Debugger/How_to/Use_a_source_map\">How to use a source map – Firefox Tools documentation</a></li> <li><a href=\"http://www.html5rocks.com/en/tutorials/developertools/sourcemaps/\">Introduction to source maps – HTML5 rocks</a></li> <li><a href=\"https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/SourceMap\"><code>SourceMap</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Deprecated_source_map_pragma$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Deprecated_source_map_pragma\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Deprecated_source_map_pragma</a>\n  </p>\n</div>\n","errors/unnamed_function_statement":"<h1>Errors: Unnamed function statement</h1> <h2 id=\"Message\">Message</h2> <pre class=\"syntaxbox\">Syntax Error: Expected identifier (Edge)\nSyntaxError: function statement requires a name [Firefox]\nSyntaxError: Unexpected token ( [Chrome]\n</pre> <h2 id=\"Error_type\">Error type</h2> <p><a href=\"../global_objects/syntaxerror\"><code>SyntaxError</code></a></p> <h2 id=\"What_went_wrong\">What went wrong?</h2> <p>There is a <a href=\"../statements/function\">function statement</a> in the code that requires a name. You'll need to check how functions are defined and if you need to provide a name for it, or if the function in question needs to be a function expression, an <a href=\"https://developer.mozilla.org/en-US/docs/Glossary/IIFE\">IIFE</a>, or if the function code is placed correctly in this context at all.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Statements_vs_expressions\">Statements vs expressions</h3> <p>A <em><a href=\"../statements/function\">function statement</a></em> (or <em>function declaration</em>) requires a name, this won't work:</p> <pre data-language=\"js\">function () {\n  return 'Hello world';\n}\n// SyntaxError: function statement requires a name\n</pre> <p>You can use a <a href=\"../operators/function\">function expression</a> (assignment) instead:</p> <pre data-language=\"js\">var greet = function() {\n  return 'Hello world';\n};</pre> <p>Or, you function is maybe intended to be an <a href=\"https://en.wikipedia.org/wiki/Immediately-invoked_function_expression\">IIFE</a> (Immediately Invoked Function Expression), which is a function that runs as soon as it is defined. You will need a few more braces in this case:</p> <pre data-language=\"js\">(function () {\n\n})();</pre> <h3 id=\"Labeled_functions\">Labeled functions</h3> <p>If you are using function <a href=\"../statements/label\">labels</a>, you will still need to provide a function name after the <code>function</code> keyword. This doesn't work:</p> <pre data-language=\"js\">function Greeter() {\n  german: function () { \n    return \"Moin\";\n  }\n}\n// SyntaxError: function statement requires a name\n</pre> <p>This would work, for example:</p> <pre data-language=\"js\">function Greeter() { \n  german: function g() { \n    return \"Moin\"; \n  } \n}</pre> <h3 id=\"Object_methods\">Object methods</h3> <p>If you intended to create a method of an object, you will need to create an object. The following syntax without a name after the <code>function</code> keyword is valid then.</p> <pre data-language=\"js\">var greeter = {\n  german: function () {\n    return \"Moin\";\n  } \n};</pre> <h3 id=\"Callback_syntax\">Callback syntax</h3> <p>Also, check your syntax when using callbacks. Brackets and commas can get difficult easily.</p> <pre data-language=\"js\">promise.then(\n  function() {\n    console.log(\"success\"); \n  });\n  function() {\n    console.log(\"error\");\n}\n// SyntaxError: function statement requires a name\n</pre> <p>Correct would be:</p> <pre data-language=\"json\">promise.then(\n  function() {\n    console.log(\"success\");\n  },\n  function() {\n    console.log(\"error\");\n  }\n);\n</pre> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Functions\">Functions in the JavaScript Guide</a></li> <li><a href=\"../statements/function\">function statement</a></li> <li><a href=\"../operators/function\">function expression</a></li> <li><a href=\"https://en.wikipedia.org/wiki/Immediately-invoked_function_expression\">IIFE</a></li> <li><a href=\"../statements/label\">label</a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Unnamed_function_statement$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Unnamed_function_statement\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Unnamed_function_statement</a>\n  </p>\n</div>\n","errors/identifier_after_number":"<h1>Errors: Identifier after number</h1> <h2 id=\"Message\">Message</h2> <pre class=\"syntaxbox\">SyntaxError: Unexpected identifier after numeric literal (Edge)\nSyntaxError: identifier starts immediately after numeric literal (Firefox)\nSyntaxError: Unexpected number (Chrome)\n</pre> <h2 id=\"Error_type\">Error type</h2> <p><a href=\"../global_objects/syntaxerror\"><code>SyntaxError</code></a></p> <h2 id=\"What_went_wrong\">What went wrong?</h2> <p>The names of variables, called <a href=\"https://developer.mozilla.org/en-US/docs/Glossary/Identifier\">identifiers</a>, conform to certain rules, which your code must adhere to!</p> <p>A JavaScript identifier must start with a letter, underscore (_), or dollar sign ($). They can't start with a digit! Only subsequent characters can be digits (0-9).</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Variable_names_starting_with_numeric_literals\">Variable names starting with numeric literals</h3> <p>Variable names can't start with numbers in JavaScript. The following fails:</p> <pre data-language=\"js\">var 1life = 'foo';\n// SyntaxError: identifier starts immediately after numeric literal\n\nvar foo = 1life;\n// SyntaxError: identifier starts immediately after numeric literal\n\nalert(1.foo);\n// SyntaxError: identifier starts immediately after numeric literal \n</pre> <p>You will need to rename your variable to avoid the leading number.</p> <pre data-language=\"js\">var life1 = 'foo';\nvar foo = life1;\n</pre> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"../lexical_grammar\">Lexical grammar</a></li> <li>\n<a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Grammar_and_types#Variables\">Variables</a> in the <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide\">JavaScript Guide</a>\n</li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Identifier_after_number$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Identifier_after_number\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Identifier_after_number</a>\n  </p>\n</div>\n","errors/delete_in_strict_mode":"<h1>Errors: Delete in strict mode</h1> <h2 id=\"Message\">Message</h2> <pre class=\"syntaxbox\">SyntaxError: Calling delete on expression not allowed in strict mode (Edge)\nSyntaxError: applying the 'delete' operator to an unqualified name is deprecated (Firefox)\nSyntaxError: Delete of an unqualified identifier in strict mode. (Chrome)\n</pre> <h2 id=\"Error_type\">Error type</h2> <p><a href=\"../global_objects/syntaxerror\"><code>SyntaxError</code></a> in <a href=\"../strict_mode\">strict mode</a> only.</p> <h2 id=\"What_went_wrong\">What went wrong?</h2> <p>Normal variables in JavaScript can't be deleted using the <code><a href=\"../operators/delete\">delete</a></code> operator. In strict mode, an attempt to delete a variable will throw an error and is not allowed.</p> <p>The <code>delete</code> operator can only delete properties on an object. Object properties are \"qualified\" if they are configurable.</p> <p>Unlike what common belief suggests, the <code>delete</code> operator has <strong>nothing</strong> to do with directly freeing memory. Memory management is done indirectly via breaking references, see the <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Memory_Management\">memory management</a> page and the <code><a href=\"../operators/delete\">delete</a></code> operator page for more details.</p> <p>This error only happens in <a href=\"../strict_mode\">strict mode code</a>. In non-strict code, the operation just returns <code>false</code>.</p> <h2 id=\"Examples\">Examples</h2> <p>Attempting to delete a plain variable, doesn't work in JavaScript and it throws an error in strict mode:</p> <pre data-language=\"js\">'use strict';\n\nvar x;\n\n// ...\n\ndelete x;\n\n// SyntaxError: applying the 'delete' operator to an unqualified name \n// is deprecated \n</pre> <p>To free the contents of a variable, you can set it to <a href=\"../global_objects/null\"><code>null</code></a>:</p> <pre data-language=\"js\">'use strict';\n\nvar x;\n\n// ...\n\nx = null;\n\n// x can be garbage collected\n</pre> <h2 id=\"See_also\">See also</h2> <ul> <li><code><a href=\"../operators/delete\">delete</a></code></li> <li><a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Memory_Management\">Memory management</a></li> <li><a href=\"cant_delete\">TypeError: property \"x\" is non-configurable and can't be deleted</a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Delete_in_strict_mode$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Delete_in_strict_mode\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Delete_in_strict_mode</a>\n  </p>\n</div>\n","errors/missing_parenthesis_after_argument_list":"<h1>Errors: Missing parenthesis after argument list</h1> <h2 id=\"Message\">Message</h2> <pre class=\"syntaxbox\">SyntaxError: Expected ')' (Edge)\nSyntaxError: missing ) after argument list (Firefox)\n</pre> <h2 id=\"Error_type\">Error type</h2> <p><a href=\"../global_objects/syntaxerror\"><code>SyntaxError</code></a>.</p> <h2 id=\"What_went_wrong\">What went wrong?</h2> <p>There is an error with how a function is called. This might be a typo, a missing operator, or an unescaped string, for example.</p> <h2 id=\"Examples\">Examples</h2> <p>Because there is no \"+\" operator to concatenate the string, JavaScript expects the argument for the <code>log</code> function to be just <code>\"PI: \"</code>. In that case, it should be terminated by a closing parenthesis.</p> <pre data-language=\"js\">console.log('PI: ' Math.PI);\n// SyntaxError: missing ) after argument list\n</pre> <p>You can correct the <code>log</code> call by adding the \"<code>+</code>\" operator:</p> <pre data-language=\"js\">console.log('PI: ' + Math.PI);\n// \"PI: 3.141592653589793\"</pre> <h3 id=\"Unterminated_strings\">Unterminated strings</h3> <pre data-language=\"js\">console.log('\"Java\" + \"Script\" = \\\"' + 'Java' + 'Script\\\");\n// SyntaxError: missing ) after argument list</pre> <p>Here JavaScript thinks that you meant to have <code>);</code> inside the string and ignores it, and it ends up not knowing that you meant the <code>);</code> to end the function <code>console.log</code>. To fix this, we could put a<code>'</code> after the \"Script\" string:</p> <pre data-language=\"js\">console.log('\"Java\" + \"Script\" = \\\"' + 'Java' + 'Script\\\"');\n// '\"Java\" + \"Script\" = \"JavaScript\"'\n</pre> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Functions\">Functions</a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Missing_parenthesis_after_argument_list$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Missing_parenthesis_after_argument_list\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Missing_parenthesis_after_argument_list</a>\n  </p>\n</div>\n","errors/bad_regexp_flag":"<h1>Errors: Bad regexp flag</h1> <h2 id=\"Message\">Message</h2> <pre class=\"syntaxbox\">SyntaxError: Syntax error in regular expression (Edge) \nSyntaxError: invalid regular expression flag \"x\" (Firefox)\nSyntaxError: Invalid regular expression flags (Chrome)\n</pre> <h2 id=\"Error_type\">Error type</h2> <p><a href=\"../global_objects/syntaxerror\"><code>SyntaxError</code></a></p> <h2 id=\"What_went_wrong\">What went wrong?</h2> <p>There are invalid regular expression flags in the code. In a regular expression literal, which consists of a pattern enclosed between slashes, the flags are defined after the second flag. They can also be defined in the constructor function of the <a href=\"../global_objects/regexp\"><code>RegExp</code></a> object (second parameter). Regular expression flags can be used separately or together in any order, but there are only five of them in ECMAScript.</p> <p>To include a flag with the regular expression, use this syntax:</p> <pre data-language=\"js\">var re = /pattern/flags;\n</pre> <p>or</p> <pre data-language=\"js\">var re = new RegExp('pattern', 'flags');</pre> <div class=\"_table\"><table class=\"standard-table\"> <caption>Regular expression flags</caption> <thead> <tr> <th scope=\"col\">Flag</th> <th scope=\"col\">Description</th> </tr> </thead> <tbody> <tr> <td><code>g</code></td> <td>Global search.</td> </tr> <tr> <td>i</td> <td>Case-insensitive search.</td> </tr> <tr> <td>m</td> <td>Multi-line search.</td> </tr> <tr> <td>u</td> <td>Unicode; treat pattern as a sequence of Unicode code points</td> </tr> <tr> <td>y</td> <td>Perform a \"sticky\" search that matches starting at the current position in the target string. See <a href=\"../global_objects/regexp/sticky\"><code>sticky</code></a>\n</td> </tr> </tbody> </table></div> <h2 id=\"Examples\">Examples</h2> <p>There are only five valid regular expression flags.</p> <pre data-language=\"js\">/foo/bar;\n\n// SyntaxError: invalid regular expression flag \"b\"\n</pre> <p>Did you intend to create a regular expression? An expression containing two slashes is interpreted as a regular expression literal.</p> <pre data-language=\"js\">let obj = {\n  url: /docs/Web\n};\n\n// SyntaxError: invalid regular expression flag \"W\"\n</pre> <p>Or did you mean to create a string instead? Add single or double quotes to create a string literal.</p> <pre data-language=\"js\">let obj = {\n  url: '/docs/Web'\n};</pre> <h3 id=\"Valid_regular_expression_flags\">Valid regular expression flags</h3> <p>See the table above for the five valid regular expression flags that are allowed in JavaScript.</p> <pre data-language=\"js\">/foo/g;\n/foo/gim;\n/foo/uy;\n</pre> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions\">Regular expressions</a></li> <li>\n<a href=\"http://xregexp.com/flags/\">XRegEx flags</a> – regular expression library that provides four new flags (<code>n</code>, <code>s</code>, <code>x</code>, <code>A</code>)</li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Bad_regexp_flag$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Bad_regexp_flag\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Bad_regexp_flag</a>\n  </p>\n</div>\n","errors/missing_parenthesis_after_condition":"<h1>Errors: Missing parenthesis after condition</h1> <h2 id=\"Message\">Message</h2> <pre class=\"syntaxbox\">SyntaxError: Expected ')' (Edge)\nSyntaxError: missing ) after condition (Firefox)\n</pre> <h2 id=\"Error_type\">Error type</h2> <p><a href=\"../global_objects/syntaxerror\"><code>SyntaxError</code></a></p> <h2 id=\"What_went_wrong\">What went wrong?</h2> <p>There is an error with how an <code><a href=\"../statements/if...else\">if</a></code> condition is written. In any programming language, code needs to make decisions and carry out actions accordingly depending on different inputs. The if statement executes a statement if a specified condition is truthy. In JavaScript, this condition must appear in parenthesis after the <code>if</code> keyword, like this:</p> <pre data-language=\"js\">if (condition) {\n  // do something if the condition is true\n}</pre> <h2 id=\"Examples\">Examples</h2> <p>It might just be an oversight, carefully check all you parenthesis in your code.</p> <pre data-language=\"js\">if (3 &gt; Math.PI {\n  console.log(\"wait what?\");\n}\n\n// SyntaxError: missing ) after condition\n</pre> <p>To fix this code, you would need to add a parenthesis that closes the condition.</p> <pre data-language=\"js\">if (3 &gt; Math.PI) {\n  console.log(\"wait what?\");\n}</pre> <p>If you are coming from another programming language, it is also easy to add keywords that don't mean the same or have no meaning at all in JavaScript.</p> <pre data-language=\"js\">if (done is true) {\n console.log(\"we are done!\");\n}\n\n// SyntaxError: missing ) after condition\n</pre> <p>Instead you need to use a correct <a href=\"../operators/comparison_operators\">comparison operator</a>. For example:</p> <pre data-language=\"js\">if (done === true) {\n console.log(\"we are done!\");\n}</pre> <h2 id=\"See_also\">See also</h2> <ul> <li><code><a href=\"../statements/if...else\">if...else</a></code></li> <li><a href=\"../operators/comparison_operators\">Comparison operators</a></li> <li> <p><a href=\"https://developer.mozilla.org/en-US/docs/Learn/JavaScript/Building_blocks/conditionals\">Making decisions in your code — conditionals</a></p> </li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Missing_parenthesis_after_condition$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Missing_parenthesis_after_condition\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Missing_parenthesis_after_condition</a>\n  </p>\n</div>\n","errors/missing_colon_after_property_id":"<h1>Errors: Missing colon after property id</h1> <h2 id=\"Message\">Message</h2> <pre class=\"syntaxbox\">SyntaxError: Expected ':' (Edge)\nSyntaxError: missing : after property id (Firefox)\n</pre> <h2 id=\"Error_type\">Error type</h2> <p><a href=\"../global_objects/syntaxerror\"><code>SyntaxError</code></a></p> <h2 id=\"What_went_wrong\">What went wrong?</h2> <p>When creating objects with the <a href=\"../operators/object_initializer\">object initializer</a> syntax, a colon (<code>:</code>) separates keys and values for the object's properties.</p> <pre data-language=\"js\">var obj = { propertyKey: 'value' };\n</pre> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Colons_vs._equal_signs\">Colons vs. equal signs</h3> <p>This code fails, as the equal sign can't be used this way in this object initializer syntax.</p> <pre data-language=\"js\">var obj = { propertyKey = 'value' };\n// SyntaxError: missing : after property id\n</pre> <p>Correct would be to use a colon, or to use square brackets to assign a new property after the object has been created already.</p> <pre data-language=\"js\">var obj = { propertyKey: 'value' };\n\n// or alternatively\n\nvar obj = { };\nobj['propertyKey'] = 'value';\n</pre> <h3 id=\"Empty_properties\">Empty properties</h3> <p>You can't create empty properties like this:</p> <pre data-language=\"js\">var obj = { propertyKey; };\n// SyntaxError: missing : after property id\n</pre> <p>If you need to define a property without a value, you might use <a href=\"../global_objects/null\"><code>null</code></a> as a value.</p> <pre data-language=\"js\">var obj = { propertyKey: null };</pre> <h3 id=\"Computed_properties\">Computed properties</h3> <p>If you create a property key from an expression, you need to use square brackets. Otherwise the property name can't be computed:</p> <pre data-language=\"js\">var obj = { 'b'+'ar': 'foo' };\n// SyntaxError: missing : after property id\n</pre> <p>Put the expression in brackets <code>[]</code>:</p> <pre data-language=\"js\">var obj = { ['b'+'ar']: 'foo' };</pre> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"../operators/object_initializer\">Object initializer</a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Missing_colon_after_property_id$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Missing_colon_after_property_id\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Missing_colon_after_property_id</a>\n  </p>\n</div>\n","errors/missing_initializer_in_const":"<h1>Errors: Missing initializer in const</h1> <h2 id=\"Message\">Message</h2> <pre class=\"syntaxbox\">SyntaxError: Const must be initalized (Edge)\nSyntaxError: missing = in const declaration (Firefox)\nSyntaxError: Missing initializer in const declaration (Chrome)\n</pre> <h2 id=\"Error_type\">Error type</h2> <p><a href=\"../global_objects/syntaxerror\"><code>SyntaxError</code></a></p> <h2 id=\"What_went_wrong\">What went wrong?</h2> <p>A constant is a value that cannot be altered by the program during normal execution. It cannot change through re-assignment, and it can't be redeclared. In JavaScript, constants are declared using the <code><a href=\"../statements/const\">const</a></code> keyword. An initializer for a constant is required; that is, you must specify its value in the same statement in which it's declared (which makes sense, given that it can't be changed later).</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Missing_const_initializer\">Missing const initializer</h3> <p>Unlike <code>var</code> or <code>let</code>, you must specify a value for a <code>const</code> declaration. This throws:</p> <pre data-language=\"js\">const COLUMNS; \n// SyntaxError: missing = in const declaration</pre> <h3 id=\"Fixing_the_error\">Fixing the error</h3> <p>There are multiple options to fix this error. Check what was intended to be achieved with the constant in question.</p> <h4 id=\"Adding_a_constant_value\">Adding a constant value</h4> <p>Specify the constant value in the same statement in which it's declared:</p> <pre data-language=\"js\">const COLUMNS = 80;</pre> <h4 id=\"const_let_or_var\">\n<code>const</code>, <code>let</code> or <code>var</code>?</h4> <p>Do not use <code>const</code> if you weren't meaning to declare a constant. Maybe you meant to declare a block-scoped variable with <code><a href=\"../statements/let\">let</a></code> or global variable with <code><a href=\"../statements/var\">var</a></code>. Both don't require an initial value.</p> <pre data-language=\"js\">let columns;\n</pre> <h2 id=\"See_also\">See also</h2> <ul> <li><code><a href=\"../statements/const\">const</a></code></li> <li><code><a href=\"../statements/let\">let</a></code></li> <li><code><a href=\"../statements/var\">var</a></code></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Missing_initializer_in_const$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Missing_initializer_in_const\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Missing_initializer_in_const</a>\n  </p>\n</div>\n","errors/missing_formal_parameter":"<h1>Errors: Missing formal parameter</h1> <h2 id=\"Message\">Message</h2> <pre class=\"syntaxbox\">SyntaxError: missing formal parameter (Firefox)\n</pre> <h2 id=\"Error_type\">Error type</h2> <p><a href=\"../global_objects/syntaxerror\"><code>SyntaxError</code></a></p> <h2 id=\"What_went_wrong\">What went wrong?</h2> <p>\"Formal parameter\" is a fancy way of saying \"function parameter\". Your function declaration is missing valid parameters. In the declaration of a function, the parameters must be <a href=\"https://developer.mozilla.org/en-US/docs/Glossary/Identifier\">identifiers</a>, not any value like numbers, strings, or objects. Declaring functions and calling functions are two separate steps. Declarations require identifier as parameters, and only when calling (invoking) the function, you provide the values the function should use.</p> <p>In <a href=\"https://developer.mozilla.org/en-US/docs/Glossary/JavaScript\">JavaScript</a>, identifiers can contain only alphanumeric characters (or \"$\" or \"_\"), and may not start with a digit. An identifier differs from a <strong>string</strong> in that a string is data, while an identifier is part of the code.</p> <h2 id=\"Examples\">Examples</h2> <p>Function parameters must be identifiers when setting up a function. All these function declarations fail, as they are providing values for their parameters:</p> <pre data-language=\"js\">function square(3) {\n  return number * number;\n};\n// SyntaxError: missing formal parameter\n\nfunction greet(\"Howdy\") {\n  return greeting;\n};\n// SyntaxError: missing formal parameter\n\nfunction log({ obj: \"value\"}) { \n  console.log(arg)\n};\n// SyntaxError: missing formal parameter\n</pre> <p>You will need to use identifiers in function declarations:</p> <pre data-language=\"js\">function square(number) {\n  return number * number;\n};\n\nfunction greet(greeting) {\n  return greeting;\n};\n\nfunction log(arg) {\n  console.log(arg)\n};</pre> <p>You can then call these functions with the arguments you like:</p> <pre data-language=\"js\">square(2); // 4\n\ngreet(\"Howdy\"); // \"Howdy\"\n\nlog({obj: \"value\"}); // Object { obj: \"value\" }\n</pre> <h2 id=\"See_also\">See also</h2> <ul> <li>Other errors regarding formal parameters: <ul> <li><a href=\"malformed_formal_parameter\">SyntaxError: Malformed formal parameter</a></li> <li><a href=\"redeclared_parameter\">SyntaxError: redeclaration of formal parameter \"x\"</a></li> </ul> </li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Missing_formal_parameter$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Missing_formal_parameter\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Missing_formal_parameter</a>\n  </p>\n</div>\n","errors/missing_bracket_after_list":"<h1>Errors: Missing bracket after list</h1> <h2 id=\"Message\">Message</h2> <pre class=\"syntaxbox\">SyntaxError: missing ] after element list\n</pre> <h2 id=\"Error_type\">Error type</h2> <p><a href=\"../global_objects/syntaxerror\"><code>SyntaxError</code></a>.</p> <h2 id=\"What_went_wrong\">What went wrong?</h2> <p>There is an error with the array initializer syntax somewhere. Likely there is a closing bracket (\"<code>]</code>\") or a comma (\"<code>,</code>\") missing.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Incomplete_array_initializer\">Incomplete array initializer</h3> <pre data-language=\"js\">var list = [1, 2,\n\nvar instruments = [\n  'Ukulele',\n  'Guitar',\n  'Piano'\n};\n\nvar data = [{foo: 'bar'} {bar: 'foo'}];\n</pre> <p>Correct would be:</p> <pre data-language=\"js\">var list = [1, 2];\n\nvar instruments = [\n 'Ukulele',\n 'Guitar',\n 'Piano'\n]; \n\nvar data = [{foo: 'bar'}, {bar: 'foo'}];</pre> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"../global_objects/array\"><code>Array</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Missing_bracket_after_list$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Missing_bracket_after_list\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Missing_bracket_after_list</a>\n  </p>\n</div>\n","errors/missing_curly_after_property_list":"<h1>Errors: Missing curly after property list</h1> <h2 id=\"Message\">Message</h2> <pre class=\"syntaxbox\">SyntaxError: Expected '}' (Edge)\nSyntaxError: missing } after property list (Firefox)\n</pre> <h2 id=\"Error_type\">Error type</h2> <p><a href=\"../global_objects/syntaxerror\"><code>SyntaxError</code></a></p> <h2 id=\"What_went_wrong\">What went wrong?</h2> <p>There is a mistake in the <a href=\"../operators/object_initializer\">object initializer</a> syntax somewhere. Might be in fact a missing curly bracket, but could also be a missing comma, for example. Also check if any closing curly brackets or parenthesis are in the correct order. Indenting or formatting the code a bit nicer might also help you to see through the jungle.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Forgotten_comma\">Forgotten comma</h3> <p>Oftentimes, there is a missing comma in your object initializer code:</p> <pre data-language=\"js\">var obj = { \n  a: 1, \n  b: { myProp: 2 }\n  c: 3\n};\n</pre> <p>Correct would be:</p> <pre data-language=\"js\">var obj = {\n  a: 1,\n  b: { myProp: 2 },\n  c: 3\n};\n</pre> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"../operators/object_initializer\">Object initializer</a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Missing_curly_after_property_list$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Missing_curly_after_property_list\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Missing_curly_after_property_list</a>\n  </p>\n</div>\n","errors/missing_semicolon_before_statement":"<h1>Errors: Missing semicolon before statement</h1> <h2 id=\"Message\">Message</h2> <pre class=\"syntaxbox\">SyntaxError: Expected ';' (Edge)\nSyntaxError: missing ; before statement (Firefox)\n</pre> <h2 id=\"Error_type\">Error type</h2> <p><a href=\"../global_objects/syntaxerror\"><code>SyntaxError</code></a>.</p> <h2 id=\"What_went_wrong\">What went wrong?</h2> <p>There is a semicolon (<code>;</code>) missing somewhere. <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements\">JavaScript statements</a> must be terminated with semicolons. Some of them are affected by <a href=\"../lexical_grammar#Automatic_semicolon_insertion\">automatic semicolon insertion (ASI)</a>, but in this case you need to provide a semicolon, so that JavaScript can parse the source code correctly.</p> <p>However, oftentimes, this error is only a consequence of another error, like not escaping strings properly, or using <code>var</code> wrongly. You might also have too many parenthesis somewhere. Carefully check the syntax when this error is thrown.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Unescaped_strings\">Unescaped strings</h3> <p>This error can occur easily when not escaping strings properly and the JavaScript engine is expecting the end of your string already. For example:</p> <pre data-language=\"js\">var foo = 'Tom's bar';\n// SyntaxError: missing ; before statement</pre> <p>You can use double quotes, or escape the apostrophe:</p> <pre data-language=\"js\">var foo = \"Tom's bar\";\nvar foo = 'Tom\\'s bar';\n</pre> <h3 id=\"Declaring_properties_with_var\">Declaring properties with var</h3> <p>You <strong>cannot</strong> declare properties of an object or array with a <code>var</code> declaration.</p> <pre data-language=\"js\">var obj = {};\nvar obj.foo = 'hi'; // SyntaxError missing ; before statement\n\nvar array = [];\nvar array[0] = 'there'; // SyntaxError missing ; before statement\n</pre> <p>Instead, omit the <code>var</code> keyword:</p> <pre data-language=\"js\">var obj = {};\nobj.foo = 'hi';\n\nvar array = [];\narray[0] = 'there';\n</pre> <h3 id=\"Bad_keywords\">Bad keywords</h3> <p>If you come from another programming language, it is also common to use keywords that don't mean the same or have no meaning at all in javaScript:</p> <pre data-language=\"js\">def print(info){\n  console.log(info);\n}; // SyntaxError missing ; before statement</pre> <p>Instead, use <code>function</code> instead of <code>def</code>:</p> <pre data-language=\"js\">function print(info){\n  console.log(info);\n};</pre> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"../lexical_grammar#Automatic_semicolon_insertion\">Automatic semicolon insertion (ASI)</a></li> <li><a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements\">JavaScript statements</a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Missing_semicolon_before_statement$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Missing_semicolon_before_statement\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Missing_semicolon_before_statement</a>\n  </p>\n</div>\n","errors/missing_name_after_dot_operator":"<h1>Errors: Missing name after dot operator</h1> <h2 id=\"Message\">Message</h2> <pre class=\"syntaxbox\">SyntaxError: missing name after . operator\n</pre> <h2 id=\"Error_type\">Error type</h2> <p><a href=\"../global_objects/syntaxerror\"><code>SyntaxError</code></a></p> <h2 id=\"What_went_wrong\">What went wrong?</h2> <p>The dot operator (<code>.</code>) is used for <a href=\"../operators/property_accessors\">property access</a>. You will have to specify the name of the property that you want to access. For computed property access, you might need to change your property access from using a dot to using square brackets. These will allow you to compute an expression. Maybe you intended to do concatenation instead? A plus operator (<code>+</code>) is needed in that case. Please see the examples below.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Property_access\">Property access</h3> <p><a href=\"../operators/property_accessors\">Property accessors</a> in JavaScript use either the dot (.) or square brackets (<code>[]</code>), but not both. Square brackets allow computed property access.</p> <pre data-language=\"js\">var obj = { foo: { bar: \"baz\", bar2: \"baz2\" } };\nvar i = 2;\n\nobj.[foo].[bar]\n// SyntaxError: missing name after . operator\n\nobj.foo.\"bar\"+i;\n// SyntaxError: missing name after . operator\n</pre> <p>To fix this code, you need to access the object like this:</p> <pre data-language=\"js\">obj.foo.bar; // \"baz\"\n// or alternatively\nobj[\"foo\"][\"bar\"]; // \"baz\"\n\n// computed properties require square brackets\nobj.foo[\"bar\" + i]; // \"baz2\"\n</pre> <h3 id=\"Property_access_vs._concatenation\">Property access vs. concatenation</h3> <p>If you are coming from another programming language (like <a href=\"https://developer.mozilla.org/en-US/docs/Glossary/PHP\">PHP</a>), it is also easy to mix up the dot operator (<code>.</code>) and the concatenation operator (<code>+</code>).</p> <pre data-language=\"js\">console.log(\"Hello\" . \"world\");\n\n// SyntaxError: missing name after . operator</pre> <p>Instead you need to use a plus sign for concatenation:</p> <pre data-language=\"js\">console.log(\"Hello\" + \"World\");</pre> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"../operators/property_accessors\">Property accessors</a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Missing_name_after_dot_operator$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Missing_name_after_dot_operator\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Missing_name_after_dot_operator</a>\n  </p>\n</div>\n","errors/no_variable_name":"<h1>Errors: No variable name</h1> <h2 id=\"Message\">Message</h2> <pre class=\"syntaxbox\">SyntaxError: missing variable name (Firefox)\nSyntaxError: Unexpected token = (Chrome)</pre> <h2 id=\"Error_type\">Error type</h2> <p><a href=\"../global_objects/syntaxerror\"><code>SyntaxError</code></a></p> <h2 id=\"What_went_wrong\">What went wrong?</h2> <p>A variable is missing a name. This is likely due to a syntax error in your code. Probably a comma is wrong somewhere or you struggled with coming up with a name. Totally understandable! Naming things is so hard.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Missing_a_variable_name\">Missing a variable name</h3> <pre data-language=\"js\">var = \"foo\";\n</pre> <p>It's tough coming up with good variable names. We all have been there.</p> <pre data-language=\"js\">var ohGodWhy = \"foo\";</pre> <h3 id=\"Reserved_keywords_can't_be_variable_names\">Reserved keywords can't be variable names</h3> <p>There are a few variable names that are <a href=\"../lexical_grammar#Keywords\">reserverd keywords</a>. You can't use these. Sorry :(</p> <pre data-language=\"js\">var debugger = \"whoop\";\n// SyntaxError: missing variable name\n</pre> <h3 id=\"Declaring_multiple_variables\">Declaring multiple variables</h3> <p>Pay special attention to commas when declaring multiple variables. Is there an excess comma? Did you accidentally add commas instead of semicolons?</p> <pre data-language=\"js\">var x, y = \"foo\",\nvar x, = \"foo\"\n\nvar first = document.getElementById('one'),\nvar second = document.getElementById('two'),\n\n// SyntaxError: missing variable name\n</pre> <p>The fixed version:</p> <pre data-language=\"js\">var x, y = \"foo\";\nvar x = \"foo\";\n\nvar first = document.getElementById('one');\nvar second = document.getElementById('two');</pre> <h3 id=\"Arrays\">Arrays</h3> <p><a href=\"../global_objects/array\"><code>Array</code></a> literals in JavaScript need square brackets around the values. This won't work:</p> <pre data-language=\"js\">var arr = 1,2,3,4,5;\n// SyntaxError: missing variable name\n</pre> <p>This would be correct:</p> <pre data-language=\"js\">var arr = [1,2,3,4,5];</pre> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"http://wiki.c2.com/?GoodVariableNames\">Good variable names</a></li> <li><code><a href=\"../statements/var\">var</a></code></li> <li><a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Grammar_and_types#Declarations\">Variable declarations in the JavaScript Guide</a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/No_variable_name$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/No_variable_name\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/No_variable_name</a>\n  </p>\n</div>\n","errors/equal_as_assign":"<h1>Errors: Equal as assign</h1> <h2 id=\"Message\">Message</h2> <pre class=\"syntaxbox\">Warning: SyntaxError: test for equality (==) mistyped as assignment (=)?\n</pre> <h2 id=\"Error_type\">Error type</h2> <p>(Firefox only) <a href=\"../global_objects/syntaxerror\"><code>SyntaxError</code></a> warning which is reported only if <code>javascript.options.strict</code> preference is set to <code>true</code>.</p> <h2 id=\"What_went_wrong\">What went wrong?</h2> <p>There was an assignment (<code>=</code>) when you would normally expect a test for equality (<code>==</code>). To help debugging, JavaScript (with strict warnings enabled) warns about this pattern.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Assignment_within_conditional_expressions\">Assignment within conditional expressions</h3> <p>It is advisable to not use simple assignments in a conditional expression (such as <code><a href=\"../statements/if...else\">if...else</a></code>), because the assignment can be confused with equality when glancing over the code. For example, do not use the following code:</p> <pre data-language=\"js\">if (x = y) {\n  // do the right thing\n}\n</pre> <p>If you need to use an assignment in a conditional expression, a common practice is to put additional parentheses around the assignment. For example:</p> <pre data-language=\"js\">if ((x = y)) {\n  // do the right thing\n}</pre> <p>Otherwise, you probably meant to use a comparison operator (e.g. <code>==</code> or <code>===</code>):</p> <pre data-language=\"js\">if (x == y) {\n  // do the right thing\n}</pre> <h2 id=\"See_also\">See also</h2> <ul> <li><code><a href=\"../statements/if...else\">if...else</a></code></li> <li><a href=\"../operators/comparison_operators\">Comparison operators</a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Equal_as_assign$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Equal_as_assign\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Equal_as_assign</a>\n  </p>\n</div>\n","errors/bad_return_or_yield":"<h1>Errors: Bad return or yield</h1> <h2 id=\"Message\">Message</h2> <pre class=\"syntaxbox\">SyntaxError: 'return' statement outside of function (Edge)\nSyntaxError: return not in function (Firefox)\nSyntaxError: yield not in function (Firefox)\n</pre> <h2 id=\"Error_type\">Error type</h2> <p><a href=\"../global_objects/syntaxerror\"><code>SyntaxError</code></a>.</p> <h2 id=\"What_went_wrong\">What went wrong?</h2> <p>A <code><a href=\"../statements/return\">return</a></code> or <code><a href=\"../operators/yield\">yield</a></code> statement is called outside of a <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Functions\">function</a>. Maybe there are missing curly brackets somewhere? The <code>return</code> and <code>yield</code> statements must be in a function, because they end (or pause and resume) function execution and specify a value to be returned to the function caller.</p> <h2 id=\"Examples\">Examples</h2> <pre data-language=\"js\">var cheer = function(score) {\n  if (score === 147)\n    return 'Maximum!';\n  };\n  if (score &gt; 100) {\n    return 'Century!';\n  }\n}\n\n// SyntaxError: return not in function</pre> <p>The curly brackets look correct at a first glance, but this code snippet is missing a <code>{</code> after the first <code>if</code> statement. Correct would be:</p> <pre data-language=\"js\">var cheer = function(score) {\n  if (score === 147) {\n    return 'Maximum!';\n  }\n  if (score &gt; 100) {\n    return 'Century!';\n  }\n};</pre> <h2 id=\"See_also\">See also</h2> <ul> <li><code><a href=\"../statements/return\">return</a></code></li> <li><code><a href=\"../operators/yield\">yield</a></code></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Bad_return_or_yield$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Bad_return_or_yield\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Bad_return_or_yield</a>\n  </p>\n</div>\n","errors/redeclared_parameter":"<h1>Errors: Redeclared parameter</h1> <h2 id=\"Message\">Message</h2> <pre class=\"syntaxbox\">SyntaxError: Let/Const redeclaration (Edge)\nSyntaxError: redeclaration of formal parameter \"x\" (Firefox)\nSyntaxError: Identifier \"x\" has already been declared (Chrome)\n</pre> <h2 id=\"Error_type\">Error type</h2> <p><a href=\"../global_objects/syntaxerror\"><code>SyntaxError</code></a></p> <h2 id=\"What_went_wrong\">What went wrong?</h2> <p>The same variable name occurs as a function parameter and is then redeclared using a <code><a href=\"../statements/let\">let</a></code> assignment in a function body again. Redeclaring the same variable within the same function or block scope using <code>let</code> is not allowed in JavaScript.</p> <h2 id=\"Examples\">Examples</h2> <p>In this case, the variable \"arg\" redeclares the argument.</p> <pre data-language=\"js\">function f(arg) { \n  let arg = 'foo'; \n}\n\n// SyntaxError: redeclaration of formal parameter \"arg\"\n</pre> <p>If you want to change the value of \"arg\" in the function body, you can do so, but you do not need to declare the same variable again. In other words: you can omit the <code>let</code> keyword. If you want to create a new variable, you need to rename it as conflicts with the function parameter already.</p> <pre data-language=\"js\">function f(arg) {\n  arg = 'foo';\n}\n\nfunction f(arg) { \n  let bar = 'foo'; \n}\n</pre> <h2 id=\"Compatibility_notes\">Compatibility notes</h2> <ul> <li>Prior to Firefox 49 (Firefox 49 / Thunderbird 49 / SeaMonkey 2.46), this was thrown as a <a href=\"../global_objects/typeerror\"><code>TypeError</code></a> (<a href=\"https://bugzilla.mozilla.org/show_bug.cgi?id=1275240\">bug 1275240</a>).</li> </ul> <h2 id=\"See_also\">See also</h2> <ul> <li><code><a href=\"../statements/let\">let</a></code></li> <li><code><a href=\"../statements/const\">const</a></code></li> <li><code><a href=\"../statements/var\">var</a></code></li> <li>\n<a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Grammar_and_Types#Declarations\">Declaring variables</a> in the <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide\">JavaScript Guide</a>\n</li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Redeclared_parameter$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Redeclared_parameter\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Redeclared_parameter</a>\n  </p>\n</div>\n","errors/unexpected_type":"<h1>Errors: Unexpected type</h1> <h2 id=\"Message\">Message</h2> <pre class=\"syntaxbox\">TypeError: Unable to get property {x} of undefined or null reference (Edge)\nTypeError: \"x\" is (not) \"y\" (Firefox)\n\nExamples:\nTypeError: \"x\" is undefined\nTypeError: \"x\" is null\nTypeError: \"undefined\" is not an object\nTypeError: \"x\" is not an object or null\nTypeError: \"x\" is not a symbol\n</pre> <h2 id=\"Error_type\">Error type</h2> <p><a href=\"../global_objects/typeerror\"><code>TypeError</code></a>.</p> <h2 id=\"What_went_wrong\">What went wrong?</h2> <p>There was an unexpected type. This occurs oftentimes with <a href=\"../global_objects/undefined\"><code>undefined</code></a> or <a href=\"../global_objects/null\"><code>null</code></a> values.</p> <p>Also, certain methods, such as <a href=\"../global_objects/object/create\"><code>Object.create()</code></a> or <a href=\"../global_objects/symbol/keyfor\"><code>Symbol.keyFor()</code></a>, require a specific type, that must be provided.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Invalid_cases\">Invalid cases</h3> <pre data-language=\"js\">// undefined and null cases on which the substring method won't work\nvar foo = undefined;\nfoo.substring(1); // TypeError: foo is undefined\n\nvar foo = null;\nfoo.substring(1); // TypeError: foo is null\n\n\n// Certain methods might require a specific type\nvar foo = {}\nSymbol.keyFor(foo); // TypeError: foo is not a symbol\n\nvar foo = 'bar'\nObject.create(foo); // TypeError: \"foo\" is not an object or null\n</pre> <h3 id=\"Fixing_the_issue\">Fixing the issue</h3> <p>To fix null pointer to <code>undefined</code> values, you can use the <a href=\"../operators/typeof\">typeof</a> operator, for example.</p> <pre data-language=\"js\">if (typeof foo !== 'undefined') {\n  // Now we know that foo is defined, we are good to go.\n}</pre> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"../global_objects/undefined\"><code>undefined</code></a></li> <li><a href=\"../global_objects/null\"><code>null</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Unexpected_type$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Unexpected_type\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Unexpected_type</a>\n  </p>\n</div>\n","errors/no_properties":"<h1>Errors: No properties</h1> <h2 id=\"Message\">Message</h2> <pre class=\"syntaxbox\">TypeError: Unable to get property {x} of undefined or null reference (Edge)\nTypeError: null has no properties (Firefox)\nTypeError: undefined has no properties (Firefox)\n</pre> <h2 id=\"Error_type\">Error type</h2> <p><a href=\"../global_objects/typeerror\"><code>TypeError</code></a>.</p> <h2 id=\"What_went_wrong\">What went wrong?</h2> <p>Both, <a href=\"../global_objects/null\"><code>null</code></a> and <a href=\"../global_objects/undefined\"><code>undefined</code></a>, have no properties you could access.</p> <h2 id=\"Examples\">Examples</h2> <pre data-language=\"js\">null.foo;\n// TypeError: null has no properties\n\nundefined.bar;\n// TypeError: undefined has no properties\n</pre> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"../global_objects/null\"><code>null</code></a></li> <li><a href=\"../global_objects/undefined\"><code>undefined</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/No_properties$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/No_properties\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/No_properties</a>\n  </p>\n</div>\n","errors/not_a_constructor":"<h1>Errors: Not a constructor</h1> <h2 id=\"Message\">Message</h2> <pre class=\"syntaxbox\">TypeError: Object doesn't support this action (Edge)\nTypeError: \"x\" is not a constructor\n\nTypeError: Math is not a constructor\nTypeError: JSON is not a constructor\nTypeError: Symbol is not a constructor\nTypeError: Reflect is not a constructor\nTypeError: Intl is not a constructor\nTypeError: SIMD is not a constructor\nTypeError: Atomics is not a constructor\n</pre> <h2 id=\"Error_type\">Error type</h2> <p><a href=\"../global_objects/typeerror\"><code>TypeError</code></a></p> <h2 id=\"What_went_wrong\">What went wrong?</h2> <p>There was an attempt to use an object or a variable as a constructor, but that object or variable is not a constructor. See <a href=\"https://developer.mozilla.org/en-US/docs/Glossary/constructor\">constructor</a> or the <a href=\"../operators/new\"><code>new</code> operator</a> for more information on what a constructor is.</p> <p>There are many global objects, like <a href=\"../global_objects/string\"><code>String</code></a> or <a href=\"../global_objects/array\"><code>Array</code></a>, which are constructable using <code>new</code>. However, some global objects are not and their properties and methods are static. The following JavaScript standard built-in objects are not a constructor: <a href=\"../global_objects/math\"><code>Math</code></a>, <a href=\"../global_objects/json\"><code>JSON</code></a>, <a href=\"../global_objects/symbol\"><code>Symbol</code></a>, <a href=\"../global_objects/reflect\"><code>Reflect</code></a>, <a href=\"../global_objects/intl\"><code>Intl</code></a>, <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/SIMD\"><code>SIMD</code></a>, <a href=\"../global_objects/atomics\"><code>Atomics</code></a>.</p> <p><a href=\"../statements/function*\">Generator functions</a> cannot be used as constructors either.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Invalid_cases\">Invalid cases</h3> <pre data-language=\"js\">var Car = 1;\nnew Car();\n// TypeError: Car is not a constructor\n\nnew Math();\n// TypeError: Math is not a constructor\n\nnew Symbol();\n// TypeError: Symbol is not a constructor\n\nfunction* f() {};\nvar obj = new f;\n// TypeError: f is not a constructor\n</pre> <h3 id=\"A_car_constructor\">A car constructor</h3> <p>Suppose you want to create an object type for cars. You want this type of object to be called <code>car</code>, and you want it to have properties for make, model, and year. To do this, you would write the following function:</p> <pre data-language=\"js\">function Car(make, model, year) {\n  this.make = make;\n  this.model = model;\n  this.year = year;\n}\n</pre> <p>Now you can create an object called <code>mycar</code> as follows:</p> <pre data-language=\"js\">var mycar = new Car('Eagle', 'Talon TSi', 1993);</pre> <h3 id=\"In_Promises\">In Promises</h3> <p>When returning an immediately-resolved or immediately-rejected Promise, you do not need to create a <em>new Promise(...)</em> and act on it.</p> <p>This is not legal (the <a href=\"https://developer.mozilla.org/en-US/docs/Mozilla/JavaScript_code_modules/Promise.jsm/Promise#Constructor\">Promise constructor</a> is not being called correctly) and will throw a <code>TypeError: this is not a constructor</code> exception:</p> <pre data-language=\"js\">return new Promise.resolve(true);\n</pre> <p>Instead, use the<a href=\"../global_objects/promise/resolve\"> Promise.resolve()</a> or <a href=\"../global_objects/promise/reject\">Promise.reject()</a> <a href=\"https://en.wikipedia.org/wiki/Method_(computer_programming)#Static_methods\">static methods</a>:</p> <pre data-language=\"js\">// This is legal, but unnecessarily long:\nreturn new Promise((resolve, reject) =&gt; { resolve(true); })\n\n// Instead, return the static method:\nreturn Promise.resolve(true);\nreturn Promise.reject(false);\n</pre> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"https://developer.mozilla.org/en-US/docs/Glossary/constructor\">constructor</a></li> <li><a href=\"../operators/new\"><code>new</code> operator</a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Not_a_constructor$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Not_a_constructor\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Not_a_constructor</a>\n  </p>\n</div>\n","errors/missing_curly_after_function_body":"<h1>Errors: Missing curly after function body</h1> <h2 id=\"Message\">Message</h2> <pre class=\"syntaxbox\">SyntaxError: Expected '}' (Edge)\nSyntaxError: missing } after function body (Firefox)\n</pre> <h2 id=\"Error_type\">Error type</h2> <p><a href=\"../global_objects/syntaxerror\"><code>SyntaxError</code></a></p> <h2 id=\"What_went_wrong\">What went wrong?</h2> <p>There is a syntax mistake when creating a function somewhere. Also check if any closing curly brackets or parenthesis are in the correct order. Indenting or formatting the code a bit nicer might also help you to see through the jungle.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Forgotten_closing_curly_bracket\">Forgotten closing curly bracket</h3> <p>Oftentimes, there is a missing curly bracket in your function code:</p> <pre data-language=\"js\">var charge = function() {\n  if (sunny) {\n    useSolarCells();\n  } else {\n    promptBikeRide();\n};\n</pre> <p>Correct would be:</p> <pre data-language=\"js\">var charge = function() {\n  if (sunny) {\n    useSolarCells();\n  } else {\n    promptBikeRide(); \n  }\n};</pre> <p>It can be more obscure when using <a href=\"https://developer.mozilla.org/en-US/docs/Glossary/IIFE\">IIFE</a>, <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Closures\">Closures</a>, or other constructs that use a lot of different parenthesis and curly brackets, for example.</p> <pre data-language=\"js\">(function() { if (true) { return false; } );\n</pre> <p>Oftentimes, indenting differently or double checking indentation helps to spot these errors.</p> <pre data-language=\"js\">(function() {\n  if (true) {\n    return false;\n  }\n});</pre> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Functions\">Functions</a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Missing_curly_after_function_body$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Missing_curly_after_function_body\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Missing_curly_after_function_body</a>\n  </p>\n</div>\n","errors/dead_object":"<h1>Errors: Dead object</h1> <h2 id=\"Message\">Message</h2> <pre class=\"syntaxbox\">TypeError: can't access dead object\n</pre> <h2 id=\"Error_type\">Error type</h2> <p><a href=\"../global_objects/typeerror\"><code>TypeError</code></a></p> <h2 id=\"What_went_wrong\">What went wrong?</h2> <p>To improve in memory usage and to prevent memory leaks, Firefox disallows add-ons to keep strong references to DOM objects after their parent document has been destroyed. A dead object, is holding a strong (keep alive) reference to a DOM element that persists even after it was destroyed in the DOM. To avoid these issues, references to DOM nodes in foreign document should instead be stored in an object which is specific to that document, and cleaned up when the document is unloaded, or stored as <a href=\"https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XPCOM/Language_Bindings/Components.utils.getWeakReference\">weak references</a>.</p> <h2 id=\"Checking_if_an_object_is_dead\">Checking if an object is dead</h2> <p><a href=\"https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XPCOM/Language_Bindings/Components.utils\">Components.utils</a> offers a <code>isDeadWrapper()</code> method, which privileged code might use.</p> <pre data-language=\"js\">if (Components.utils.isDeadWrapper(window)) {\n  // dead\n}</pre> <p>Unprivileged code has no access to Component.utils and might just be able catch the exception.</p> <pre data-language=\"js\">try {\n  String(window);\n}\ncatch (e) {\n  console.log(\"window is likely dead\");\n}</pre> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"https://blog.mozilla.org/addons/2012/09/12/what-does-cant-access-dead-object-mean/\">What does “can’t access dead object” mean?</a></li> <li><a href=\"https://developer.mozilla.org/en-US/docs/Extensions/Common_causes_of_memory_leaks_in_extensions\">Common causes of memory leaks in extensions</a></li> <li><a href=\"https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XPCOM/Language_Bindings/Components.utils\">Components.utils</a></li> <li><a href=\"https://developer.mozilla.org/en-US/docs/Mozilla/Zombie_compartments\">Zombie Compartments</a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Dead_object$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Dead_object\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Dead_object</a>\n  </p>\n</div>\n","errors/unterminated_string_literal":"<h1>Errors: Unterminated string literal</h1> <h2 id=\"Message\">Message</h2> <pre class=\"syntaxbox\">SyntaxError: Unterminated string constant (Edge)\nSyntaxError: unterminated string literal (Firefox)\n</pre> <h2 id=\"Error_type\">Error type</h2> <p><a href=\"../global_objects/syntaxerror\"><code>SyntaxError</code></a></p> <h2 id=\"What_went_wrong\">What went wrong?</h2> <p>There is an unterminated <a href=\"../global_objects/string\"><code>String</code></a> somewhere. String literals must be enclosed by single (<code>'</code>) or double (<code>\"</code>) quotes. JavaScript makes no distinction between single-quoted strings and double-quoted strings. <a href=\"../global_objects/string#Escape_notation\">Escape sequences</a> work in strings created with either single or double quotes. To fix this error, check if:</p> <ul> <li>you have opening and closing quotes (single or double) for your string literal,</li> <li>you have escaped your string literal correctly,</li> <li>your string literal isn't split across multiple lines.</li> </ul> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Multiple_lines\">Multiple lines</h3> <p>You can't split a string across multiple lines like this in JavaScript:</p> <pre data-language=\"js\">var longString = 'This is a very long string which needs \n                  to wrap across multiple lines because \n                  otherwise my code is unreadable.';\n// SyntaxError: unterminated string literal</pre> <p>Instead, use the <a href=\"../operators/arithmetic_operators#Addition\">+ operator</a>, a backslash, or <a href=\"../template_literals\">template literals</a>. The <code>+</code> operator variant looks like this:</p> <pre data-language=\"js\">var longString = 'This is a very long string which needs ' +\n                 'to wrap across multiple lines because ' +\n                 'otherwise my code is unreadable.';\n</pre> <p>Or you can use the backslash character (\"\\\") at the end of each line to indicate that the string will continue on the next line. Make sure there is no space or any other character after the backslash (except for a line break), or as an indent; otherwise it will not work. That form looks like this:</p> <pre data-language=\"js\">var longString = 'This is a very long string which needs \\\nto wrap across multiple lines because \\\notherwise my code is unreadable.';\n</pre> <p>Another possibility is to use <a href=\"../template_literals\">template literals</a>, which are supported in ECMAScript 2015 environments:</p> <pre data-language=\"js\">var longString = `This is a very long string which needs \n                  to wrap across multiple lines because\n                  otherwise my code is unreadable.`;</pre> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"../global_objects/string\"><code>String</code></a></li> <li><a href=\"../template_literals\">Template literals</a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Unterminated_string_literal$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Unterminated_string_literal\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Unterminated_string_literal</a>\n  </p>\n</div>\n","errors/cant_access_property":"<h1>Errors: Cant access property</h1> <h2 id=\"Message\">Message</h2> <pre class=\"syntaxbox\">TypeError: Unable to get property {x} of undefined or null reference (Edge)\nTypeError: can't access property {x} of {y} (Firefox)\nTypeError: {y} is undefined, can't access property {x} of it (Firefox)\nTypeError: {y} is null, can't access property {x} of it (Firefox)\n\nExamples:\nTypeError: x is undefined, can't access property \"prop\" of it\nTypeError: x is null, can't access property \"prop\" of it\nTypeError: can't access property \"prop\" of undefined\nTypeError: can't access property \"prop\" of null\n</pre> <h2 id=\"Error_type\">Error type</h2> <p><a href=\"../global_objects/typeerror\"><code>TypeError</code></a>.</p> <h2 id=\"What_went_wrong\">What went wrong?</h2> <p>The property access was operated on <a href=\"../global_objects/undefined\"><code>undefined</code></a> or <a href=\"../global_objects/null\"><code>null</code></a> value.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Invalid_cases\">Invalid cases</h3> <pre data-language=\"js\">// undefined and null cases on which the substring method won't work\nvar foo = undefined;\nfoo.substring(1); // TypeError: x is undefined, can't access property \"substring\" of it\n\nvar foo = null;\nfoo.substring(1); // TypeError: x is null, can't access property \"substring\" of it\n</pre> <h3 id=\"Fixing_the_issue\">Fixing the issue</h3> <p>To fix null pointer to <code>undefined</code> or <code>null</code> values, you can use the <a href=\"../operators/typeof\">typeof</a> operator, for example.</p> <pre data-language=\"js\">if (typeof foo !== 'undefined') {\n  // Now we know that foo is defined, we are good to go.\n}</pre> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"../global_objects/undefined\"><code>undefined</code></a></li> <li><a href=\"../global_objects/null\"><code>null</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Cant_access_property$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Cant_access_property\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Cant_access_property</a>\n  </p>\n</div>\n","errors/cant_define_property_object_not_extensible":"<h1>Errors: Cant define property object not extensible</h1> <h2 id=\"Message\">Message</h2> <pre class=\"syntaxbox\">TypeError: Cannot create property for a non-extensible object (Edge)\nTypeError: can't define property \"x\": \"obj\" is not extensible (Firefox)\nTypeError: Cannot define property: \"x\", object is not extensible. (Chrome)\n</pre> <h2 id=\"Error_type\">Error type</h2> <p><a href=\"../global_objects/typeerror\"><code>TypeError</code></a></p> <h2 id=\"What_went_wrong\">What went wrong?</h2> <p>Usually, an object is extensible and new properties can be added to it. However, in this case <a href=\"../global_objects/object/preventextensions\"><code>Object.preventExtensions()</code></a> marked an object as no longer extensible, so that it will never have properties beyond the ones it had at the time it was marked as non-extensible.</p> <h2 id=\"Examples\">Examples</h2> <p>In <a href=\"../strict_mode\">strict mode</a>, attempting to add new properties to a non-extensible object throws a <code>TypeError</code>. In sloppy mode, the addition of the \"x\" property is silently ignored.</p> <pre data-language=\"js\">'use strict';\n\nvar obj = {};\nObject.preventExtensions(obj);\n\nobj.x = 'foo';\n// TypeError: can't define property \"x\": \"obj\" is not extensible\n</pre> <p>In both, <a href=\"../strict_mode\">strict mode</a> and sloppy mode, a call to <a href=\"../global_objects/object/defineproperty\"><code>Object.defineProperty()</code></a> throws when adding a new property to a non-extensible object.</p> <pre data-language=\"js\">var obj = { }; \nObject.preventExtensions(obj); \n\nObject.defineProperty(obj, \n  'x', { value: \"foo\" }\n);\n// TypeError: can't define property \"x\": \"obj\" is not extensible\n</pre> <p>To fix this error, you will either need to remove the call to <a href=\"../global_objects/object/preventextensions\"><code>Object.preventExtensions()</code></a> entirely, or move it to a position so that the property is added earlier and only later the object is marked as non-extensible. Of course you can also remove the property that was attempted to be added, if you don't need it.</p> <pre data-language=\"js\">'use strict'; \n\nvar obj = {}; \nobj.x = 'foo'; // add property first and only then prevent extensions\n\nObject.preventExtensions(obj);</pre> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"../global_objects/object/preventextensions\"><code>Object.preventExtensions()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Cant_define_property_object_not_extensible$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Cant_define_property_object_not_extensible\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Cant_define_property_object_not_extensible</a>\n  </p>\n</div>\n","errors/more_arguments_needed":"<h1>Errors: More arguments needed</h1> <h2 id=\"Message\">Message</h2> <pre class=\"syntaxbox\">TypeError: argument is not an Object and is not null (Edge)\nTypeError: Object.create requires more than 0 arguments\nTypeError: Object.setPrototypeOf requires more than 1 argument\nTypeError: Object.defineProperties requires more than 0 arguments\n</pre> <h2 id=\"Error_type\">Error type</h2> <p><a href=\"../global_objects/typeerror\"><code>TypeError</code></a>.</p> <h2 id=\"What_went_wrong\">What went wrong?</h2> <p>There is an error with how a function is called. More arguments need to be provided.</p> <h2 id=\"Examples\">Examples</h2> <p>The <a href=\"../global_objects/object/create\"><code>Object.create()</code></a> method requires at least one argument and the <a href=\"../global_objects/object/setprototypeof\"><code>Object.setPrototypeOf()</code></a> method requires at least two arguments:</p> <pre data-language=\"js\">var obj = Object.create();\n// TypeError: Object.create requires more than 0 arguments\n\nvar obj = Object.setPrototypeOf({});\n// TypeError: Object.setPrototypeOf requires more than 1 argument\n</pre> <p>You can fix this by setting <a href=\"../global_objects/null\"><code>null</code></a> as the prototype, for example:</p> <pre data-language=\"js\">var obj = Object.create(null);\n\nvar obj = Object.setPrototypeOf({}, null);</pre> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Functions\">Functions</a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/More_arguments_needed$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/More_arguments_needed\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/More_arguments_needed</a>\n  </p>\n</div>\n","errors/not_a_function":"<h1>Errors: Not a function</h1> <h2 id=\"Message\">Message</h2> <pre class=\"syntaxbox\">TypeError: Object doesn't support property or method {x} (Edge)\nTypeError: \"x\" is not a function\n</pre> <h2 id=\"Error_type\">Error type</h2> <p><a href=\"../global_objects/typeerror\"><code>TypeError</code></a>.</p> <h2 id=\"What_went_wrong\">What went wrong?</h2> <p>It attempted to call a value from a function, but the value is not actually a function. Some code expects you to provide a function, but that didn't happen.</p> <p>Maybe there is a typo in the function name? Maybe the object you are calling the method on does not have this function? For example, JavaScript objects have no <code>map</code> function, but the JavaScript Array object does.</p> <p>There are many built-in functions in need of a (callback) function. You will have to provide a function in order to have these methods working properly:</p> <ul> <li>When working with <a href=\"../global_objects/array\"><code>Array</code></a> or <a href=\"../global_objects/typedarray\"><code>TypedArray</code></a> objects: <ul> <li>\n<a href=\"../global_objects/array/every\"><code>Array.prototype.every()</code></a>, <a href=\"../global_objects/array/some\"><code>Array.prototype.some()</code></a>, <a href=\"../global_objects/array/foreach\"><code>Array.prototype.forEach()</code></a>, <a href=\"../global_objects/array/map\"><code>Array.prototype.map()</code></a>, <a href=\"../global_objects/array/filter\"><code>Array.prototype.filter()</code></a>, <a href=\"../global_objects/array/reduce\"><code>Array.prototype.reduce()</code></a>, <a href=\"../global_objects/array/reduceright\"><code>Array.prototype.reduceRight()</code></a>, <a href=\"../global_objects/array/find\"><code>Array.prototype.find()</code></a>\n</li> </ul> </li> <li>When working with <a href=\"../global_objects/map\"><code>Map</code></a> and <a href=\"../global_objects/set\"><code>Set</code></a> objects: <ul> <li>\n<a href=\"../global_objects/map/foreach\"><code>Map.prototype.forEach()</code></a> and <a href=\"../global_objects/set/foreach\"><code>Set.prototype.forEach()</code></a>\n</li> </ul> </li> </ul> <h2 id=\"Examples\">Examples</h2> <h3 id=\"A_typo_in_the_function_name\">A typo in the function name</h3> <p>In this case, which happens way too often, there is a typo in the method name:</p> <pre data-language=\"js\">var x = document.getElementByID('foo');\n// TypeError: document.getElementByID is not a function\n</pre> <p>The correct function name is <code>getElementByI<strong>d</strong></code>:</p> <pre data-language=\"js\">var x = document.getElementById('foo');\n</pre> <h3 id=\"Function_called_on_the_wrong_object\">Function called on the wrong object</h3> <p>For certain methods, you have to provide a (callback) function and it will work on specific objects only. In this example, <a href=\"../global_objects/array/map\"><code>Array.prototype.map()</code></a> is used, which will work with <a href=\"../global_objects/array\"><code>Array</code></a> objects only.</p> <pre data-language=\"js\">var obj = {a: 13, b: 37, c: 42};\n\nobj.map(function(num) {\n  return num * 2;\n});\n\n// TypeError: obj.map is not a function</pre> <p>Use an array instead:</p> <pre data-language=\"js\">var numbers = [1, 4, 9];\n\nnumbers.map(function(num) { \n  return num * 2; \n}); \n\n// Array [2, 8, 18]\n</pre> <h3 id=\"Function_shares_a_name_with_a_pre-existing_property\">Function shares a name with a pre-existing property</h3> <p>Sometimes when making a class, you may have a property and a function with the same name. Upon calling the function, the compiler thinks that the function ceases to exist.</p> <pre data-language=\"js\">var Dog = function () {\n this.age = 11;\n this.color = \"black\";\n this.name = \"Ralph\";\n return this;\n} \n\nDog.prototype.name = function(name) {\n this.name = name;\n return this;\n}\n\n\nvar myNewDog = new Dog();\nmyNewDog.name(\"Cassidy\"); //Uncaught TypeError: myNewDog.name is not a function\n</pre> <p>Use a different property name instead:</p> <pre data-language=\"js\">var Dog = function () {\n this.age = 11;\n this.color = \"black\";\n this.dogName = \"Ralph\"; //Using this.dogName instead of .name\n return this;\n} \n\nDog.prototype.name = function(name) {\n this.dogName = name;\n return this;\n}\n\n\nvar myNewDog = new Dog();\nmyNewDog.name(\"Cassidy\"); //Dog { age: 11, color: 'black', dogName: 'Cassidy' }\n</pre> <h3 id=\"Using_brackets_for_multiplication\">Using brackets for multiplication</h3> <p>In math, you can write 2 x (3 + 5) as 2*(3 + 5) or just 2(3 + 5). Using the latter will throw an error:</p> <pre class=\"js example-bad\">var sixteen = 2(3 + 5);\nalert('2 x (3 + 5) is ' + String(sixteen));\n//Uncaught TypeError: 2 is not a function</pre> <p>You can correct the code by adding a * operator:</p> <pre class=\"js example-good\">var sixteen = 2 * (3 + 5);\nalert('2 x (3 + 5) is ' + String(sixteen));\n//2 x (3 + 5) is 16\n</pre>  <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"../functions\">Functions</a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Not_a_function$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Not_a_function\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Not_a_function</a>\n  </p>\n</div>\n","errors/no_non-null_object":"<h1>Errors: No non-null object</h1> <h2 id=\"Message\">Message</h2> <pre class=\"syntaxbox\">TypeError: Invalid descriptor for property {x} (Edge)\nTypeError: \"x\" is not a non-null object (Firefox)\nTypeError: Property description must be an object: \"x\" (Chrome)\nTypeError: Invalid value used in weak set (Chrome)\n</pre> <h2 id=\"Error_type\">Error type</h2> <p><a href=\"../global_objects/typeerror\"><code>TypeError</code></a></p> <h2 id=\"What_went_wrong\">What went wrong?</h2> <p>An object is expected somewhere and wasn't provided. <a href=\"../global_objects/null\"><code>null</code></a> is not an object and won't work. You must provide a proper object in the given situation.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Property_descriptor_expected\">Property descriptor expected</h3> <p>When methods like <a href=\"../global_objects/object/create\"><code>Object.create()</code></a> or <a href=\"../global_objects/object/defineproperty\"><code>Object.defineProperty()</code></a> and <a href=\"../global_objects/object/defineproperties\"><code>Object.defineProperties()</code></a> are used, the optional descriptor parameter expects a property descriptor object. Providing no object (like just a number), will throw an error:</p> <pre data-language=\"js\">Object.defineProperty({}, 'key', 1);\n// TypeError: 1 is not a non-null object\n\nObject.defineProperty({}, 'key', null);\n// TypeError: null is not a non-null object\n</pre> <p>A valid property descriptor object might look like this:</p> <pre data-language=\"js\">Object.defineProperty({}, 'key', { value: 'foo', writable: false });\n</pre> <h3 id=\"WeakMap_and_WeakSet_objects_require_object_keys\">\n<code>WeakMap</code> and <code>WeakSet</code> objects require object keys</h3> <p><a href=\"../global_objects/weakmap\"><code>WeakMap</code></a> and <a href=\"../global_objects/weakset\"><code>WeakSet</code></a> objects store object keys. You can't use other types as keys.</p> <pre data-language=\"js\">var ws = new WeakSet();\nws.add('foo');\n// TypeError: \"foo\" is not a non-null object</pre> <p>Use objects instead:</p> <pre data-language=\"js\">ws.add({foo: 'bar'});\nws.add(window);\n</pre> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"../global_objects/object/create\"><code>Object.create()</code></a></li> <li>\n<a href=\"../global_objects/object/defineproperty\"><code>Object.defineProperty()</code></a>, <a href=\"../global_objects/object/defineproperties\"><code>Object.defineProperties()</code></a>\n</li> <li>\n<a href=\"../global_objects/weakmap\"><code>WeakMap</code></a>, <a href=\"../global_objects/weakset\"><code>WeakSet</code></a>\n</li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/No_non-null_object$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/No_non-null_object\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/No_non-null_object</a>\n  </p>\n</div>\n","errors/is_not_iterable":"<h1>Errors: is not iterable</h1> <h2 id=\"Message\">Message</h2> <pre class=\"syntaxbox\">TypeError: 'x' is not iterable (Firefox, Chrome)\nTypeError: 'x' is not a function or its return value is not iterable (Chrome)\n</pre> <h2 id=\"Error_type\">Error type</h2> <p><a href=\"../global_objects/typeerror\"><code>TypeError</code></a></p> <h2 id=\"What_went_wrong\">What went wrong?</h2> <p>The value which is given as the right hand-side of <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Loops_and_iteration#for...of_statement\">for…of </a>or as argument of a function such as <a href=\"../global_objects/promise/all\"><code>Promise.all</code></a> or <a href=\"../global_objects/typedarray/from\"><code>TypedArray.from</code></a>, is not an <a href=\"../iteration_protocols\">iterable object</a>. An iterable can be a built-in iterable type such as <a href=\"../global_objects/array\"><code>Array</code></a>, <a href=\"../global_objects/string\"><code>String</code></a> or <a href=\"../global_objects/map\"><code>Map</code></a>, a generator result, or an object implementing the <a href=\"../iteration_protocols#The_iterable_protocol\">iterable protocol</a>.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Iterating_over_Object_properties\">Iterating over Object properties</h3> <p>In JavaScript, <a href=\"../global_objects/object\"><code>Object</code></a>s are not iterable unless they implement the <a href=\"../iteration_protocols#The_iterable_protocol\">iterable protocol</a>. Therefore, you cannot use <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Loops_and_iteration#for...of_statement\">for…of </a>to iterate over the properties of an object.</p> <pre data-language=\"js\">var obj = { 'France': 'Paris', 'England': 'London' };\nfor (let p of obj) { // TypeError: obj is not iterable\n    // …\n}\n</pre> <p>Instead you have to use <a href=\"../global_objects/object/keys\"><code>Object.keys</code></a> or <a href=\"../global_objects/object/entries\"><code>Object.entries</code></a>, to iterate over the properties or entries of an object.</p> <pre data-language=\"js\">var obj = { 'France': 'Paris', 'England': 'London' };\n// Iterate over the property names:\nfor (let country of Object.keys(obj)) {\n    var capital = obj[country];\n    console.log(country, capital);\n}\n\nfor (const [country, capital] of Object.entries(obj))\n    console.log(country, capital);\n\n\n</pre> <p>Another option for this use case might be to use a <a href=\"../global_objects/map\"><code>Map</code></a>:</p> <pre data-language=\"js\">var map = new Map;\nmap.set('France', 'Paris');\nmap.set('England', 'London');\n// Iterate over the property names:\nfor (let country of map.keys()) {\n    let capital = map[country];\n    console.log(country, capital);\n}\n\nfor (let capital of map.values())\n    console.log(capital);\n\nfor (const [country, capital] of map.entries())\n    console.log(country, capital);\n</pre> <h3 id=\"Iterating_over_a_generator\">Iterating over a generator</h3> <p><a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Iterators_and_Generators#Generators\">Generators</a> are functions you call to produce an iterable object.</p> <pre data-language=\"js\">function* generate(a, b) {\n  yield a;\n  yield b;\n}\n\nfor (let x of generate) // TypeError: generate is not iterable\n    console.log(x);\n</pre> <p>When they are not called, the <a href=\"../global_objects/function\"><code>Function</code></a> object corresponding to the generator is callable, but not iterable. Calling a generator produces an iterable object which will iterate over the values yielded during the execution of the generator.</p> <pre data-language=\"js\">function* generate(a, b) {\n    yield a;\n    yield b;\n}\n\nfor (let x of generate(1,2))\n    console.log(x);\n</pre> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"../iteration_protocols#The_iterable_protocol\">iterable protocol</a></li> <li><a href=\"../global_objects/object/keys\"><code>Object.keys</code></a></li> <li><a href=\"../global_objects/object/entries\"><code>Object.entries</code></a></li> <li><a href=\"../global_objects/map\"><code>Map</code></a></li> <li><a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Iterators_and_Generators#Generators\">generators</a></li> <li><a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Loops_and_iteration#for...of_statement\">for…of</a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/is_not_iterable$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/is_not_iterable\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/is_not_iterable</a>\n  </p>\n</div>\n","errors/non_configurable_array_element":"<h1>Errors: Non configurable array element</h1> <h2 id=\"Message\">Message</h2> <pre class=\"syntaxbox\">TypeError: can't delete non-configurable array element (Firefox)\nTypeError: Cannot delete property '2' of [object Array] (Chrome)\n</pre> <h2 id=\"Error_type\">Error type</h2> <p><a href=\"../global_objects/typeerror\"><code>TypeError</code></a></p> <h2 id=\"What_went_wrong\">What went wrong?</h2> <p>It was attempted to <a href=\"../global_objects/array/length#Shortening_an_array\">shorten the length</a> of an array, but one of the array's elements is <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Properties\">non-configurable</a>. When shortening an array, the elements beyond the new array length will be deleted, which failed in this situation.</p> <p>The <code>configurable</code> attribute controls whether the property can be deleted from the object and whether its attributes (other than <code>writable</code>) can be changed.</p> <p>Usually, properties in an object created by an <a href=\"../global_objects/array#Syntax\">array initializer</a> are configurable. However, for example, when using <a href=\"../global_objects/object/defineproperty\"><code>Object.defineProperty()</code></a>, the property isn't configurable by default.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Non-configurable_properties_created_by_Object.defineProperty\">Non-configurable properties created by <code>Object.defineProperty</code>\n</h3> <p>The <a href=\"../global_objects/object/defineproperty\"><code>Object.defineProperty()</code></a> creates non-configurable properties by default if you haven't specified them as configurable.</p> <pre data-language=\"js\">var arr = [];\nObject.defineProperty(arr, 0, {value: 0}); \nObject.defineProperty(arr, 1, {value: \"1\"});\n\narr.length = 1;\n// TypeError: can't delete non-configurable array element\n</pre> <p>You will need to set the elements as configurable, if you intend to shorten the array.</p> <pre data-language=\"js\">var arr = [];\nObject.defineProperty(arr, 0, {value: 0, configurable: true});\nObject.defineProperty(arr, 1, {value: \"1\", configurable: true});\n\narr.length = 1;\n</pre> <h3 id=\"Seal-ed_Arrays\">\n<code>Seal</code>-ed Arrays</h3> <p>The <a href=\"../global_objects/object/seal\"><code>Object.seal()</code></a> function marks all existing elements as non-configurable.</p> <pre data-language=\"js\">var arr = [1,2,3];\nObject.seal(arr);\n\narr.length = 1;\n// TypeError: can't delete non-configurable array element\n</pre> <p>You either need to remove the <a href=\"../global_objects/object/seal\"><code>Object.seal()</code></a> call, or make a copy of it. In case of a copy, shortening the copy of the array does not modify the original array length.</p> <pre data-language=\"js\">var arr = [1,2,3];\nObject.seal(arr);\n\n// Copy the initial array to shorten the copy\nvar copy = Array.from(arr);\ncopy.length = 1;\n// arr.length == 3\n</pre> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Properties\">[[Configurable]]</a></li> <li><a href=\"../global_objects/array/length\"><code>Array.length</code></a></li> <li><a href=\"../global_objects/object/defineproperty\"><code>Object.defineProperty()</code></a></li> <li><a href=\"../global_objects/object/seal\"><code>Object.seal()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Non_configurable_array_element$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Non_configurable_array_element\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Non_configurable_array_element</a>\n  </p>\n</div>\n","errors/invalid_right_hand_side_instanceof_operand":"<h1>Errors: invalid right hand side instanceof operand</h1> <h2 id=\"Message\">Message</h2> <pre class=\"syntaxbox\">TypeError: invalid 'instanceof' operand \"x\" (Firefox) \nTypeError: \"x\" is not a function (Firefox) \nTypeError: Right-hand side of 'instanceof' is not an object (Chrome) \nTypeError: Right-hand side of 'instanceof' is not callable (Chrome)</pre> <h2 id=\"Error_type\">Error type</h2> <p><a href=\"../global_objects/typeerror\"><code>TypeError</code></a></p> <h2 id=\"What_went_wrong\">What went wrong?</h2> <p>The <a href=\"../operators/instanceof\"><code>instanceof</code> operator</a> expects the right hand side operands to be a constructor object, i.e. an object which has a <code>prototype</code> property and is callable.</p> <h2 id=\"Examples\">Examples</h2> <pre data-language=\"js\">\"test\" instanceof \"\"; // TypeError: invalid 'instanceof' operand \"\"\n42 instanceof 0;      // TypeError: invalid 'instanceof' operand 0\n\nfunction Foo() {}\nvar f = Foo();        // Foo() is called and returns undefined\nvar x = new Foo();\n\nx instanceof f;       // TypeError: invalid 'instanceof' operand f\nx instanceof x;       // TypeError: x is not a function\n</pre> <p>To fix these errors, you will either need to replace the <a href=\"../operators/instanceof\"><code>instanceof</code> operator</a> with the <a href=\"../operators/typeof\"><code>typeof</code> operator</a>, or to make sure you use the function name, instead of the result of its evaluation.</p> <pre data-language=\"js\">typeof \"test\" == \"string\"; // true\ntypeof 42 == \"number\"      // true\n\nfunction Foo() {}\nvar f = Foo;               // Do not call Foo.\nvar x = new Foo();\n\nx instanceof f;            // true\nx instanceof Foo;          // true\n</pre> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"../operators/instanceof\"><code>instanceof</code> operator</a></li> <li><a href=\"../operators/typeof\"><code>typeof</code> operator</a></li> </ul> <div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/invalid_right_hand_side_instanceof_operand$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/invalid_right_hand_side_instanceof_operand\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/invalid_right_hand_side_instanceof_operand</a>\n  </p>\n</div>\n","errors/cyclic_object_value":"<h1>Errors: Cyclic object value</h1> <h2 id=\"Message\">Message</h2> <pre class=\"syntaxbox\">TypeError: cyclic object value (Firefox)\nTypeError: Converting circular structure to JSON (Chrome and Opera)\nTypeError: Circular reference in value argument not supported (Edge)\n</pre> <h2 id=\"Error_type\">Error type</h2> <p><a href=\"../global_objects/typeerror\"><code>TypeError</code></a></p> <h2 id=\"What_went_wrong\">What went wrong?</h2> <p>The <a href=\"https://www.json.org/\">JSON format</a> per se doesn't support object references (although an <a href=\"http://tools.ietf.org/html/draft-pbryan-zyp-json-ref-03\">IETF draft exists</a>), hence <a href=\"../global_objects/json/stringify\"><code>JSON.stringify()</code></a> doesn't try to solve them and fail accordingly.</p> <h2 id=\"Examples\">Examples</h2> <p>In a circular structure like the following</p> <pre data-language=\"js\">var circularReference = {otherData: 123};\ncircularReference.myself = circularReference;\n</pre> <p><a href=\"../global_objects/json/stringify\"><code>JSON.stringify()</code></a> will fail</p> <pre data-language=\"js\">JSON.stringify(circularReference);\n// TypeError: cyclic object value\n</pre> <p>To serialize circular references you can use a library that supports them (e.g. <a href=\"https://github.com/douglascrockford/JSON-js/blob/master/cycle.js\">cycle.js</a>) or implement a solution by yourself, which will require finding and replacing (or removing) the cyclic references by serializable values.</p> <p>The snippet below illustrates how to find and filter (thus causing data loss) a cyclic reference by using the <code>replacer</code> parameter of <a href=\"../global_objects/json/stringify\"><code>JSON.stringify()</code></a>:</p> <pre data-language=\"js\">const getCircularReplacer = () =&gt; {\n  const seen = new WeakSet();\n  return (key, value) =&gt; {\n    if (typeof value === \"object\" &amp;&amp; value !== null) {\n      if (seen.has(value)) {\n        return;\n      }\n      seen.add(value);\n    }\n    return value;\n  };\n};\n\nJSON.stringify(circularReference, getCircularReplacer());\n// {\"otherData\":123}\n</pre> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"../global_objects/json/stringify\"><code>JSON.stringify</code></a></li> <li>\n<a href=\"https://github.com/douglascrockford/JSON-js/blob/master/cycle.js\">cycle.js</a> – Introduces two functions, <code>JSON.decycle</code> and <code>JSON.retrocycle</code>, which makes it possible to encode and decode cyclical structures and dags into an extended and retrocompatible JSON format.</li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Cyclic_object_value$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Cyclic_object_value\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Cyclic_object_value</a>\n  </p>\n</div>\n","errors/reduce_of_empty_array_with_no_initial_value":"<h1>Errors: Reduce of empty array with no initial value</h1> <h2 id=\"Message\">Message</h2> <pre class=\"syntaxbox\">TypeError: reduce of empty array with no initial value\n</pre> <h2 id=\"Error_type\">Error type</h2> <p><a href=\"../global_objects/typeerror\"><code>TypeError</code></a></p> <h2 id=\"What_went_wrong\">What went wrong?</h2> <p>In JavaScript, there are several reduce functions:</p> <ul> <li>\n<a href=\"../global_objects/array/reduce\"><code>Array.prototype.reduce()</code></a>, <a href=\"../global_objects/array/reduceright\"><code>Array.prototype.reduceRight()</code></a> and</li> <li>\n<a href=\"../global_objects/typedarray/reduce\"><code>TypedArray.prototype.reduce()</code></a>, <a href=\"../global_objects/typedarray/reduceright\"><code>TypedArray.prototype.reduceRight()</code></a>).</li> </ul> <p>These functions optionally take an <code>initialValue</code> (which will be used as the first argument to the first call of the <code>callback</code>). However, if no initial value is provided, it will use the first element of the <a href=\"../global_objects/array\"><code>Array</code></a> or <a href=\"../global_objects/typedarray\"><code>TypedArray</code></a> as the initial value. This error is raised when an empty array is provided because no initial value can be returned in that case.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Invalid_cases\">Invalid cases</h3> <p>This problem appears frequently when combined with a filter (<a href=\"../global_objects/array/filter\"><code>Array.prototype.filter()</code></a>, <a href=\"../global_objects/typedarray/filter\"><code>TypedArray.prototype.filter()</code></a>) which will remove all elements of the list. Thus leaving none to be used as the initial value.</p> <pre data-language=\"js\">var ints = [0, -1, -2, -3, -4, -5];\nints.filter(x =&gt; x &gt; 0)         // removes all elements\n    .reduce((x, y) =&gt; x + y)    // no more elements to use for the initial value.</pre> <p>Similarly, the same issue can happen if there is a typo in a selector, or an unexpected number of elements in a list:</p> <pre data-language=\"js\">var names = document.getElementsByClassName(\"names\");\nvar name_list = Array.prototype.reduce.call(names, (acc, name) =&gt; acc + \", \" + name);\n</pre> <h3 id=\"Valid_cases\">Valid cases</h3> <p>These problems can be solved in two different ways.</p> <p>One way is to actually provide an <code>initialValue</code> as the neutral element of the operator, such as 0 for the addition, 1 for a multiplication, or an empty string for a concatenation.</p> <pre data-language=\"js\">var ints = [0, -1, -2, -3, -4, -5];\nints.filter(x =&gt; x &lt; 0)         // removes all elements\n    .reduce((x, y) =&gt; x + y, 0) // the initial value is the neutral element of the addition\n</pre> <p>Another way would be two to handle the empty case, either before calling <code>reduce</code>, or in the callback after adding an unexpected dummy initial value.</p> <pre data-language=\"js\">var names = document.getElementsByClassName(\"names\");\n\nvar name_list1 = \"\";\nif (names1.length &gt;= 1)\n  name_list1 = Array.prototype.reduce.call(names, (acc, name) =&gt; acc + \", \" + name);\n// name_list1 == \"\" when names is empty.\n\nvar name_list2 = Array.prototype.reduce.call(names, (acc, name) =&gt; {\n  if (acc == \"\") // initial value\n    return name;\n  return acc + \", \" + name;\n}, \"\");\n// name_list2 == \"\" when names is empty.\n</pre> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"../global_objects/array/reduce\"><code>Array.prototype.reduce()</code></a></li> <li><a href=\"../global_objects/array/reduceright\"><code>Array.prototype.reduceRight()</code></a></li> <li><a href=\"../global_objects/typedarray/reduce\"><code>TypedArray.prototype.reduce()</code></a></li> <li><a href=\"../global_objects/typedarray/reduceright\"><code>TypedArray.prototype.reduceRight()</code></a></li> <li><a href=\"../global_objects/array\"><code>Array</code></a></li> <li><a href=\"../global_objects/typedarray\"><code>TypedArray</code></a></li> <li><a href=\"../global_objects/array/filter\"><code>Array.prototype.filter()</code></a></li> <li><a href=\"../global_objects/typedarray/filter\"><code>TypedArray.prototype.filter()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Reduce_of_empty_array_with_no_initial_value$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Reduce_of_empty_array_with_no_initial_value\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Reduce_of_empty_array_with_no_initial_value</a>\n  </p>\n</div>\n","errors/read-only":"<h1>Errors: Read-only</h1> <h2 id=\"Message\">Message</h2> <pre class=\"syntaxbox\">TypeError: Assignment to read-only properties is not allowed in strict mode (Edge)\nTypeError: \"x\" is read-only (Firefox)\nTypeError: 0 is read-only (Firefox)\nTypeError: Cannot assign to read only property 'x' of #&lt;Object&gt; (Chrome)\nTypeError: Cannot assign to read only property '0' of [object Array] (Chrome)\n</pre> <h2 id=\"Error_type\">Error type</h2> <p><a href=\"../global_objects/typeerror\"><code>TypeError</code></a></p> <h2 id=\"What_went_wrong\">What went wrong?</h2> <p>The global variable or object property that was assigned to is a read-only property. (Technically, it is a <a href=\"../global_objects/object/defineproperty#Writable_attribute\">non-writable data property</a>.)</p> <p>This error happens only in <a href=\"../strict_mode\">strict mode code</a>. In non-strict code, the assignment is silently ignored.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Invalid_cases\">Invalid cases</h3> <p>Read-only properties are not super common, but they can be created using <a href=\"../global_objects/object/defineproperty\"><code>Object.defineProperty()</code></a> or <a href=\"../global_objects/object/freeze\"><code>Object.freeze()</code></a>.</p> <pre data-language=\"js\">'use strict';\nvar obj = Object.freeze({name: 'Elsa', score: 157});\nobj.score = 0;  // TypeError\n\n'use strict';\nObject.defineProperty(this, 'LUNG_COUNT', {value: 2, writable: false});\nLUNG_COUNT = 3;  // TypeError\n\n'use strict';\nvar frozenArray = Object.freeze([0, 1, 2]);\nfrozenArray[0]++;  // TypeError\n</pre> <p>There are also a few read-only properties built into JavaScript. Maybe you tried to redefine a mathematical constant.</p> <pre data-language=\"js\">'use strict';\nMath.PI = 4;  // TypeError\n</pre> <p>Sorry, you can't do that.</p> <p>The global variable <code>undefined</code> is also read-only, so you can't silence the infamous \"undefined is not a function\" error by doing this:</p> <pre data-language=\"js\">'use strict';\nundefined = function() {};  // TypeError: \"undefined\" is read-only\n</pre> <h3 id=\"Valid_cases\">Valid cases</h3> <pre data-language=\"js\">'use strict';\nvar obj = Object.freeze({name: 'Score', points: 157});\nobj = {name: obj.name, points: 0};   // replacing it with a new object works\n\n'use strict';\nvar LUNG_COUNT = 2;  // a `var` works, because it's not read-only\nLUNG_COUNT = 3;  // ok (anatomically unlikely, though)\n</pre> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"../global_objects/object/defineproperty\"><code>Object.defineProperty()</code></a></li> <li><a href=\"../global_objects/object/freeze\"><code>Object.freeze()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Read-only$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Read-only\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Read-only</a>\n  </p>\n</div>\n","errors/typed_array_invalid_arguments":"<h1>Errors: Typed array invalid arguments</h1> <h2 id=\"Message\">Message</h2> <pre class=\"syntaxbox\">TypeError: invalid arguments (Firefox)</pre> <h2 id=\"Error_type\">Error type</h2> <p><a href=\"../global_objects/typeerror\"><code>TypeError</code></a></p> <h2 id=\"What_went_wrong\">What went wrong?</h2> <p><a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Typed_arrays\">Typed array</a> constructors require either</p> <ul> <li>a length,</li> <li>another typed array,</li> <li>array-like objects,</li> <li>iterable objects or</li> <li>an <a href=\"../global_objects/arraybuffer\"><code>ArrayBuffer</code></a> object</li> </ul> <p>to create a new typed array. Other constructor arguments will not create a valid typed array.</p> <h2 id=\"Examples\">Examples</h2> <p>Typed arrays, for example a <a href=\"../global_objects/uint8array\"><code>Uint8Array</code></a>, can't be constructed from a string. In fact, strings can't be in typed arrays at all.</p> <pre data-language=\"js\">var ta = new Uint8Array(\"nope\");\n// TypeError: invalid arguments\n</pre> <p>Different ways to create a valid <a href=\"../global_objects/uint8array\"><code>Uint8Array</code></a>:</p> <pre data-language=\"js\">// From a length\nvar uint8 = new Uint8Array(2);\nuint8[0] = 42;\nconsole.log(uint8[0]); // 42\nconsole.log(uint8.length); // 2\nconsole.log(uint8.BYTES_PER_ELEMENT); // 1\n\n// From an array\nvar arr = new Uint8Array([21,31]);\nconsole.log(arr[1]); // 31\n\n// From another TypedArray\nvar x = new Uint8Array([21, 31]);\nvar y = new Uint8Array(x);\nconsole.log(y[0]); // 21\n\n// From an ArrayBuffer\nvar buffer = new ArrayBuffer(8);\nvar z = new Uint8Array(buffer, 1, 4);\n\n// From an iterable \nvar iterable = function*(){ yield* [1,2,3]; }(); \nvar uint8 = new Uint8Array(iterable); \n// Uint8Array[1, 2, 3]\n</pre> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Typed_arrays\">Typed arrays</a></li> <li><a href=\"../global_objects/arraybuffer\"><code>ArrayBuffer</code></a></li> <li><a href=\"../global_objects/uint8array\"><code>Uint8Array</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Typed_array_invalid_arguments$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Typed_array_invalid_arguments\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Typed_array_invalid_arguments</a>\n  </p>\n</div>\n","errors/in_operator_no_object":"<h1>Errors: in operator no object</h1> <h2 id=\"Message\">Message</h2> <pre class=\"syntaxbox\">TypeError: Invalid operand to 'in' (Edge)\nTypeError: right-hand side of 'in' should be an object, got 'x' (Firefox)\nTypeError: cannot use 'in' operator to search for 'x' in 'y' (Firefox, Chrome)\n</pre> <h2 id=\"Error_type\">Error type</h2> <p><a href=\"../global_objects/typeerror\"><code>TypeError</code></a></p> <h2 id=\"What_went_wrong\">What went wrong?</h2> <p>The <a href=\"../operators/in\"><code>in</code> operator</a> can only be used to check if a property is in an object. You can't search in strings, or in numbers, or other primitive types.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Searching_in_strings\">Searching in strings</h3> <p>Unlike in other programming languages (e.g. Python), you can't search in strings using the <a href=\"../operators/in\"><code>in</code> operator</a>.</p> <pre data-language=\"js\">\"Hello\" in \"Hello World\"; \n// TypeError: cannot use 'in' operator to search for 'Hello' in 'Hello World'</pre> <p>Instead you will need to use <a href=\"../global_objects/string/indexof\"><code>String.prototype.indexOf()</code></a>, for example.</p> <pre data-language=\"js\">\"Hello World\".indexOf(\"Hello\") !== -1; \n// true</pre> <h3 id=\"The_operand_can't_be_null_or_undefined\">The operand can't be <code>null</code> or <code>undefined</code>\n</h3> <p>Make sure the object you are inspecting isn't actually <a href=\"../global_objects/null\"><code>null</code></a> or <a href=\"../global_objects/undefined\"><code>undefined</code></a>.</p> <pre data-language=\"js\">var foo = null;\n\"bar\" in foo;\n// TypeError: cannot use 'in' operator to search for 'bar' in 'foo' (Chrome)\n// TypeError: right-hand side of 'in' should be an object, got null (Firefox)\n</pre> <p>The <code>in</code> operator always expects an object.</p> <pre data-language=\"js\">var foo = { baz: \"bar\" };\n\"bar\" in foo; // false\n\n\"PI\" in Math; // true\n\"pi\" in Math; // false\n</pre> <h3 id=\"Searching_in_arrays\">Searching in arrays</h3> <p>Be careful when using the <code>in</code> operator to search in <a href=\"../global_objects/array\"><code>Array</code></a> objects. The <code>in</code> operator checks the index number, not the value at that index.</p> <pre data-language=\"js\">var trees = ['redwood', 'bay', 'cedar', 'oak', 'maple'];\n3 in trees; // true\n\"oak\" in trees; // false</pre> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"../operators/in\"><code>in</code> operator</a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/in_operator_no_object$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/in_operator_no_object\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/in_operator_no_object</a>\n  </p>\n</div>\n","errors/array_sort_argument":"<h1>Errors: Array sort argument</h1> <h2 id=\"Message\">Message</h2> <pre class=\"syntaxbox\">TypeError: argument is not a function object (Edge)\nTypeError: invalid Array.prototype.sort argument (Firefox)\n</pre> <h2 id=\"Error_type\">Error type</h2> <p><a href=\"../global_objects/typeerror\"><code>TypeError</code></a></p> <h2 id=\"What_went_wrong\">What went wrong?</h2> <p>The argument of <a href=\"../global_objects/array/sort\"><code>Array.prototype.sort()</code></a> is expected to be either <a href=\"../global_objects/undefined\"><code>undefined</code></a> or a function which compares its operands.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Invalid_cases\">Invalid cases</h3> <pre data-language=\"js\">[1, 3, 2].sort(5);  // TypeError\n\nvar cmp = { asc: (x, y) =&gt; x &gt;= y, dsc: (x, y) =&gt; x &lt;= y };\n[1, 3, 2].sort(cmp[this.key] || 'asc');  // TypeError\n</pre> <h3 id=\"Valid_cases\">Valid cases</h3> <pre data-language=\"js\">[1, 3, 2].sort();   // [1, 2, 3]\n\n\nvar cmp = { asc: (x, y) =&gt; x &gt;= y, dsc: (x, y) =&gt; x &lt;= y };\n[1, 3, 2].sort(cmp[this.key || 'asc']); // [1, 2, 3]</pre> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"../global_objects/array/sort\"><code>Array.prototype.sort()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Array_sort_argument$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Array_sort_argument\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Array_sort_argument</a>\n  </p>\n</div>\n","errors/cant_delete":"<h1>Errors: Cant delete</h1> <h2 id=\"Message\">Message</h2> <pre class=\"syntaxbox\">TypeError: Calling delete on 'x' is not allowed in strict mode (Edge)\nTypeError: property \"x\" is non-configurable and can't be deleted. (Firefox)\nTypeError: Cannot delete property 'x' of #&lt;Object&gt; (Chrome)\n</pre> <h2 id=\"Error_type\">Error type</h2> <p><a href=\"../global_objects/typeerror\"><code>TypeError</code></a> in strict mode only.</p> <h2 id=\"What_went_wrong\">What went wrong?</h2> <p>It was attempted to delete a property, but that property is <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Properties\">non-configurable</a>. The <code>configurable</code> attribute controls whether the property can be deleted from the object and whether its attributes (other than <code>writable</code>) can be changed.</p> <p>This error happens only in <a href=\"../strict_mode\">strict mode code</a>. In non-strict code, the operation returns <code>false</code>.</p> <h2 id=\"Examples\">Examples</h2> <p>Non-configurable properties are not super common, but they can be created using <a href=\"../global_objects/object/defineproperty\"><code>Object.defineProperty()</code></a> or <a href=\"../global_objects/object/freeze\"><code>Object.freeze()</code></a>.</p> <pre data-language=\"js\">'use strict';\nvar obj = Object.freeze({name: 'Elsa', score: 157});\ndelete obj.score;  // TypeError\n\n'use strict';\nvar obj = {};\nObject.defineProperty(obj, 'foo', {value: 2, configurable: false});\ndelete obj.foo;  // TypeError\n\n'use strict';\nvar frozenArray = Object.freeze([0, 1, 2]);\nfrozenArray.pop();  // TypeError\n</pre> <p>There are also a few non-configurable properties built into JavaScript. Maybe you tried to delete a mathematical constant.</p> <pre data-language=\"js\">'use strict';\ndelete Math.PI;  // TypeError</pre> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"../operators/delete\">delete operator</a></li> <li><a href=\"../global_objects/object/defineproperty\"><code>Object.defineProperty()</code></a></li> <li><a href=\"../global_objects/object/freeze\"><code>Object.freeze()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Cant_delete$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Cant_delete\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Cant_delete</a>\n  </p>\n</div>\n","errors/var_hides_argument":"<h1>Errors: Var hides argument</h1> <h2 id=\"Message\">Message</h2> <pre class=\"syntaxbox\">TypeError: variable \"x\" redeclares argument (Firefox)\n</pre> <h2 id=\"Error_type\">Error type</h2> <p><a href=\"../global_objects/typeerror\"><code>TypeError</code></a> warning in <a href=\"../strict_mode\">strict mode</a> only.</p> <h2 id=\"What_went_wrong\">What went wrong?</h2> <p>The same variable name occurs as a function parameter and is then redeclared using a <code><a href=\"../statements/var\">var</a></code> assignment in a function body again. This might be a naming conflict and thus JavaScript warns about it.</p> <p>This error occurs as a warning in <a href=\"../strict_mode\">strict mode code</a> only. In non-strict code, the redeclaration is silently ignored.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Invalid_cases\">Invalid cases</h3> <p>In this case, the variable \"arg\" redeclares the argument.</p> <pre data-language=\"js\">'use strict';\n\nfunction f(arg) { \n  var arg = 'foo'; \n}\n</pre> <h3 id=\"Valid_cases\">Valid cases</h3> <p>To fix this warning, the <code><a href=\"../statements/var\">var</a></code> statement can just be omitted, because the variable exists already. In other cases, you might to rename either the function parameter or the variable name.</p> <pre data-language=\"js\">'use strict';\n\nfunction f(arg) {\n  arg = 'foo';\n}\n</pre> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"../strict_mode\">Strict mode</a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Var_hides_argument$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Var_hides_argument\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Var_hides_argument</a>\n  </p>\n</div>\n","errors/invalid_const_assignment":"<h1>Errors: Invalid const assignment</h1> <h2 id=\"Message\">Message</h2> <pre class=\"syntaxbox\">TypeError: invalid assignment to const \"x\" (Firefox)\nTypeError: Assignment to constant variable. (Chrome)\nTypeError: Assignment to const (Edge)\nTypeError: Redeclaration of const 'x' (IE)\n</pre> <h2 id=\"Error_type\">Error type</h2> <p><a href=\"../global_objects/typeerror\"><code>TypeError</code></a></p> <h2 id=\"What_went_wrong\">What went wrong?</h2> <p>A constant is a value that cannot be altered by the program during normal execution. It cannot change through re-assignment, and it can't be redeclared. In JavaScript, constants are declared using the <code><a href=\"../statements/const\">const</a></code> keyword.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Invalid_redeclaration\">Invalid redeclaration</h3> <p>Assigning a value to the same constant name in the same block-scope will throw.</p> <pre data-language=\"js\">const COLUMNS = 80;\n\n// ...\n\nCOLUMNS = 120; // TypeError: invalid assignment to const `COLUMNS'</pre> <h3 id=\"Fixing_the_error\">Fixing the error</h3> <p>There are multiple options to fix this error. Check what was intended to be achieved with the constant in question.</p> <h4 id=\"Rename\">Rename</h4> <p>If you meant to declare another constant, pick another name and re-name. This constant name is already taken in this scope.</p> <pre data-language=\"js\">const COLUMNS = 80;\nconst WIDE_COLUMNS = 120;</pre> <h4 id=\"const_let_or_var\">\n<code>const</code>, <code>let</code> or <code>var</code>?</h4> <p>Do not use const if you weren't meaning to declare a constant. Maybe you meant to declare a block-scoped variable with <code><a href=\"../statements/let\">let</a></code> or global variable with <code><a href=\"../statements/var\">var</a></code>.</p> <pre data-language=\"js\">let columns = 80;\n\n// ...\n\nlet columns = 120;\n</pre> <h4 id=\"Scoping\">Scoping</h4> <p>Check if you are in the correct scope. Should this constant appear in this scope or was it meant to appear in a function, for example?</p> <pre data-language=\"js\">const COLUMNS = 80;\n\nfunction setupBigScreenEnvironment() {\n  const COLUMNS = 120;\n}</pre> <h3 id=\"const_and_immutability\">\n<code>const</code> and immutability</h3> <p>The <code>const</code> declaration creates a read-only reference to a value. It does <strong>not</strong> mean the value it holds is immutable, just that the variable identifier cannot be reassigned. For instance, in case the content is an object, this means the object itself can still be altered. This means that you can't mutate the value stored in a variable:</p> <pre data-language=\"js\">const obj = {foo: 'bar'};\nobj = {foo: 'baz'}; // TypeError: invalid assignment to const `obj'\n</pre> <p>But you can mutate the properties in a variable:</p> <pre data-language=\"js\">obj.foo = 'baz';\nobj; // Object { foo: \"baz\" }</pre> <h2 id=\"See_also\">See also</h2> <ul> <li><code><a href=\"../statements/const\">const</a></code></li> <li><code><a href=\"../statements/let\">let</a></code></li> <li><code><a href=\"../statements/var\">var</a></code></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Invalid_const_assignment$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Invalid_const_assignment\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Invalid_const_assignment</a>\n  </p>\n</div>\n","global_objects/webassembly/instance":"<h1>WebAssembly.instance</h1> <p>A <code>WebAssembly.Instance</code> object is a stateful, executable instance of a <a href=\"module\">WebAssembly.Module</a>. <code>Instance</code> objects contain all the <a href=\"https://developer.mozilla.org/en-US/docs/WebAssembly/Exported_functions\">Exported WebAssembly functions</a> that allow calling into WebAssembly code from JavaScript.</p> <p>The <code>WebAssembly.Instance()</code> constructor function can be called to synchronously instantiate a given <a href=\"module\"><code>WebAssembly.Module</code></a> object. However, the primary way to get an <code>Instance</code> is through the asynchronous <a href=\"instantiatestreaming\"><code>WebAssembly.instantiateStreaming()</code></a> function.</p> <h2 id=\"Constructor_Syntax\">Constructor Syntax</h2> <div class=\"warning\"> <p><strong>Important</strong>: Since instantiation for large modules can be expensive, developers should only use the <code>Instance()</code> constructor when synchronous instantiation is absolutely required; the asynchronous <a href=\"instantiatestreaming\"><code>WebAssembly.instantiateStreaming()</code></a> method should be used at all other times.</p> </div> <pre class=\"syntaxbox\">var myInstance = new WebAssembly.Instance(<em>module</em>, <em>importObject</em>);</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><em>module</em></dt> <dd>The <a href=\"module\"><code>WebAssembly.Module</code></a> object to be instantiated.</dd> <dt>\n<em>importObject</em> <span class=\"inlineIndicator optional optionalInline\">Optional</span>\n</dt> <dd>An object containing the values to be imported into the newly-created <code>Instance</code>, such as functions or <a href=\"memory\"><code>WebAssembly.Memory</code></a> objects. There must be one matching property for each declared import of <code>module</code> or else a <a href=\"linkerror\">WebAssembly.LinkError</a> is thrown.</dd> </dl> <h2 id=\"Instance_instances\">\n<code>Instance</code> instances</h2> <p>All <code>Instance</code> instances inherit from the <code>Instance()</code> constructor's <a href=\"instance/prototype\">prototype object</a> — this can be modified to affect all <code>Instance</code> instances.</p> <h3 id=\"Instance_properties\">Instance properties</h3> <dl> <dt><code>Instance.prototype.constructor</code></dt> <dd>Returns the function that created this object's instance. By default this is the <a href=\"instance\"><code>WebAssembly.Instance()</code></a> constructor.</dd> <dt>\n<code><a href=\"instance/exports\">Instance.prototype.exports</a></code> <span class=\"inlineIndicator readOnly readOnlyInline\">Read only </span>\n</dt> <dd>Returns an object containing as its members all the functions exported from the WebAssembly module instance, to allow them to be accessed and used by JavaScript.</dd> </dl> <h3 id=\"Instance_methods\">Instance methods</h3> <p>None.</p> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <thead> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> </thead> <tbody> <tr> <td><a href=\"https://webassembly.github.io/spec/js-api/#webassemblyinstance-objects\" hreflang=\"en\">WebAssembly JavaScript Interface<br><small>The definition of 'Instance' in that specification.</small></a></td> <td><span class=\"spec-WD\">Working Draft</span></td> <td>Initial draft definition.</td> </tr> </tbody> </table></div> <h2 name=\"Browser_compatibility\" id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>   <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 57</td>\n<td class=\"bc-supports-yes\"> 16</td>\n<td class=\"bc-supports-yes bc-has-history\"> 52\n<section class=\"bc-history\" id=\"sect1\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 52\n</dt>\n<dd> Disabled in the Firefox 52 Extended Support Release (ESR).</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 44</td>\n<td class=\"bc-supports-yes\"> 11</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Instance/exports\"><code>exports</code></a></th>\n<td class=\"bc-supports-yes\"> 57</td>\n<td class=\"bc-supports-yes\"> 16</td>\n<td class=\"bc-supports-yes bc-has-history\"> 52\n<section class=\"bc-history\" id=\"sect4\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 52\n</dt>\n<dd> Disabled in the Firefox 52 Extended Support Release (ESR).</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 44</td>\n<td class=\"bc-supports-yes\"> 11</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Instance/prototype\"><code>prototype</code></a></th>\n<td class=\"bc-supports-yes\"> 57</td>\n<td class=\"bc-supports-yes\"> 16</td>\n<td class=\"bc-supports-yes bc-has-history\"> 52\n<section class=\"bc-history\" id=\"sect7\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 52\n</dt>\n<dd> Disabled in the Firefox 52 Extended Support Release (ESR).</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 44</td>\n<td class=\"bc-supports-yes\"> 11</td>\n</tr>\n</tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 57</td>\n<td class=\"bc-supports-yes\"> 57</td>\n<td class=\"bc-supports-yes bc-has-history\"> Yes<div class=\"bc-icons\">Disabled </div>\n<section class=\"bc-history\" id=\"sect2\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> Yes<div class=\"bc-icons\">Disabled </div>\n</dt>\n<dd>Disabled This feature is behind the <code>Experimental JavaScript Features</code> preference.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-yes bc-has-history\"> 52\n<section class=\"bc-history\" id=\"sect3\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 52\n</dt>\n<dd> Disabled in the Firefox 52 Extended Support Release (ESR).</dd>\n</dl></section>\n</td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 11</td>\n<td class=\"bc-supports-yes\"> 7.0</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Instance/exports\"><code>exports</code></a></th>\n<td class=\"bc-supports-yes\"> 57</td>\n<td class=\"bc-supports-yes\"> 57</td>\n<td class=\"bc-supports-yes bc-has-history\"> Yes<div class=\"bc-icons\">Disabled </div>\n<section class=\"bc-history\" id=\"sect5\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> Yes<div class=\"bc-icons\">Disabled </div>\n</dt>\n<dd>Disabled This feature is behind the <code>Experimental JavaScript Features</code> preference.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-yes bc-has-history\"> 52\n<section class=\"bc-history\" id=\"sect6\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 52\n</dt>\n<dd> Disabled in the Firefox 52 Extended Support Release (ESR).</dd>\n</dl></section>\n</td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 11</td>\n<td class=\"bc-supports-yes\"> 7.0</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Instance/prototype\"><code>prototype</code></a></th>\n<td class=\"bc-supports-yes\"> 57</td>\n<td class=\"bc-supports-yes\"> 57</td>\n<td class=\"bc-supports-yes bc-has-history\"> Yes<div class=\"bc-icons\">Disabled </div>\n<section class=\"bc-history\" id=\"sect8\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> Yes<div class=\"bc-icons\">Disabled </div>\n</dt>\n<dd>Disabled This feature is behind the <code>Experimental JavaScript Features</code> preference.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-yes bc-has-history\"> 52\n<section class=\"bc-history\" id=\"sect9\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 52\n</dt>\n<dd> Disabled in the Firefox 52 Extended Support Release (ESR).</dd>\n</dl></section>\n</td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 11</td>\n<td class=\"bc-supports-yes\"> 7.0</td>\n</tr>\n</tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 8.0.0</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Instance/exports\"><code>exports</code></a></th>\n<td class=\"bc-supports-yes\"> 8.0.0</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Instance/prototype\"><code>prototype</code></a></th>\n<td class=\"bc-supports-yes\"> 8.0.0</td>\n</tr>\n</tbody>\n</table>\n</div>  <h2 id=\"See_also\">See also</h2> <ul> <li>\n<a href=\"https://developer.mozilla.org/en-US/docs/WebAssembly\">WebAssembly</a> overview page</li> <li><a href=\"https://developer.mozilla.org/en-US/docs/WebAssembly/Concepts\">WebAssembly concepts</a></li> <li><a href=\"https://developer.mozilla.org/en-US/docs/WebAssembly/Using_the_JavaScript_API\">Using the WebAssembly JavaScript API</a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Instance$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Instance\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Instance</a>\n  </p>\n</div>\n","errors/malformed_uri":"<h1>Errors: Malformed URI</h1> <h2 id=\"Message\">Message</h2> <pre class=\"syntaxbox\">URIError: The URI to be encoded contains invalid character (Edge)\nURIError: malformed URI sequence (Firefox)\nURIError: URI malformed (Chrome)\n</pre> <h2 id=\"Error_type\">Error type</h2> <p><a href=\"../global_objects/urierror\"><code>URIError</code></a></p> <h2 id=\"What_went_wrong\">What went wrong?</h2> <p>URI encoding or decoding wasn't successful. An argument given to either the <a href=\"../global_objects/decodeuri\"><code>decodeURI</code></a>, <a href=\"../global_objects/encodeuri\"><code>encodeURI</code></a>, <a href=\"../global_objects/encodeuricomponent\"><code>encodeURIComponent</code></a>, or <a href=\"../global_objects/decodeuricomponent\"><code>decodeURIComponent</code></a> function was not valid, so that the function was unable encode or decode properly.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Encoding\">Encoding</h3> <p>Encoding replaces each instance of certain characters by one, two, three, or four escape sequences representing the UTF-8 encoding of the character. An <a href=\"../global_objects/urierror\"><code>URIError</code></a> will be thrown if there is an attempt to encode a surrogate which is not part of a high-low pair, for example:</p> <pre data-language=\"js\">encodeURI('\\uD800');\n// \"URIError: malformed URI sequence\"\n\nencodeURI('\\uDFFF');\n// \"URIError: malformed URI sequence\"\n</pre> <p>A high-low pair is ok. For example:</p> <pre data-language=\"js\">encodeURI('\\uD800\\uDFFF');\n// \"%F0%90%8F%BF\"</pre> <h3 id=\"Decoding\">Decoding</h3> <p>Decoding replaces each escape sequence in the encoded URI component with the character that it represents. If there isn't such a character, an error will be thrown:</p> <pre data-language=\"js\">decodeURIComponent('%E0%A4%A');\n// \"URIError: malformed URI sequence\"\n</pre> <p>With proper input, this should usually look like something like this:</p> <pre data-language=\"js\">decodeURIComponent('JavaScript_%D1%88%D0%B5%D0%BB%D0%BB%D1%8B');\n// \"JavaScript_шеллы\"</pre> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"../global_objects/urierror\"><code>URIError</code></a></li> <li><a href=\"../global_objects/decodeuri\"><code>decodeURI</code></a></li> <li><a href=\"../global_objects/encodeuri\"><code>encodeURI</code></a></li> <li><a href=\"../global_objects/encodeuricomponent\"><code>encodeURIComponent</code></a></li> <li><a href=\"../global_objects/decodeuricomponent\"><code>decodeURIComponent</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Malformed_URI$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Malformed_URI\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Malformed_URI</a>\n  </p>\n</div>\n","errors/bad_octal":"<h1>Errors: Bad octal</h1> <h2 id=\"Message\">Message</h2> <pre class=\"syntaxbox\">Warning: SyntaxError: 08 is not a legal ECMA-262 octal constant.\nWarning: SyntaxError: 09 is not a legal ECMA-262 octal constant.\n</pre> <h2 id=\"Error_type\">Error type</h2> <p>Warning. JavaScript execution won't be halted.</p> <h2 id=\"What_went_wrong\">What went wrong?</h2> <p>Decimal literals can start with a zero (<code>0</code>) followed by another decimal digit, but If all digits after the leading <code>0</code> are smaller than 8, the number is interpreted as an octal number. Because this is not the case with <code>08</code> and <code>09</code>, JavaScript warns about it.</p> <p>Note that octal literals and octal escape sequences are deprecated and will present an additional deprecation warning. With ECMAScript 6 and later, the syntax uses a leading zero followed by a lowercase or uppercase Latin letter \"O\" (<code>0o</code> or <code>0O)</code>. See the page about <a href=\"../lexical_grammar#Octal\">lexical grammar</a> for more information.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Invalid_octal_numbers\">Invalid octal numbers</h3> <pre data-language=\"js\">08;\n09;\n// SyntaxError: 08 is not a legal ECMA-262 octal constant\n// SyntaxError: \"0\"-prefixed octal literals and octal escape sequences\n// are deprecated</pre> <h3 id=\"Valid_octal_numbers\">Valid octal numbers</h3> <p>Use a leading zero followed by the letter \"o\";</p> <pre data-language=\"js\">0O755;\n0o644;\n</pre> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"../lexical_grammar#Octal\">Lexical grammar</a></li> <li> <p><a href=\"deprecated_octal\">SyntaxError: \"0\"-prefixed octal literals and octal escape seq. are deprecated</a></p> </li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Bad_octal$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Bad_octal\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Bad_octal</a>\n  </p>\n</div>\n","errors/deprecated_tolocaleformat":"<h1>Errors: Deprecated toLocaleFormat</h1> <h2 id=\"Message\">Message</h2> <pre class=\"syntaxbox\">Warning: Date.prototype.toLocaleFormat is deprecated; consider using Intl.DateTimeFormat instead\n</pre> <h2 id=\"Error_Type\">Error Type</h2> <p>Warning. JavaScript execution won't be halted.</p> <h2 id=\"What_went_wrong\">What went wrong?</h2> <p>The non-standard <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toLocaleFormat\"><code>Date.prototype.toLocaleFormat</code></a> method is deprecated and shouldn't be used anymore. It uses a format string in the same format expected by the <code>strftime()</code> function in C. <strong>The function is no longer available in Firefox 58+</strong>.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Deprecated_syntax\">Deprecated syntax</h3> <p>The <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toLocaleFormat\"><code>Date.prototype.toLocaleFormat</code></a> method is deprecated and will be removed (no cross-browser support, available in Firefox only).</p> <pre data-language=\"js\">var today = new Date(); \nvar date = today.toLocaleFormat('%A, %e. %B %Y');\n\nconsole.log(date);\n// In German locale\n// \"Freitag, 10. März 2017\"</pre> <h3 id=\"Alternative_standard_syntax_using_the_ECMAScript_Intl_API\">Alternative standard syntax using the ECMAScript Intl API</h3> <p>The ECMA-402 (ECMAScript Intl API) standard specifies standard objects and methods that enable language sensitive date and time formatting (available in Chrome 24+, Firefox 29+, IE11+, Safari10+).</p> <p>You can now either use the <a href=\"../global_objects/date/tolocaledatestring\"><code>Date.prototype.toLocaleDateString</code></a> method if you just want to format one date.</p> <pre data-language=\"js\">var today = new Date();\nvar options = { weekday: 'long', year: 'numeric',\n                month: 'long', day: 'numeric' };\nvar date = today.toLocaleDateString('de-DE', options);\n\nconsole.log(date);\n// \"Freitag, 10. März 2017\"\n</pre> <p>Or, you can make use of the <a href=\"../global_objects/datetimeformat\"><code>Intl.DateTimeFormat</code></a> object, which allows you to cache an object with most of the computations done so that formatting is fast. This is useful if you have a loop of dates to format.</p> <pre data-language=\"js\">var options = { weekday: 'long', year: 'numeric', \n                month: 'long', day: 'numeric' }; \nvar dateFormatter = new Intl.DateTimeFormat('de-DE', options)\n\nvar dates = [Date.UTC(2012, 11, 20, 3, 0, 0), \n             Date.UTC(2014, 04, 12, 8, 0, 0)]; \n\ndates.forEach(date =&gt; console.log(dateFormatter.format(date)));\n\n// \"Donnerstag, 20. Dezember 2012\"\n// \"Montag, 12. Mai 2014\"\n</pre> <h3 id=\"Alternative_standard_syntax_using_Date_methods\">Alternative standard syntax using Date methods</h3> <p>The <a href=\"../global_objects/date\"><code>Date</code></a> object offers several methods to build a custom date string.</p> <pre data-language=\"js\">(new Date()).toLocaleFormat(\"%Y%m%d\");\n// \"20170310\"\n</pre> <p>Can be converted to:</p> <pre data-language=\"js\">let now = new Date();\nlet date = now.getFullYear() * 10000 + \n          (now.getMonth() + 1) * 100 + now.getDate();\n\nconsole.log(date);\n// \"20170310\"</pre> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toLocaleFormat\"><code>Date.prototype.toLocaleFormat</code></a></li> <li><a href=\"../global_objects/date/tolocaledatestring\"><code>Date.prototype.toLocaleDateString</code></a></li> <li><a href=\"../global_objects/datetimeformat\"><code>Intl.DateTimeFormat</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Deprecated_toLocaleFormat$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Deprecated_toLocaleFormat\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Deprecated_toLocaleFormat</a>\n  </p>\n</div>\n","errors/cant_redefine_property":"<h1>Errors: Cant redefine property</h1> <h2 id=\"Message\">Message</h2> <pre class=\"syntaxbox\">TypeError: Cannot modify non-writable property {x} (Edge)\nTypeError: can't redefine non-configurable property \"x\" (Firefox)\nTypeError: Cannot redefine property: \"x\" (Chrome)\n</pre> <h2 id=\"Error_type\">Error type</h2> <p><a href=\"../global_objects/typeerror\"><code>TypeError</code></a></p> <h2 id=\"What_went_wrong\">What went wrong?</h2> <p>It was attempted to redefine a property, but that property is <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Properties\">non-configurable</a>. The <code>configurable</code> attribute controls whether the property can be deleted from the object and whether its attributes (other than <code>writable</code>) can be changed. Usually, properties in an object created by an <a href=\"../operators/object_initializer\">object initializer</a> are configurable. However, for example, when using <a href=\"../global_objects/object/defineproperty\"><code>Object.defineProperty()</code></a>, the property isn't configurable by default.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Non-configurable_properties_created_by_Object.defineProperty\">Non-configurable properties created by <code>Object.defineProperty</code>\n</h3> <p>The <a href=\"../global_objects/object/defineproperty\"><code>Object.defineProperty()</code></a> creates non-configurable properties if you haven't specified them as configurable.</p> <pre data-language=\"js\">var obj = Object.create({});\nObject.defineProperty(obj, \"foo\", {value: \"bar\"}); \n\nObject.defineProperty(obj, \"foo\", {value: \"baz\"});\n// TypeError: can't redefine non-configurable property \"foo\"\n</pre> <p>You will need to set the \"foo\" property to configurable, if you intend to redefine it later in the code.</p> <pre data-language=\"js\">var obj = Object.create({});\nObject.defineProperty(obj, \"foo\", {value: \"bar\", configurable: true});\nObject.defineProperty(obj, \"foo\", {value: \"baz\", configurable: true});</pre> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Properties\">[[Configurable]]</a></li> <li><a href=\"../global_objects/object/defineproperty\"><code>Object.defineProperty()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Cant_redefine_property$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Cant_redefine_property\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Cant_redefine_property</a>\n  </p>\n</div>\n","errors/for-each-in_loops_are_deprecated":"<h1>Errors: For-each-in loops are deprecated</h1> <h2 id=\"Message\">Message</h2> <pre class=\"syntaxbox\">Warning: JavaScript 1.6's for-each-in loops are deprecated; consider using ES6 for-of instead\n</pre> <h2 id=\"Error_Type\">Error Type</h2> <p>Warning</p> <h2 id=\"What_went_wrong\">What went wrong?</h2> <p>JavaScript 1.6's <a href=\"../statements/for_each...in\"><code>for each (variable in obj)</code></a> statement is deprecated, and will be removed in the near future.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Object_iteration\">Object iteration</h3> <p><a href=\"../statements/for_each...in\"><code>for each...in</code></a> has been used to iterate over the specified object values.</p> <h4 id=\"Deprecated_syntax\">Deprecated syntax</h4> <pre data-language=\"js\">var object = { a: 10, b: 20 };\n\nfor each (var x in object) {\n  console.log(x);        // 10\n                         // 20\n}\n</pre> <h4 id=\"Alternative_standard_syntax\">Alternative standard syntax</h4> <p>You can now use the standard <a href=\"../statements/for...in\"><code>for...in</code></a> loop to iterate over specified object keys, and get each value inside the loop:</p> <pre data-language=\"js\">var object = { a: 10, b: 20 };\n\nfor (var key in object) {\n  var x = object[key];\n  console.log(x);        // 10\n                         // 20\n}\n</pre> <p>Or, using <a href=\"../statements/for...of\"><code>for...of</code></a> (ES2015) and <a href=\"../global_objects/object/values\"><code>Object.values</code></a> (ES2017), you can get an array of the specified object values and iterate over the array like this:</p> <pre data-language=\"js\">var object = { a: 10, b: 20 };\n\nfor (var x of Object.values(object)) {\n  console.log(x);        // 10\n                         // 20\n}\n</pre> <h3 id=\"Array_iteration\">Array iteration</h3> <p><a href=\"../statements/for_each...in\"><code>for each...in</code></a> has been used to iterate over specified array elements.</p> <h4 id=\"Deprecated_syntax_2\">Deprecated syntax</h4> <pre data-language=\"js\">var array = [10, 20, 30];\n\nfor each (var x in array) {\n  console.log(x);        // 10\n                         // 20\n                         // 30\n}\n</pre> <h4 id=\"Alternative_standard_syntax_2\">Alternative standard syntax</h4> <p>This is now possible with <a href=\"../statements/for...of\"><code>for...of</code></a> (ES2015) loops as well.</p> <pre data-language=\"js\">var array = [10, 20, 30];\n\nfor (var x of array) {\n  console.log(x);        // 10\n                         // 20\n                         // 30\n}\n</pre> <h3 id=\"Iterating_over_a_null-able_array\">Iterating over a null-able array</h3> <p><a href=\"../statements/for_each...in\"><code>for each...in</code></a> does nothing if the specified value is <code>null</code> or <code>undefined</code>, but <a href=\"../statements/for...of\"><code>for...of</code></a> will throw an exception in these cases.</p> <h4 id=\"Deprecated_syntax_3\">Deprecated syntax</h4> <pre data-language=\"js\">function func(array) {\n  for each (var x in array) {\n    console.log(x);\n  }\n}\nfunc([10, 20]);        // 10\n                       // 20\nfunc(null);            // prints nothing\nfunc(undefined);       // prints nothing\n</pre> <h4 id=\"Alternative_standard_syntax_3\">Alternative standard syntax</h4> <p>To rewrite <a href=\"../statements/for_each...in\"><code>for each...in</code></a> statements so that values can be <code>null</code> or <code>undefined</code> with <a href=\"../statements/for...of\"><code>for...of</code></a> as well, you need to guard around <a href=\"../statements/for...of\"><code>for...of</code></a>.</p> <pre data-language=\"js\">function func(array) {\n  if (array) {\n    for (var x of array) {\n      console.log(x);\n    }\n  }\n}\nfunc([10, 20]);        // 10\n                       // 20\nfunc(null);            // prints nothing\nfunc(undefined);       // prints nothing\n</pre> <h3 id=\"Iterating_over_an_object's_key-value_pair\">Iterating over an object's key-value pair</h3> <h4 id=\"Deprecated_syntax_4\">Deprecated syntax</h4> <p>There's a deprecated idiom to iterate over the specified object's key-value pairs using <a href=\"../statements/for_each...in\"><code>for each...in</code></a> and the deprecated <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Iterator\"><code>Iterator</code></a> object.</p> <pre data-language=\"js\">var object = { a: 10, b: 20 };\n\nfor each (var [key, value] in Iterator(object)) {\n  console.log(key, value);  // \"a\", 10\n                            // \"b\", 20\n}\n</pre> <h4 id=\"Alternative_standard_syntax_4\">Alternative standard syntax</h4> <p>You can now use the standard <a href=\"../statements/for...in\"><code>for...in</code></a> loop to iterate over specified object keys, and get each value inside the loop:</p> <pre data-language=\"js\">var object = { a: 10, b: 20 };\n\nfor (var key in object) {\n  var value = object[key];\n  console.log(key, value);  // \"a\", 10\n                            // \"b\", 20\n}\n</pre> <p>Or, using <a href=\"../statements/for...of\"><code>for...of</code></a> (ES2015) and <a href=\"../global_objects/object/entries\"><code>Object.entries</code></a> (ES2017), you can get an array of the specified object values and iterate over the array like this:</p> <pre data-language=\"js\">var object = { a: 10, b: 20 };\n\nfor (var [key, value] of Object.entries(object)) {\n  console.log(key, value);  // \"a\", 10\n                            // \"b\", 20\n}\n</pre> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"../statements/for...of\"><code>for...of</code></a></li> <li><a href=\"../global_objects/object/values\"><code>Object.values</code></a></li> <li><a href=\"../global_objects/object/entries\"><code>Object.entries</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/For-each-in_loops_are_deprecated$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/For-each-in_loops_are_deprecated\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/For-each-in_loops_are_deprecated</a>\n  </p>\n</div>\n","global_objects/webassembly/memory":"<h1>WebAssembly.memory</h1> <p>The <code><strong>WebAssembly.Memory()</strong></code> constructor creates a new <code>Memory</code> object which is a resizable <a href=\"../arraybuffer\">ArrayBuffer</a> that holds the raw bytes of memory accessed by a WebAssembly <code>Instance</code>.</p> <p>A memory created by JavaScript or in WebAssembly code will be accessible and mutable from both JavaScript and WebAssembly.</p> <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\">var myMemory = new WebAssembly.Memory(memoryDescriptor);</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><em>memoryDescriptor</em></dt> <dd>An object that can contain the following members: <dl> <dt><em>initial</em></dt> <dd>The initial size of the WebAssembly Memory, in units of WebAssembly pages.</dd> <dt><em>maximum <span class=\"inlineIndicator optional optionalInline\">Optional</span></em></dt> <dd>The maximum size the WebAssembly Memory is allowed to grow to, in units of WebAssembly pages. When present, the <code>maximum</code> parameter acts as a hint to the engine to reserve memory up front. However, the engine may ignore or clamp this reservation request. In general, most WebAssembly modules shouldn't need to set a <code>maximum</code>.</dd> </dl> </dd> </dl> <div class=\"note\"> <p><strong>Note</strong>: A WebAssembly page has a constant size of 65,536 bytes, i.e., 64KiB.</p> </div> <h3 id=\"Exceptions\">Exceptions</h3> <ul> <li>If <code>memoryDescriptor</code> is not of type object, a <a href=\"../typeerror\"><code>TypeError</code></a> is thrown.</li> <li>If <code>maximum</code> is specified and is smaller than <code>initial</code>, a <a href=\"../rangeerror\"><code>RangeError</code></a> is thrown.</li> </ul> <h2 id=\"Memory_instances\">\n<code>Memory</code> instances</h2> <p>All <code>Memory</code> instances inherit from the <code>Memory()</code> constructor's <a href=\"memory/prototype\">prototype object</a> — this can be modified to affect all <code>Memory</code> instances.</p> <h3 id=\"Instance_properties\">Instance properties</h3> <dl> <dt><code>Memory.prototype.constructor</code></dt> <dd>Returns the function that created this object's instance. By default this is the <a href=\"memory\"><code>WebAssembly.Memory()</code></a> constructor.</dd> <dt><a href=\"memory/buffer\"><code>Memory.prototype.buffer</code></a></dt> <dd>An accessor property that returns the buffer contained in the memory.</dd> </dl> <h3 id=\"Instance_methods\">Instance methods</h3> <dl> <dt><a href=\"memory/grow\"><code>Memory.prototype.grow()</code></a></dt> <dd>Increases the size of the memory instance by a specified number of WebAssembly pages (each one is 64KB in size).</dd> </dl> <h2 id=\"Examples\">Examples</h2> <p>There are two ways to get a <code>WebAssembly.Memory</code> object. The first way is to construct it from JavaScript. The following example creates a new WebAssembly Memory instance with an initial size of 10 pages (640KiB), and a maximum size of 100 pages (6.4MiB).</p> <pre data-language=\"js\">var memory = new WebAssembly.Memory({initial:10, maximum:100});</pre> <p>The second way to get a <code>WebAssembly.Memory</code> object is to have it exported by a WebAssembly module. The following example (see <a href=\"https://github.com/mdn/webassembly-examples/blob/master/js-api-examples/memory.html\">memory.html</a> on GitHub, and <a href=\"https://mdn.github.io/webassembly-examples/js-api-examples/memory.html\">view it live also</a>) fetches and instantiates the loaded memory.wasm byte code using the <a href=\"instantiatestreaming\"><code>WebAssembly.instantiateStreaming()</code></a> method, while importing the memory created in the line above. It then stores some values in that memory, then exports a function and uses it to sum some values.</p> <pre data-language=\"js\">WebAssembly.instantiateStreaming(fetch('memory.wasm'), { js: { mem: memory } })\n.then(obj =&gt; {\n  var i32 = new Uint32Array(memory.buffer);\n  for (var i = 0; i &lt; 10; i++) {\n    i32[i] = i;\n  }\n  var sum = obj.instance.exports.accumulate(0, 10);\n  console.log(sum);\n});</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <thead> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> </thead> <tbody> <tr> <td><a href=\"https://webassembly.github.io/spec/js-api/#webassemblymemory-objects\" hreflang=\"en\">WebAssembly JavaScript Interface<br><small>The definition of 'Memory' in that specification.</small></a></td> <td><span class=\"spec-WD\">Working Draft</span></td> <td>Initial draft definition.</td> </tr> </tbody> </table></div> <h2 name=\"Browser_compatibility\" id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>   <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 57</td>\n<td class=\"bc-supports-yes\"> 16</td>\n<td class=\"bc-supports-yes bc-has-history\"> 52\n<section class=\"bc-history\" id=\"sect1\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 52\n</dt>\n<dd> Disabled in the Firefox 52 Extended Support Release (ESR).</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 44</td>\n<td class=\"bc-supports-yes\"> 11</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Memory/buffer\"><code>buffer</code></a></th>\n<td class=\"bc-supports-yes\"> 57</td>\n<td class=\"bc-supports-yes\"> 16</td>\n<td class=\"bc-supports-yes bc-has-history\"> 52\n<section class=\"bc-history\" id=\"sect4\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 52\n</dt>\n<dd> Disabled in the Firefox 52 Extended Support Release (ESR).</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 44</td>\n<td class=\"bc-supports-yes\"> 11</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Memory/grow\"><code>grow</code></a></th>\n<td class=\"bc-supports-yes\"> 57</td>\n<td class=\"bc-supports-yes\"> 16</td>\n<td class=\"bc-supports-yes bc-has-history\"> 52\n<section class=\"bc-history\" id=\"sect7\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 52\n</dt>\n<dd> Disabled in the Firefox 52 Extended Support Release (ESR).</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 44</td>\n<td class=\"bc-supports-yes\"> 11</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Memory/prototype\"><code>prototype</code></a></th>\n<td class=\"bc-supports-yes\"> 57</td>\n<td class=\"bc-supports-yes\"> 16</td>\n<td class=\"bc-supports-yes bc-has-history\"> 52\n<section class=\"bc-history\" id=\"sect10\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 52\n</dt>\n<dd> Disabled in the Firefox 52 Extended Support Release (ESR).</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 44</td>\n<td class=\"bc-supports-yes\"> 11</td>\n</tr>\n</tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 57</td>\n<td class=\"bc-supports-yes\"> 57</td>\n<td class=\"bc-supports-yes bc-has-history\"> Yes<div class=\"bc-icons\">Disabled </div>\n<section class=\"bc-history\" id=\"sect2\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> Yes<div class=\"bc-icons\">Disabled </div>\n</dt>\n<dd>Disabled This feature is behind the <code>Experimental JavaScript Features</code> preference.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-yes bc-has-history\"> 52\n<section class=\"bc-history\" id=\"sect3\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 52\n</dt>\n<dd> Disabled in the Firefox 52 Extended Support Release (ESR).</dd>\n</dl></section>\n</td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 11</td>\n<td class=\"bc-supports-yes\"> 7.0</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Memory/buffer\"><code>buffer</code></a></th>\n<td class=\"bc-supports-yes\"> 57</td>\n<td class=\"bc-supports-yes\"> 57</td>\n<td class=\"bc-supports-yes bc-has-history\"> Yes<div class=\"bc-icons\">Disabled </div>\n<section class=\"bc-history\" id=\"sect5\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> Yes<div class=\"bc-icons\">Disabled </div>\n</dt>\n<dd>Disabled This feature is behind the <code>Experimental JavaScript Features</code> preference.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-yes bc-has-history\"> 52\n<section class=\"bc-history\" id=\"sect6\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 52\n</dt>\n<dd> Disabled in the Firefox 52 Extended Support Release (ESR).</dd>\n</dl></section>\n</td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 11</td>\n<td class=\"bc-supports-yes\"> 7.0</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Memory/grow\"><code>grow</code></a></th>\n<td class=\"bc-supports-yes\"> 57</td>\n<td class=\"bc-supports-yes\"> 57</td>\n<td class=\"bc-supports-yes bc-has-history\"> Yes<div class=\"bc-icons\">Disabled </div>\n<section class=\"bc-history\" id=\"sect8\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> Yes<div class=\"bc-icons\">Disabled </div>\n</dt>\n<dd>Disabled This feature is behind the <code>Experimental JavaScript Features</code> preference.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-yes bc-has-history\"> 52\n<section class=\"bc-history\" id=\"sect9\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 52\n</dt>\n<dd> Disabled in the Firefox 52 Extended Support Release (ESR).</dd>\n</dl></section>\n</td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 11</td>\n<td class=\"bc-supports-yes\"> 7.0</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Memory/prototype\"><code>prototype</code></a></th>\n<td class=\"bc-supports-yes\"> 57</td>\n<td class=\"bc-supports-yes\"> 57</td>\n<td class=\"bc-supports-yes bc-has-history\"> Yes<div class=\"bc-icons\">Disabled </div>\n<section class=\"bc-history\" id=\"sect11\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> Yes<div class=\"bc-icons\">Disabled </div>\n</dt>\n<dd>Disabled This feature is behind the <code>Experimental JavaScript Features</code> preference.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-yes bc-has-history\"> 52\n<section class=\"bc-history\" id=\"sect12\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 52\n</dt>\n<dd> Disabled in the Firefox 52 Extended Support Release (ESR).</dd>\n</dl></section>\n</td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 11</td>\n<td class=\"bc-supports-yes\"> 7.0</td>\n</tr>\n</tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 8.0.0</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Memory/buffer\"><code>buffer</code></a></th>\n<td class=\"bc-supports-yes\"> 8.0.0</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Memory/grow\"><code>grow</code></a></th>\n<td class=\"bc-supports-yes\"> 8.0.0</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Memory/prototype\"><code>prototype</code></a></th>\n<td class=\"bc-supports-yes\"> 8.0.0</td>\n</tr>\n</tbody>\n</table>\n</div>  <h2 id=\"See_also\">See also</h2> <ul> <li>\n<a href=\"https://developer.mozilla.org/en-US/docs/WebAssembly\">WebAssembly</a> overview page</li> <li><a href=\"https://developer.mozilla.org/en-US/docs/WebAssembly/Concepts\">WebAssembly concepts</a></li> <li><a href=\"https://developer.mozilla.org/en-US/docs/WebAssembly/Using_the_JavaScript_API\">Using the WebAssembly JavaScript API</a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Memory$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Memory\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Memory</a>\n  </p>\n</div>\n","global_objects/webassembly/runtimeerror":"<h1>WebAssembly.runtimeError</h1> <p>The <code><strong>WebAssembly.RuntimeError()</strong></code> constructor creates a new WebAssembly <code>RuntimeError</code> object — the type that is thrown whenever WebAssembly specifies a <a href=\"http://webassembly.org/docs/semantics/#traps\">trap</a>.</p> <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\">new WebAssembly.RuntimeError(<var>message</var>, <var>fileName</var>, <var>lineNumber</var>)</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt>\n<code>message</code> <span class=\"inlineIndicator optional optionalInline\">Optional</span>\n</dt> <dd>Human-readable description of the error.</dd> <dt>\n<code>fileName</code> <span class=\"inlineIndicator optional optionalInline\">Optional</span>\n</dt> <dd>The name of the file containing the code that caused the exception.</dd> <dt>\n<code>lineNumber</code> <span class=\"inlineIndicator optional optionalInline\">Optional</span>\n</dt> <dd>The line number of the code that caused the exception.</dd> </dl> <h2 id=\"Properties\">Properties</h2> <p><em>The <code>RuntimeError</code> constructor contains no unique properties of its own, however, it does inherit some properties through the prototype chain.</em></p> <dl> <dt><code>WebAssembly.RuntimeError.prototype.constructor</code></dt> <dd>Specifies the function that created an instance's prototype.</dd> <dt><a href=\"../error/message\"><code>WebAssembly.RuntimeError.prototype.message</code></a></dt> <dd>Error message. Although ECMA-262 specifies that <a href=\"../urierror\"><code>URIError</code></a> should provide its own <code>message</code> property, in <a href=\"https://developer.mozilla.org/en-US/docs/Mozilla/Projects/SpiderMonkey\">SpiderMonkey</a>, it inherits <a href=\"../error/message\"><code>Error.prototype.message</code></a>.</dd> <dt><a href=\"../error/name\"><code>WebAssembly.RuntimeError.prototype.name</code></a></dt> <dd>Error name. Inherited from <a href=\"../error\"><code>Error</code></a>.</dd> <dt><a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/fileName\"><code>WebAssembly.RuntimeError.prototype.fileName</code></a></dt> <dd>Path to file that raised this error. Inherited from <a href=\"../error\"><code>Error</code></a>.</dd> <dt><a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/lineNumber\"><code>WebAssembly.RuntimeError.prototype.lineNumber</code></a></dt> <dd>Line number in file that raised this error. Inherited from <a href=\"../error\"><code>Error</code></a>.</dd> <dt><a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/columnNumber\"><code>WebAssembly.RuntimeError.prototype.columnNumber</code></a></dt> <dd>Column number in line that raised this error. Inherited from <a href=\"../error\"><code>Error</code></a>.</dd> <dt><a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/stack\"><code>WebAssembly.RuntimeError.prototype.stack</code></a></dt> <dd>Stack trace. Inherited from <a href=\"../error\"><code>Error</code></a>.</dd> </dl> <h2 id=\"Methods\">Methods</h2> <p><em>The <code>RuntimeError</code> constructor contains no methods of its own, however, it does inherit some methods through the prototype chain.</em></p> <dl> <dt><a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/toSource\"><code>WebAssembly.RuntimeError.prototype.toSource()</code></a></dt> <dd>Returns code that could eval to the same error. Inherited from <a href=\"../error\"><code>Error</code></a>.</dd> <dt><a href=\"../error/tostring\"><code>WebAssembly.RuntimeError.prototype.toString()</code></a></dt> <dd>Returns a string representing the specified <code>Error</code> object.. Inherited from <a href=\"../error\"><code>Error</code></a>.</dd> </dl> <h2 id=\"Examples\">Examples</h2> <p>The following snippet creates a new <code>RuntimeError</code> instance, and logs its details to the console:</p> <pre data-language=\"js\">try {\n  throw new WebAssembly.RuntimeError('Hello', 'someFile', 10);\n} catch (e) {\n  console.log(e instanceof RuntimeError); // true\n  console.log(e.message);                 // \"Hello\"\n  console.log(e.name);                    // \"RuntimeError\"\n  console.log(e.fileName);                // \"someFile\"\n  console.log(e.lineNumber);              // 10\n  console.log(e.columnNumber);            // 0\n  console.log(e.stack);                   // returns the location where the code was run\n}</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <thead> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> </thead> <tbody> <tr> <td><a href=\"https://webassembly.github.io/spec/js-api/#constructor-properties-of-the-webassembly-object\" hreflang=\"en\">WebAssembly JavaScript Interface<br><small>The definition of 'WebAssembly constructors' in that specification.</small></a></td> <td><span class=\"spec-WD\">Working Draft</span></td> <td>Initial WebAssembly draft definition.</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-native-error-types-used-in-this-standard\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'NativeError' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td>Definition of standard NativeError types.</td> </tr> </tbody> </table></div> <h2 name=\"Browser_compatibility\" id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>   <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 57</td>\n<td class=\"bc-supports-yes\"> 16</td>\n<td class=\"bc-supports-yes bc-has-history\"> 52\n<section class=\"bc-history\" id=\"sect1\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 52\n</dt>\n<dd> Disabled in the Firefox 52 Extended Support Release (ESR).</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 44</td>\n<td class=\"bc-supports-yes\"> 11</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 57</td>\n<td class=\"bc-supports-yes\"> 57</td>\n<td class=\"bc-supports-yes bc-has-history\"> Yes<div class=\"bc-icons\">Disabled </div>\n<section class=\"bc-history\" id=\"sect2\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> Yes<div class=\"bc-icons\">Disabled </div>\n</dt>\n<dd>Disabled This feature is behind the <code>Experimental JavaScript Features</code> preference.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-yes bc-has-history\"> 52\n<section class=\"bc-history\" id=\"sect3\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 52\n</dt>\n<dd> Disabled in the Firefox 52 Extended Support Release (ESR).</dd>\n</dl></section>\n</td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 11</td>\n<td class=\"bc-supports-yes\"> 7.0</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 8.0.0</td>\n</tr></tbody>\n</table>\n</div>  <h2 id=\"See_also\">See also</h2> <ul> <li>\n<a href=\"https://developer.mozilla.org/en-US/docs/WebAssembly\">WebAssembly</a> overview page</li> <li><a href=\"https://developer.mozilla.org/en-US/docs/WebAssembly/Concepts\">WebAssembly concepts</a></li> <li><a href=\"https://developer.mozilla.org/en-US/docs/WebAssembly/Using_the_JavaScript_API\">Using the WebAssembly JavaScript API</a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/RuntimeError$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/RuntimeError\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/RuntimeError</a>\n  </p>\n</div>\n","errors/getter_only":"<h1>Errors: Getter only</h1> <h2 id=\"Message\">Message</h2> <pre class=\"syntaxbox\">TypeError: Assignment to read-only properties is not allowed in strict mode (Edge)\nTypeError: setting getter-only property \"x\" (Firefox)\nTypeError: Cannot set property \"prop\" of #&lt;Object&gt; which has only a getter (Chrome)\n</pre> <h2 id=\"Error_type\">Error type</h2> <p><a href=\"../global_objects/typeerror\"><code>TypeError</code></a> in <a href=\"../strict_mode\">strict mode</a> only.</p> <h2 id=\"What_went_wrong\">What went wrong?</h2> <p>There is an attempt to set a new value to a property for which only a <a href=\"../functions/get\">getter</a> is specified. While this will be silently ignored in non-strict mode, it will throw a <a href=\"../global_objects/typeerror\"><code>TypeError</code></a> in <a href=\"../strict_mode\">strict mode</a>.</p> <h2 id=\"Examples\">Examples</h2> <p>The example below shows how to set getter for a property. It doesn't specify a <a href=\"../functions/set\">setter</a>, so a <code>TypeError</code> will be thrown upon trying to set the <code>temperature</code> property to <code>30</code>. For more details see also the <a href=\"../global_objects/object/defineproperty\"><code>Object.defineProperty()</code></a> page.</p> <pre data-language=\"js\">\"use strict\";\n\nfunction Archiver() { \n  var temperature = null; \n  Object.defineProperty(this, 'temperature', { \n    get: function() { \n      console.log('get!'); \n      return temperature; \n    }\n  });\n}\n\nvar arc = new Archiver(); \narc.temperature; // 'get!'\n\narc.temperature = 30;\n// TypeError: setting getter-only property \"temperature\"</pre> <p>To fix this error, you will either need to remove line 16, where there is an attempt to set the temperature property, or you will need to implement a <a href=\"../functions/set\">setter</a> for it, for example like this:</p> <pre data-language=\"js\">\"use strict\";\n\nfunction Archiver() {\n  var temperature = null;\n  var archive = [];\n\n  Object.defineProperty(this, 'temperature', {\n    get: function() {\n      console.log('get!');\n      return temperature;\n    },\n    set: function(value) {\n      temperature = value;\n      archive.push({ val: temperature });\n    }\n  });\n\n  this.getArchive = function() { return archive; };\n}\n\nvar arc = new Archiver();\narc.temperature; // 'get!'\narc.temperature = 11;\narc.temperature = 13;\narc.getArchive(); // [{ val: 11 }, { val: 13 }]</pre> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"../global_objects/object/defineproperty\"><code>Object.defineProperty()</code></a></li> <li><a href=\"../global_objects/object/defineproperties\"><code>Object.defineProperties()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Getter_only$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Getter_only\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Getter_only</a>\n  </p>\n</div>\n","global_objects/webassembly/linkerror":"<h1>WebAssembly.linkError</h1> <p>The <code><strong>WebAssembly.LinkError()</strong></code> constructor creates a new WebAssembly <code>LinkError</code> object, which indicates an error during module instantiation (besides <a href=\"http://webassembly.org/docs/semantics/#traps\">traps</a> from the start function).</p> <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\">new WebAssembly.LinkError(<var>message</var>, <var>fileName</var>, <var>lineNumber</var>)</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt>\n<code>message</code> <span class=\"inlineIndicator optional optionalInline\">Optional</span>\n</dt> <dd>Human-readable description of the error.</dd> <dt>\n<code>fileName</code> <span class=\"inlineIndicator optional optionalInline\">Optional</span>\n</dt> <dd>The name of the file containing the code that caused the exception.</dd> <dt>\n<code>lineNumber</code> <span class=\"inlineIndicator optional optionalInline\">Optional</span>\n</dt> <dd>The line number of the code that caused the exception.</dd> </dl> <h2 id=\"Properties\">Properties</h2> <p><em>The <code>LinkError</code> constructor contains no unique properties of its own, however, it does inherit some properties through the prototype chain.</em></p> <dl> <dt><code>WebAssembly.LinkError.prototype.constructor</code></dt> <dd>Specifies the function that created an instance's prototype.</dd> <dt><a href=\"../error/message\"><code>WebAssembly.LinkError.prototype.message</code></a></dt> <dd>Error message. Although ECMA-262 specifies that <a href=\"../urierror\"><code>URIError</code></a> should provide its own <code>message</code> property, in <a href=\"https://developer.mozilla.org/en-US/docs/Mozilla/Projects/SpiderMonkey\">SpiderMonkey</a>, it inherits <a href=\"../error/message\"><code>Error.prototype.message</code></a>.</dd> <dt><a href=\"../error/name\"><code>WebAssembly.LinkError.prototype.name</code></a></dt> <dd>Error name. Inherited from <a href=\"../error\"><code>Error</code></a>.</dd> <dt><a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/fileName\"><code>WebAssembly.LinkError.prototype.fileName</code></a></dt> <dd>Path to file that raised this error. Inherited from <a href=\"../error\"><code>Error</code></a>.</dd> <dt><a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/lineNumber\"><code>WebAssembly.LinkError.prototype.lineNumber</code></a></dt> <dd>Line number in file that raised this error. Inherited from <a href=\"../error\"><code>Error</code></a>.</dd> <dt><a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/columnNumber\"><code>WebAssembly.LinkError.prototype.columnNumber</code></a></dt> <dd>Column number in line that raised this error. Inherited from <a href=\"../error\"><code>Error</code></a>.</dd> <dt><a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/stack\"><code>WebAssembly.LinkError.prototype.stack</code></a></dt> <dd>Stack trace. Inherited from <a href=\"../error\"><code>Error</code></a>.</dd> </dl> <h2 id=\"Methods\">Methods</h2> <p><em>The <code>LinkError</code> constructor contains no methods of its own, however, it does inherit some methods through the prototype chain.</em></p> <dl> <dt><a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/toSource\"><code>WebAssembly.LinkError.prototype.toSource()</code></a></dt> <dd>Returns code that could eval to the same error. Inherited from <a href=\"../error\"><code>Error</code></a>.</dd> <dt><a href=\"../error/tostring\"><code>WebAssembly.LinkError.prototype.toString()</code></a></dt> <dd>Returns a string representing the specified <code>Error</code> object.. Inherited from <a href=\"../error\"><code>Error</code></a>.</dd> </dl> <h2 id=\"Examples\">Examples</h2> <p>The following snippet creates a new <code>LinkError</code> instance, and logs its details to the console:</p> <pre data-language=\"js\">try {\n  throw new WebAssembly.LinkError('Hello', 'someFile', 10);\n} catch (e) {\n  console.log(e instanceof LinkError); // true\n  console.log(e.message);                 // \"Hello\"\n  console.log(e.name);                    // \"LinkError\"\n  console.log(e.fileName);                // \"someFile\"\n  console.log(e.lineNumber);              // 10\n  console.log(e.columnNumber);            // 0\n  console.log(e.stack);                   // returns the location where the code was run\n}</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <thead> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> </thead> <tbody> <tr> <td><a href=\"https://webassembly.github.io/spec/js-api/#constructor-properties-of-the-webassembly-object\" hreflang=\"en\">WebAssembly JavaScript Interface<br><small>The definition of 'WebAssembly constructors' in that specification.</small></a></td> <td><span class=\"spec-WD\">Working Draft</span></td> <td>Initial WebAssembly draft definition.</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-native-error-types-used-in-this-standard\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'NativeError' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td>Definition of standard NativeError types.</td> </tr> </tbody> </table></div> <h2 name=\"Browser_compatibility\" id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>   <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 57</td>\n<td class=\"bc-supports-yes\"> 16</td>\n<td class=\"bc-supports-yes bc-has-history\"> 52\n<section class=\"bc-history\" id=\"sect1\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 52\n</dt>\n<dd> Disabled in the Firefox 52 Extended Support Release (ESR).</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 44</td>\n<td class=\"bc-supports-yes\"> 11</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 57</td>\n<td class=\"bc-supports-yes\"> 57</td>\n<td class=\"bc-supports-yes bc-has-history\"> Yes<div class=\"bc-icons\">Disabled </div>\n<section class=\"bc-history\" id=\"sect2\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> Yes<div class=\"bc-icons\">Disabled </div>\n</dt>\n<dd>Disabled This feature is behind the <code>Experimental JavaScript Features</code> preference.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-yes bc-has-history\"> 52\n<section class=\"bc-history\" id=\"sect3\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 52\n</dt>\n<dd> Disabled in the Firefox 52 Extended Support Release (ESR).</dd>\n</dl></section>\n</td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 11</td>\n<td class=\"bc-supports-yes\"> 7.0</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 8.0.0</td>\n</tr></tbody>\n</table>\n</div>  <h2 id=\"See_also\">See also</h2> <ul> <li>\n<a href=\"https://developer.mozilla.org/en-US/docs/WebAssembly\">WebAssembly</a> overview page</li> <li><a href=\"https://developer.mozilla.org/en-US/docs/WebAssembly/Concepts\">WebAssembly concepts</a></li> <li><a href=\"https://developer.mozilla.org/en-US/docs/WebAssembly/Using_the_JavaScript_API\">Using the WebAssembly JavaScript API</a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/LinkError$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/LinkError\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/LinkError</a>\n  </p>\n</div>\n","global_objects/function/arguments":"<h1>function.arguments</h1> <div class=\"blockIndicator deprecated deprecatedHeader\"> <p><strong> Deprecated</strong><br>This feature is no longer recommended. Though some browsers might still support it, it may have already been removed from the relevant web standards, may be in the process of being dropped, or may only be kept for compatibility purposes. Avoid using it, and update existing code if possible; see the <a href=\"#Browser_compatibility\">compatibility table</a> at the bottom of this page to guide your decision. Be aware that this feature may cease to work at any time.</p> </div> <p>The <code><strong><em>function</em>.arguments</strong></code> property refers to an an array-like object corresponding to the arguments passed to a function. Use the simple variable <a href=\"../../functions/arguments\"><code>arguments</code></a> instead. This property is forbidden in strict model due to <a href=\"http://www.ecma-international.org/ecma-262/6.0/#sec-addrestrictedfunctionproperties\">tail call optimization</a>.</p> <h2 id=\"Description\">Description</h2> <p>The syntax <code><em>function</em>.arguments</code> is deprecated. The recommended way to access the <a href=\"../../functions/arguments\"><code>arguments</code></a> object available within functions is simply to refer to the variable <a href=\"../../functions/arguments\"><code>arguments</code></a>.</p> <p>In the case of recursion, i.e. if function <code>f</code> appears several times on the call stack, the value of <code>f.arguments</code> represents the arguments corresponding to the most recent invocation of the function.</p> <p>The value of the arguments property is normally null if there is no outstanding invocation of the function in progress (that is, the function has been called but has not yet returned.</p> <h2 id=\"Examples\">Examples</h2> <pre data-language=\"js\">function f(n) { g(n - 1); }\n\nfunction g(n) {\n  console.log('before: ' + g.arguments[0]);\n  if (n &gt; 0) { f(n); }\n  console.log('after: ' + g.arguments[0]);\n}\n\nf(2);\n\nconsole.log('returned: ' + g.arguments);\n\n// Output\n\n// before: 1\n// before: 0\n// after: 0\n// after: 1\n// returned: null\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/publications/files/ECMA-ST-ARCH/ECMA-262,%201st%20edition,%20June%201997.pdf\" hreflang=\"en\">ECMAScript 1st Edition (ECMA-262)</a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition. Implemented in JavaScript 1.0. Deprecated in favor of <a href=\"../../functions/arguments\"><code>arguments</code></a> in ES3.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/5.1/#sec-10.6\" hreflang=\"en\">ECMAScript 5.1 (ECMA-262)<br><small>The definition of 'arguments object' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>\n<a href=\"../../functions/arguments\"><code>arguments</code></a> object</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-arguments-object\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'arguments object' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>\n<a href=\"../../functions/arguments\"><code>arguments</code></a> object</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-arguments-object\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'arguments object' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td>\n<a href=\"../../functions/arguments\"><code>arguments</code></a> object</td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>   <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support \n</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support \n</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support \n</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div>  <h2 id=\"See_also\">See also</h2> <ul> <li>\n<a href=\"../../functions/arguments\"><code>arguments</code></a> object</li> <li><a href=\"../../functions\">Functions and function scope</a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/arguments$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/arguments\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/arguments</a>\n  </p>\n</div>\n","errors/called_on_incompatible_type":"<h1>Errors: Called on incompatible type</h1> <h2 id=\"Message\">Message</h2> <pre class=\"syntaxbox\">TypeError: 'this' is not a Set object (EdgE)\nTypeError: Function.prototype.toString called on incompatible object (Firefox)\nTypeError: Function.prototype.bind called on incompatible target (Firefox)\nTypeError: Method Set.prototype.add called on incompatible receiver undefined (Chrome)\nTypeError: Bind must be called on a function (Chrome)\n</pre> <h2 id=\"Error_type\">Error type</h2> <p><a href=\"../global_objects/typeerror\"><code>TypeError</code></a></p> <h2 id=\"What_went_wrong\">What went wrong?</h2> <p>When this error is thrown, a function (on a given object), is called with a <code>this</code> not corresponding to the type expected by the function.</p> <p>This issue can arise when using the <a href=\"../global_objects/function/call\"><code>Function.prototype.call()</code></a> or <a href=\"../global_objects/function/apply\"><code>Function.prototype.apply()</code></a> methods, and providing a <code>this</code> argument which does not have the expected type.</p> <p>This issue can also happen when providing a function (stored in an object) as an argument to another function. In this case, the object won't the <code>this</code> target of the function. To work-around this issue, you will either need to provide a lambda which is making the call, or use the <a href=\"../global_objects/function/bind\"><code>Function.prototype.bind()</code></a> function to force the <code>this</code> argument to the expected object.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Invalid_cases\">Invalid cases</h3> <pre data-language=\"js\">var mySet = new Set;\n['bar', 'baz'].forEach(mySet.add);\n// mySet.add is a function, but \"mySet\" is not captured as this.\n\nvar myFun = function () {\n  console.log(this);\n};\n['bar', 'baz'].forEach(myFun.bind);\n// myFun.bind is a function, but \"myFun\" is not captured as this.\n\n</pre> <h3 id=\"Valid_cases\">Valid cases</h3> <pre data-language=\"js\">var mySet = new Set;\n['bar', 'baz'].forEach(mySet.add.bind(mySet));\n// This works due to binding \"mySet\" as this.\n\nvar myFun = function () {\n  console.log(this);\n};\n['bar', 'baz'].forEach(x =&gt; myFun.bind(x));\n// This works using the \"bind\" function. It creates a lambda forwarding the argument.\n\n</pre> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"../global_objects/function/call\"><code>Function.prototype.call()</code></a></li> <li><a href=\"../global_objects/function/apply\"><code>Function.prototype.apply()</code></a></li> <li><a href=\"../global_objects/function/bind\"><code>Function.prototype.bind()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Called_on_incompatible_type$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Called_on_incompatible_type\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Called_on_incompatible_type</a>\n  </p>\n</div>\n","global_objects/webassembly/module":"<h1>WebAssembly.module</h1> A <code>WebAssembly.Module</code> object contains stateless WebAssembly code that has already been compiled by the browser and can be efficiently <a href=\"https://developer.mozilla.org/en-US/docs/Web/API/Worker/postMessage\">shared with Workers</a>, and instantiated multiple times. To instantiate the module, call <a href=\"instantiate#Secondary_overload_%E2%80%94_taking_a_module_object_instance\">the secondary overload of <code>WebAssembly.instantiate()</code></a>.   The <code>WebAssembly.Module()</code> constructor function can be called to synchronously compile given WebAssembly binary code. However, the primary way to get a <code>Module</code> is through an asynchronous compilation function like <a href=\"compile\"><code>WebAssembly.compile()</code></a>.   <h2 id=\"Constructor_Syntax\">Constructor Syntax</h2> <div class=\"warning\"> <p><strong>Important</strong>: Since compilation for large modules can be expensive, developers should only use the <code>Module()</code> constructor when synchronous compilation is absolutely required; the asynchronous <a href=\"compilestreaming\"><code>WebAssembly.compileStreaming()</code></a> method should be used at all other times.</p> </div> <pre class=\"syntaxbox\">var myModule = new WebAssembly.Module(bufferSource);</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><em>bufferSource</em></dt> <dd>A <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Typed_arrays\">typed array</a> or <a href=\"../arraybuffer\">ArrayBuffer</a> containing the binary code of the .wasm module you want to compile.</dd> </dl> <h2 id=\"Function_Properties_of_the_Module_Constructor\">Function Properties of the <code>Module</code> Constructor</h2> <dl> <dt><a href=\"module/customsections\"><code>WebAssembly.Module.customSections()</code></a></dt> <dd>Given a <code>Module</code> and string, returns a copy of the contents of all custom sections in the module with the given string name.</dd> <dt><a href=\"module/exports\"><code>WebAssembly.Module.exports()</code></a></dt> <dd>Given a <code>Module</code>, returns an array containing descriptions of all the declared exports.</dd> <dt><a href=\"module/imports\"><code>WebAssembly.Module.imports()</code></a></dt> <dd>Given a <code>Module</code>, returns an array containing descriptions of all the declared imports.</dd> </dl> <h2 id=\"Module_instances\">\n<code>Module</code> instances</h2> <p>All <code>Module</code> instances inherit from the <code>Module()</code> constructor's <a href=\"module/prototype\">prototype object</a> — this can be modified to affect all <code>Module</code> instances.</p> <h3 id=\"Instance_properties\">Instance properties</h3> <dl> <dt><code>Module.prototype.constructor</code></dt> <dd>Returns the function that created this object's instance. By default this is the <a href=\"module\"><code>WebAssembly.Module()</code></a> constructor.</dd> <dt><code>Module.prototype[@@toStringTag]</code></dt> <dd>The initial value of the <a href=\"../symbol/tostringtag\">@@toStringTag</a> property is the String value \"WebAssembly.Module\".</dd> </dl> <h3 id=\"Instance_methods\">Instance methods</h3> <p>Module instances have no default methods of their own.</p> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <thead> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> </thead> <tbody> <tr> <td><a href=\"https://webassembly.github.io/spec/js-api/#webassemblymodule-objects\" hreflang=\"en\">WebAssembly JavaScript Interface<br><small>The definition of 'WebAssembly.Module()' in that specification.</small></a></td> <td><span class=\"spec-WD\">Working Draft</span></td> <td>Initial draft definition.</td> </tr> </tbody> </table></div> <h2 name=\"Browser_compatibility\" id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>   <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 57</td>\n<td class=\"bc-supports-yes\"> 16</td>\n<td class=\"bc-supports-yes bc-has-history\"> 52\n<section class=\"bc-history\" id=\"sect1\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 52\n</dt>\n<dd> Disabled in the Firefox 52 Extended Support Release (ESR).</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 44</td>\n<td class=\"bc-supports-yes\"> 11</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Module/customSections\"><code>customSections</code></a></th>\n<td class=\"bc-supports-yes\"> 57</td>\n<td class=\"bc-supports-yes\"> 16</td>\n<td class=\"bc-supports-yes bc-has-history\"> 52\n<section class=\"bc-history\" id=\"sect4\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 52\n</dt>\n<dd> Disabled in the Firefox 52 Extended Support Release (ESR).</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 44</td>\n<td class=\"bc-supports-yes\"> 11</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Module/exports\"><code>exports</code></a></th>\n<td class=\"bc-supports-yes\"> 57</td>\n<td class=\"bc-supports-yes\"> 16</td>\n<td class=\"bc-supports-yes bc-has-history\"> 52\n<section class=\"bc-history\" id=\"sect7\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 52\n</dt>\n<dd> Disabled in the Firefox 52 Extended Support Release (ESR).</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 44</td>\n<td class=\"bc-supports-yes\"> 11</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Module/imports\"><code>imports</code></a></th>\n<td class=\"bc-supports-yes\"> 57</td>\n<td class=\"bc-supports-yes\"> 16</td>\n<td class=\"bc-supports-yes bc-has-history\"> 52\n<section class=\"bc-history\" id=\"sect10\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 52\n</dt>\n<dd> Disabled in the Firefox 52 Extended Support Release (ESR).</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 44</td>\n<td class=\"bc-supports-yes\"> 11</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Module/prototype\"><code>prototype</code></a></th>\n<td class=\"bc-supports-yes\"> 57</td>\n<td class=\"bc-supports-yes\"> 16</td>\n<td class=\"bc-supports-yes bc-has-history\"> 52\n<section class=\"bc-history\" id=\"sect13\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 52\n</dt>\n<dd> Disabled in the Firefox 52 Extended Support Release (ESR).</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 44</td>\n<td class=\"bc-supports-yes\"> 11</td>\n</tr>\n</tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 57</td>\n<td class=\"bc-supports-yes\"> 57</td>\n<td class=\"bc-supports-yes bc-has-history\"> Yes<div class=\"bc-icons\">Disabled </div>\n<section class=\"bc-history\" id=\"sect2\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> Yes<div class=\"bc-icons\">Disabled </div>\n</dt>\n<dd>Disabled This feature is behind the <code>Experimental JavaScript Features</code> preference.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-yes bc-has-history\"> 52\n<section class=\"bc-history\" id=\"sect3\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 52\n</dt>\n<dd> Disabled in the Firefox 52 Extended Support Release (ESR).</dd>\n</dl></section>\n</td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 11</td>\n<td class=\"bc-supports-yes\"> 7.0</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Module/customSections\"><code>customSections</code></a></th>\n<td class=\"bc-supports-yes\"> 57</td>\n<td class=\"bc-supports-yes\"> 57</td>\n<td class=\"bc-supports-yes bc-has-history\"> Yes<div class=\"bc-icons\">Disabled </div>\n<section class=\"bc-history\" id=\"sect5\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> Yes<div class=\"bc-icons\">Disabled </div>\n</dt>\n<dd>Disabled This feature is behind the <code>Experimental JavaScript Features</code> preference.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-yes bc-has-history\"> 52\n<section class=\"bc-history\" id=\"sect6\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 52\n</dt>\n<dd> Disabled in the Firefox 52 Extended Support Release (ESR).</dd>\n</dl></section>\n</td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 11</td>\n<td class=\"bc-supports-yes\"> 7.0</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Module/exports\"><code>exports</code></a></th>\n<td class=\"bc-supports-yes\"> 57</td>\n<td class=\"bc-supports-yes\"> 57</td>\n<td class=\"bc-supports-yes bc-has-history\"> Yes<div class=\"bc-icons\">Disabled </div>\n<section class=\"bc-history\" id=\"sect8\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> Yes<div class=\"bc-icons\">Disabled </div>\n</dt>\n<dd>Disabled This feature is behind the <code>Experimental JavaScript Features</code> preference.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-yes bc-has-history\"> 52\n<section class=\"bc-history\" id=\"sect9\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 52\n</dt>\n<dd> Disabled in the Firefox 52 Extended Support Release (ESR).</dd>\n</dl></section>\n</td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 11</td>\n<td class=\"bc-supports-yes\"> 7.0</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Module/imports\"><code>imports</code></a></th>\n<td class=\"bc-supports-yes\"> 57</td>\n<td class=\"bc-supports-yes\"> 57</td>\n<td class=\"bc-supports-yes bc-has-history\"> Yes<div class=\"bc-icons\">Disabled </div>\n<section class=\"bc-history\" id=\"sect11\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> Yes<div class=\"bc-icons\">Disabled </div>\n</dt>\n<dd>Disabled This feature is behind the <code>Experimental JavaScript Features</code> preference.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-yes bc-has-history\"> 52\n<section class=\"bc-history\" id=\"sect12\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 52\n</dt>\n<dd> Disabled in the Firefox 52 Extended Support Release (ESR).</dd>\n</dl></section>\n</td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 11</td>\n<td class=\"bc-supports-yes\"> 7.0</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Module/prototype\"><code>prototype</code></a></th>\n<td class=\"bc-supports-yes\"> 57</td>\n<td class=\"bc-supports-yes\"> 57</td>\n<td class=\"bc-supports-yes bc-has-history\"> Yes<div class=\"bc-icons\">Disabled </div>\n<section class=\"bc-history\" id=\"sect14\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> Yes<div class=\"bc-icons\">Disabled </div>\n</dt>\n<dd>Disabled This feature is behind the <code>Experimental JavaScript Features</code> preference.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-yes bc-has-history\"> 52\n<section class=\"bc-history\" id=\"sect15\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 52\n</dt>\n<dd> Disabled in the Firefox 52 Extended Support Release (ESR).</dd>\n</dl></section>\n</td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 11</td>\n<td class=\"bc-supports-yes\"> 7.0</td>\n</tr>\n</tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 8.0.0</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Module/customSections\"><code>customSections</code></a></th>\n<td class=\"bc-supports-yes\"> 8.0.0</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Module/exports\"><code>exports</code></a></th>\n<td class=\"bc-supports-yes\"> 8.0.0</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Module/imports\"><code>imports</code></a></th>\n<td class=\"bc-supports-yes\"> 8.0.0</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Module/prototype\"><code>prototype</code></a></th>\n<td class=\"bc-supports-yes\"> 8.0.0</td>\n</tr>\n</tbody>\n</table>\n</div>  <h2 id=\"See_also\">See also</h2> <ul> <li>\n<a href=\"https://developer.mozilla.org/en-US/docs/WebAssembly\">WebAssembly</a> overview page</li> <li><a href=\"https://developer.mozilla.org/en-US/docs/WebAssembly/Concepts\">WebAssembly concepts</a></li> <li><a href=\"https://developer.mozilla.org/en-US/docs/WebAssembly/Using_the_JavaScript_API\">Using the WebAssembly JavaScript API</a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Module$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Module\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Module</a>\n  </p>\n</div>\n","global_objects/webassembly/compileerror":"<h1>WebAssembly.compileError</h1> <p>The <code><strong>WebAssembly.CompileError()</strong></code> constructor creates a new WebAssembly <code>CompileError</code> object, which indicates an error during WebAssembly decoding or validation.</p> <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\">new WebAssembly.CompileError(<var>message</var>, <var>fileName</var>, <var>lineNumber</var>)</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt>\n<code>message</code> <span class=\"inlineIndicator optional optionalInline\">Optional</span>\n</dt> <dd>Human-readable description of the error.</dd> <dt>\n<code>fileName</code> <span class=\"inlineIndicator optional optionalInline\">Optional</span>\n</dt> <dd>The name of the file containing the code that caused the exception.</dd> <dt>\n<code>lineNumber</code> <span class=\"inlineIndicator optional optionalInline\">Optional</span>\n</dt> <dd>The line number of the code that caused the exception.</dd> </dl> <h2 id=\"Properties\">Properties</h2> <p><em>The <code>CompileError</code> constructor contains no unique properties of its own, however, it does inherit some properties through the prototype chain.</em></p> <dl> <dt><code>WebAssembly.CompileError.prototype.constructor</code></dt> <dd>Specifies the function that created an instance's prototype.</dd> <dt><a href=\"../error/message\"><code>WebAssembly.CompileError.prototype.message</code></a></dt> <dd>Error message. Although ECMA-262 specifies that <a href=\"../urierror\"><code>URIError</code></a> should provide its own <code>message</code> property, in <a href=\"https://developer.mozilla.org/en-US/docs/Mozilla/Projects/SpiderMonkey\">SpiderMonkey</a>, it inherits <a href=\"../error/message\"><code>Error.prototype.message</code></a>.</dd> <dt><a href=\"../error/name\"><code>WebAssembly.CompileError.prototype.name</code></a></dt> <dd>Error name. Inherited from <a href=\"../error\"><code>Error</code></a>.</dd> <dt><a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/fileName\"><code>WebAssembly.CompileError.prototype.fileName</code></a></dt> <dd>Path to file that raised this error. Inherited from <a href=\"../error\"><code>Error</code></a>.</dd> <dt><a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/lineNumber\"><code>WebAssembly.CompileError.prototype.lineNumber</code></a></dt> <dd>Line number in file that raised this error. Inherited from <a href=\"../error\"><code>Error</code></a>.</dd> <dt><a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/columnNumber\"><code>WebAssembly.CompileError.prototype.columnNumber</code></a></dt> <dd>Column number in line that raised this error. Inherited from <a href=\"../error\"><code>Error</code></a>.</dd> <dt><a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/stack\"><code>WebAssembly.CompileError.prototype.stack</code></a></dt> <dd>Stack trace. Inherited from <a href=\"../error\"><code>Error</code></a>.</dd> </dl> <h2 id=\"Methods\">Methods</h2> <p><em>The <code>CompileError</code> constructor contains no methods of its own, however, it does inherit some methods through the prototype chain.</em></p> <dl> <dt><a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/toSource\"><code>WebAssembly.CompileError.prototype.toSource()</code></a></dt> <dd>Returns code that could eval to the same error. Inherited from <a href=\"../error\"><code>Error</code></a>.</dd> <dt><a href=\"../error/tostring\"><code>WebAssembly.CompileError.prototype.toString()</code></a></dt> <dd>Returns a string representing the specified <code>Error</code> object.. Inherited from <a href=\"../error\"><code>Error</code></a>.</dd> </dl> <h2 id=\"Examples\">Examples</h2> <p>The following snippet creates a new <code>CompileError</code> instance, and logs its details to the console:</p> <pre data-language=\"js\">try {\n  throw new WebAssembly.CompileError('Hello', 'someFile', 10);\n} catch (e) {\n  console.log(e instanceof CompileError); // true\n  console.log(e.message);                 // \"Hello\"\n  console.log(e.name);                    // \"CompileError\"\n  console.log(e.fileName);                // \"someFile\"\n  console.log(e.lineNumber);              // 10\n  console.log(e.columnNumber);            // 0\n  console.log(e.stack);                   // returns the location where the code was run\n}</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <thead> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> </thead> <tbody> <tr> <td><a href=\"https://webassembly.github.io/spec/js-api/#constructor-properties-of-the-webassembly-object\" hreflang=\"en\">WebAssembly JavaScript Interface<br><small>The definition of 'WebAssembly constructors' in that specification.</small></a></td> <td><span class=\"spec-WD\">Working Draft</span></td> <td>Initial WebAssembly draft definition.</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-native-error-types-used-in-this-standard\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'NativeError' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td>Definition of standard NativeError types.</td> </tr> </tbody> </table></div> <h2 name=\"Browser_compatibility\" id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>   <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 57</td>\n<td class=\"bc-supports-yes\"> 16</td>\n<td class=\"bc-supports-yes bc-has-history\"> 52\n<section class=\"bc-history\" id=\"sect1\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 52\n</dt>\n<dd> Disabled in the Firefox 52 Extended Support Release (ESR).</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 44</td>\n<td class=\"bc-supports-yes\"> 11</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 57</td>\n<td class=\"bc-supports-yes\"> 57</td>\n<td class=\"bc-supports-yes bc-has-history\"> Yes<div class=\"bc-icons\">Disabled </div>\n<section class=\"bc-history\" id=\"sect2\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> Yes<div class=\"bc-icons\">Disabled </div>\n</dt>\n<dd>Disabled This feature is behind the <code>Experimental JavaScript Features</code> preference.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-yes bc-has-history\"> 52\n<section class=\"bc-history\" id=\"sect3\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 52\n</dt>\n<dd> Disabled in the Firefox 52 Extended Support Release (ESR).</dd>\n</dl></section>\n</td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 11</td>\n<td class=\"bc-supports-yes\"> 7.0</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 8.0.0</td>\n</tr></tbody>\n</table>\n</div>  <h2 id=\"See_also\">See also</h2> <ul> <li>\n<a href=\"https://developer.mozilla.org/en-US/docs/WebAssembly\">WebAssembly</a> overview page</li> <li><a href=\"https://developer.mozilla.org/en-US/docs/WebAssembly/Concepts\">WebAssembly concepts</a></li> <li><a href=\"https://developer.mozilla.org/en-US/docs/WebAssembly/Using_the_JavaScript_API\">Using the WebAssembly JavaScript API</a></li> </ul> <div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/CompileError$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/CompileError\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/CompileError</a>\n  </p>\n</div>\n","global_objects/asyncfunction/prototype":"<h1>AsyncFunction.prototype</h1> <p>The <code><strong>AsyncFunction.prototype</strong></code> property represents the <a href=\"../asyncfunction\"><code>AsyncFunction</code></a> prototype object.</p> <h2 id=\"Description\">Description</h2> <p><a href=\"../asyncfunction\"><code>AsyncFunction</code></a> objects inherit from <code>AsyncFunction.prototype</code>. <code>AsyncFunction.prototype</code> cannot be modified.</p> <h2 id=\"Properties\">Properties</h2> <dl> <dt><code><strong>AsyncFunction.constructor</strong></code></dt> <dd>The initial value is <a href=\"../asyncfunction\"><code>AsyncFunction</code></a>.</dd> <dt><code><strong>AsyncFunction.prototype[@@toStringTag]</strong></code></dt> <dd>Returns \"AsyncFunction\".</dd> </dl> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <thead> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> </thead> <tbody> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-async-function-constructor-prototype\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'AsyncFunction.prototype' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td>Initial definition in ES2017.</td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>   <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 55</td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 52</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 42</td>\n<td> ? </td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 55</td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 52</td>\n<td class=\"bc-supports-yes\"> 42</td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 6.0</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes bc-has-history\"> 7.6.0\n<section class=\"bc-history\" id=\"sect1\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 7.6.0\n</dt>\n\n<dt class=\"bc-supports-yes bc-supports\"> 7.0.0<div class=\"bc-icons\">Disabled </div>\n</dt>\n<dd>Disabled From version 7.0.0: this feature is behind the <code>--harmony</code> runtime flag.</dd>\n</dl></section>\n</td>\n</tr></tbody>\n</table>\n</div>  <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"../asyncfunction\"><code>AsyncFunction</code></a></li> <li><a href=\"../function\"><code>Function</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/AsyncFunction/prototype$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/AsyncFunction/prototype\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/AsyncFunction/prototype</a>\n  </p>\n</div>\n","errors/deprecated_string_generics":"<h1>Errors: Deprecated String generics</h1> <h2 id=\"Message\">Message</h2> <pre class=\"syntaxbox\">Warning: String.charAt            is deprecated; use String.prototype.charAt            instead\nWarning: String.charCodeAt        is deprecated; use String.prototype.charCodeAt        instead\nWarning: String.concat            is deprecated; use String.prototype.concat            instead\nWarning: String.contains          is deprecated; use String.prototype.contains          instead\nWarning: String.endsWith          is deprecated; use String.prototype.endsWith          instead\nWarning: String.includes          is deprecated; use String.prototype.includes          instead\nWarning: String.indexOf           is deprecated; use String.prototype.indexOf           instead\nWarning: String.lastIndexOf       is deprecated; use String.prototype.lastIndexOf       instead\nWarning: String.localeCompare     is deprecated; use String.prototype.localeCompare     instead\nWarning: String.match             is deprecated; use String.prototype.match             instead\nWarning: String.normalize         is deprecated; use String.prototype.normalize         instead\nWarning: String.replace           is deprecated; use String.prototype.replace           instead\nWarning: String.search            is deprecated; use String.prototype.search            instead\nWarning: String.slice             is deprecated; use String.prototype.slice             instead\nWarning: String.split             is deprecated; use String.prototype.split             instead\nWarning: String.startsWith        is deprecated; use String.prototype.startsWith        instead\nWarning: String.substr            is deprecated; use String.prototype.substr            instead\nWarning: String.substring         is deprecated; use String.prototype.substring         instead\nWarning: String.toLocaleLowerCase is deprecated; use String.prototype.toLocaleLowerCase instead\nWarning: String.toLocaleUpperCase is deprecated; use String.prototype.toLocaleUpperCase instead\nWarning: String.toLowerCase       is deprecated; use String.prototype.toLowerCase       instead\nWarning: String.toUpperCase       is deprecated; use String.prototype.toUpperCase       instead\nWarning: String.trim              is deprecated; use String.prototype.trim              instead\nWarning: String.trimLeft          is deprecated; use String.prototype.trimLeft          instead\nWarning: String.trimRight         is deprecated; use String.prototype.trimRight         instead\n</pre> <h2 id=\"Error_Type\">Error Type</h2> <p>Warning. JavaScript execution won't be halted.</p> <h2 id=\"What_went_wrong\">What went wrong?</h2> <p>The non-standard generic <a href=\"../global_objects/string\"><code>String</code></a> methods are deprecated and will be removed in the future (no cross-browser support, available in Firefox only). String generics provide <code>String</code> instance methods on the <code>String</code> object allowing <code>String</code> methods to be applied to any object.</p> <p>Firefox <a href=\"https://bugzilla.mozilla.org/show_bug.cgi?id=1222552\">bug 1222552</a> tracks the removal of String generic methods.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Deprecated_syntax\">Deprecated syntax</h3> <pre data-language=\"js\">var num = 15; \nString.replace(num, /5/, '2');</pre> <h3 id=\"Standard_syntax\">Standard syntax</h3> <pre data-language=\"js\">var num = 15;\nString(num).replace(/5/, '2');\n</pre> <h2 id=\"Shim\">Shim</h2> <p>The following is a shim to provide support to non-supporting browsers:</p> <pre data-language=\"js\">/*globals define*/\n// Assumes all supplied String instance methods already present\n// (one may use shims for these if not available)\n(function() {\n  'use strict';\n\n  var i,\n    // We could also build the array of methods with the following, but the\n    //   getOwnPropertyNames() method is non-shimable:\n    // Object.getOwnPropertyNames(String).filter(function(methodName) {\n    //   return typeof String[methodName] === 'function';\n    // });\n    methods = [\n      'contains', 'substring', 'toLowerCase', 'toUpperCase', 'charAt',\n      'charCodeAt', 'indexOf', 'lastIndexOf', 'startsWith', 'endsWith',\n      'trim', 'trimLeft', 'trimRight', 'toLocaleLowerCase', 'normalize',\n      'toLocaleUpperCase', 'localeCompare', 'match', 'search', 'slice',\n      'replace', 'split', 'substr', 'concat', 'localeCompare'\n    ],\n    methodCount = methods.length,\n    assignStringGeneric = function(methodName) {\n      var method = String.prototype[methodName];\n      String[methodName] = function(arg1) {\n        return method.apply(arg1, Array.prototype.slice.call(arguments, 1));\n      };\n    };\n\n  for (i = 0; i &lt; methodCount; i++) {\n    assignStringGeneric(methods[i]);\n  }\n}());</pre> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"../global_objects/string\"><code>String</code></a></li> <li>\n<a href=\"../global_objects/array#Array_generic_methods\">Generics</a> are also available on <a href=\"../global_objects/array\"><code>Array</code></a> methods (and deprecated as well).</li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Deprecated_String_generics$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Deprecated_String_generics\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Deprecated_String_generics</a>\n  </p>\n</div>\n","errors/stmt_after_return":"<h1>Errors: Stmt after return</h1> <h2 id=\"Message\">Message</h2> <pre class=\"syntaxbox\">Warning: unreachable code after return statement (Firefox)\n</pre> <h2 id=\"Error_Type\">Error Type</h2> <p>Warning</p> <h2 id=\"What_went_wrong\">What went wrong?</h2> <p>Unreachable code after a return statement might occur in these situations:</p> <ul> <li>When using an expression after a <a href=\"../statements/return\"><code>return</code></a> statement, or</li> <li>when using a semicolon-less return statement but including an expression directly after.</li> </ul> <p>When an expression exists after a valid <code>return</code> statement, a warning is given to indicate that the code after the <code>return</code> statement is unreachable, meaning it can never be run.</p> <p>Why should I have semicolons after <code>return</code> statements? In the case of semicolon-less <code>return</code> statements, it can be unclear whether the developer intended to return the statement on the following line, or to stop execution and return. The warning indicates that there is ambiguity in the way the <code>return</code> statement is written.</p> <p>Warnings will not be shown for semicolon-less returns if these statements follow it:</p> <ul> <li><a href=\"../statements/throw\"><code>throw</code></a></li> <li><a href=\"../statements/break\"><code>break</code></a></li> <li><a href=\"../statements/var\"><code>var</code></a></li> <li><a href=\"../statements/function\"><code>function</code></a></li> </ul> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Invalid_cases\">Invalid cases</h3> <pre data-language=\"js\">function f() {\n  var x = 3;\n  x += 4;\n  return x;   // return exits the function immediately\n  x -= 3;     // so this line will never run; it is unreachable\n}\n\nfunction f() {\n  return     // this is treated like `return;`\n    3 + 4;   // so the function returns, and this line is never reached\n}\n</pre> <h3 id=\"Valid_cases\">Valid cases</h3> <pre data-language=\"js\">function f() {\n  var x = 3;\n  x += 4;\n  x -= 3;\n  return x;  // OK: return after all other statements\n}\n\nfunction f() {\n  return 3 + 4  // OK: semicolon-less return with expression on the same line\n}\n</pre> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"../statements/return#Automatic_Semicolon_Insertion\">Automatic Semicolon Insertion</a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Stmt_after_return$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Stmt_after_return\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Stmt_after_return</a>\n  </p>\n</div>\n","global_objects/function/length":"<h1>Function.length</h1> <p>The <code><strong>length</strong></code> property indicates the number of Parameters expected by the function.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/function-length.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <div class=\"_table\"><table class=\"standard-table\"> <thead> <tr> <th colspan=\"2\" class=\"header\">Property attributes of <code>Function.length</code>\n</th> </tr> </thead> <tbody> <tr> <td>Writable</td> <td>no</td> </tr> <tr> <td>Enumerable</td> <td>no</td> </tr> <tr> <td>Configurable</td> <td>yes</td> </tr> </tbody> </table></div> <h2 id=\"Description\">Description</h2> <p><code>length</code> is a property of a function object, and indicates how many arguments the function expects, i.e. the number of formal parameters. This number excludes the <a href=\"../../functions/rest_parameters\">rest parameter</a> and only includes parameters before the first one with a default value. By contrast, <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/arguments/length\"><code>arguments.length</code></a> is local to a function and provides the number of arguments actually passed to the function.</p> <h3 id=\"Data_property_of_the_Function_constructor\">Data property of the <code>Function</code> constructor</h3> <p>The <a href=\"../function\"><code>Function</code></a> constructor is itself a <a href=\"../function\"><code>Function</code></a> object. Its <code>length</code> data property has a value of 1. The property attributes are: Writable: <code>false</code>, Enumerable: <code>false</code>, Configurable: <code>true</code>.</p> <h3 id=\"Property_of_the_Function_prototype_object\">Property of the <code>Function</code> prototype object</h3> <p>The length property of the <a href=\"../function\"><code>Function</code></a> prototype object has a value of 0.</p> <h2 id=\"Examples\">Examples</h2> <pre data-language=\"js\">console.log(Function.length); /* 1 */\n\nconsole.log((function()        {}).length); /* 0 */\nconsole.log((function(a)       {}).length); /* 1 */\nconsole.log((function(a, b)    {}).length); /* 2 etc. */\n\nconsole.log((function(...args) {}).length); \n// 0, rest parameter is not counted\n\nconsole.log((function(a, b = 1, c) {}).length);\n// 1, only parameters before the first one with \n// a default value is counted</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/publications/files/ECMA-ST-ARCH/ECMA-262,%201st%20edition,%20June%201997.pdf\" hreflang=\"en\">ECMAScript 1st Edition (ECMA-262)</a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition. Implemented in JavaScript 1.1.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/5.1/#sec-15.3.5.1\" hreflang=\"en\">ECMAScript 5.1 (ECMA-262)<br><small>The definition of 'Function.length' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-function-instances-length\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Function.length' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>The <code>configurable</code> attribute of this property is now <code>true</code>.</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-function-instances-length\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Function.length' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>   <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">Configurable: true</th>\n<td> ? </td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 37</td>\n<td> ? </td>\n<td> ? </td>\n<td> ? </td>\n</tr>\n</tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">Configurable: true</th>\n<td> ? </td>\n<td> ? </td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 37</td>\n<td> ? </td>\n<td> ? </td>\n<td> ? </td>\n</tr>\n</tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">Configurable: true</th>\n<td> ? </td>\n</tr>\n</tbody>\n</table>\n</div>  <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"../function\"><code>Function</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/length$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/length\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/length</a>\n  </p>\n</div>\n","global_objects/function/call":"<h1>function.call</h1> <p>The <code><strong>call()</strong></code> method calls a function with a given <code>this</code> value and arguments provided individually.</p> <div class=\"note\"> <p><strong>Note:</strong> While the syntax of this function is almost identical to that of <a href=\"apply\"><code>apply()</code></a>, the fundamental difference is that <code>call()</code> accepts an <strong>argument list</strong>, while <code>apply()</code> accepts a <strong>single array of arguments</strong>.</p> </div> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/function-call.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\"><var>function</var>.call(<var>thisArg</var>, <var>arg1</var>, <var>arg2</var>, ...)</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><code>thisArg</code></dt> <dd>Optional. The value of <code>this</code> provided for the call to a <code><var>function</var></code>. Note that <code>this</code> may not be the actual value seen by the method: if the method is a function in <a href=\"../../strict_mode\">non-strict mode</a>, <a href=\"../null\"><code>null</code></a> and <a href=\"../undefined\"><code>undefined</code></a> will be replaced with the global object and primitive values will be converted to objects.</dd> <dt><code>arg1, arg2, ...</code></dt> <dd>Optional. Arguments for the function.</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p>The result of calling the function with the specified <code><strong>this</strong></code> value and arguments.</p> <h2 id=\"Description\">Description</h2> <p>The <code>call()</code> allows for a function/method belonging to one object to be assigned and called for a different object.</p> <p><code>call()</code> provides a new value of <strong>this</strong> to the function/method. With <code>call</code>, you can write a method once and then inherit it in another object, without having to rewrite the method for the new object.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Using_call_to_chain_constructors_for_an_object\">Using <code>call</code> to chain constructors for an object</h3> <p>You can use <code>call</code> to chain constructors for an object, similar to Java. In the following example, the constructor for the <code>Product</code> object is defined with two parameters, <code>name</code> and <code>price</code>. Two other functions <code>Food</code> and <code>Toy</code> invoke <code>Product</code> passing <code>this</code> and <code>name</code> and <code>price</code>. Product initializes the properties <code>name</code> and <code>price</code>, both specialized functions define the <code>category</code>.</p> <pre data-language=\"js\">function Product(name, price) {\n  this.name = name;\n  this.price = price;\n}\n\nfunction Food(name, price) {\n  Product.call(this, name, price);\n  this.category = 'food';\n}\n\nfunction Toy(name, price) {\n  Product.call(this, name, price);\n  this.category = 'toy';\n}\n\nvar cheese = new Food('feta', 5);\nvar fun = new Toy('robot', 40);\n</pre> <h3 id=\"Using_call_to_invoke_an_anonymous_function\">Using <code>call</code> to invoke an anonymous function</h3> <p>In this example, we create an anonymous function and use <code>call</code> to invoke it on every object in an array. The main purpose of the anonymous function here is to add a print function to every object, which is able to print the right index of the object in the array. Passing the object as <code>this</code> value was not strictly necessary, but is done for explanatory purpose.</p> <pre data-language=\"js\">var animals = [\n  { species: 'Lion', name: 'King' },\n  { species: 'Whale', name: 'Fail' }\n];\n\nfor (var i = 0; i &lt; animals.length; i++) {\n  (function(i) {\n    this.print = function() {\n      console.log('#' + i + ' ' + this.species\n                  + ': ' + this.name);\n    }\n    this.print();\n  }).call(animals[i], i);\n}\n</pre> <h3 id=\"Using_call_to_invoke_a_function_and_specifying_the_context_for_'this'\">Using <code>call</code> to invoke a function and specifying the context for '<code>this</code>'</h3> <p>In the example below, when we call <code>greet</code>, the value of <code>this</code> will be bound to object <code>obj</code>.</p> <pre data-language=\"js\">function greet() {\n  var reply = [this.animal, 'typically sleep between', this.sleepDuration].join(' ');\n  console.log(reply);\n}\n\nvar obj = {\n  animal: 'cats', sleepDuration: '12 and 16 hours'\n};\n\ngreet.call(obj);  // cats typically sleep between 12 and 16 hours\n</pre> <h3 id=\"Using_call_to_invoke_a_function_and_without_specifying_the_first_argument\">Using <code>call</code> to invoke a function and without specifying the first argument</h3> <p>In the example below, we invoke the <code>display</code> function without passing the first argument. If the first argument is not passed, the value of <code>this</code> is bound to the global object.</p> <pre data-language=\"js\">var sData = 'Wisen';\n\nfunction display() {\n  console.log('sData value is %s ', this.sData);\n}\n\ndisplay.call();  // sData value is Wisen</pre> <div class=\"note\"> <p><strong>Note:</strong> The value of <code>this</code> will be <code>undefined</code> in strict mode. See below.</p> </div> <pre data-language=\"js\">'use strict';\n\nvar sData = 'Wisen';\n\nfunction display() {\n  console.log('sData value is %s ', this.sData);\n}\n\ndisplay.call(); // Cannot read the property of 'sData' of undefined</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <thead> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> </thead> <tbody> <tr> <td><a href=\"https://www.ecma-international.org/publications/files/ECMA-ST-ARCH/ECMA-262,%201st%20edition,%20June%201997.pdf\" hreflang=\"en\">ECMAScript 1st Edition (ECMA-262)</a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition. Implemented in JavaScript 1.3.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/5.1/#sec-15.3.4.4\" hreflang=\"en\">ECMAScript 5.1 (ECMA-262)<br><small>The definition of 'Function.prototype.call' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-function.prototype.call\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Function.prototype.call' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-function.prototype.call\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Function.prototype.call' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"bind\"><code>Function.prototype.bind()</code></a></li> <li><a href=\"apply\"><code>Function.prototype.apply()</code></a></li> <li> <p><a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Introduction_to_Object-Oriented_JavaScript\">Introduction to Object-Oriented JavaScript</a></p> </li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/call$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/call\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/call</a>\n  </p>\n</div>\n","errors/deprecated_expression_closures":"<h1>Errors: Deprecated expression closures</h1> <h2 id=\"Message\">Message</h2> <pre class=\"syntaxbox\">Warning: expression closures are deprecated\n</pre> <h2 id=\"Error_Type\">Error Type</h2> <p>Warning. JavaScript execution won't be halted.</p> <h2 id=\"What_went_wrong\">What went wrong?</h2> <p>The non-standard <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Expression_closures\">expression closure</a> syntax (shorthand function syntax) is deprecated and shouldn't be used anymore. This syntax will be removed entirely in <a href=\"https://bugzilla.mozilla.org/show_bug.cgi?id=1083458\">bug 1083458</a> and scripts using it will throw a <a href=\"../global_objects/syntaxerror\"><code>SyntaxError</code></a> then.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Deprecated_syntax\">Deprecated syntax</h3> <p>Expression closures omit curly braces or return statements from function declarations or from method definitions in objects.</p> <pre data-language=\"js\">var x = function() 1;\n\nvar obj = { \n  count: function() 1\n};\n</pre> <h3 id=\"Standard_syntax\">Standard syntax</h3> <p>To convert the non-standard expression closures syntax to standard ECMAScript syntax, you can add curly braces and return statements.</p> <pre data-language=\"js\">var x = function() { return 1; }\n\nvar obj = {\n  count: function() { return 1; }\n};\n</pre> <h3 id=\"Standard_syntax_using_arrow_functions\">Standard syntax using arrow functions</h3> <p>Alternatively, you can use <a href=\"../functions/arrow_functions\">arrow functions</a>:</p> <pre data-language=\"js\">var x = () =&gt; 1;</pre> <h3 id=\"Standard_syntax_using_shorthand_method_syntax\">Standard syntax using shorthand method syntax</h3> <p>Expression closures can also be found with getter and setter, like this:</p> <pre data-language=\"js\">var obj = {\n  get x() 1,\n  set x(v) this.v = v\n};\n</pre> <p>With ES2015 <a href=\"../functions/method_definitions\">method definitions</a>, this can be converted to:</p> <pre data-language=\"js\">var obj = { \n  get x() { return 1 }, \n  set x(v) { this.v = v } \n};\n</pre> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Expression_closures\">Expression closures</a></li> <li><a href=\"../functions/arrow_functions\">Arrow functions</a></li> <li><a href=\"../functions/method_definitions\">Method definitions</a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Deprecated_expression_closures$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Deprecated_expression_closures\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Deprecated_expression_closures</a>\n  </p>\n</div>\n","global_objects/function/prototype":"<h1>Function.prototype</h1> <p>The <code><strong>Function.prototype</strong></code> property represents the <a href=\"../function\"><code>Function</code></a> prototype object.</p> <h2 id=\"Description\">Description</h2> <p><a href=\"../function\"><code>Function</code></a> objects inherit from <code>Function.prototype</code>. <code>Function.prototype</code> cannot be modified.</p> <h2 id=\"Properties\">Properties</h2> <dl> <dt>\n<a href=\"arguments\"><code>Function.prototype.arguments</code></a> \n</dt> <dd>An array corresponding to the arguments passed to a function. This is deprecated as property of <a href=\"../function\"><code>Function</code></a>. Use the <a href=\"../../functions/arguments\"><code>arguments</code></a> object available within the function instead.</dd> <dt><s class=\"obsoleteElement\"><a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/arity\"><code>Function.arity</code></a> </s></dt> <dd><s class=\"obsoleteElement\">Used to specifiy the number of arguments expected by the function, but has been removed. Use the <a href=\"length\"><code>length</code></a> property instead.</s></dd> <dt>\n<a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/caller\"><code>Function.prototype.caller</code></a> \n</dt> <dd>Specifies the function that invoked the currently executing function.</dd> <dt><a href=\"length\"><code>Function.prototype.length</code></a></dt> <dd>Specifies the number of arguments expected by the function.</dd> <dt><a href=\"name\"><code>Function.prototype.name</code></a></dt> <dd>The name of the function.</dd> <dt>\n<a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/displayName\"><code>Function.displayName</code></a> \n</dt> <dd>The display name of the function.</dd> <dt><code>Function.prototype.constructor</code></dt> <dd>Specifies the function that creates an object's prototype. See <a href=\"../object/constructor\"><code>Object.prototype.constructor</code></a> for more details.</dd> </dl> <h2 id=\"Methods\">Methods</h2> <dl> <dt><a href=\"apply\"><code>Function.prototype.apply()</code></a></dt> <dd>Calls a function and sets its <em>this</em> to the provided value, arguments can be passed as an <a href=\"../array\"><code>Array</code></a> object.</dd> <dt><a href=\"bind\"><code>Function.prototype.bind()</code></a></dt> <dd>Creates a new function which, when called, has its <em>this</em> set to the provided value, with a given sequence of arguments preceding any provided when the new function was called.</dd> <dt><a href=\"call\"><code>Function.prototype.call()</code></a></dt> <dd>Calls (executes) a function and sets its <em>this</em> to the provided value, arguments can be passed as they are.</dd> <dt>\n<a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/isGenerator\"><code>Function.prototype.isGenerator()</code></a> \n</dt> <dd>Returns <code>true</code> if the function is a <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Iterators_and_Generators\">generator</a>; otherwise returns <code>false</code>.</dd> <dt>\n<a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/toSource\"><code>Function.prototype.toSource()</code></a> \n</dt> <dd>Returns a string representing the source code of the function. Overrides the <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/toSource\"><code>Object.prototype.toSource</code></a> method.</dd> <dt><a href=\"tostring\"><code>Function.prototype.toString()</code></a></dt> <dd>Returns a string representing the source code of the function. Overrides the <a href=\"../object/tostring\"><code>Object.prototype.toString</code></a> method.</dd> </dl> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/publications/files/ECMA-ST-ARCH/ECMA-262,%201st%20edition,%20June%201997.pdf\" hreflang=\"en\">ECMAScript 1st Edition (ECMA-262)</a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition. Implemented in JavaScript 1.1</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/5.1/#sec-15.3.5.2\" hreflang=\"en\">ECMAScript 5.1 (ECMA-262)<br><small>The definition of 'Function.prototype' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-function-instances-prototype\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Function.prototype' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-function-instances-prototype\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Function.prototype' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>   <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div>  <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"../function\"><code>Function</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/prototype$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/prototype\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/prototype</a>\n  </p>\n</div>\n","strict_mode/transitioning_to_strict_mode":"<h1>Strict mode: Transitioning to strict mode</h1> <p>ECMAScript 5 introduced <a href=\"https://developer.mozilla.org/en-US/docs/JavaScript/Strict_mode\">strict mode</a> which is now implemented in all major browsers (including IE10). While making web browsers interpret code as strict is easy (just add <code>'use strict';</code> at the top of your source code), transitioning an existing code base to strict mode requires a bit more work.</p> <p>This article aims at providing guidance for developers.</p> <h2 id=\"Gradual_transition\">Gradual transition</h2> <p>Strict mode has been designed so that the transition to it can be made gradually. It is possible to change each file individually and even to transition code to strict mode down to the function granularity.</p> <h2 id=\"Differences_from_non-strict_to_strict\">Differences from non-strict to strict</h2> <h3 id=\"Syntax_errors\">Syntax errors</h3> <p>When adding <code>'use strict';</code>, the following cases will throw a <a href=\"../global_objects/syntaxerror\"><code>SyntaxError</code></a> before the script is executing:</p> <ul> <li>Octal syntax <code>var n = 023;</code>\n</li> <li>\n<a href=\"../statements/with\"><code>with</code></a> statement</li> <li>Using <code><a href=\"../operators/delete\">delete</a></code> on a variable name <code>delete myVariable</code>;</li> <li>Using <a href=\"../global_objects/eval\"><code>eval</code></a> or <a href=\"../functions/arguments\"><code>arguments</code></a> as variable or function argument name</li> <li>Using one of the newly <a href=\"../lexical_grammar#Keywords\">reserved keywords</a> (in prevision for ECMAScript 2015): <code>implements</code>, <code>interface</code>, <code>let</code>, <code>package</code>, <code>private</code>, <code>protected</code>, <code>public</code>, <code>static</code>, and <code>yield</code>\n</li> <li>Declaring function in blocks <code>if (a &lt; b) { function f() {} }</code>\n</li> <li>Obvious errors <ul> <li>Declaring twice the same name for a property name in an object literal <code>{a: 1, b: 3, a: 7}</code> This is no longer the case in ECMAScript 2015 (<a href=\"https://bugzilla.mozilla.org/show_bug.cgi?id=1041128\">bug 1041128</a>).</li> <li>Declaring two function parameters with the same name <code>function f(a, b, b) {}</code>\n</li> </ul> </li> </ul> <p>These errors are good, because they reveal plain errors or bad practices. They occur before the code is running.</p> <h3 id=\"New_runtime_errors\">New runtime errors</h3> <p>JavaScript used to silently fail in contexts where what was done was an error. Strict mode throws in such cases. If your code base contains such cases, testing will be necessary to be sure nothing is broken. Once again, it can happen at the function granularity level.</p> <h4 id=\"Setting_a_value_to_an_undeclared_variable\">Setting a value to an undeclared variable</h4> <pre data-language=\"js\">function f(x) {\n  'use strict';\n  var a = 12;\n  b = a + x * 35; // error!\n}\nf(42);\n</pre> <p>This used to change a value on the global object which is rarely the expected effect. If you really want to set a value to the global object, pass it as an argument and explicitly assign it as a property:</p> <pre data-language=\"js\">var global = this; // in the top-level context, \"this\" always\n                   // refers to the global object\nfunction f(x) {\n  'use strict';\n  var a = 12;\n  global.b = a + x * 35;\n}\nf(42);\n</pre> <h4 id=\"Trying_to_delete_a_non-configurable_property\">Trying to delete a non-configurable property</h4> <pre data-language=\"js\">'use strict';\ndelete Object.prototype; // error!\n</pre> <p>In non-strict, this would silently fail, in contradiction with the user expectation.</p> <h4 id=\"Poisoned_arguments_and_function_properties\">Poisoned arguments and function properties</h4> <p>Accessing <code>arguments.callee</code>, <code>arguments.caller</code>, <code>anyFunction.caller</code>, or <code>anyFunction.arguments</code> throws an error in strict mode. The only legitimate use case would be to reuse a function as in:</p> <pre data-language=\"js\">// example taken from vanillajs: http://vanilla-js.com/\nvar s = document.getElementById('thing').style;\ns.opacity = 1;\n(function() { \n  if ((s.opacity-=.1) &lt; 0)\n    s.display = 'none';\n  else\n    setTimeout(arguments.callee, 40);\n})();</pre> <p>which can be rewritten as:</p> <pre data-language=\"js\">'use strict';\nvar s = document.getElementById('thing').style;\ns.opacity = 1;\n(function fadeOut() { // name the function\n  if((s.opacity-=.1) &lt; 0)\n    s.display = 'none';\n  else\n    setTimeout(fadeOut, 40); // use the name of the function\n})();</pre> <h3 id=\"Semantic_differences\">Semantic differences</h3> <p>These differences are very subtle differences. It's possible that a test suite doesn't catch this kind of subtle difference. Careful review of your code base will probably be necessary to be sure these differences don't affect the semantics of your code. Fortunately, this careful review can be done gradually down the function granularity.</p> <h4 id=\"this_in_function_calls\">\n<code>this</code> in function calls</h4> <p>In function calls like <code>f()</code>, the <code>this</code> value was the global object. In strict mode, it is now <code>undefined</code>. When a function was called with <code><a href=\"../global_objects/function/call\">call</a></code> or <code><a href=\"../global_objects/function/apply\">apply</a></code>, if the value was a primitive value, this one was boxed into an object (or the global object for <code>undefined</code> and <code>null</code>). In strict mode, the value is passed directly without conversion or replacement.</p> <h4 id=\"arguments_doesn't_alias_named_function_arguments\">\n<code>arguments</code> doesn't alias named function arguments</h4> <p>In non-strict mode, modifying a value in the <code>arguments</code> object modifies the corresponding named argument. This made optimizations complicated for JavaScript engine and made code harder to read/understand. In strict mode, the <code>arguments</code> object is created and initialized with the same values than the named arguments, but changes to either the <code>arguments</code> object or the named arguments aren't reflected in one another.</p> <h4 id=\"Change_to_eval\">Change to <code>eval</code>\n</h4> <p>In strict mode code, <code>eval</code> doesn't create a new variable in the scope from which it was called. Also, of course, in strict mode, the string is evaluated with strict mode rules. Thorough testing will need to be performed to make sure nothing breaks. Not using eval if you don't really need it may be another pragmatic solution.</p> <h2 id=\"Strictness-neutral_code\">Strictness-neutral code</h2> <p>A potential \"downside\" of moving strict code to strict mode is that the semantics may be different in legacy browsers which do not implement strict mode. In some rare occasions (like bad concatenation or minification), your code also may not run in the mode you wrote and tested it in. Here are the rules to make your code strictness-neutral:</p> <ol> <li>Write your code as strict and make sure no strict-only errors (from the above \"New runtime errors\" section) are thrown.</li> <li>Stay away from semantic differences <ol> <li>\n<code>eval</code>: use it only if you know what you're doing</li> <li>\n<code>arguments</code>: always access function arguments via their name or perform a copy of the arguments object using:<br> <code>var args = Array.prototype.slice.call(arguments)</code><br> as the first line of your function</li> <li>\n<code>this</code>: only use <code>this</code> when it refers to an object you created.</li> </ol> </li> </ol> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"../strict_mode\">Strict mode</a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Strict_mode/Transitioning_to_strict_mode$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Strict_mode/Transitioning_to_strict_mode\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Strict_mode/Transitioning_to_strict_mode</a>\n  </p>\n</div>\n","global_objects/webassembly/table":"<h1>WebAssembly.table</h1> <p>The <code><strong>WebAssembly.Table()</strong></code> constructor creates a new <code>Table</code> object of the given size and element type.</p> <p>This is a JavaScript wrapper object — an array-like structure representing a WebAssembly Table, which stores function references. A table created by JavaScript or in WebAssembly code will be accessible and mutable from both JavaScript and WebAssembly.</p> <div class=\"note\"> <p><strong>Note</strong>: Tables can currently only store function references, but this will likely be expanded in the future.</p> </div> <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\">var myTable = new WebAssembly.Table(tableDescriptor);</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><em>tableDescriptor</em></dt> <dd>An object that can contain the following members: <dl> <dt><em>element</em></dt> <dd>A string representing the type of value to be stored in the table. At the moment this can only have a value of <code>\"anyfunc\"</code> (functions).</dd> <dt><em>initial</em></dt> <dd>The initial number of elements of the WebAssembly Table.</dd> <dt><em>maximum <span class=\"inlineIndicator optional optionalInline\">Optional</span></em></dt> <dd>The maximum number of elements the WebAssembly Table is allowed to grow to.</dd> </dl> </dd> </dl> <h3 id=\"Exceptions\">Exceptions</h3> <ul> <li>If <code>tableDescriptor</code> is not of type object, a <a href=\"../typeerror\"><code>TypeError</code></a> is thrown.</li> <li>If <code>maximum</code> is specified and is smaller than <code>initial</code>, a <a href=\"../rangeerror\"><code>RangeError</code></a> is thrown.</li> </ul> <h2 id=\"Table_instances\">\n<code>Table</code> instances</h2> <p>All <code>Table</code> instances inherit from the <code>Table()</code> constructor's <a href=\"table/prototype\">prototype object</a> — this can be modified to affect all <code>Table</code> instances.</p> <h3 id=\"Instance_properties\">Instance properties</h3> <dl> <dt><code>Table.prototype.constructor</code></dt> <dd>Returns the function that created this object's instance. By default this is the <a href=\"table\"><code>WebAssembly.Table()</code></a> constructor.</dd> <dt><a href=\"table/length\"><code>Table.prototype.length</code></a></dt> <dd>Returns the length of the table, i.e. the number of elements.</dd> </dl> <h3 id=\"Instance_methods\">Instance methods</h3> <dl> <dt><a href=\"table/get\"><code>Table.prototype.get()</code></a></dt> <dd>Accessor function — gets the element stored at a given index.</dd> <dt><a href=\"table/grow\"><code>Table.prototype.grow()</code></a></dt> <dd>Increases the size of the Table instance by a specified number of elements.</dd> <dt><a href=\"table/set\"><code>Table.prototype.set()</code></a></dt> <dd>Sets an element stored at a given index to a given value.</dd> </dl> <h2 id=\"Examples\">Examples</h2> <p>The following example (see table2.html <a href=\"https://github.com/mdn/webassembly-examples/blob/master/js-api-examples/table2.html\">source code</a> and <a href=\"https://mdn.github.io/webassembly-examples/js-api-examples/table2.html\">live version</a>) creates a new WebAssembly Table instance with an initial size of 2 elements. We then print out the table length and contents of the two indexes (retrieved via <a href=\"table/get\"><code>Table.prototype.get()</code></a> to show that the length is two and both elements are <a href=\"../null\"><code>null</code></a>.</p> <pre data-language=\"js\">var tbl = new WebAssembly.Table({initial:2, element:\"anyfunc\"});\nconsole.log(tbl.length);  // \"2\"\nconsole.log(tbl.get(0));  // \"null\"\nconsole.log(tbl.get(1));  // \"null\"</pre> <p>We then create an import object that contains the table:</p> <pre data-language=\"js\">var importObj = {\n  js: {\n    tbl:tbl\n  }\n};</pre> <p>Finally, we load and instantiate a wasm module (table2.wasm) using the <a href=\"instantiatestreaming\"><code>WebAssembly.instantiateStreaming()</code></a> method. The table2.wasm module contains two functions (one that returns 42 and another that returns 83) and stores both into elements 0 and 1 of the imported table (see <a href=\"https://github.com/mdn/webassembly-examples/blob/master/js-api-examples/table2.wat\">text representation</a>). So after instantiation, the table still has length 2, but the elements now contain callable <a href=\"https://developer.mozilla.org/en-US/docs/WebAssembly/Exported_functions\">Exported WebAssembly Functions</a> which we can call from JS.</p> <pre data-language=\"js\">WebAssembly.instantiateStreaming(fetch('table2.wasm'), importObject)\n.then(function(obj) {\n  console.log(tbl.length);\n  console.log(tbl.get(0)());\n  console.log(tbl.get(1)());\n});</pre> <p>Note how you've got to include a second function invocation operator at the end of the accessor to actually invoke the referenced function and log the value stored inside it (e.g. <code>get(0)()</code> rather than <code>get(0)</code>) .</p> <p>This example shows that we're creating and accessing the table from JavaScript, but the same table is visible and callable inside the wasm instance too.</p> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <thead> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> </thead> <tbody> <tr> <td><a href=\"https://webassembly.github.io/spec/js-api/#webassemblytable-objects\" hreflang=\"en\">WebAssembly JavaScript Interface<br><small>The definition of 'Table' in that specification.</small></a></td> <td><span class=\"spec-WD\">Working Draft</span></td> <td>Initial draft definition.</td> </tr> </tbody> </table></div> <h2 name=\"Browser_compatibility\" id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>   <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 57</td>\n<td class=\"bc-supports-yes\"> 16</td>\n<td class=\"bc-supports-yes bc-has-history\"> 52\n<section class=\"bc-history\" id=\"sect1\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 52\n</dt>\n<dd> Disabled in the Firefox 52 Extended Support Release (ESR).</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 44</td>\n<td class=\"bc-supports-yes\"> 11</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Table/get\"><code>get</code></a></th>\n<td class=\"bc-supports-yes\"> 57</td>\n<td class=\"bc-supports-yes\"> 16</td>\n<td class=\"bc-supports-yes bc-has-history\"> 52\n<section class=\"bc-history\" id=\"sect4\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 52\n</dt>\n<dd> Disabled in the Firefox 52 Extended Support Release (ESR).</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 44</td>\n<td class=\"bc-supports-yes\"> 11</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Table/grow\"><code>grow</code></a></th>\n<td class=\"bc-supports-yes\"> 57</td>\n<td class=\"bc-supports-yes\"> 16</td>\n<td class=\"bc-supports-yes bc-has-history\"> 52\n<section class=\"bc-history\" id=\"sect7\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 52\n</dt>\n<dd> Disabled in the Firefox 52 Extended Support Release (ESR).</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 44</td>\n<td class=\"bc-supports-yes\"> 11</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Table/length\"><code>length</code></a></th>\n<td class=\"bc-supports-yes\"> 57</td>\n<td class=\"bc-supports-yes\"> 16</td>\n<td class=\"bc-supports-yes bc-has-history\"> 52\n<section class=\"bc-history\" id=\"sect10\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 52\n</dt>\n<dd> Disabled in the Firefox 52 Extended Support Release (ESR).</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 44</td>\n<td class=\"bc-supports-yes\"> 11</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Table/prototype\"><code>prototype</code></a></th>\n<td class=\"bc-supports-yes\"> 57</td>\n<td class=\"bc-supports-yes\"> 16</td>\n<td class=\"bc-supports-yes bc-has-history\"> 52\n<section class=\"bc-history\" id=\"sect13\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 52\n</dt>\n<dd> Disabled in the Firefox 52 Extended Support Release (ESR).</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 44</td>\n<td class=\"bc-supports-yes\"> 11</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Table/set\"><code>set</code></a></th>\n<td class=\"bc-supports-yes\"> 57</td>\n<td class=\"bc-supports-yes\"> 16</td>\n<td class=\"bc-supports-yes bc-has-history\"> 52\n<section class=\"bc-history\" id=\"sect16\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 52\n</dt>\n<dd> Disabled in the Firefox 52 Extended Support Release (ESR).</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 44</td>\n<td class=\"bc-supports-yes\"> 11</td>\n</tr>\n</tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 57</td>\n<td class=\"bc-supports-yes\"> 57</td>\n<td class=\"bc-supports-yes bc-has-history\"> Yes<div class=\"bc-icons\">Disabled </div>\n<section class=\"bc-history\" id=\"sect2\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> Yes<div class=\"bc-icons\">Disabled </div>\n</dt>\n<dd>Disabled This feature is behind the <code>Experimental JavaScript Features</code> preference.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-yes bc-has-history\"> 52\n<section class=\"bc-history\" id=\"sect3\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 52\n</dt>\n<dd> Disabled in the Firefox 52 Extended Support Release (ESR).</dd>\n</dl></section>\n</td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 11</td>\n<td class=\"bc-supports-yes\"> 7.0</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Table/get\"><code>get</code></a></th>\n<td class=\"bc-supports-yes\"> 57</td>\n<td class=\"bc-supports-yes\"> 57</td>\n<td class=\"bc-supports-yes bc-has-history\"> Yes<div class=\"bc-icons\">Disabled </div>\n<section class=\"bc-history\" id=\"sect5\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> Yes<div class=\"bc-icons\">Disabled </div>\n</dt>\n<dd>Disabled This feature is behind the <code>Experimental JavaScript Features</code> preference.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-yes bc-has-history\"> 52\n<section class=\"bc-history\" id=\"sect6\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 52\n</dt>\n<dd> Disabled in the Firefox 52 Extended Support Release (ESR).</dd>\n</dl></section>\n</td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 11</td>\n<td class=\"bc-supports-yes\"> 7.0</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Table/grow\"><code>grow</code></a></th>\n<td class=\"bc-supports-yes\"> 57</td>\n<td class=\"bc-supports-yes\"> 57</td>\n<td class=\"bc-supports-yes bc-has-history\"> Yes<div class=\"bc-icons\">Disabled </div>\n<section class=\"bc-history\" id=\"sect8\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> Yes<div class=\"bc-icons\">Disabled </div>\n</dt>\n<dd>Disabled This feature is behind the <code>Experimental JavaScript Features</code> preference.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-yes bc-has-history\"> 52\n<section class=\"bc-history\" id=\"sect9\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 52\n</dt>\n<dd> Disabled in the Firefox 52 Extended Support Release (ESR).</dd>\n</dl></section>\n</td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 11</td>\n<td class=\"bc-supports-yes\"> 7.0</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Table/length\"><code>length</code></a></th>\n<td class=\"bc-supports-yes\"> 57</td>\n<td class=\"bc-supports-yes\"> 57</td>\n<td class=\"bc-supports-yes bc-has-history\"> Yes<div class=\"bc-icons\">Disabled </div>\n<section class=\"bc-history\" id=\"sect11\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> Yes<div class=\"bc-icons\">Disabled </div>\n</dt>\n<dd>Disabled This feature is behind the <code>Experimental JavaScript Features</code> preference.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-yes bc-has-history\"> 52\n<section class=\"bc-history\" id=\"sect12\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 52\n</dt>\n<dd> Disabled in the Firefox 52 Extended Support Release (ESR).</dd>\n</dl></section>\n</td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 11</td>\n<td class=\"bc-supports-yes\"> 7.0</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Table/prototype\"><code>prototype</code></a></th>\n<td class=\"bc-supports-yes\"> 57</td>\n<td class=\"bc-supports-yes\"> 57</td>\n<td class=\"bc-supports-yes bc-has-history\"> Yes<div class=\"bc-icons\">Disabled </div>\n<section class=\"bc-history\" id=\"sect14\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> Yes<div class=\"bc-icons\">Disabled </div>\n</dt>\n<dd>Disabled This feature is behind the <code>Experimental JavaScript Features</code> preference.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-yes bc-has-history\"> 52\n<section class=\"bc-history\" id=\"sect15\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 52\n</dt>\n<dd> Disabled in the Firefox 52 Extended Support Release (ESR).</dd>\n</dl></section>\n</td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 11</td>\n<td class=\"bc-supports-yes\"> 7.0</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Table/set\"><code>set</code></a></th>\n<td class=\"bc-supports-yes\"> 57</td>\n<td class=\"bc-supports-yes\"> 57</td>\n<td class=\"bc-supports-yes bc-has-history\"> Yes<div class=\"bc-icons\">Disabled </div>\n<section class=\"bc-history\" id=\"sect17\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> Yes<div class=\"bc-icons\">Disabled </div>\n</dt>\n<dd>Disabled This feature is behind the <code>Experimental JavaScript Features</code> preference.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-yes bc-has-history\"> 52\n<section class=\"bc-history\" id=\"sect18\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 52\n</dt>\n<dd> Disabled in the Firefox 52 Extended Support Release (ESR).</dd>\n</dl></section>\n</td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 11</td>\n<td class=\"bc-supports-yes\"> 7.0</td>\n</tr>\n</tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 8.0.0</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Table/get\"><code>get</code></a></th>\n<td class=\"bc-supports-yes\"> 8.0.0</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Table/grow\"><code>grow</code></a></th>\n<td class=\"bc-supports-yes\"> 8.0.0</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Table/length\"><code>length</code></a></th>\n<td class=\"bc-supports-yes\"> 8.0.0</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Table/prototype\"><code>prototype</code></a></th>\n<td class=\"bc-supports-yes\"> 8.0.0</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Table/set\"><code>set</code></a></th>\n<td class=\"bc-supports-yes\"> 8.0.0</td>\n</tr>\n</tbody>\n</table>\n</div>  <h2 id=\"See_also\">See also</h2> <ul> <li>\n<a href=\"https://developer.mozilla.org/en-US/docs/WebAssembly\">WebAssembly</a> overview page</li> <li><a href=\"https://developer.mozilla.org/en-US/docs/WebAssembly/Concepts\">WebAssembly concepts</a></li> <li><a href=\"https://developer.mozilla.org/en-US/docs/WebAssembly/Using_the_JavaScript_API\">Using the WebAssembly JavaScript API</a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Table$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Table\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Table</a>\n  </p>\n</div>\n","global_objects/function/bind":"<h1>function.bind</h1> <p>The <code><strong>bind()</strong></code> method creates a new function that, when called, has its <code>this</code> keyword set to the provided value, with a given sequence of arguments preceding any provided when the new function is called.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/function-bind.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js taller\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\"><var>function</var>.bind(<var>thisArg</var>[, <var>arg1</var>[, <var>arg2</var>[, ...]]])</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><code>thisArg</code></dt> <dd>The value to be passed as the <code>this</code> parameter to the target function when the bound function is called. The value is ignored if the bound function is constructed using the <a href=\"../../operators/new\"><code>new</code></a> operator. When using <code>bind</code> to create a function(supplied as a callback) inside a <code>setTimeout</code>, any primitive value passed as <code>thisArg</code> is converted to object. If no arguments are provided to <code>bind</code>, the <code>this</code> of the executing scope is treated as the <code>thisArg</code> for the new function.</dd> <dt><code>arg1, arg2, ...</code></dt> <dd>Arguments to prepend to arguments provided to the bound function when invoking the target function.</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p>A copy of the given function with the specified <code>this</code> value and initial arguments.</p> <h2 id=\"Description\">Description</h2> <p>The <strong>bind()</strong> function creates a new <strong>bound function</strong> <strong>(BF)</strong>. A <strong>BF</strong> is an <strong>exotic function object</strong> (a term from <strong>ECMAScript 2015</strong>) that wraps the original function object. Calling a <strong>BF</strong> generally results in the execution of its <strong>wrapped function</strong>.<br> A<strong> BF</strong> has the following internal properties:</p> <ul> <li>\n<strong>[[BoundTargetFunction]] </strong>- the wrapped function object;</li> <li>\n<strong>[[BoundThis]]</strong> - the value that is always passed as <strong>this</strong> value when calling the wrapped function.</li> <li>\n<strong>[[BoundArguments]]</strong> - a list of values whose elements are used as the first arguments to any call to the wrapped function.</li> <li>\n<strong>[[Call]]</strong> - executes code associated with this object. Invoked via a function call expression. The arguments to the internal method are a <strong>this</strong> value and a list containing the arguments passed to the function by a call expression.</li> </ul> <p>When bound function is called, it calls internal method<strong> [[Call]]</strong> on <strong>[[BoundTargetFunction]], </strong>with following arguments <strong>Call(<em>boundThis</em>, <em>args</em>).</strong> Where, <strong><em>boundThis </em></strong>is <strong>[[BoundThis]]</strong>, <em><strong>args </strong></em>is <strong>[[BoundArguments]]</strong> followed by the arguments passed by the function call.</p> <p>A bound function may also be constructed using the <a href=\"../../operators/new\"><code>new</code></a> operator: doing so acts as though the target function had instead been constructed. The provided <code>this</code> value is ignored, while prepended arguments are provided to the emulated function.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Creating_a_bound_function\">Creating a bound function</h3> <p>The simplest use of <code>bind()</code> is to make a function that, no matter how it is called, is called with a particular <code>this</code> value. A common mistake for new JavaScript programmers is to extract a method from an object, then to later call that function and expect it to use the original object as its <code>this</code> (e.g. by using that method in callback-based code). Without special care, however, the original object is usually lost. Creating a bound function from the function, using the original object, neatly solves this problem:</p> <pre data-language=\"js\">this.x = 9;    // this refers to global \"window\" object here in the browser\nvar module = {\n  x: 81,\n  getX: function() { return this.x; }\n};\n\nmodule.getX(); // 81\n\nvar retrieveX = module.getX;\nretrieveX();   \n// returns 9 - The function gets invoked at the global scope\n\n// Create a new function with 'this' bound to module\n// New programmers might confuse the\n// global var x with module's property x\nvar boundGetX = retrieveX.bind(module);\nboundGetX(); // 81\n</pre> <h3 id=\"Partially_applied_functions\">Partially applied functions</h3> <p>The next simplest use of <code>bind()</code> is to make a function with pre-specified initial arguments. These arguments (if any) follow the provided <code>this</code> value and are then inserted at the start of the arguments passed to the target function, followed by the arguments passed to the bound function, whenever the bound function is called.</p> <pre data-language=\"js\">function list() {\n  return Array.prototype.slice.call(arguments);\n}\n\nfunction addArguments(arg1, arg2) {\n    return arg1 + arg2\n}\n\nvar list1 = list(1, 2, 3); // [1, 2, 3]\n\nvar result1 = addArguments(1, 2); // 3\n\n// Create a function with a preset leading argument\nvar leadingThirtysevenList = list.bind(null, 37);\n\n// Create a function with a preset first argument.\nvar addThirtySeven = addArguments.bind(null, 37); \n\nvar list2 = leadingThirtysevenList(); \n// [37]\n\nvar list3 = leadingThirtysevenList(1, 2, 3); \n// [37, 1, 2, 3]\n\nvar result2 = addThirtySeven(5); \n// 37 + 5 = 42 \n\nvar result3 = addThirtySeven(5, 10);\n// 37 + 5 = 42 , second argument is ignored\n\n</pre>  <h3 id=\"With_setTimeout\">With <code>setTimeout</code>\n</h3> <p>By default within <a href=\"https://developer.mozilla.org/en-US/docs/Web/API/Window/setTimeout\"><code>window.setTimeout()</code></a>, the <code>this</code> keyword will be set to the <a href=\"https://developer.mozilla.org/en-US/docs/Web/API/Window\"><code>window</code></a> (or <code>global</code>) object. When working with class methods that require <code>this</code> to refer to class instances, you may explicitly bind <code>this</code> to the callback function, in order to maintain the instance.</p> <pre data-language=\"js\">function LateBloomer() {\n  this.petalCount = Math.floor(Math.random() * 12) + 1;\n}\n\n// Declare bloom after a delay of 1 second\nLateBloomer.prototype.bloom = function() {\n  window.setTimeout(this.declare.bind(this), 1000);\n};\n\nLateBloomer.prototype.declare = function() {\n  console.log('I am a beautiful flower with ' +\n    this.petalCount + ' petals!');\n};\n\nvar flower = new LateBloomer();\nflower.bloom();  \n// after 1 second, triggers the 'declare' method</pre> <h3 id=\"Bound_functions_used_as_constructors\">Bound functions used as constructors</h3> <div class=\"warning\"> <p><strong>Warning:</strong> This section demonstrates JavaScript capabilities and documents some edge cases of the <code>bind()</code> method. The methods shown below are not the best way to do things and probably should not be used in any production environment.</p> </div> <p>Bound functions are automatically suitable for use with the <a href=\"../../operators/new\"><code>new</code></a> operator to construct new instances created by the target function. When a bound function is used to construct a value, the provided <code>this</code> is ignored. However, provided arguments are still prepended to the constructor call:</p> <pre data-language=\"js\">function Point(x, y) {\n  this.x = x;\n  this.y = y;\n}\n\nPoint.prototype.toString = function() { \n  return this.x + ',' + this.y; \n};\n\nvar p = new Point(1, 2);\np.toString(); // '1,2'\n\n// not supported in the polyfill below,\n\n// works fine with native bind:\n\nvar YAxisPoint = Point.bind(null, 0/*x*/);\n\n\nvar emptyObj = {};\nvar YAxisPoint = Point.bind(emptyObj, 0/*x*/);\n\nvar axisPoint = new YAxisPoint(5);\naxisPoint.toString(); // '0,5'\n\naxisPoint instanceof Point; // true\naxisPoint instanceof YAxisPoint; // true\nnew Point(17, 42) instanceof YAxisPoint; // true\n</pre> <p>Note that you need do nothing special to create a bound function for use with <a href=\"../../operators/new\"><code>new</code></a>. The corollary is that you need do nothing special to create a bound function to be called plainly, even if you would rather require the bound function to only be called using <a href=\"../../operators/new\"><code>new</code></a>.</p> <pre data-language=\"js\">// Example can be run directly in your JavaScript console\n// ...continuing from above\n\n// Can still be called as a normal function \n// (although usually this is undesired)\nYAxisPoint(13);\n\nemptyObj.x + ',' + emptyObj.y;\n// &gt;  '0,13'\n</pre> <p>If you wish to support the use of a bound function only using <a href=\"../../operators/new\"><code>new</code></a>, or only by calling it, the target function must enforce that restriction.</p> <h3 id=\"Creating_shortcuts\">Creating shortcuts</h3> <p><code>bind()</code> is also helpful in cases where you want to create a shortcut to a function which requires a specific <code>this</code> value.</p> <p>Take <a href=\"../array/slice\"><code>Array.prototype.slice</code></a>, for example, which you want to use for converting an array-like object to a real array. You could create a shortcut like this:</p> <pre data-language=\"js\">var slice = Array.prototype.slice;\n\n// ...\n\nslice.apply(arguments);\n</pre> <p>With <code>bind()</code>, this can be simplified. In the following piece of code, <code>slice</code> is a bound function to the <a href=\"apply\"><code>apply()</code></a> function of <a href=\"prototype\"><code>Function.prototype</code></a>, with the <code>this</code> value set to the <a href=\"../array/slice\"><code>slice()</code></a> function of <a href=\"../array/prototype\"><code>Array.prototype</code></a>. This means that additional <code>apply()</code> calls can be eliminated:</p> <pre data-language=\"js\">// same as \"slice\" in the previous example\nvar unboundSlice = Array.prototype.slice;\nvar slice = Function.prototype.apply.bind(unboundSlice);\n\n// ...\n\nslice(arguments);\n</pre> <h2 id=\"Polyfill\">Polyfill</h2> <p>You can partially work around this by inserting the following code at the beginning of your scripts, allowing use of much of the functionality of <code>bind()</code> in implementations that do not natively support it.</p> <pre data-language=\"js\">if (!Function.prototype.bind) {\n  Function.prototype.bind = function(oThis) {\n    if (typeof this !== 'function') {\n      // closest thing possible to the ECMAScript 5\n      // internal IsCallable function\n      throw new TypeError('Function.prototype.bind - what is trying to be bound is not callable');\n    }\n\n    var aArgs   = Array.prototype.slice.call(arguments, 1),\n        fToBind = this,\n        fNOP    = function() {},\n        fBound  = function() {\n          return fToBind.apply(this instanceof fNOP\n                 ? this\n                 : oThis,\n                 aArgs.concat(Array.prototype.slice.call(arguments)));\n        };\n\n    if (this.prototype) {\n      // Function.prototype doesn't have a prototype property\n      fNOP.prototype = this.prototype; \n    }\n    fBound.prototype = new fNOP();\n\n    return fBound;\n  };\n}\n</pre> <p>Some of the many differences (there may well be others, as this list does not seriously attempt to be exhaustive) between this algorithm and the specified algorithm are:</p> <ul> <li>The partial implementation relies on <a href=\"../array/slice\"><code>Array.prototype.slice()</code></a>, <a href=\"../array/concat\"><code>Array.prototype.concat()</code></a>, <a href=\"call\"><code>Function.prototype.call()</code></a> and <a href=\"apply\"><code>Function.prototype.apply()</code></a>, built-in methods to have their original values.</li> <li>The partial implementation creates functions that do not have immutable \"poison pill\" <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/caller\"><code>caller</code></a> and <code>arguments</code> properties that throw a <a href=\"../typeerror\"><code>TypeError</code></a> upon get, set, or deletion. (This could be added if the implementation supports <a href=\"../object/defineproperty\"><code>Object.defineProperty</code></a>, or partially implemented [without throw-on-delete behavior] if the implementation supports the <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/defineGetter\"><code>__defineGetter__</code></a> and <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/defineSetter\"><code>__defineSetter__</code></a> extensions.)</li> <li>The partial implementation creates functions that have a <code>prototype</code> property. (Proper bound functions have none.)</li> <li>The partial implementation creates bound functions whose <a href=\"length\"><code>length</code></a> property does not agree with that mandated by ECMA-262: it creates functions with length 0, while a full implementation, depending on the length of the target function and the number of pre-specified arguments, may return a non-zero length.</li> </ul> <p>If you choose to use this partial implementation, <strong>you must not rely on those cases where behavior deviates from ECMA-262, 5th edition!</strong> With some care, however (and perhaps with additional modification to suit specific needs), this partial implementation may be a reasonable bridge to the time when <code>bind()</code> is widely implemented according to the specification.</p> <p>Please check <a href=\"https://github.com/Raynos/function-bind\">https://github.com/Raynos/function-bind</a> for a more thorough solution!</p> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/5.1/#sec-15.3.4.5\" hreflang=\"en\">ECMAScript 5.1 (ECMA-262)<br><small>The definition of 'Function.prototype.bind' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition. Implemented in JavaScript 1.8.5.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-function.prototype.bind\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Function.prototype.bind' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-function.prototype.bind\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Function.prototype.bind' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>   <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 7</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> 9</td>\n<td class=\"bc-supports-yes\"> 11.6</td>\n<td class=\"bc-supports-yes\"> 5.1</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> 18</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> 11.5</td>\n<td class=\"bc-supports-yes\"> 6</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div>  <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"apply\"><code>Function.prototype.apply()</code></a></li> <li><a href=\"call\"><code>Function.prototype.call()</code></a></li> <li><a href=\"../../functions\">Functions</a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/bind$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/bind\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/bind</a>\n  </p>\n</div>\n","template_literals":"<h1>Template literals</h1> <p>Template literals are string literals allowing embedded expressions. You can use multi-line strings and string interpolation features with them. They were called \"template strings\" in prior editions of the ES2015 specification.</p> <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\">`string text`\n\n`string text line 1\n string text line 2`\n\n`string text ${expression} string text`\n\ntag `string text ${expression} string text`\n</pre> <h2 id=\"Description\">Description</h2> <p>Template literals are enclosed by the back-tick (` `) (<a href=\"https://en.wikipedia.org/wiki/Grave_accent\">grave accent</a>) character instead of double or single quotes. Template literals can contain placeholders. These are indicated by the dollar sign and curly braces (<code>${expression}</code>). The expressions in the placeholders and the text between them get passed to a function. The default function just concatenates the parts into a single string. If there is an expression preceding the template literal (<code>tag</code> here), this is called a \"tagged template\". In that case, the tag expression (usually a function) gets called with the processed template literal, which you can then manipulate before outputting. To escape a back-tick in a template literal, put a backslash <strong>\\ </strong>before the back-tick.</p> <pre data-language=\"js\">`\\`` === '`' // --&gt; true</pre> <h3 id=\"Multi-line_strings\">Multi-line strings</h3> <p>Any newline characters inserted in the source are part of the template literal. Using normal strings, you would have to use the following syntax in order to get multi-line strings:</p> <pre data-language=\"js\">console.log('string text line 1\\n' +\n'string text line 2');\n// \"string text line 1\n// string text line 2\"</pre> <p>To get the same effect using template literals, you can now write:</p> <pre data-language=\"js\">console.log(`string text line 1\nstring text line 2`);\n// \"string text line 1\n// string text line 2\"</pre> <h3 id=\"Expression_interpolation\">Expression interpolation</h3> <p>In order to embed expressions within normal strings, you would use the following syntax:</p> <pre data-language=\"js\">var a = 5;\nvar b = 10;\nconsole.log('Fifteen is ' + (a + b) + ' and\\nnot ' + (2 * a + b) + '.');\n// \"Fifteen is 15 and\n// not 20.\"</pre> <p>Now, with template literals, you are able to make use of the syntactic sugar making substitutions like this more readable:</p> <pre data-language=\"js\">var a = 5;\nvar b = 10;\nconsole.log(`Fifteen is ${a + b} and\nnot ${2 * a + b}.`);\n// \"Fifteen is 15 and\n// not 20.\"</pre> <h3 id=\"Nesting_templates\">Nesting templates</h3> <p>In certain times, nesting a template is the easiest and perhaps more readable way to have configurable strings. Within a backticked template it is simple to allow inner backticks simply by using them inside a placeholder <code>${ }</code> within the template. For instance, if condition a is true: then return this templated literal.</p> <p>In ES5:</p> <pre data-language=\"js\">var classes = 'header'\nclasses += (isLargeScreen() ?\n   '' : item.isCollapsed ?\n     ' icon-expander' : ' icon-collapser');\n</pre> <p>In ES2015 with template literals and without nesting:</p> <pre data-language=\"js\">const classes = `header ${ isLargeScreen() ? '' :\n    (item.isCollapsed ? 'icon-expander' : 'icon-collapser') }`;</pre> <p>In ES2015 with nested template literals:</p> <pre data-language=\"js\">const classes = `header $<strong>{</strong> isLargeScreen() ? '' :\n `icon-${item.isCollapsed ? 'expander' : 'collapser'}`<strong>}`</strong>;</pre> <h3 id=\"Tagged_templates\">Tagged templates</h3> <p>A more advanced form of template literals are <em>tagged</em> templates. Tags allow you to parse template literals with a function. The first argument of a tag function contains an array of string values. The remaining arguments are related to the expressions. In the end, your function can return your manipulated string (or it can return something completely different as described in the next example). The name of the function used for the tag can be whatever you want.</p> <pre data-language=\"js\">var person = 'Mike';\nvar age = 28;\n\nfunction myTag(strings, personExp, ageExp) {\n  var str0 = strings[0]; // \"That \"\n  var str1 = strings[1]; // \" is a \"\n\n  // There is technically a string after\n  // the final expression (in our example),\n  // but it is empty (\"\"), so disregard.\n  // var str2 = strings[2];\n\n  var ageStr;\n  if (ageExp &gt; 99){\n    ageStr = 'centenarian';\n  } else {\n    ageStr = 'youngster';\n  }\n\n  // We can even return a string built using a template literal\n  return `${str0}${personExp}${str1}${ageStr}`;\n}\n\nvar output = myTag`That ${ person } is a ${ age }`;\n\nconsole.log(output);\n// That Mike is a youngster</pre> <p>Tag functions don't need to return a string, as shown in the following example.</p> <pre data-language=\"js\">function template(strings, ...keys) {\n  return (function(...values) {\n    var dict = values[values.length - 1] || {};\n    var result = [strings[0]];\n    keys.forEach(function(key, i) {\n      var value = Number.isInteger(key) ? values[key] : dict[key];\n      result.push(value, strings[i + 1]);\n    });\n    return result.join('');\n  });\n}\n\nvar t1Closure = template`${0}${1}${0}!`;\nt1Closure('Y', 'A');  // \"YAY!\"\nvar t2Closure = template`${0} ${'foo'}!`;\nt2Closure('Hello', {foo: 'World'});  // \"Hello World!\"\n</pre> <h3 id=\"Raw_strings\">Raw strings</h3> <p>The special <code>raw</code> property, available on the first function argument of tagged templates, allows you to access the raw strings as they were entered, without processing <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Grammar_and_types#Using_special_characters_in_strings\">escape sequences</a>.</p> <pre data-language=\"js\">function tag(strings) {\n  console.log(strings.raw[0]);\n}\n\ntag`string text line 1 \\n string text line 2`;\n// logs \"string text line 1 \\n string text line 2\" ,\n// including the two characters '\\' and 'n'\n</pre> <p>In addition, the <a href=\"global_objects/string/raw\"><code>String.raw()</code></a> method exists to create raw strings just like the default template function and string concatenation would create.</p> <pre data-language=\"js\">var str = String.raw`Hi\\n${2+3}!`;\n// \"Hi\\n5!\"\n\nstr.length;\n// 6\n\nstr.split('').join(',');\n// \"H,i,\\,n,5,!\"\n</pre> <h3 id=\"Tagged_templates_and_escape_sequences\">Tagged templates and escape sequences</h3> <h4 id=\"ES2016_behavior\">ES2016 behavior</h4> <p>As of ECMAScript 2016, tagged templates conform to the rules of the following escape sequences:</p> <ul> <li>Unicode escapes started by \"\\u\", for example <code>\\u00A9</code>\n</li> <li>Unicode code point escapes indicated by \"\\u{}\", for example <code>\\u{2F804}</code>\n</li> <li>Hexadecimal escapes started by \"\\x\", for example <code>\\xA9</code>\n</li> <li>Octal literal escapes started by \"\\\" and (a) digit(s), for example <code>\\251</code>\n</li> </ul> <p>This means that a tagged template like the following is problematic, because, per ECMAScript grammar, a parser looks for valid Unicode escape sequences, but finds malformed syntax:</p> <pre data-language=\"js\">latex`\\unicode`\n// Throws in older ECMAScript versions (ES2016 and earlier)\n// SyntaxError: malformed Unicode character escape sequence</pre> <h4 id=\"ES2018_revision_of_illegal_escape_sequences\">ES2018 revision of illegal escape sequences</h4> <p>Tagged templates should allow the embedding of languages (for example <a href=\"https://en.wikipedia.org/wiki/Domain-specific_language\">DSLs</a>, or <a href=\"https://en.wikipedia.org/wiki/LaTeX\">LaTeX</a>), where other escapes sequences are common. The ECMAScript proposal <a href=\"https://tc39.github.io/proposal-template-literal-revision/\">Template Literal Revision</a> (stage 4, to be integrated in the ECMAScript 2018 standard) removes the syntax restriction of ECMAScript escape sequences from tagged templates.</p> <p>However, illegal escape sequences must still be represented in the “cooked” representation. They will show up as <a href=\"global_objects/undefined\"><code>undefined</code></a> element in the “cooked” array:</p> <pre data-language=\"js\">function latex(str) { \n return { \"cooked\": str[0], \"raw\": str.raw[0] }\n} \n\nlatex`\\unicode`\n\n// { cooked: undefined, raw: \"\\\\unicode\" }</pre> <p>Note that the escape sequence restriction is only dropped from <em>tagged</em> templates and not from <em>untagged</em> template literals:</p> <pre data-language=\"js\">let bad = `bad escape sequence: \\unicode`;</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-template-literals\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Template Literals' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition. Defined in several section of the specification: <a href=\"http://www.ecma-international.org/ecma-262/6.0/#sec-template-literals\">Template Literals</a>, <a href=\"http://www.ecma-international.org/ecma-262/6.0/#sec-tagged-templates\">Tagged Templates</a>\n</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-template-literals\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Template Literals' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td>Defined in several section of the specification: <a href=\"https://tc39.github.io/ecma262/#sec-template-literals\">Template Literals</a>, <a href=\"https://tc39.github.io/ecma262/#sec-tagged-templates\">Tagged Templates</a>\n</td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>   <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 41</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 34</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 28</td>\n<td class=\"bc-supports-yes\"> 9</td>\n</tr>\n<tr>\n<th scope=\"row\">Escape sequences allowed in tagged template literals \n</th>\n<td class=\"bc-supports-yes\"> 62</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 53</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 49</td>\n<td class=\"bc-supports-no\"> No</td>\n</tr>\n</tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 41</td>\n<td class=\"bc-supports-yes\"> 41</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 34</td>\n<td class=\"bc-supports-yes\"> 28</td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 4.0</td>\n</tr>\n<tr>\n<th scope=\"row\">Escape sequences allowed in tagged template literals \n</th>\n<td class=\"bc-supports-yes\"> 62</td>\n<td class=\"bc-supports-yes\"> 62</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 53</td>\n<td class=\"bc-supports-yes\"> 49</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n</tr>\n</tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 4.0.0</td>\n</tr>\n<tr>\n<th scope=\"row\">Escape sequences allowed in tagged template literals \n</th>\n<td class=\"bc-supports-no\"> No</td>\n</tr>\n</tbody>\n</table>\n</div>  <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"global_objects/string\"><code>String</code></a></li> <li><a href=\"global_objects/string/raw\"><code>String.raw()</code></a></li> <li><a href=\"lexical_grammar\">Lexical grammar</a></li> <li><a href=\"https://gist.github.com/WebReflection/8f227532143e63649804\">Template-like strings in ES3 compatible syntax</a></li> <li><a href=\"https://hacks.mozilla.org/2015/05/es6-in-depth-template-strings-2/\">\"ES6 in Depth: Template strings\" on hacks.mozilla.org</a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals</a>\n  </p>\n</div>\n","global_objects/function/tostring":"<h1>function.toString</h1> <p>The <code><strong>toString()</strong></code> method returns a string representing the source code of the function.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/function-tostring.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\"><var>function</var>.toString()</pre> <h3 id=\"Return_value\">Return value</h3> <p>A string representing the source code of the function.</p> <h2 id=\"Description\">Description</h2> <p>The <a href=\"../function\"><code>Function</code></a> object overrides the <a href=\"../object/tostring\"><code>toString</code></a> method inherited from <a href=\"../object\"><code>Object</code></a>; it does not inherit <a href=\"../object/tostring\"><code>Object.prototype.toString</code></a>. For user-defined <a href=\"../function\"><code>Function</code></a> objects, the <code>toString</code> method returns a string containing the source text segment which was used to define the function.</p> <p>JavaScript calls the <code>toString</code> method automatically when a <a href=\"../function\"><code>Function</code></a> is to be represented as a text value, e.g. when a function is concatenated with a string.</p> <p>The <code>toString()</code> method will throw a <a href=\"../typeerror\"><code>TypeError</code></a> exception (\"Function.prototype.toString called on incompatible object\"), if its <code>this</code> value object is not a <code>Function</code> object. It will also throw for <a href=\"../proxy\"><code>Proxy</code></a> objects, for example.</p> <pre data-language=\"js\">Function.prototype.toString.call('foo'); // TypeError\n\nvar proxy = new Proxy(function() {}, {});\nFunction.prototype.toString.call(proxy); // TypeError\n</pre> <p>If the <code>toString()</code> method is called on built-in function objects or a function created by <code>Function.prototype.bind</code>, <code>toString()</code> returns a <em>native function string</em> which looks like</p> <pre data-language=\"js\">\"function () {\\n    [native code]\\n}\"\n</pre> <p>If the <code>toString()</code> method is called on a function created by the <code>Function</code> constructor, <code>toString()</code> returns the source code of a synthesized function declaration named \"anonymous\" using the provided parameters and function body.</p> <h2 id=\"Examples\">Examples</h2> <div class=\"_table\"><table class=\"standard-table\"> <thead> <tr> <th scope=\"col\">Function</th> <th scope=\"col\">Function.prototype.toString result</th> </tr> </thead> <tbody> <tr> <td> <pre>\nfunction f(){}</pre> </td> <td> <pre>\n\"function f(){}\"</pre> </td> </tr> <tr> <td> <pre>\nclass A { a(){} }</pre> </td> <td> <pre>\n\"class A { a(){} }\"</pre> </td> </tr> <tr> <td> <pre>\nfunction* g(){}</pre> </td> <td> <pre>\n\"function* g(){}\"</pre> </td> </tr> <tr> <td> <pre>\na =&gt; a</pre> </td> <td> <pre>\n\"a =&gt; a\"</pre> </td> </tr> <tr> <td> <pre>\n({ a(){} }.a)</pre> </td> <td> <pre>\n\"a(){}\"</pre> </td> </tr> <tr> <td> <pre>\n({ *a(){} }.a)</pre> </td> <td> <pre>\n\"*a(){}\"</pre> </td> </tr> <tr> <td> <pre>\n({ [0](){} }[0])</pre> </td> <td> <pre>\n\"[0](){}\"</pre> </td> </tr> <tr> <td> <pre>\nObject.getOwnPropertyDescriptor({\n    get a(){}\n}, \"a\").get</pre> </td> <td> <pre>\n\"get a(){}\"</pre> </td> </tr> <tr> <td> <pre>\nObject.getOwnPropertyDescriptor({\n    set a(x){}\n}, \"a\").set</pre> </td> <td> <pre>\n\"set a(x){}\"</pre> </td> </tr> <tr> <td> <pre>\nFunction.prototype.toString</pre> </td> <td> <pre>\n\"function toString() { [native code] }\"</pre> </td> </tr> <tr> <td> <pre>\n(function f(){}.bind(0))</pre> </td> <td> <pre>\n\"function () { [native code] }\"</pre> </td> </tr> <tr> <td> <pre>\nFunction(\"a\", \"b\")</pre> </td> <td> <pre>\n\"function anonymous(a\\n) {\\nb\\n}\"</pre> </td> </tr> </tbody> </table></div> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/publications/files/ECMA-ST-ARCH/ECMA-262,%201st%20edition,%20June%201997.pdf\" hreflang=\"en\">ECMAScript 1st Edition (ECMA-262)</a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition. Implemented in JavaScript 1.1.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-function.prototype.tostring\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Function.prototype.toString' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Added more specific requirements for the string representation.</td> </tr> <tr> <td><a href=\"https://tc39.github.io/Function-prototype-toString-revision/#sec-introduction\"><code>Function.prototype.toString</code> revisions proposal</a></td> <td>Draft</td> <td>Standardizes native function string, line endings.</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-function.prototype.tostring\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Function.prototype.toString' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>   <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> 5</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">Support of <a href=\"http://tc39.github.io/Function-prototype-toString-revision/\">toString revision</a>\n</th>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 54</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n</tr>\n</tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">Support of <a href=\"http://tc39.github.io/Function-prototype-toString-revision/\">toString revision</a>\n</th>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 54</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n</tr>\n</tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">Support of <a href=\"http://tc39.github.io/Function-prototype-toString-revision/\">toString revision</a>\n</th>\n<td class=\"bc-supports-no\"> No</td>\n</tr>\n</tbody>\n</table>\n</div>  <h2 id=\"Firefox-specific_notes\">Firefox-specific notes</h2> <ul> <li>Since Firefox 17, <code>Function.prototype.toString()</code> has been implemented by saving the function's source. The decompiler was removed, so that the <code>indentation</code> parameter is not needed any more. See <a href=\"https://bugzilla.mozilla.org/show_bug.cgi?id=761723\">bug 761723</a> for more details.</li> <li>Starting with Firefox 38, <code>Function.prototype.toString()</code> throws for <a href=\"../proxy\"><code>Proxy</code></a> objects (<a href=\"https://bugzilla.mozilla.org/show_bug.cgi?id=1100936\">bug 1100936</a>).</li> </ul> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"../object/tostring\"><code>Object.prototype.toString()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/toString$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/toString\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/toString</a>\n  </p>\n</div>\n","global_objects/object/__definesetter__":"<h1>object.__defineSetter__</h1> <div class=\"warning\"> <p>This feature is deprecated in favor of defining setters using the <a href=\"../../operators/object_initializer\">object initializer syntax</a> or the <a href=\"defineproperty\"><code>Object.defineProperty()</code></a> API.</p> <p>However, as it is widely implemented and used on the Web, it is very unlikely that browsers will stop implementing it.</p> </div> <p>The <code><strong>__defineSetter__</strong></code> method binds an object's property to a function to be called when an attempt is made to set that property.</p> <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\"><var>obj</var>.__defineSetter__(<var>prop</var>, <var>fun</var>)</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><code>prop</code></dt> <dd>A string containing the name of the property to be bound to the given function.</dd> <dt><code>fun</code></dt> <dd>A function to be called when there is an attempt to set the specified property. This function takes the form <pre data-language=\"js\">function(<var>val</var>) { . . . }</pre> <dl> <dt><code>val</code></dt> <dd>An alias for the variable that holds the value attempted to be assigned to <code>prop</code>.</dd> </dl> </dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p><a href=\"../undefined\"><code>undefined</code></a>.</p> <h2 id=\"Description\">Description</h2> <p>The <code>__defineSetter__</code> method allows a <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/set\">setter</a> to be defined on a pre-existing object.</p> <h2 id=\"Examples\">Examples</h2> <pre data-language=\"js\">// Non-standard and deprecated way\n\nvar o = {};\no.__defineSetter__('value', function(val) { this.anotherValue = val; });\no.value = 5;\nconsole.log(o.value); // undefined\nconsole.log(o.anotherValue); // 5\n\n\n// Standard-compliant ways\n\n// Using the set operator\nvar o = { set value(val) { this.anotherValue = val; } };\no.value = 5;\nconsole.log(o.value); // undefined\nconsole.log(o.anotherValue); // 5\n\n// Using Object.defineProperty\nvar o = {};\nObject.defineProperty(o, 'value', {\n  set: function(val) {\n    this.anotherValue = val;\n  }\n});\no.value = 5;\nconsole.log(o.value); // undefined\nconsole.log(o.anotherValue); // 5\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"spectable standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-object.prototype.__defineSetter__\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Object.prototype.__defineSetter__()' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td>Included in the (normative) annex for additional ECMAScript legacy features for Web browsers (note that the specification codifies what is already in implementations).</td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>   <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support \n</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes bc-has-history\"> 1\n<section class=\"bc-history\" id=\"sect1\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 1\n</dt>\n<dd> Starting with Firefox 48, this method can no longer be called at the global scope without any object. A <code>TypeError</code> will be thrown otherwise. Previously, the global object was used in these cases automatically, but this is no longer the case.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-yes\"> 11</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support \n</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support \n</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div>  <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"__definegetter__\"><code>Object.prototype.__defineGetter__()</code></a></li> <li>\n<a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/set\"><code>set</code></a> operator</li> <li><a href=\"defineproperty\"><code>Object.defineProperty()</code></a></li> <li><a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/__lookupGetter__\"><code>Object.prototype.__lookupGetter__()</code></a></li> <li><a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/__lookupSetter__\"><code>Object.prototype.__lookupSetter__()</code></a></li> <li><a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Working_with_Objects#Defining_getters_and_setters\">JS Guide: Defining Getters and Setters</a></li> <li><a href=\"http://whereswalden.com/2010/04/16/more-spidermonkey-changes-ancient-esoteric-very-rarely-used-syntax-for-creating-getters-and-setters-is-being-removed/\">[Blog Post] Deprecation of __defineGetter__ and __defineSetter__</a></li> <li><a href=\"https://bugzilla.mozilla.org/show_bug.cgi?id=647423\">bug 647423</a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/__defineSetter__$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/__defineSetter__\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/__defineSetter__</a>\n  </p>\n</div>\n","global_objects/object/__definegetter__":"<h1>object.__defineGetter__</h1> <div class=\"warning\"> <p>This feature is deprecated in favor of defining getters using the <a href=\"../../operators/object_initializer\">object initializer syntax</a> or the <a href=\"defineproperty\"><code>Object.defineProperty()</code></a> API. While this feature is widely implemented, it is only described in the <a href=\"https://tc39.github.io/ecma262/#sec-additional-ecmascript-features-for-web-browsers\">ECMAScript specification</a> because of legacy usage. This method should not be used since better alternatives exist.</p> </div> <p>The <code><strong>__defineGetter__</strong></code> method binds an object's property to a function to be called when that property is looked up.</p> <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\"><var>obj</var>.__defineGetter__(<var>prop</var>, <var>func</var>)</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><code>prop</code></dt> <dd>A string containing the name of the property to bind to the given function.</dd> <dt><code>func</code></dt> <dd>A function to be bound to a lookup of the specified property.</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p><a href=\"../undefined\"><code>undefined</code></a>.</p> <h2 id=\"Description\">Description</h2> <p>The <code>__defineGetter__</code> allows a <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/get\">getter</a> to be defined on a pre-existing object.</p> <h2 id=\"Examples\">Examples</h2> <pre data-language=\"js\">// Non-standard and deprecated way\n\nvar o = {};\no.__defineGetter__('gimmeFive', function() { return 5; });\nconsole.log(o.gimmeFive); // 5\n\n\n// Standard-compliant ways\n\n// Using the get operator\nvar o = { get gimmeFive() { return 5; } };\nconsole.log(o.gimmeFive); // 5\n\n// Using Object.defineProperty\nvar o = {};\nObject.defineProperty(o, 'gimmeFive', {\n  get: function() {\n    return 5;\n  }\n});\nconsole.log(o.gimmeFive); // 5\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"spectable standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-object.prototype.__defineGetter__\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Object.prototype.__defineGetter__()' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td>Included in the (normative) annex for additional ECMAScript legacy features for Web browsers (note that the specification codifies what is already in implementations).</td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>   <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support \n</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes bc-has-history\"> 1\n<section class=\"bc-history\" id=\"sect1\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 1\n</dt>\n<dd> Starting with Firefox 48, this method can no longer be called at the global scope without any object. A <code>TypeError</code> will be thrown otherwise. Previously, the global object was used in these cases automatically, but this is no longer the case.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-yes\"> 11</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support \n</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support \n</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div>  <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"__definesetter__\"><code>Object.prototype.__defineSetter__()</code></a></li> <li>\n<a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/get\"><code>get</code></a> operator</li> <li><a href=\"defineproperty\"><code>Object.defineProperty()</code></a></li> <li><a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/__lookupGetter__\"><code>Object.prototype.__lookupGetter__()</code></a></li> <li><a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/__lookupSetter__\"><code>Object.prototype.__lookupSetter__()</code></a></li> <li><a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Working_with_Objects#Defining_getters_and_setters\">JS Guide: Defining Getters and Setters</a></li> <li><a href=\"https://whereswalden.com/2010/04/16/more-spidermonkey-changes-ancient-esoteric-very-rarely-used-syntax-for-creating-getters-and-setters-is-being-removed/\">[Blog Post] Deprecation of __defineGetter__ and __defineSetter__</a></li> <li><a href=\"https://bugzilla.mozilla.org/show_bug.cgi?id=647423\">bug 647423</a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/__defineGetter__$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/__defineGetter__\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/__defineGetter__</a>\n  </p>\n</div>\n","errors/already_has_pragma":"<h1>Errors: Already has pragma</h1> <h2 id=\"Message\">Message</h2> <pre class=\"syntaxbox\">Warning: -file- is being assigned a //# sourceMappingURL, but already has one.</pre> <h2 id=\"Error_type\">Error type</h2> <p>A warning. JavaScript execution won't be halted.</p> <h2 id=\"What_went_wrong\">What went wrong?</h2> <p>A source map has been specified more than once for a given JavaScript source.</p> <p>JavaScript sources are often combined and minified to make delivering them from the server more efficient. With <a href=\"http://www.html5rocks.com/en/tutorials/developertools/sourcemaps/\">source maps</a>, the debugger can map the code being executed to the original source files. There are two ways to assign a source map, either by using a comment or by setting a header to the JavaScript file.</p> <h2 id=\"Examples\">Examples</h2> <p>Setting a source map by using a comment in the file:</p> <pre data-language=\"js\">//# sourceMappingURL=http://example.com/path/to/your/sourcemap.map</pre> <p>Or, alternatively, you can set a header to your JavaScript file:</p> <pre data-language=\"js\">X-SourceMap: /path/to/file.js.map</pre> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"https://developer.mozilla.org/en-US/docs/Tools/Debugger/How_to/Use_a_source_map\">How to use a source map – Firefox Tools documentation</a></li> <li><a href=\"http://www.html5rocks.com/en/tutorials/developertools/sourcemaps/\">Introduction to source maps – HTML5 rocks</a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Already_has_pragma$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Already_has_pragma\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Already_has_pragma</a>\n  </p>\n</div>\n","iteration_protocols":"<h1>Iteration protocols</h1> <p>A couple of additions to ECMAScript 2015 aren't new built-ins or syntax, but protocols. These protocols can be implemented by any object respecting some conventions.</p> <p>There are two protocols: The <a href=\"#The_iterable_protocol\">iterable protocol</a> and the <a href=\"#The_iterator_protocol\">iterator protocol</a>.</p> <h2 id=\"The_iterable_protocol\">The iterable protocol</h2> <p>The <strong>iterable</strong> protocol allows JavaScript objects to define or customize their iteration behavior, such as what values are looped over in a <a href=\"statements/for...of\"><code>for..of</code></a> construct. Some built-in types are <a href=\"#Built-in_iterables\">built-in iterables</a> with a default iteration behavior, such as <a href=\"global_objects/array\"><code>Array</code></a> or <a href=\"global_objects/map\"><code>Map</code></a>, while other types (such as <a href=\"global_objects/object\"><code>Object</code></a>) are not.</p> <p>In order to be <strong>iterable</strong>, an object must implement the <strong>@@iterator</strong> method, meaning that the object (or one of the objects up its <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Inheritance_and_the_prototype_chain\">prototype chain</a>) must have a property with a <strong>@@iterator </strong>key which is available via constant <code><a href=\"global_objects/symbol/iterator\"><code>Symbol.iterator</code></a></code>:</p> <div class=\"_table\"><table class=\"standard-table\"> <thead> <tr> <th scope=\"col\">Property</th> <th scope=\"col\">Value</th> </tr> </thead> <tbody> <tr> <td><code>[Symbol.iterator]</code></td> <td>A zero arguments function that returns an object, conforming to the <a href=\"#The_iterator_protocol\">iterator protocol</a>.</td> </tr> </tbody> </table></div> <p>Whenever an object needs to be iterated (such as at the beginning of a <code>for..of</code> loop), its <code>@@iterator</code> method is called with no arguments, and the returned <strong>iterator</strong> is used to obtain the values to be iterated.</p> <h2 id=\"The_iterator_protocol\">The iterator protocol</h2> <p>The <strong>iterator</strong> protocol defines a standard way to produce a sequence of values (either finite or infinite), and potentially a return value when all values have been generated.</p> <p>An object is an iterator when it implements a <code><strong>next()</strong></code> method with the following semantics:</p> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Property</th> <th scope=\"col\">Value</th> </tr> <tr> <td><code>next</code></td> <td> <p>A zero arguments function that returns an object with at least the following two properties:</p> <ul> <li>\n<code>done</code> (boolean) <ul> <li>Has the value <code>true</code> if the iterator is past the end of the iterated sequence. In this case <code>value</code> optionally specifies the return value of the iterator.</li> <li>Has the value <code>false</code> if the iterator was able to produce the next value in the sequence. This is equivalent of not specifying the <code>done</code> property altogether.</li> </ul> </li> <li>\n<code>value</code> - any JavaScript value returned by the iterator. Can be omitted when <code>done</code> is <code>true</code>.</li> </ul> <p>The <code>next</code> method always has to return an object with appropriate properties including <code>done</code> and <code>value</code>. If a non-object value gets returned (such as <code>false</code> or <code>undefined</code>), a <a href=\"global_objects/typeerror\"><code>TypeError</code></a> (\"iterator.next() returned a non-object value\") will be thrown.</p> </td> </tr> </tbody> </table></div> <div class=\"note\"> <p>It is not possible to know reflectively whether a particular object implements the iterator protocol, however it is easy to create an object that satisfies both the iterator and iterable protocols (as shown in the example below). Doing so allows an iterator to be consumed by the various syntaxes expecting iterables. Thus it is rarely desireable to implement the iterator protocol without also implementing iterable. </p> <pre data-language=\"js\">var myIterator = {\n    next: function() {\n        // ...\n    },\n    [Symbol.iterator]: function() { return this }\n};\n</pre> </div> <h2 id=\"Examples_using_the_iteration_protocols\">Examples using the iteration protocols</h2> <p>A <a href=\"global_objects/string\"><code>String</code></a> is an example of a built-in iterable object:</p> <pre data-language=\"js\">var someString = 'hi';\ntypeof someString[Symbol.iterator];          // \"function\"\n</pre> <p><code>String</code>'s <a href=\"global_objects/string/@@iterator\">default iterator</a> returns the string's code points one by one:</p> <pre data-language=\"js\">var iterator = someString[Symbol.iterator]();\niterator + '';                               // \"[object String Iterator]\"\n \niterator.next();                             // { value: \"h\", done: false }\niterator.next();                             // { value: \"i\", done: false }\niterator.next();                             // { value: undefined, done: true }</pre> <p>Some built-in constructs, such as the <a href=\"operators/spread_syntax\">spread syntax</a>, use the same iteration protocol under the hood:</p> <pre data-language=\"js\">[...someString]                              // [\"h\", \"i\"]</pre> <p>We can redefine the iteration behavior by supplying our own <code>@@iterator</code>:</p> <pre data-language=\"js\">var someString = new String('hi');           // need to construct a String object explicitly to avoid auto-boxing\n\nsomeString[Symbol.iterator] = function() {\n  return { // this is the iterator object, returning a single element, the string \"bye\"\n    next: function() {\n      if (this._first) {\n        this._first = false;\n        return { value: 'bye', done: false };\n      } else {\n        return { done: true };\n      }\n    },\n    _first: true\n  };\n};\n</pre> <p>Notice how redefining <code>@@iterator</code> affects the behavior of built-in constructs that use the iteration protocol:</p> <pre data-language=\"js\">[...someString];                             // [\"bye\"]\nsomeString + '';                             // \"hi\"\n</pre> <h2 id=\"Iterable_examples\">Iterable examples</h2> <h3 id=\"Built-in_iterables\">Built-in iterables</h3> <p><a href=\"global_objects/string\"><code>String</code></a>, <a href=\"global_objects/array\"><code>Array</code></a>, <a href=\"global_objects/typedarray\"><code>TypedArray</code></a>, <a href=\"global_objects/map\"><code>Map</code></a> and <a href=\"global_objects/set\"><code>Set</code></a> are all built-in iterables, because each of their prototype objects implements an <code>@@iterator</code> method.</p> <h3 id=\"User-defined_iterables\">User-defined iterables</h3> <p>We can make our own iterables like this:</p> <pre data-language=\"js\">var myIterable = {};\nmyIterable[Symbol.iterator] = function* () {\n    yield 1;\n    yield 2;\n    yield 3;\n};\n[...myIterable]; // [1, 2, 3]\n</pre> <h3 id=\"Built-in_APIs_accepting_iterables\">Built-in APIs accepting iterables</h3> <p>There are many APIs that accept iterables, for example: <a href=\"global_objects/map\"><code>Map([iterable])</code></a>, <a href=\"global_objects/weakmap\"><code>WeakMap([iterable])</code></a>, <a href=\"global_objects/set\"><code>Set([iterable])</code></a> and <a href=\"global_objects/weakset\"><code>WeakSet([iterable])</code></a>:</p> <pre data-language=\"js\">var myObj = {};\nnew Map([[1, 'a'], [2, 'b'], [3, 'c']]).get(2);               // \"b\"\nnew WeakMap([[{}, 'a'], [myObj, 'b'], [{}, 'c']]).get(myObj); // \"b\"\nnew Set([1, 2, 3]).has(3);                               // true\nnew Set('123').has('2');                                 // true\nnew WeakSet(function* () {\n    yield {};\n    yield myObj;\n    yield {};\n}()).has(myObj);                                         // true\n</pre> <p>Also see <a href=\"global_objects/promise/all\"><code>Promise.all(iterable)</code></a>, <a href=\"global_objects/promise/race\"><code>Promise.race(iterable)</code></a>, and <a href=\"global_objects/array/from\"><code>Array.from()</code></a>.</p> <h3 id=\"Syntaxes_expecting_iterables\">Syntaxes expecting iterables</h3> <p>Some statements and expressions expect iterables, for example the <code><a href=\"statements/for...of\">for-of</a></code> loops, <a href=\"operators/spread_syntax\">spread syntax</a>, <code><a href=\"operators/yield*\">yield*</a></code>, and <a href=\"operators/destructuring_assignment\">destructuring assignment</a>:</p> <pre data-language=\"js\">for(let value of ['a', 'b', 'c']){\n    console.log(value);\n}\n// \"a\"\n// \"b\"\n// \"c\"\n\n[...'abc']; // [\"a\", \"b\", \"c\"]\n\nfunction* gen() {\n  yield* ['a', 'b', 'c'];\n}\n\ngen().next(); // { value:\"a\", done:false }\n\n[a, b, c] = new Set(['a', 'b', 'c']);\na // \"a\"\n\n</pre> <h3 id=\"Non-well-formed_iterables\">Non-well-formed iterables</h3> <p>If an iterable's <code>@@iterator</code> method doesn't return an iterator object, then it's a non-well-formed iterable. Using it as such is likely to result in runtime exceptions or buggy behavior:</p> <pre data-language=\"js\">var nonWellFormedIterable = {}\nnonWellFormedIterable[Symbol.iterator] = () =&gt; 1\n[...nonWellFormedIterable] // TypeError: [] is not a function\n</pre> <h2 id=\"Iterator_examples\">Iterator examples</h2> <h3 id=\"Simple_iterator\">Simple iterator</h3> <pre data-language=\"js\">function makeIterator(array) {\n    var nextIndex = 0;\n    \n    return {\n       next: function() {\n           return nextIndex &lt; array.length ?\n               {value: array[nextIndex++], done: false} :\n               {done: true};\n       }\n    };\n}\n\nvar it = makeIterator(['yo', 'ya']);\n\nconsole.log(it.next().value); // 'yo'\nconsole.log(it.next().value); // 'ya'\nconsole.log(it.next().done);  // true\n</pre> <h3 id=\"Infinite_iterator\">Infinite iterator</h3> <pre data-language=\"js\">function idMaker() {\n    var index = 0;\n    \n    return {\n       next: function(){\n           return {value: index++, done: false};\n       }\n    };\n}\n\nvar it = idMaker();\n\nconsole.log(it.next().value); // '0'\nconsole.log(it.next().value); // '1'\nconsole.log(it.next().value); // '2'\n// ...\n</pre> <h3 id=\"With_a_generator\">With a generator</h3> <pre data-language=\"js\">function* makeSimpleGenerator(array) {\n    var nextIndex = 0;\n    \n    while (nextIndex &lt; array.length) {\n        yield array[nextIndex++];\n    }\n}\n\nvar gen = makeSimpleGenerator(['yo', 'ya']);\n\nconsole.log(gen.next().value); // 'yo'\nconsole.log(gen.next().value); // 'ya'\nconsole.log(gen.next().done);  // true\n\n\n\nfunction* idMaker() {\n    var index = 0;\n    while (true)\n        yield index++;\n}\n\nvar gen = idMaker();\n\nconsole.log(gen.next().value); // '0'\nconsole.log(gen.next().value); // '1'\nconsole.log(gen.next().value); // '2'\n// ...\n</pre> <h3 id=\"With_ES2015_class\">With ES2015 class</h3> <pre data-language=\"js\">class SimpleClass {\n  constructor(data) {\n    this.index = 0;\n    this.data = data;\n  }\n\n  [Symbol.iterator]() {\n    return {\n      next: () =&gt; {\n        if (this.index &lt; this.data.length) {\n          return {value: this.data[this.index++], done: false};\n        } else {\n          this.index = 0; //If we would like to iterate over this again without forcing manual update of the index\n          return {done: true};\n        }\n      }\n    };\n  }\n}\n\nconst simple = new SimpleClass([1,2,3,4,5]);\n\nfor (const val of simple) {\n  console.log(val);  //'0' '1' '2' '3' '4' '5' \n}\n</pre> <h2 id=\"Is_a_generator_object_an_iterator_or_an_iterable\">Is a generator object an iterator or an iterable?</h2> <p>A <a href=\"global_objects/generator\">generator object</a> is both, iterator and iterable:</p> <pre data-language=\"js\">var aGeneratorObject = function* () {\n    yield 1;\n    yield 2;\n    yield 3;\n}();\ntypeof aGeneratorObject.next;\n// \"function\", because it has a next method, so it's an iterator\ntypeof aGeneratorObject[Symbol.iterator];\n// \"function\", because it has an @@iterator method, so it's an iterable\naGeneratorObject[Symbol.iterator]() === aGeneratorObject;\n// true, because its @@iterator method returns itself (an iterator), so it's an well-formed iterable\n[...aGeneratorObject];\n// [1, 2, 3]\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-iteration\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Iteration' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-iteration\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Iteration' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"See_also\">See also</h2> <ul> <li>For more information on ES2015 generators, see <a href=\"statements/function*\">the function* documentation</a>.</li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols</a>\n  </p>\n</div>\n","global_objects/function/name":"<h1>function.name</h1> <p>A <a href=\"../function\"><code>Function</code></a> object's read-only <code><strong>name</strong></code> property indicates the function's name as specified when it was created, or <code>\"anonymous\"</code> for functions created anonymously.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/function-name.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <div class=\"_table\"><table class=\"standard-table\"> <thead> <tr> <th colspan=\"2\" class=\"header\">Property attributes of <code>Function.prototype.name</code>\n</th> </tr> </thead> <tbody> <tr> <td>Writable</td> <td>no</td> </tr> <tr> <td>Enumerable</td> <td>no</td> </tr> <tr> <td>Configurable</td> <td>yes</td> </tr> </tbody> </table></div><br>  <div class=\"note\"> <p>Note that in non-standard, pre-ES2015 implementations the <code>configurable</code> attribute was <code>false</code> as well.</p> </div> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Function_statement_name\">Function statement name</h3> <p>The <code>name</code> property returns the name of a function statement.</p> <pre data-language=\"js\">function doSomething() {}\ndoSomething.name; // \"doSomething\"\n</pre> <h3 id=\"Function_constructor_name\">Function constructor name</h3> <p>Functions created with the syntax <code>new Function(...)</code> or just <code>Function(...) create</code> <a href=\"../function\"><code>Function</code></a> objects and their name is \"anonymous\".</p> <pre>(new Function).name; // \"anonymous\"</pre> <h3 id=\"Inferred_function_names\">Inferred function names</h3> <p>Variables and methods can infer the name of an anonymous function from its syntactic position (new in ECMAScript 2015).</p> <pre data-language=\"js\">let f = function() {};\nlet object = {\n  someMethod: function() {}\n};\n\nconsole.log(f.name); // \"f\"\nconsole.log(object.someMethod.name); // \"someMethod\"\n</pre> <p>You can define a function with a name in a <a href=\"../../operators/function\">function expression</a>:</p> <pre data-language=\"js\">let object = {\n  someMethod: function object_someMethod() {}\n};\nconsole.log(object.someMethod.name); // logs \"object_someMethod\"\n\ntry { object_someMethod } catch(e) { console.log(e); }\n// ReferenceError: object_someMethod is not defined\n</pre> <p>You cannot change the name of a function, this property is read-only:</p>  <pre data-language=\"js\"> let object = {\n  // anonymous\n  someMethod: function() {}\n};\n\nobject.someMethod.name = 'otherMethod';\nconsole.log(object.someMethod.name); // someMethod\n</pre> <p>To change it, you could use <a href=\"../object/defineproperty\"><code>Object.defineProperty()</code></a> though.</p> <h3 id=\"Shorthand_method_names\">Shorthand method names</h3> <pre data-language=\"js\">var o = {\n  foo(){}\n};\no.foo.name; // \"foo\";</pre> <h3 id=\"Bound_function_names\">Bound function names</h3> <p><a href=\"bind\"><code>Function.bind()</code></a> produces a function whose name is \"bound \" plus the function name.</p> <pre data-language=\"js\">function foo() {}; \nfoo.bind({}).name; // \"bound foo\"\n</pre> <h3 id=\"Function_names_for_getters_and_setters\">Function names for getters and setters</h3> <p>When using <code><a href=\"../../functions/get\">get</a></code> and <code><a href=\"../../functions/set\">set</a></code> accessor properties, \"get\" or \"set\" will appear in the function name.</p> <pre data-language=\"js\">let o = { \n  get foo(){}, \n  set foo(x){} \n}; \n\nvar descriptor = Object.getOwnPropertyDescriptor(o, \"foo\"); \ndescriptor.get.name; // \"get foo\" \ndescriptor.set.name; // \"set foo\";</pre> <h3 id=\"Function_names_in_classes\">Function names in classes</h3> <p>You can use <code>obj.constructor.name</code> to check the \"class\" of an object (but be sure to read the warnings below):</p> <pre data-language=\"js\">function Foo() {}  // ES2015 Syntax: class Foo {}\n\nvar fooInstance = new Foo();\nconsole.log(fooInstance.constructor.name); // logs \"Foo\"\n</pre> <div class=\"warning\"> <p><strong>Warning:</strong> The script interpreter will set the built-in <code>Function.name</code> property only if a function does not have an own property called <em>name</em> (see section <a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-setfunctionname\">9.2.11 of the ECMAScript2015 Language Specification</a>). However, ES2015 specifies the <em>static</em> keyword such that static methods will be set as OwnProperty of the class constructor function (ECMAScript2015, <a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-runtime-semantics-classdefinitionevaluation\">14.5.14.21.b</a> + <a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-object-initializer-runtime-semantics-propertydefinitionevaluation\">12.2.6.9</a>).</p> </div> <p>Therefore we can't obtain the class name for virtually any class with a static method property <code>name()</code>:</p> <pre data-language=\"js\">class Foo {\n  constructor() {}\n  static name() {}\n}\n</pre> <p>With a <code>static name()</code> method <code>Foo.name</code> no longer holds the actual class name but a reference to the <code>name()</code> function object. Above class definition in ES2015 syntax will behave in Chrome or Firefox similar to the following snippet in ES5 syntax:</p> <pre data-language=\"js\">function Foo() {}\nObject.defineProperty(Foo, 'name', { writable: true });\nFoo.name = function() {};\n</pre> <p>Trying to obtain the class of <code>fooInstance</code> via <code>fooInstance.constructor.name</code> won't give us the class name at all but a reference to the static class method. Example:</p> <pre data-language=\"js\">let fooInstance = new Foo();\nconsole.log(fooInstance.constructor.name); // logs function name()\n</pre> <p>You may also see from the ES5 syntax example that in Chrome or Firefox our static definition of <code>Foo.name</code> becomes <em>writable</em>. The built-in definition in the absence of a custom static definition is <em>read-only</em>:</p> <pre data-language=\"js\">Foo.name = 'Hello';\nconsole.log(Foo.name); // logs \"Hello\" if class Foo has a static name() property but \"Foo\" if not.\n</pre> <p>Therefore you may not rely on the built-in <code>Function.name</code> property to always hold a class's name.</p> <h3 id=\"Symbols_as_function_names\">Symbols as function names</h3> <p>If a <a href=\"../symbol\"><code>Symbol</code></a> is used a function name and the symbol has a description, the method's name is the description in square brackets.</p> <pre data-language=\"js\">let sym1 = Symbol(\"foo\"); \nlet sym2 = Symbol(); \nlet o = { \n  [sym1]: function(){}, \n  [sym2]: function(){} \n}; \n\no[sym1].name; // \"[foo]\"\no[sym2].name; // \"\"</pre> <h2 id=\"JavaScript_compressors_and_minifiers\">JavaScript compressors and minifiers</h2> <div class=\"warning\"> <p><strong>Warning:</strong> Be careful when using <code>Function.name</code> and 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 pipeline to reduce the size of a program prior to deploying it to production. Such transformations often change a function's name at build-time.</p> </div> <p>Source code such as:</p> <pre data-language=\"js\">function Foo() {};\nlet foo = new Foo();\n\nif (foo.constructor.name === 'Foo') {\n  console.log(\"'foo' is an instance of 'Foo'\");\n} else {\n  console.log('Oops!');\n}\n</pre> <p>may be compressed to:</p> <pre data-language=\"js\">function a() {};\nlet b = new a();\nif (b.constructor.name === 'Foo') {\n  console.log(\"'foo' is an instance of 'Foo'\");\n} else {\n  console.log('Oops!');\n}\n</pre> <p>In the uncompressed version, the program runs into the truthy-branch and logs <em>'foo' is an instance of 'Foo'</em>. Whereas, in the compressed version it behaves differently, and runs into the else-branch. If you rely on <code>Function.name</code>, like in the example above, make sure your build pipeline doesn't change function names, or don't assume a function to have a particular name.</p> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-name\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'name' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-function-instances-name\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'name' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>   <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 15</td>\n<td class=\"bc-supports-yes\"> 14</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">Configurable: true</th>\n<td class=\"bc-supports-yes\"> 43</td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 38</td>\n<td> ? </td>\n<td> ? </td>\n<td> ? </td>\n</tr>\n<tr>\n<th scope=\"row\">Inferred names on anonymous functions</th>\n<td class=\"bc-supports-yes\"> 51</td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 53</td>\n<td> ? </td>\n<td> ? </td>\n<td> ? </td>\n</tr>\n</tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">Configurable: true</th>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 43</td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 38</td>\n<td> ? </td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 4.0</td>\n</tr>\n<tr>\n<th scope=\"row\">Inferred names on anonymous functions</th>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 51</td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 53</td>\n<td> ? </td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 5.0</td>\n</tr>\n</tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">Configurable: true</th>\n<td> ? </td>\n</tr>\n<tr>\n<th scope=\"row\">Inferred names on anonymous functions</th>\n<td> ? </td>\n</tr>\n</tbody>\n</table>\n</div><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/name$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/name\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/name</a>\n  </p>\n</div>\n","global_objects/function/apply":"<h1>function.apply</h1> <p>The <code><strong>apply()</strong></code> method calls a function with a given <code>this</code> value, and <code>arguments</code> provided as an array (or an <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Indexed_collections#Working_with_array-like_objects\">array-like object</a>).</p> <div class=\"note\"> <p><strong>Note:</strong> While the syntax of this function is almost identical to that of <a href=\"call\"><code>call()</code></a>, the fundamental difference is that <code>call()</code> accepts an <strong>argument list</strong>, while <code>apply()</code> accepts a <strong>single array of arguments</strong>.</p> </div> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/function-apply.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre><var>function</var>.apply(<var>thisArg, </var>[<var>argsArray</var>])</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><code>thisArg</code></dt> <dd>Optional. The value of <code>this</code> provided for the call to <em><code>func</code></em>. Note that <code>this</code> may not be the actual value seen by the method: if the method is a function in <a href=\"../../strict_mode\">non-strict mode</a> code, <a href=\"../null\"><code>null</code></a> and <a href=\"../undefined\"><code>undefined</code></a> will be replaced with the global object, and primitive values will be boxed.</dd> <dt><code>argsArray</code></dt> <dd>Optional. An array-like object, specifying the arguments with which <em><code>func</code></em> should be called, or <a href=\"../null\"><code>null</code></a> or <a href=\"../undefined\"><code>undefined</code></a> if no arguments should be provided to the function. Starting with ECMAScript 5 these arguments can be a generic array-like object instead of an array. See below for <a href=\"#Browser_compatibility\">browser compatibility</a> information.</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p>The result of calling the function with the specified <code><strong>this</strong></code> value and arguments.</p> <h2 id=\"Description\">Description</h2> <p>You can assign a different <code>this</code> object when calling an existing function. <code>this</code> refers to the current object, the calling object. With <code>apply</code>, you can write a method once and then inherit it in another object, without having to rewrite the method for the new object.</p> <p><code>apply</code> is very similar to <a href=\"call\"><code>call()</code></a>, except for the type of arguments it supports. You use an arguments array instead of a list of arguments (parameters). With <code>apply</code>, you can also use an array literal, for example, <code><em>func</em>.apply(this, ['eat', 'bananas'])</code>, or an <a href=\"../array\"><code>Array</code></a> object, for example, <code><em>func</em>.apply(this, new Array('eat', 'bananas'))</code>.</p> <p>You can also use <a href=\"../../functions/arguments\"><code>arguments</code></a> for the <code>argsArray</code> parameter. <code>arguments</code> is a local variable of a function. It can be used for all unspecified arguments of the called object. Thus, you do not have to know the arguments of the called object when you use the <code>apply</code> method. You can use <code>arguments</code> to pass all the arguments to the called object. The called object is then responsible for handling the arguments.</p> <p>Since ECMAScript 5th Edition you can also use any kind of object which is array-like, so in practice, this means it's going to have a property <code>length</code> and integer properties in the range <code>(0..length-1)</code>. As an example you can now use a <a href=\"https://developer.mozilla.org/en-US/docs/Web/API/NodeList\"><code>NodeList</code></a> or a custom object like <code>{ 'length': 2, '0': 'eat', '1': 'bananas' }</code>.</p> <div class=\"note\"> <p>Most browsers, including Chrome 14 and Internet Explorer 9, still do not accept array-like objects and will throw an exception.</p> </div> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Using_apply_to_append_an_array_to_another\">Using <code>apply</code> to append an array to another</h3> <p>We can use <code>push</code> to append an element to an array. And, because <code>push</code> accepts a variable number of arguments, we can also push multiple elements at once. But, if we pass an array to <code>push</code>, it will actually add that array as a single element, instead of adding the elements individually, so we end up with an array inside an array. What if that is not what we want? <code>concat</code> does have the behaviour we want in this case, but it does not actually append to the existing array but creates and returns a new array. But we wanted to append to our existing array... So what now? Write a loop? Surely not?</p> <p><code>apply</code> to the rescue!</p> <pre data-language=\"js\">var array = ['a', 'b'];\nvar elements = [0, 1, 2];\narray.push.apply(array, elements);\nconsole.info(array); // [\"a\", \"b\", 0, 1, 2]\n</pre> <h3 id=\"Using_apply_and_built-in_functions\">Using <code>apply</code> and built-in functions</h3> <p>Clever usage of <code>apply</code> allows you to use built-in functions for some tasks, that otherwise probably would have been written by looping over the array values. As an example here we are going to use <code>Math.max</code>/<code>Math.min</code>, to find out the maximum/minimum value in an array.</p> <pre data-language=\"js\">// min/max number in an array\nvar numbers = [5, 6, 2, 3, 7];\n\n// using Math.min/Math.max apply\nvar max = Math.max.apply(null, numbers); \n// This about equal to Math.max(numbers[0], ...)\n// or Math.max(5, 6, ...)\n\nvar min = Math.min.apply(null, numbers);\n\n// vs. simple loop based algorithm\nmax = -Infinity, min = +Infinity;\n\nfor (var i = 0; i &lt; numbers.length; i++) {\n  if (numbers[i] &gt; max) {\n    max = numbers[i];\n  }\n  if (numbers[i] &lt; min) {\n    min = numbers[i];\n  }\n}\n</pre> <p>But beware: in using <code>apply</code> this way, you run the risk of exceeding the JavaScript engine's argument length limit. The consequences of applying a function with too many arguments (think more than tens of thousands of arguments) vary across engines (JavaScriptCore has hard-coded <a href=\"https://bugs.webkit.org/show_bug.cgi?id=80797\" class=\"link-https\">argument limit of 65536</a>), because the limit (indeed even the nature of any excessively-large-stack behavior) is unspecified. Some engines will throw an exception. More perniciously, others will arbitrarily limit the number of arguments actually passed to the applied function. To illustrate this latter case: if such an engine had a limit of four arguments (actual limits are of course significantly higher), it would be as if the arguments <code>5, 6, 2, 3</code> had been passed to <code>apply</code> in the examples above, rather than the full array.</p> <p>If your value array might grow into the tens of thousands, use a hybrid strategy: apply your function to chunks of the array at a time:</p> <pre data-language=\"js\">function minOfArray(arr) {\n  var min = Infinity;\n  var QUANTUM = 32768;\n\n  for (var i = 0, len = arr.length; i &lt; len; i += QUANTUM) {\n    var submin = Math.min.apply(null, \n                                arr.slice(i, Math.min(i+QUANTUM, len)));\n    min = Math.min(submin, min);\n  }\n\n  return min;\n}\n\nvar min = minOfArray([5, 6, 2, 3, 7]);\n</pre> <h3 id=\"Using_apply_to_chain_constructors\">Using <code>apply</code> to chain constructors</h3> <p>You can use <code>apply</code> to chain <a href=\"../../operators/new\">constructors</a> for an object, similar to Java. In the following example we will create a global <a href=\"../function\"><code>Function</code></a> method called <code>construct</code>, which will enable you to use an array-like object with a constructor instead of an arguments list.</p> <pre data-language=\"js\">Function.prototype.construct = function(aArgs) {\n  var oNew = Object.create(this.prototype);\n  this.apply(oNew, aArgs);\n  return oNew;\n};\n</pre> <div class=\"note\" style=\"height: 250px; overflow: auto;\"> <p><strong>Note:</strong> The <code>Object.create()</code> method used above is relatively new. For alternative methods, please consider one of the following approaches:</p> <p>Using <a href=\"../object/proto\"><code>Object.__proto__</code></a>:</p> <pre data-language=\"js\">Function.prototype.construct = function (aArgs) {\n  var oNew = {};\n  oNew.__proto__ = this.prototype;\n  this.apply(oNew, aArgs);\n  return oNew;\n};\n</pre> <p>Using <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Closures\">closures</a>:</p> <pre data-language=\"js\">Function.prototype.construct = function(aArgs) {\n  var fConstructor = this, fNewConstr = function() { \n    fConstructor.apply(this, aArgs); \n  };\n  fNewConstr.prototype = fConstructor.prototype;\n  return new fNewConstr();\n};</pre> <p>Using the <a href=\"../function\"><code>Function</code></a> constructor:</p> <pre data-language=\"js\">Function.prototype.construct = function (aArgs) {\n  var fNewConstr = new Function(\"\");\n  fNewConstr.prototype = this.prototype;\n  var oNew = new fNewConstr();\n  this.apply(oNew, aArgs);\n  return oNew;\n};\n</pre> </div> <p>Example usage:</p> <pre data-language=\"js\">function MyConstructor() {\n  for (var nProp = 0; nProp &lt; arguments.length; nProp++) {\n    this['property' + nProp] = arguments[nProp];\n  }\n}\n\nvar myArray = [4, 'Hello world!', false];\nvar myInstance = MyConstructor.construct(myArray);\n\nconsole.log(myInstance.property1);                // logs 'Hello world!'\nconsole.log(myInstance instanceof MyConstructor); // logs 'true'\nconsole.log(myInstance.constructor);              // logs 'MyConstructor'\n</pre> <div class=\"note\"> <p><strong>Note:</strong> This non-native <code>Function.construct</code> method will not work with some native constructors; like <a href=\"../date\"><code>Date</code></a>, for example. In these cases you have to use the <a href=\"bind\"><code>Function.prototype.bind</code></a> method. For example, imagine having an array like the following, to be used with <a href=\"../date\"><code>Date</code></a> constructor: <code>[2012, 11, 4]</code>; in this case you have to write something like: <code>new (Function.prototype.bind.apply(Date, [null].concat([2012, 11, 4])))()</code>. This is not the best way to do things, and probably not to be used in any production environment.</p> </div> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/publications/files/ECMA-ST-ARCH/ECMA-262,%203rd%20edition,%20December%201999.pdf\" hreflang=\"en\">ECMAScript 3rd Edition (ECMA-262)</a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition. Implemented in JavaScript 1.3.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/5.1/#sec-15.3.4.3\" hreflang=\"en\">ECMAScript 5.1 (ECMA-262)<br><small>The definition of 'Function.prototype.apply' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-function.prototype.apply\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Function.prototype.apply' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-function.prototype.apply\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Function.prototype.apply' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>   <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">ES 5.1: generic array-like object as <code>arguments</code>\n</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td> ? </td>\n<td> ? </td>\n<td> ? </td>\n</tr>\n</tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">ES 5.1: generic array-like object as <code>arguments</code>\n</th>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td> ? </td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n</tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">ES 5.1: generic array-like object as <code>arguments</code>\n</th>\n<td> ? </td>\n</tr>\n</tbody>\n</table>\n</div>  <h2 id=\"See_also\">See also</h2> <ul> <li>\n<a href=\"../../functions/arguments\"><code>arguments</code></a> object</li> <li><a href=\"bind\"><code>Function.prototype.bind()</code></a></li> <li><a href=\"call\"><code>Function.prototype.call()</code></a></li> <li><a href=\"../../functions\">Functions and function scope</a></li> <li><a href=\"../reflect/apply\"><code>Reflect.apply()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/apply$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/apply\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/apply</a>\n  </p>\n</div>\n","global_objects/object/proto":"<h1>Object.proto</h1><div class=\"blockIndicator deprecated deprecatedHeader\"> <p><strong> Deprecated</strong><br>This feature is no longer recommended. Though some browsers might still support it, it may have already been removed from the relevant web standards, may be in the process of being dropped, or may only be kept for compatibility purposes. Avoid using it, and update existing code if possible; see the <a href=\"#Browser_compatibility\">compatibility table</a> at the bottom of this page to guide your decision. Be aware that this feature may cease to work at any time.</p> </div> <div class=\"blockIndicator warning\"> <p><strong>Warning:</strong> Changing the <code>[[Prototype]]</code> of an object is, by the nature of how modern JavaScript engines optimize property accesses, a very slow operation, in <strong><em>every</em></strong> browser and JavaScript engine. The effects on performance of altering inheritance are subtle and far-flung, and are not limited to simply the time spent in <code>obj.__proto__ = ...</code> statement, but may extend to <strong><em>any</em></strong> code that has access to <strong><em>any</em></strong> object whose <code>[[Prototype]]</code> has been altered. If you care about performance you should avoid setting the <code>[[Prototype]]</code> of an object. Instead, create a new object with the desired <code>[[Prototype]]</code> using <a href=\"create\"><code>Object.create()</code></a>.</p> </div> <div class=\"blockIndicator warning\"> <p><strong>Warning:</strong> While <code>Object.prototype.__proto__</code> is supported today in most browsers, its existence and exact behavior has only been standardized in the ECMAScript 2015 specification as a legacy feature to ensure compatibility for web browsers. For better support, it is recommended that only <a href=\"getprototypeof\"><code>Object.getPrototypeOf()</code></a> be used instead.</p> </div>  <p>The <code>__proto__</code> property of <a href=\"prototype\"><code>Object.prototype</code></a> is an accessor property (a getter function and a setter function) that exposes the internal <code>[[Prototype]]</code> (either an object or <a href=\"../null\"><code>null</code></a>) of the object through which it is accessed.</p> <p>The use of <code>__proto__</code> is controversial, and has been discouraged. It was never originally included in the EcmaScript language spec, but modern browsers decided to implement it anyway. Only recently, the <code>__proto__</code> property has been standardized in the ECMAScript 2015 language specification for web browsers to ensure compatibility, so will be supported into the future. It is deprecated in favor of <a href=\"getprototypeof\"><code>Object.getPrototypeOf</code></a>/<a href=\"../reflect/getprototypeof\"><code>Reflect.getPrototypeOf</code></a> and <a href=\"setprototypeof\"><code>Object.setPrototypeOf</code></a>/<a href=\"../reflect/setprototypeof\"><code>Reflect.setPrototypeOf</code></a> (though still, setting the <code>[[Prototype]]</code> of an object is a slow operation that should be avoided if performance is a concern).</p> <p>The <code>__proto__</code> property can also be used in an object literal definition to set the object <code>[[Prototype]]</code> on creation, as an alternative to <a href=\"create\"><code>Object.create()</code></a>. See: <a href=\"../../operators/object_initializer\">object initializer / literal syntax</a>.</p> <h2 id=\"Syntax\">Syntax</h2> <pre data-language=\"js\">var Circle = function () {};\nvar shape = {};\nvar circle = new Circle();\n\n// Set the object prototype.\n// DEPRECATED. This is for example purposes only. DO NOT DO THIS in real code.\nshape.__proto__ = circle;\n\n// Get the object prototype\nconsole.log(shape.__proto__ === circle); // true\n</pre> <pre data-language=\"js\">var shape = function () {};\nvar p = {\n    a: function () {\n        console.log('aaa');\n    }\n};\nshape.prototype.__proto__ = p;\n\nvar circle = new shape();\ncircle.a(); // aaa\nconsole.log(shape.prototype === circle.__proto__); // true\n\n// or\nvar shape = function () {};\nvar p = {\n    a: function () {\n        console.log('a');\n    }\n};\n\nvar circle = new shape();\ncircle.__proto__ = p;\ncircle.a(); // a\nconsole.log(shape.prototype === circle.__proto__); // false\n\n// or\nfunction test() {};\ntest.prototype.myname = function () {\n    console.log('myname');\n};\n\nvar a = new test();\nconsole.log(a.__proto__ === test.prototype); // true\na.myname(); // myname\n\n\n// or\nvar fn = function () {};\nfn.prototype.myname = function () {\n    console.log('myname');\n};\n\nvar obj = {\n    __proto__: fn.prototype\n};\n\nobj.myname(); // myname\n</pre> <p>Note: that is two underscores, followed by the five characters \"proto\", followed by two more underscores.</p> <h2 id=\"Description\">Description</h2> <p>The <code>__proto__</code> getter function exposes the value of the internal <code>[[Prototype]]</code> of an object. For objects created using an object literal, this value is <a href=\"prototype\"><code>Object.prototype</code></a>. For objects created using array literals, this value is <a href=\"../array/prototype\"><code>Array.prototype</code></a>. For functions, this value is <a href=\"../function/prototype\"><code>Function.prototype</code></a>. For objects created using <code>new fun</code>, where <code>fun</code> is one of the built-in constructor functions provided by JavaScript (<a href=\"../array\"><code>Array</code></a>, <a href=\"../boolean\"><code>Boolean</code></a>, <a href=\"../date\"><code>Date</code></a>, <a href=\"../number\"><code>Number</code></a>, <a href=\"../object\"><code>Object</code></a>, <a href=\"../string\"><code>String</code></a>, and so on — including new constructors added as JavaScript evolves), this value is always <code>fun.prototype</code>. For objects created using <code>new fun</code>, where <code>fun</code> is a function defined in a script, this value is the value of <code>fun.prototype</code>. (That is, if the constructor didn't return an other object explicitly, or the <code>fun.prototype</code> has been reassigned since the instance was created).</p> <p>The <code>__proto__</code> setter allows the <code>[[Prototype]]</code> of an object to be mutated. The object must be extensible according to <a href=\"isextensible\"><code>Object.isExtensible()</code></a>: if it is not, a <a href=\"../typeerror\"><code>TypeError</code></a> is thrown. The value provided must be an object or <a href=\"../null\"><code>null</code></a>. Providing any other value will do nothing.</p> <p>To understand how prototypes are used for inheritance, see guide article <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Inheritance_and_the_prototype_chain\">Inheritance and the prototype chain</a>.</p> <p>The <code>__proto__</code> property is a simple accessor property on <a href=\"prototype\"><code>Object.prototype</code></a> consisting of a getter and setter function. A property access for <code>__proto__</code> that eventually consults <a href=\"prototype\"><code>Object.prototype</code></a> will find this property, but an access that does not consult <a href=\"prototype\"><code>Object.prototype</code></a> will not find it. If some other <code>__proto__</code> property is found before <a href=\"prototype\"><code>Object.prototype</code></a> is consulted, that property will hide the one found on <a href=\"prototype\"><code>Object.prototype</code></a>.</p> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <thead> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> </thead> <tbody> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-additional-properties-of-the-object.prototype-object\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Object.prototype.__proto__' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Included in the (normative) annex for additional ECMAScript legacy features for Web browsers (note that the specification codifies what is already in implementations).</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-additional-properties-of-the-object.prototype-object\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Object.prototype.__proto__' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support \n</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> 11</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support \n</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support \n</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"Compatibility_notes\">Compatibility notes</h2> <p>While the ECMAScript 2015 specification dictates that support for <code>__proto__</code> is required <em>only</em> for web browsers (although being normative), other environments may support it as well for legacy usage.</p> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"isprototypeof\"><code>Object.prototype.isPrototypeOf()</code></a></li> <li><a href=\"getprototypeof\"><code>Object.getPrototypeOf()</code></a></li> <li><a href=\"setprototypeof\"><code>Object.setPrototypeOf()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/proto$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/proto\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/proto</a>\n  </p>\n</div>\n","global_objects/object/propertyisenumerable":"<h1>object.propertyIsEnumerable</h1> <p>The <code><strong>propertyIsEnumerable()</strong></code> method returns a Boolean indicating whether the specified property is enumerable.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/object-prototype-propertyisenumerable.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\"><var>obj</var>.propertyIsEnumerable(<var>prop</var>)</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><code>prop</code></dt> <dd>The name of the property to test.</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p>A <a href=\"../boolean\"><code>Boolean</code></a> indicating whether the specified property is enumerable.</p> <h2 id=\"Description\">Description</h2> <p>Every object has a <code>propertyIsEnumerable</code> method. This method can determine whether the specified property in an object can be enumerated by a <a href=\"../../statements/for...in\"><code>for...in</code></a> loop, with the exception of properties inherited through the prototype chain. If the object does not have the specified property, this method returns <code>false</code>.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"A_basic_use_of_propertyIsEnumerable\">A basic use of <code>propertyIsEnumerable</code>\n</h3> <p>The following example shows the use of <code>propertyIsEnumerable</code> on objects and arrays:</p> <pre data-language=\"js\">var o = {};\nvar a = [];\no.prop = 'is enumerable';\na[0] = 'is enumerable';\n\no.propertyIsEnumerable('prop');   // returns true\na.propertyIsEnumerable(0);        // returns true\n</pre> <h3 id=\"User-defined_vs._built-in_objects\">User-defined vs. built-in objects</h3> <p>The following example demonstrates the enumerability of user-defined vs. built-in properties:</p> <pre data-language=\"js\">var a = ['is enumerable'];\n\na.propertyIsEnumerable(0);          // returns true\na.propertyIsEnumerable('length');   // returns false\n\nMath.propertyIsEnumerable('random');   // returns false\nthis.propertyIsEnumerable('Math');     // returns false\n</pre> <h3 id=\"Direct_vs._inherited_properties\">Direct vs. inherited properties</h3> <pre data-language=\"js\">var a = [];\na.propertyIsEnumerable('constructor');         // returns false\n\nfunction firstConstructor() {\n  this.property = 'is not enumerable';\n}\n\nfirstConstructor.prototype.firstMethod = function() {};\n\nfunction secondConstructor() {\n  this.method = function method() { return 'is enumerable'; };\n}\n\nsecondConstructor.prototype = new firstConstructor;\nsecondConstructor.prototype.constructor = secondConstructor;\n\nvar o = new secondConstructor();\no.arbitraryProperty = 'is enumerable';\n\no.propertyIsEnumerable('arbitraryProperty');   // returns true\no.propertyIsEnumerable('method');              // returns true\no.propertyIsEnumerable('property');            // returns false\n\no.property = 'is enumerable';\n\no.propertyIsEnumerable('property');            // returns true\n\n// These return false as they are on the prototype which \n// propertyIsEnumerable does not consider (even though the last two\n// are iteratable with for-in)\no.propertyIsEnumerable('prototype');   // returns false (as of JS 1.8.1/FF3.6)\no.propertyIsEnumerable('constructor'); // returns false\no.propertyIsEnumerable('firstMethod'); // returns false\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/publications/files/ECMA-ST-ARCH/ECMA-262,%203rd%20edition,%20December%201999.pdf\" hreflang=\"en\">ECMAScript 3rd Edition (ECMA-262)</a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/5.1/#sec-15.2.4.7\" hreflang=\"en\">ECMAScript 5.1 (ECMA-262)<br><small>The definition of 'Object.prototype.propertyIsEnumerable' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-object.prototype.propertyisenumerable\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Object.prototype.propertyIsEnumerable' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-object.prototype.propertyisenumerable\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Object.prototype.propertyIsEnumerable' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>   <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div>  <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"https://developer.mozilla.org/en-US/docs/Enumerability_and_ownership_of_properties\">Enumerability and ownership of properties</a></li> <li><a href=\"../../statements/for...in\"><code>for...in</code></a></li> <li><a href=\"keys\"><code>Object.keys()</code></a></li> <li><a href=\"defineproperty\"><code>Object.defineProperty()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/propertyIsEnumerable$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/propertyIsEnumerable\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/propertyIsEnumerable</a>\n  </p>\n</div>\n","global_objects/object/constructor":"<h1>object.constructor</h1> <p>The <code>constructor</code> property returns a reference to the <a href=\"../object\"><code>Object</code></a> constructor function that created the instance object. Note that the value of this property is a reference to the function itself, not a string containing the function's name. The value is only read-only for primitive values such as <code>1</code>, <code>true</code> and <code>\"test\"</code>.</p> <h2 id=\"Description\">Description</h2> <p>All objects (with the exception of objects created with <code>Object.create(null)</code>) will have a <code>constructor</code> property. Objects created without the explicit use of a constructor function (i.e. the object and array literals) will have a <code>constructor</code> property that points to the Fundamental Object constructor type for that object.</p> <pre data-language=\"js\">var o = {};\no.constructor === Object; // true\n\nvar o = new Object;\no.constructor === Object; // true\n\nvar a = [];\na.constructor === Array; // true\n\nvar a = new Array;\na.constructor === Array; // true\n\nvar n = new Number(3);\nn.constructor === Number; // true\n</pre> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Displaying_the_constructor_of_an_object\">Displaying the constructor of an object</h3> <p>The following example creates a prototype, <code>Tree</code>, and an object of that type, <code>theTree</code>. The example then displays the <code>constructor</code> property for the object <code>theTree</code>.</p> <pre data-language=\"js\">function Tree(name) {\n  this.name = name;\n}\n\nvar theTree = new Tree('Redwood');\nconsole.log('theTree.constructor is ' + theTree.constructor);\n</pre> <p>This example displays the following output:</p> <pre data-language=\"js\">theTree.constructor is function Tree(name) {\n  this.name = name;\n}\n</pre> <h3 id=\"Changing_the_constructor_of_an_object\">Changing the constructor of an object</h3> <p>The following example shows how to modify constructor value of generic objects. Only <code>true</code>, <code>1</code> and <code>\"test\"</code> will not be affected as they have read-only native constructors. This example shows that it is not always safe to rely on the <code>constructor</code> property of an object.</p> <pre data-language=\"js\">function Type () {}\n\nvar types = [\n  new Array(),\n  [],\n  new Boolean(),\n  true,             // remains unchanged\n  new Date(),\n  new Error(),\n  new Function(),\n  function () {},\n  Math,\n  new Number(),\n  1,                // remains unchanged\n  new Object(),\n  {},\n  new RegExp(),\n  /(?:)/,\n  new String(),\n  'test'            // remains unchanged\n];\n\nfor (var i = 0; i &lt; types.length; i++) {\n  types[i].constructor = Type;\n  types[i] = [types[i].constructor, types[i] instanceof Type, types[i].toString()];\n}\n\nconsole.log(types.join('\\n'));\n</pre> <p>This example displays the following output (comments added for reference):</p> <pre data-language=\"js\">function Type() {},false,                                     // new Array()\nfunction Type() {},false,                                     // []\nfunction Type() {},false,false                                // new Boolean()\nfunction Boolean() {\n    [native code]\n},false,true                                                  // true\nfunction Type() {},false,Mon Sep 01 2014 16:03:49 GMT+0600    // new Date()\nfunction Type() {},false,Error                                // new Error()\nfunction Type() {},false,function anonymous() {\n\n}                                                             // new Function()\nfunction Type() {},false,function () {}                       // function () {}\nfunction Type() {},false,[object Math]                        // Math\nfunction Type() {},false,0                                    // new Number()\nfunction Number() {\n    [native code]\n},false,1                                                     // 1\nfunction Type() {},false,[object Object]                      // new Object()\nfunction Type() {},false,[object Object]                      // {} \nfunction Type() {},false,/(?:)/                               // new Regexp()\nfunction Type() {},false,/(?:)/                               // /(?:)/ \nfunction Type() {},false,                                     // new String()\nfunction String() {\n    [native code]\n},false,test                                                  // 'test'\n</pre> <h3 id=\"Changing_the_constructor_of_a_function\">Changing the constructor of a function</h3> <p>Mostly this property is used for defining a function as a <strong>function-constructor</strong> with further calling it with <strong>new</strong> and prototype-inherits chain.</p> <pre data-language=\"js\">function Parent() {}\nParent.prototype.parentMethod = function parentMethod() {};\n\nfunction Child() {}\nChild.prototype = Object.create(Parent.prototype); // re-define child prototype to Parent prototype\n\nChild.prototype.constructor = Child; // return original constructor to Child</pre> <p>But when do we need to perform last line here? Unfortunately the answer is - it depends.</p> <p>Let's try to define the cases in which re-assignment of the original constructor will play a major role and when it will be one extra unused line of code.</p> <p>Take the following case: the object has <strong>create </strong>method to create itself.</p> <pre data-language=\"js\">function Parent() {};\nfunction CreatedConstructor() {}\n\nCreatedConstructor.prototype = Object.create(Parent.prototype);\n\nCreatedConstructor.prototype.create = function create() {\n  return new this.constructor();\n}\n\nnew CreatedConstructor().create().create(); // TypeError undefined is not a function since constructor === Parent</pre> <p>In the example above the exception will be shown since constructor links to Parent.</p> <p>To avoid this just assign necessary constructor which you are going to use.</p> <pre data-language=\"js\">function Parent() {}; \nfunction CreatedConstructor() {} \n\nCreatedConstructor.prototype = Object.create(Parent.prototype); \nCreatedConstructor.prototype.constructor = CreatedConstructor; // set right constructor for further using\n\nCreatedConstructor.prototype.create = function create() { \n  return new this.constructor();\n} \n\nnew CreatedConstructor().create().create(); // it's pretty fine</pre> <p>Ok, now it's pretty clear why changing of the constructor can be useful.</p> <p>Let's consider one more case.</p> <pre data-language=\"js\">function ParentWithStatic() {}\n\nParentWithStatic.startPosition = { x: 0, y:0 };\nParentWithStatic.getStartPosition = function getStartPosition() {\n  return this.startPosition;\n} \n\nfunction Child(x, y) {\n  this.position = {\n    x: x,\n    y: y\n  };\n}\n\nChild.prototype = Object.create(ParentWithStatic.prototype); \nChild.prototype.constructor = Child;\n\nChild.prototype.getOffsetByInitialPosition = function getOffsetByInitialPosition() {\n  var position = this.position;\n  var startPosition = this.constructor.getStartPosition(); // error undefined is not a function, since the constructor is Child\n\n  return {\n    offsetX: startPosition.x - position.x,\n    offsetY: startPosition.y - position.y\n  }\n};</pre> <p>For this example we need to stay parent constructor to continue to work properly.</p> <p><strong>Summary</strong>: manually updating or setting the constructor can lead to differrent and sometimes confusing consequences. To prevent this just define the role of constructor in each specific case. In most cases constructor is not used and reassignment of it is not necessary.</p> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <thead> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> </thead> <tbody> <tr> <td><a href=\"https://www.ecma-international.org/publications/files/ECMA-ST-ARCH/ECMA-262,%201st%20edition,%20June%201997.pdf\" hreflang=\"en\">ECMAScript 1st Edition (ECMA-262)</a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition. Implemented in JavaScript 1.1.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/5.1/#sec-15.2.4.1\" hreflang=\"en\">ECMAScript 5.1 (ECMA-262)<br><small>The definition of 'Object.prototype.constructor' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-object.prototype.constructor\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Object.prototype.constructor' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-object.prototype.constructor\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Object.prototype.constructor' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>   <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/constructor$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/constructor\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/constructor</a>\n  </p>\n</div>\n","global_objects/error/prototype":"<h1>Error.prototype</h1> <p>The <code><strong>Error.prototype</strong></code> property represents the prototype for the <a href=\"../error\"><code>Error</code></a> constructor.</p> <div class=\"_table\"><table class=\"standard-table\"> <thead> <tr> <th colspan=\"2\" class=\"header\">Property attributes of <code>Error.prototype</code>\n</th> </tr> </thead> <tbody> <tr> <td>Writable</td> <td>no</td> </tr> <tr> <td>Enumerable</td> <td>no</td> </tr> <tr> <td>Configurable</td> <td>no</td> </tr> </tbody> </table></div> <h2 id=\"Description\">Description</h2> <p>All <a href=\"../error\"><code>Error</code></a> instances and instances of <a href=\"../error#Error_types\">non-generic errors</a> inherit from <code>Error.prototype</code>. As with all constructor functions, you can use the prototype of the constructor to add properties or methods to all instances created with that constructor.</p> <h2 id=\"Properties\">Properties</h2> <h3 id=\"Standard_properties\">Standard properties</h3> <dl> <dt><code>Error.prototype.constructor</code></dt> <dd>Specifies the function that created an instance's prototype.</dd> <dt><a href=\"message\"><code>Error.prototype.message</code></a></dt> <dd>Error message.</dd> <dt><a href=\"name\"><code>Error.prototype.name</code></a></dt> <dd>Error name.</dd> </dl> <h3 id=\"Vendor-specific_extensions\">Vendor-specific extensions</h3> <div class=\"blockIndicator nonStandard nonStandardHeader\"> <p><strong> Non-standard</strong><br> This feature is non-standard and is not on a standards track. Do not use it on production sites facing the Web: it will not work for every user. There may also be large incompatibilities between implementations and the behavior may change in the future.</p> </div> <h4 id=\"Microsoft\">Microsoft</h4> <dl> <dt><a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/description\"><code>Error.prototype.description</code></a></dt> <dd>Error description. Similar to <a href=\"message\"><code>message</code></a>.</dd> <dt><a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/number\"><code>Error.prototype.number</code></a></dt> <dd>Error number.</dd> </dl> <h4 id=\"Mozilla\">Mozilla</h4> <dl> <dt><a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/fileName\"><code>Error.prototype.fileName</code></a></dt> <dd>Path to file that raised this error.</dd> <dt><a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/lineNumber\"><code>Error.prototype.lineNumber</code></a></dt> <dd>Line number in file that raised this error.</dd> <dt><a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/columnNumber\"><code>Error.prototype.columnNumber</code></a></dt> <dd>Column number in line that raised this error.</dd> <dt><a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/stack\"><code>Error.prototype.stack</code></a></dt> <dd>Stack trace.</dd> </dl> <h2 id=\"Methods\">Methods</h2> <dl> <dt>\n<a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/toSource\"><code>Error.prototype.toSource()</code></a> \n</dt> <dd>Returns a string containing the source of the specified <a href=\"../error\"><code>Error</code></a> object; you can use this value to create a new object. Overrides the <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/toSource\"><code>Object.prototype.toSource()</code></a> method.</dd> <dt><a href=\"tostring\"><code>Error.prototype.toString()</code></a></dt> <dd>Returns a string representing the specified object. Overrides the <a href=\"../object/tostring\"><code>Object.prototype.toString()</code></a> method.</dd> </dl> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/publications/files/ECMA-ST-ARCH/ECMA-262,%201st%20edition,%20June%201997.pdf\" hreflang=\"en\">ECMAScript 1st Edition (ECMA-262)</a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition. Implemented in JavaScript 1.1.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/5.1/#sec-15.11.3.1\" hreflang=\"en\">ECMAScript 5.1 (ECMA-262)<br><small>The definition of 'Error' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-error.prototype\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Error' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-error.prototype\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Error' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>   <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> 6</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div>  <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"../error\"><code>Error</code></a></li> <li><a href=\"../object/prototype\"><code>Object.prototype</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/prototype$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/prototype\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/prototype</a>\n  </p>\n</div>\n","about":"<h1>About</h1> <p>The JavaScript reference serves as a repository of facts about the JavaScript language. The entire language is described here in detail. As you write JavaScript code, you'll refer to these pages often (thus the title \"JavaScript reference\"). If you're learning JavaScript, or need help understanding some of its capabilities or features, check out the <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide\">JavaScript guide</a>.</p> <p>The JavaScript language is intended to be used within some larger environment, be it a browser, server-side scripts, or similar. For the most part, this reference attempts to be environment-agnostic and does not target a web browser environment.</p> <h2 id=\"Where_to_find_JavaScript_information\">Where to find JavaScript information</h2> <p>JavaScript documentation of core language features (pure <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Language_Resources\">ECMAScript</a>, for the most part) includes the following:</p> <ul> <li>The <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide\">JavaScript guide</a>\n</li> <li>The <a href=\"index\">JavaScript reference</a>\n</li> </ul> <p>If you are new to JavaScript, start with the <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide\">guide</a>. Once you have a firm grasp of the fundamentals, you can use the <a href=\"index\">reference</a> to get more details on individual objects and language constructs.</p> <h2 id=\"Structure_of_the_reference\">Structure of the reference</h2> <p>In the JavaScript reference you can find the following chapters:</p> <dl> <dt><a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects\">Standard built-in objects</a></dt> <dd>This chapter documents all the JavaScript standard built-in objects, along with their methods and properties.</dd> <dt><a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements\">Statements and declarations</a></dt> <dd>JavaScript applications consist of statements with an appropriate syntax. A single statement may span multiple lines. Multiple statements may occur on a single line if each statement is separated by a semicolon. This isn't a keyword, but a group of keywords.</dd> <dt><a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators\">Expressions and operators</a></dt> <dd>This chapter documents all the JavaScript language operators, expressions and keywords.</dd> <dt><a href=\"functions\">Functions</a></dt> <dd>Chapter about JavaScript functions.</dd> <dt><a href=\"classes\">Classes</a></dt> <dd>Chapter about JavaScript classes introduced in ECMAScript 2015.</dd> <dt><a href=\"errors\">Errors</a></dt> <dd>Chapter about specific errors, exceptions and warnings thrown by JavaScript.</dd> <dt><a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/New_in_JavaScript\">New in JavaScript</a></dt> <dd>Chapter about JavaScript version history.</dd> </dl> <h3 id=\"More_reference_pages\">More reference pages</h3> <ul> <li><a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Deprecated_and_obsolete_features\">Deprecated and obsolete features</a></li> <li><a href=\"lexical_grammar\">Lexical grammar</a></li> <li><a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures\">Data types and data structures</a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/About$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/About\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/About</a>\n  </p>\n</div>\n","global_objects/object/isprototypeof":"<h1>object.isPrototypeOf</h1> <p>The <code><strong>isPrototypeOf()</strong></code> method checks if an object exists in another object's prototype chain.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/object-prototype-isprototypeof.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <div class=\"note\"> <p><code>isPrototypeOf()</code> differs from the <a href=\"../../operators/instanceof\"><code>instanceof</code></a> operator. In the expression \"<code>object instanceof AFunction</code>\", the <code>object</code> prototype chain is checked against <code>AFunction.prototype</code>, not against <code>AFunction</code> itself.</p> </div> <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\"><var>prototypeObj</var>.isPrototypeOf(<var>object</var>)</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><code>object</code></dt> <dd>The object whose prototype chain will be searched.</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p>A <a href=\"../boolean\"><code>Boolean</code></a> indicating whether the calling object lies in the prototype chain of the specified object.</p> <h3 id=\"Errors_thrown\">Errors thrown</h3> <dl> <dt><a href=\"../typeerror\"><code>TypeError</code></a></dt> <dd>A <a href=\"../typeerror\"><code>TypeError</code></a> is thrown if <code><var>prototypeObj</var></code> is undefined or null.</dd> </dl> <h2 id=\"Description\">Description</h2> <p>The <code>isPrototypeOf()</code> method allows you to check whether or not an object exists within another object's prototype chain.</p> <h2 id=\"Examples\">Examples</h2> <p>This example demonstrates that <code>Baz.prototype</code>, <code>Bar.prototype</code>, <code>Foo.prototype</code> and <code>Object.prototype</code> exist in the prototype chain for object <code>baz</code>:</p> <pre data-language=\"js\">function Foo() {}\nfunction Bar() {}\nfunction Baz() {}\n\nBar.prototype = Object.create(Foo.prototype);\nBaz.prototype = Object.create(Bar.prototype);\n\nvar baz = new Baz();\n\nconsole.log(Baz.prototype.isPrototypeOf(baz)); // true\nconsole.log(Bar.prototype.isPrototypeOf(baz)); // true\nconsole.log(Foo.prototype.isPrototypeOf(baz)); // true\nconsole.log(Object.prototype.isPrototypeOf(baz)); // true\n</pre> <p><code>isPrototypeOf()</code> method, along with the <a href=\"../../operators/instanceof\"><code>instanceof</code></a> operator particularly comes in handy if you have code that can only function when dealing with objects descended from a specific prototype chain, e.g., to guarantee that certain methods or properties will be present on that object.</p> <p>For example, check if <code>baz</code> object descends from <code>Foo.prototype</code>:</p> <pre data-language=\"js\">if (Foo.prototype.isPrototypeOf(baz)) {\n  // do something safe\n}\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/publications/files/ECMA-ST-ARCH/ECMA-262,%203rd%20edition,%20December%201999.pdf\" hreflang=\"en\">ECMAScript 3rd Edition (ECMA-262)</a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/5.1/#sec-15.2.4.6\" hreflang=\"en\">ECMAScript 5.1 (ECMA-262)<br><small>The definition of 'Object.prototype.isPrototypeOf' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-object.prototype.isprototypeof\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Object.prototype.isPrototypeOf' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-object.prototype.isprototypeof\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Object.prototype.isPrototypeOf' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>   <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div>  <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"../../operators/instanceof\"><code>instanceof</code></a></li> <li><a href=\"getprototypeof\"><code>Object.getPrototypeOf()</code></a></li> <li> <a href=\"setprototypeof\"><code>Object.setPrototypeOf()</code></a> </li> <li>\n<a href=\"proto\"><code>Object.prototype.__proto__</code></a> </li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/isPrototypeOf$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/isPrototypeOf\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/isPrototypeOf</a>\n  </p>\n</div>\n","global_objects/object/tolocalestring":"<h1>object.toLocaleString</h1> <p>The <code><strong>toLocaleString()</strong></code> method returns a string representing the object. This method is meant to be overridden by derived objects for locale-specific purposes.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/object-prototype-tolocalestring.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\"><var>obj</var>.toLocaleString()</pre> <h3 id=\"Return_value\">Return value</h3> <p>A string representing the object.</p> <h2 id=\"Description\">Description</h2> <p><a href=\"../object\"><code>Object</code></a>'s <code>toLocaleString</code> returns the result of calling <a href=\"tostring\"><code>toString()</code></a>.</p> <p>This function is provided to give objects a generic <code>toLocaleString</code> method, even though not all may use it. See the list below.</p> <h3 id=\"Objects_overriding_toLocaleString\">Objects overriding <code>toLocaleString</code>\n</h3> <ul> <li>\n<a href=\"../array\"><code>Array</code></a>: <a href=\"../array/tolocalestring\"><code>Array.prototype.toLocaleString()</code></a>\n</li> <li>\n<a href=\"../number\"><code>Number</code></a>: <a href=\"../number/tolocalestring\"><code>Number.prototype.toLocaleString()</code></a>\n</li> <li>\n<a href=\"../date\"><code>Date</code></a>: <a href=\"../date/tolocalestring\"><code>Date.prototype.toLocaleString()</code></a>\n</li> </ul> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <thead> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> </thead> <tbody> <tr> <td><a href=\"https://www.ecma-international.org/publications/files/ECMA-ST-ARCH/ECMA-262,%203rd%20edition,%20December%201999.pdf\" hreflang=\"en\">ECMAScript 3rd Edition (ECMA-262)</a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/5.1/#sec-15.2.4.3\" hreflang=\"en\">ECMAScript 5.1 (ECMA-262)<br><small>The definition of 'Object.prototype.toLocaleString' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-object.prototype.tolocalestring\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Object.prototype.toLocaleString' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-object.prototype.tolocalestring\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Object.prototype.toLocaleString' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"tostring\"><code>Object.prototype.toString()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/toLocaleString$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/toLocaleString\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/toLocaleString</a>\n  </p>\n</div>\n","global_objects/object/tostring":"<h1>object.toString</h1> <p>The <code><strong>toString()</strong></code> method returns a string representing the object.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/object-prototype-tostring.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\"><var>obj</var>.toString()</pre> <h3 id=\"Return_value\">Return value</h3> <p>A string representing the object.</p> <h2 id=\"Description\">Description</h2> <p>Every object has a <code>toString()</code> method that is automatically called when the object is to be represented as a text value or when an object is referred to in a manner in which a string is expected. By default, the <code>toString()</code> method is inherited by every object descended from <code>Object</code>. If this method is not overridden in a custom object, <code>toString()</code> returns \"[object <em>type</em>]\", where <code><em>type</em></code> is the object type. The following code illustrates this:</p> <pre data-language=\"js\">var o = new Object();\no.toString(); // returns [object Object]\n</pre> <div class=\"note\"> <p><strong>Note:</strong> Starting in JavaScript 1.8.5 <code>toString()</code> called on <a href=\"../null\"><code>null</code></a> returns <code>[object <em>Null</em>]</code>, and <a href=\"../undefined\"><code>undefined</code></a> returns <code>[object <em>Undefined</em>]</code>, as defined in the 5th Edition of ECMAScript and a subsequent Errata. See <a href=\"#Using_toString()_to_detect_object_class\">Using_toString()_to_detect_object_class</a>.</p> </div> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Overriding_the_default_toString_method\">Overriding the default <code>toString</code> method</h3> <p>You can create a function to be called in place of the default <code>toString()</code> method. The <code>toString()</code> method takes no arguments and should return a string. The <code>toString()</code> method you create can be any value you want, but it will be most useful if it carries information about the object.</p> <p>The following code defines the <code>Dog</code> object type and creates <code>theDog</code>, an object of type <code>Dog</code>:</p> <pre data-language=\"js\">function Dog(name, breed, color, sex) {\n  this.name = name;\n  this.breed = breed;\n  this.color = color;\n  this.sex = sex;\n}\n\ntheDog = new Dog('Gabby', 'Lab', 'chocolate', 'female');\n</pre> <p>If you call the <code>toString()</code> method on this custom object, it returns the default value inherited from <a href=\"../object\"><code>Object</code></a>:</p> <pre data-language=\"js\">theDog.toString(); // returns [object Object]\n</pre> <p>The following code creates and assigns <code>dogToString()</code> to override the default <code>toString()</code> method. This function generates a string containing the name, breed, color, and sex of the object, in the form \"<code>property = value;</code>\".</p> <pre data-language=\"js\">Dog.prototype.toString = function dogToString() {\n  var ret = 'Dog ' + this.name + ' is a ' + this.sex + ' ' + this.color + ' ' + this.breed;\n  return ret;\n}\n</pre> <p>With the preceding code in place, any time <code>theDog</code> is used in a string context, JavaScript automatically calls the <code>dogToString()</code> function, which returns the following string:</p> <pre data-language=\"js\">\"Dog Gabby is a female chocolate Lab\"\n</pre> <h3 id=\"Using_toString()_to_detect_object_class\">Using <code>toString()</code> to detect object class</h3> <p><code>toString()</code> can be used with every object and allows you to get its class. To use the <code>Object.prototype.toString()</code> with every object, you need to call <a href=\"../function/call\"><code>Function.prototype.call()</code></a> or <a href=\"../function/apply\"><code>Function.prototype.apply()</code></a> on it, passing the object you want to inspect as the first parameter called <code>thisArg</code>.</p> <pre data-language=\"js\">var toString = Object.prototype.toString;\n\ntoString.call(new Date);    // [object Date]\ntoString.call(new String);  // [object String]\ntoString.call(Math);        // [object Math]\n\n// Since JavaScript 1.8.5\ntoString.call(undefined);   // [object Undefined]\ntoString.call(null);        // [object Null]\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/publications/files/ECMA-ST-ARCH/ECMA-262,%201st%20edition,%20June%201997.pdf\" hreflang=\"en\">ECMAScript 1st Edition (ECMA-262)</a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition. Implemented in JavaScript 1.0.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/5.1/#sec-15.2.4.2\" hreflang=\"en\">ECMAScript 5.1 (ECMA-262)<br><small>The definition of 'Object.prototype.toString' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Call on <a href=\"../null\"><code>null</code></a> returns <code>[object <em>Null</em>]</code>, and <a href=\"../undefined\"><code>undefined</code></a> returns <code>[object <em>Undefined</em>]</code>\n</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-object.prototype.tostring\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Object.prototype.toString' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-object.prototype.tostring\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Object.prototype.toString' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>   <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div>  <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/toSource\"><code>Object.prototype.toSource()</code></a></li> <li><a href=\"valueof\"><code>Object.prototype.valueOf()</code></a></li> <li><a href=\"../number/tostring\"><code>Number.prototype.toString()</code></a></li> <li><a href=\"../symbol/toprimitive\"><code>Symbol.toPrimitive</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/toString$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/toString\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/toString</a>\n  </p>\n</div>\n","global_objects/object/unwatch":"<h1>object.unwatch</h1> <div class=\"warning\"> <p><strong>Deprecation warning:</strong> Do not use <code>unwatch()</code> and <a href=\"watch\"><code>watch()</code></a>! These two methods were implemented only in Firefox prior to version 58, they're <strong>deprecated and removed in Firefox 58+</strong>. In addition, using watchpoints has a serious negative impact on performance, which is especially true when used on global objects, such as <code>window</code>. You can usually use <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Working_with_Objects#Defining_getters_and_setters\">setters and getters</a> or <a href=\"../proxy\">proxies</a> instead.</p> </div> <p>The <code><strong>unwatch()</strong></code> method removes a watchpoint set with the <a href=\"watch\"><code>watch()</code></a> method.</p> <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\"><var>obj</var>.unwatch(<var>prop</var>)</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><code>prop</code></dt> <dd>The name of a property of the object to stop watching.</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p><a href=\"../undefined\"><code>undefined</code></a>.</p> <h2 id=\"Description\">Description</h2> <p>The JavaScript debugger has functionality similar to that provided by this method, as well as other debugging options. For information on the debugger, see <a href=\"https://developer.mozilla.org/en-US/docs/Venkman\">Venkman</a>.</p> <p>By default, this method is inherited by every object descended from <a href=\"../object\"><code>Object</code></a>.</p> <div class=\"note\"> <p><strong>Note:</strong> The reason for <code>unwatch()</code> to take the property name <em>prop</em> as its only parameter is due to the \"single handler allowing\" behavior of the <a href=\"watch\"><code>watch()</code></a> method.</p> </div> <h2 id=\"Examples\">Examples</h2> <p>See <a href=\"watch\"><code>watch()</code></a>.</p> <h2 id=\"Specifications\">Specifications</h2> <p>Not part of any specifications. Implemented in JavaScript 1.2.</p> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>   <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support \n</th>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\">1 — 58</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support \n</th>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\">4 — 58</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support \n</th>\n<td class=\"bc-supports-no\"> No</td>\n</tr></tbody>\n</table>\n</div>  <h2 id=\"Compatibility_notes\">Compatibility notes</h2> <ul> <li>Calling <code>unwatch()</code> on the <a href=\"https://developer.mozilla.org/en-US/docs/Web/API/Document\"><code>Document</code></a> object throws a <a href=\"../typeerror\"><code>TypeError</code></a> since Firefox 23 (<a href=\"https://bugzilla.mozilla.org/show_bug.cgi?id=903332\">bug 903332</a>). This regression has been fixed with Firefox 27.</li> </ul> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"watch\"><code>Object.watch()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/unwatch$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/unwatch\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/unwatch</a>\n  </p>\n</div>\n","global_objects/object/valueof":"<h1>object.valueOf</h1> <p>The <code>valueOf()</code> method returns the primitive value of the specified object.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/object-prototype-valueof.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\"><var>object</var>.valueOf()</pre> <h3 id=\"Return_value\">Return value</h3> <p>The primitive value of the specified object.</p> <h2 id=\"Description\">Description</h2> <p>JavaScript calls the <code>valueOf</code> method to convert an object to a primitive value. You rarely need to invoke the <code>valueOf</code> method yourself; JavaScript automatically invokes it when encountering an object where a primitive value is expected.</p> <p>By default, the <code>valueOf</code> method is inherited by every object descended from <a href=\"../object\"><code>Object</code></a>. Every built-in core object overrides this method to return an appropriate value. If an object has no primitive value, <code>valueOf</code> returns the object itself.</p> <p>You can use <code>valueOf</code> within your own code to convert a built-in object into a primitive value. When you create a custom object, you can override <code>Object.prototype.valueOf()</code> to call a custom method instead of the default <a href=\"../object\"><code>Object</code></a> method.</p> <h3 id=\"Overriding_valueOf_for_custom_objects\">Overriding valueOf for custom objects</h3> <p>You can create a function to be called in place of the default <code>valueOf</code> method. Your function must take no arguments.</p> <p>Suppose you have an object type <code>MyNumberType</code> and you want to create a <code>valueOf</code> method for it. The following code assigns a user-defined function to the object's <code>valueOf</code> method:</p> <pre data-language=\"js\">MyNumberType.prototype.valueOf = function() { return customPrimitiveValue; };</pre> <p>With the preceding code in place, any time an object of type <code>MyNumberType</code> is used in a context where it is to be represented as a primitive value, JavaScript automatically calls the function defined in the preceding code.</p> <p>An object's <code>valueOf</code> method is usually invoked by JavaScript, but you can invoke it yourself as follows:</p> <pre data-language=\"js\"><var>myNumberType</var>.valueOf()</pre> <div class=\"note\"> <p><strong>Note:</strong> Objects in string contexts convert via the <a href=\"tostring\"><code>toString()</code></a> method, which is different from <a href=\"../string\"><code>String</code></a> objects converting to string primitives using <code>valueOf</code>. All objects have a string conversion, if only \"<code>[object <em>type</em>]</code>\". But many objects do not convert to number, boolean, or function.</p> </div> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Using_valueOf\">Using valueOf</h3> <pre data-language=\"js\">function MyNumberType(n) {\n    this.number = n;\n}\n\nMyNumberType.prototype.valueOf = function() {\n    return this.number;\n};\n\nvar myObj = new MyNumberType(4);\nmyObj + 3; // 7\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <thead> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> </thead> <tbody> <tr> <td><a href=\"https://www.ecma-international.org/publications/files/ECMA-ST-ARCH/ECMA-262,%201st%20edition,%20June%201997.pdf\" hreflang=\"en\">ECMAScript 1st Edition (ECMA-262)</a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition. Implemented in JavaScript 1.1.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/5.1/#sec-15.2.4.4\" hreflang=\"en\">ECMAScript 5.1 (ECMA-262)<br><small>The definition of 'Object.prototype.valueOf' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-object.prototype.valueof\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Object.prototype.valueOf' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-object.prototype.valueof\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Object.prototype.valueOf' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"tostring\"><code>Object.prototype.toString()</code></a></li> <li><a href=\"../parseint\"><code>parseInt()</code></a></li> <li><a href=\"../symbol/toprimitive\"><code>Symbol.toPrimitive</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/valueOf$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/valueOf\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/valueOf</a>\n  </p>\n</div>\n","global_objects/error/name":"<h1>error.name</h1> <p>The <code><strong>name</strong></code> property represents a name for the type of error. The initial value is \"Error\".</p> <h2 id=\"Description\">Description</h2> <p>By default, <a href=\"../error\"><code>Error</code></a> instances are given the name \"Error\". The <code>name</code> property, in addition to the <a href=\"message\"><code>message</code></a> property, is used by the <a href=\"tostring\"><code>Error.prototype.toString()</code></a> method to create a string representation of the error.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Throwing_a_custom_error\">Throwing a custom error</h3> <pre data-language=\"js\">var e = new Error('Malformed input'); // e.name is 'Error'\n\ne.name = 'ParseError';\nthrow e;\n// e.toString() would return 'ParseError: Malformed input'\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/publications/files/ECMA-ST-ARCH/ECMA-262,%201st%20edition,%20June%201997.pdf\" hreflang=\"en\">ECMAScript 1st Edition (ECMA-262)</a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/5.1/#sec-15.11.4.2\" hreflang=\"en\">ECMAScript 5.1 (ECMA-262)<br><small>The definition of 'Error.prototype.name' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-error.prototype.name\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Error.prototype.name' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-error.prototype.name\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Error.prototype.name' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>    <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> 6</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div>   <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"message\"><code>Error.prototype.message</code></a></li> <li><a href=\"tostring\"><code>Error.prototype.toString()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/name$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/name\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/name</a>\n  </p>\n</div>\n","global_objects/arraybuffer/prototype":"<h1>ArrayBuffer.prototype</h1> <p>The <code>ArrayBuffer.prototype</code> property represents the prototype for the <a href=\"../arraybuffer\"><code>ArrayBuffer</code></a> object.</p> <div class=\"_table\"><table class=\"standard-table\"> <thead> <tr> <th colspan=\"2\" class=\"header\">Property attributes of <code>ArrayBuffer.prototype</code>\n</th> </tr> </thead> <tbody> <tr> <td>Writable</td> <td>no</td> </tr> <tr> <td>Enumerable</td> <td>no</td> </tr> <tr> <td>Configurable</td> <td>no</td> </tr> </tbody> </table></div> <h2 id=\"Description\">Description</h2> <p><code>ArrayBuffer</code> instances inherit from <code>ArrayBuffer.prototype</code>. As with all constructors, you can change the constructor's prototype object to make changes to all <code>ArrayBuffer</code> instances.</p> <h2 id=\"Properties\">Properties</h2> <dl> <dt>ArrayBuffer.prototype.constructor</dt> <dd>Specifies the function that creates an object's prototype. The initial value is the standard built-in <code>ArrayBuffer</code> constructor.</dd> <dt>\n<a href=\"bytelength\"><code>ArrayBuffer.prototype.byteLength</code></a> <span class=\"inlineIndicator readOnly readOnlyInline\">Read only </span>\n</dt> <dd>The size, in bytes, of the array. This is established when the array is constructed and cannot be changed. <strong>Read only.</strong>\n</dd> </dl> <h2 id=\"Methods\">Methods</h2> <dl> <dt><a href=\"slice\"><code>ArrayBuffer.prototype.slice()</code></a></dt> <dd>Returns a new <code>ArrayBuffer</code> whose contents are a copy of this <code>ArrayBuffer</code>'s bytes from <code>begin</code>, inclusive, up to <code>end</code>, exclusive. If either <code>begin</code> or <code>end</code> is negative, it refers to an index from the end of the array, as opposed to from the beginning.</dd> </dl> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-arraybuffer.prototype\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'ArrayBuffer.prototype' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-arraybuffer.prototype\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'ArrayBuffer.prototype' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 7</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> 10</td>\n<td class=\"bc-supports-yes\"> 11.6</td>\n<td class=\"bc-supports-yes\"> 5.1</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> 11.6</td>\n<td class=\"bc-supports-yes\"> 4.2</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"../arraybuffer\"><code>ArrayBuffer</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer/prototype$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer/prototype\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer/prototype</a>\n  </p>\n</div>\n","global_objects/object/watch":"<h1>object.watch</h1> <div class=\"warning\"> <p><strong>Deprecation warning:</strong> Do not use <code>watch()</code> and <a href=\"unwatch\"><code>unwatch()</code></a>! These two methods were implemented only in Firefox prior to version 58, they're <strong>deprecated and removed in Firefox 58+</strong>. In addition, using watchpoints has a serious negative impact on performance, which is especially true when used on global objects, such as <code>window</code>. You can usually use <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Working_with_Objects#Defining_getters_and_setters\">setters and getters</a> or <a href=\"../proxy\">proxies</a> instead.</p> </div> <p>The <code><strong>watch()</strong></code> method watches for a property to be assigned a value and runs a function when that occurs.</p> <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\"><var>obj</var>.watch(<var>prop</var>, <var>handler</var>)</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><code>prop</code></dt> <dd>The name of a property of the object on which you wish to monitor changes.</dd> <dt><code>handler</code></dt> <dd>A function to call when the specified property's value changes.</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p><a href=\"../undefined\"><code>undefined</code></a>.</p> <h2 id=\"Description\">Description</h2> <p>Watches for assignment to a property named <code>prop</code> in this object, calling <code>handler(prop, oldval, newval)</code> whenever <code>prop</code> is set and storing the return value in that property. A watchpoint can filter (or nullify) the value assignment, by returning a modified <code>newval</code> (or by returning <code>oldval</code>).</p> <p>If you delete a property for which a watchpoint has been set, that watchpoint does not disappear. If you later recreate the property, the watchpoint is still in effect.</p> <p>To remove a watchpoint, use the <a href=\"unwatch\"><code>unwatch()</code></a> method. By default, the <code>watch</code> method is inherited by every object descended from <a href=\"../object\"><code>Object</code></a>.</p> <p>The JavaScript debugger has functionality similar to that provided by this method, as well as other debugging options. For information on the debugger, see <a href=\"https://developer.mozilla.org/en-US/docs/Venkman\">Venkman</a>.</p> <p>In Firefox, <code>handler</code> is only called from assignments in script, not from native code. For example, <code>window.watch('location', myHandler)</code> will not call <code>myHandler</code> if the user clicks a link to an anchor within the current document. However, <code>window.location += '#myAnchor'</code> will call <code>myHandler</code>.</p> <div class=\"note\"> <p><strong>Note:</strong> Calling <code>watch()</code> on an object for a specific property overrides any previous handler attached for that property.</p> </div> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Using_watch_and_unwatch\">Using <code>watch</code> and <code>unwatch</code>\n</h3> <pre data-language=\"js\">var o = { p: 1 };\n\no.watch('p', function (id, oldval, newval) {\n  console.log('o.' + id + ' changed from ' + oldval + ' to ' + newval);\n  return newval;\n});\n\no.p = 2;\no.p = 3;\ndelete o.p;\no.p = 4;\n\no.unwatch('p');\no.p = 5;\n</pre> <p>This script displays the following:</p> <pre>o.p changed from 1 to 2\no.p changed from 2 to 3\no.p changed from undefined to 4\n</pre> <h3 id=\"Using_watch_to_validate_an_object's_properties\">Using <code>watch</code> to validate an object's properties</h3> <p>You can use <code>watch</code> to test any assignment to an object's properties. This example ensures that every Person always has a valid name and an age between 0 and 200.</p> <pre data-language=\"js\">Person = function(name, age) {\n  this.watch('age', Person.prototype._isValidAssignment);\n  this.watch('name', Person.prototype._isValidAssignment);\n  this.name = name;\n  this.age = age;\n};\n\nPerson.prototype.toString = function() {\n  return this.name + ', ' + this.age;\n};\n\nPerson.prototype._isValidAssignment = function(id, oldval, newval) {\n  if (id === 'name' &amp;&amp; (!newval || newval.length &gt; 30)) {\n    throw new RangeError('invalid name for ' + this);\n  }\n  if (id === 'age'  &amp;&amp; (newval &lt; 0 || newval &gt; 200)) {\n    throw new RangeError('invalid age for ' + this);\n  }\n  return newval;\n}\n\nwill = new Person('Will', 29);\nconsole.log(will);   // Will, 29\n\ntry {\n  will.name = '';\n} catch (e) {\n  console.log(e);\n}\n\ntry {\n  will.age = -4;\n} catch (e) {\n  console.log(e);\n}\n</pre> <p>This script displays the following:</p> <pre>Will, 29\nRangeError: invalid name for Will, 29\nRangeError: invalid age for Will, 29\n</pre> <h2 id=\"Specifications\">Specifications</h2> <p>Not part of any specifications. Implemented in JavaScript 1.2.</p> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>   <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support \n</th>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\">1 — 58</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support \n</th>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\">4 — 58</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support \n</th>\n<td class=\"bc-supports-no\"> No</td>\n</tr></tbody>\n</table>\n</div>  <h2 id=\"Compatibility_notes\">Compatibility notes</h2> <ul> <li>This <a href=\"https://gist.github.com/384583\">Polyfill</a> offers <code>watch</code> to all ES5 compatible browsers.</li> <li>Using a <a href=\"../proxy\"><code>Proxy</code></a> enables you do even deeper changes to how property assignments work.</li> <li>Calling <code>watch()</code> on the <a href=\"https://developer.mozilla.org/en-US/docs/Web/API/Document\"><code>Document</code></a> object throws a <a href=\"../typeerror\"><code>TypeError</code></a> since Firefox 23 (<a href=\"https://bugzilla.mozilla.org/show_bug.cgi?id=903332\">bug 903332</a>). This regression has been fixed with Firefox 27.</li> </ul> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"unwatch\"><code>Object.unwatch()</code></a></li> <li>\n<a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/observe\"><code>Object.observe()</code></a> \n</li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/watch$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/watch\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/watch</a>\n  </p>\n</div>\n","global_objects/error/tostring":"<h1>error.toString</h1> <p>The <code><strong>toString()</strong></code> method returns a string representing the specified <a href=\"../error\"><code>Error</code></a> object.</p> <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\"><var>e</var>.toString()</pre> <h3 id=\"Return_value\">Return value</h3> <p>A string representing the specified <a href=\"../error\"><code>Error</code></a> object.</p> <h2 id=\"Description\">Description</h2> <p>The <a href=\"../error\"><code>Error</code></a> object overrides the <a href=\"../object/tostring\"><code>Object.prototype.toString()</code></a> method inherited by all objects. Its semantics are as follows (assuming <a href=\"../object\"><code>Object</code></a> and <a href=\"../string\"><code>String</code></a> have their original values):</p> <pre data-language=\"js\">Error.prototype.toString = function() {\n  'use strict';\n\n  var obj = Object(this);\n  if (obj !== this) {\n    throw new TypeError();\n  }\n\n  var name = this.name;\n  name = (name === undefined) ? 'Error' : String(name);\n\n  var msg = this.message;\n  msg = (msg === undefined) ? '' : String(msg);\n\n  if (name === '') {\n    return msg;\n  }\n  if (msg === '') {\n    return name;\n  }\n\n  return name + ': ' + msg;\n};\n</pre> <h2 id=\"Examples\">Examples</h2> <pre data-language=\"js\">var e = new Error('fatal error');\nconsole.log(e.toString()); // 'Error: fatal error'\n\ne.name = undefined;\nconsole.log(e.toString()); // 'Error: fatal error'\n\ne.name = '';\nconsole.log(e.toString()); // 'fatal error'\n\ne.message = undefined;\nconsole.log(e.toString()); // 'Error'\n\ne.name = 'hello';\nconsole.log(e.toString()); // 'hello'\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/publications/files/ECMA-ST-ARCH/ECMA-262,%201st%20edition,%20June%201997.pdf\" hreflang=\"en\">ECMAScript 1st Edition (ECMA-262)</a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition. Implemented in JavaScript 1.1.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/5.1/#sec-15.11.4.4\" hreflang=\"en\">ECMAScript 5.1 (ECMA-262)<br><small>The definition of 'Error.prototype.toString' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-error.prototype.tostring\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Error.prototype.toString' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-error.prototype.tostring\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Error.prototype.toString' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>    <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> 6</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div>   <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/toSource\"><code>Error.prototype.toSource()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/toString$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/toString\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/toString</a>\n  </p>\n</div>\n","global_objects/evalerror/prototype":"<h1>EvalError.prototype</h1> <p>The <code><strong>EvalError.prototype</strong></code> property represents the prototype of the <a href=\"../evalerror\"><code>EvalError</code></a> constructor.</p> <div class=\"_table\"><table class=\"standard-table\"> <thead> <tr> <th colspan=\"2\" class=\"header\">Property attributes of <code>EvalError.prototype</code>\n</th> </tr> </thead> <tbody> <tr> <td>Writable</td> <td>no</td> </tr> <tr> <td>Enumerable</td> <td>no</td> </tr> <tr> <td>Configurable</td> <td>no</td> </tr> </tbody> </table></div> <h2 id=\"Description\">Description</h2> <p>All <a href=\"../evalerror\"><code>EvalError</code></a> instances inherit from <code>EvalError.prototype</code>. You can use the prototype to add properties or methods to all instances.</p> <h2 id=\"Properties\">Properties</h2> <dl> <dt><code>EvalError.prototype.constructor</code></dt> <dd>Specifies the function that created an instance's prototype.</dd> <dt><a href=\"../error/message\"><code>EvalError.prototype.message</code></a></dt> <dd>Error message. Although ECMA-262 specifies that <a href=\"../evalerror\"><code>EvalError</code></a> should provide its own <code>message</code> property, in <a href=\"https://developer.mozilla.org/en-US/docs/Mozilla/Projects/SpiderMonkey\">SpiderMonkey</a>, it inherits <a href=\"../error/message\"><code>Error.prototype.message</code></a>.</dd> <dt><a href=\"../error/name\"><code>EvalError.prototype.name</code></a></dt> <dd>Error name. Inherited from <a href=\"../error\"><code>Error</code></a>.</dd> <dt><a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/fileName\"><code>EvalError.prototype.fileName</code></a></dt> <dd>Path to file that raised this error. Inherited from <a href=\"../error\"><code>Error</code></a>.</dd> <dt><a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/lineNumber\"><code>EvalError.prototype.lineNumber</code></a></dt> <dd>Line number in file that raised this error. Inherited from <a href=\"../error\"><code>Error</code></a>.</dd> <dt><a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/columnNumber\"><code>EvalError.prototype.columnNumber</code></a></dt> <dd>Column number in line that raised this error. Inherited from <a href=\"../error\"><code>Error</code></a>.</dd> <dt><a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/stack\"><code>EvalError.prototype.stack</code></a></dt> <dd>Stack trace. Inherited from <a href=\"../error\"><code>Error</code></a>.</dd> </dl> <h2 id=\"Methods\">Methods</h2> <p>Although the <a href=\"../evalerror\"><code>EvalError</code></a> prototype object does not contain any methods of its own, <a href=\"../evalerror\"><code>EvalError</code></a> instances do inherit some methods through the prototype chain.</p> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/publications/files/ECMA-ST-ARCH/ECMA-262,%203rd%20edition,%20December%201999.pdf\" hreflang=\"en\">ECMAScript 3rd Edition (ECMA-262)</a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/5.1/#sec-15.11.7.6\" hreflang=\"en\">ECMAScript 5.1 (ECMA-262)<br><small>The definition of 'NativeError.prototype' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Defined as <code><em>NativeError</em>.prototype</code>.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-nativeerror.prototype\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'NativeError.prototype' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Defined as <code><em>NativeError</em>.prototype</code>.</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-nativeerror.prototype\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'NativeError.prototype' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td>Defined as <code><em>NativeError</em>.prototype</code>.</td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>   <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/EvalError\">Basic support</a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/EvalError\">Basic support</a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/EvalError\">Basic support</a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div>  <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"../error/prototype\"><code>Error.prototype</code></a></li> <li><a href=\"../function/prototype\"><code>Function.prototype</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/EvalError/prototype$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/EvalError/prototype\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/EvalError/prototype</a>\n  </p>\n</div>\n","global_objects/generator/return":"<h1>generator.return</h1> <p>The <code><strong>return()</strong></code> method returns the given value and finishes the generator.</p> <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\"><var>gen</var>.return(value)</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><code>value</code></dt> <dd>The value to return.</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p>The value that is given as an argument.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Using_return()\">Using <code>return()</code>\n</h3> <p>The following example shows a simple generator and the <code>return</code> method.</p> <pre data-language=\"js\">function* gen() { \n  yield 1;\n  yield 2;\n  yield 3;\n}\n\nvar g = gen();\n\ng.next();        // { value: 1, done: false }\ng.return('foo'); // { value: \"foo\", done: true }\ng.next();        // { value: undefined, done: true }\n</pre> <p>If <code>return(value)</code> is called on a generator that is already in \"completed\" state, the generator will remain in \"completed\" state. If no argument is provided, the return object is the same as if <code>.next()</code>. If an argument is provided, it will be set to the value of the <code>value</code> property of the returned object.</p> <pre data-language=\"js\">function* gen() {\n  yield 1;\n  yield 2;\n  yield 3;\n}\n\nvar g = gen();\ng.next(); // { value: 1, done: false }\ng.next(); // { value: 2, done: false }\ng.next(); // { value: 3, done: false }\ng.next(); // { value: undefined, done: true }\ng.return(); // { value: undefined, done: true }\ng.return(1); // { value: 1, done: true }\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-generator.prototype.return\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Generator.prototype.return' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-generator.prototype.return\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Generator.prototype.return' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>   <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 50</td>\n<td class=\"bc-supports-yes\"> 13</td>\n<td class=\"bc-supports-yes\"> 38</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 37</td>\n<td class=\"bc-supports-yes\"> 10</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 50</td>\n<td class=\"bc-supports-yes\"> 13</td>\n<td class=\"bc-supports-yes\"> 38</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 10</td>\n<td class=\"bc-supports-yes\"> 5.0</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 6.0.0</td>\n</tr></tbody>\n</table>\n</div>  <h2 id=\"See_also\">See also</h2> <ul> <li><code><a href=\"../../statements/function*\">function*</a></code></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Generator/return$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Generator/return\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Generator/return</a>\n  </p>\n</div>\n","global_objects/generatorfunction/prototype":"<h1>GeneratorFunction.prototype</h1> <p>The <code><strong>GeneratorFunction.prototype</strong></code> property represents the <a href=\"../generatorfunction\"><code>GeneratorFunction</code></a> prototype object.</p> <h2 id=\"Description\">Description</h2> <p><a href=\"../generatorfunction\"><code>GeneratorFunction</code></a> objects inherit from <code>GeneratorFunction.prototype</code>. <code>GeneratorFunction.prototype</code> cannot be modified.</p> <h2 id=\"Properties\">Properties</h2> <dl> <dt><code><strong>GeneratorFunction.constructor</strong></code></dt> <dd>The initial value is <a href=\"../generatorfunction\"><code>GeneratorFunction</code></a>.</dd> <dt><code><strong>GeneratorFunction.prototype.prototype</strong></code></dt> <dd>The value is <code>%GeneratorPrototype%</code>.</dd> </dl> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-generatorfunction.prototype\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'GeneratorFunction.prototype' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-generatorfunction.prototype\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'GeneratorFunction.prototype' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>   <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 26</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td> ? </td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 26</td>\n<td> ? </td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td> ? </td>\n</tr></tbody>\n</table>\n</div>  <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"../generatorfunction\"><code>GeneratorFunction</code></a></li> <li><a href=\"../function\"><code>Function</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/GeneratorFunction/prototype$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/GeneratorFunction/prototype\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/GeneratorFunction/prototype</a>\n  </p>\n</div>\n","global_objects/generator/throw":"<h1>generator.throw</h1> <p>The <code><strong>throw()</strong></code> method resumes the execution of a generator by throwing an error into it and returns an object with two properties <code>done</code> and <code>value</code>.</p> <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\"><var>gen</var>.throw(exception)</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><code>exception</code></dt> <dd>The exception to throw. For debugging purposes, it is useful to make it an <code>instanceof</code> <a href=\"../error\"><code>Error</code></a>.</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p>An <code><a href=\"../object\">Object</a></code> with two properties:</p> <ul> <li>\n<code>done</code> (boolean) <ul> <li>Has the value <code>true</code> if the iterator is past the end of the iterated sequence. In this case <code>value</code> optionally specifies the <em>return value</em> of the iterator.</li> <li>Has the value <code>false</code> if the iterator was able to produce the next value in the sequence. This is equivalent of not specifying the <code>done</code> property altogether.</li> </ul> </li> <li>\n<code>value</code> - any JavaScript value returned by the iterator. Can be omitted when <code>done</code> is <code>true</code>.</li> </ul> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Using_throw()\">Using <code>throw()</code>\n</h3> <p>The following example shows a simple generator and an error that is thrown using the <code>throw</code> method. An error can be caught by a <code><a href=\"../../statements/try...catch\">try...catch</a></code> block as usual.</p> <pre data-language=\"js\">function* gen() {\n  while(true) {\n    try {\n       yield 42;\n    } catch(e) {\n      console.log('Error caught!');\n    }\n  }\n}\n\nvar g = gen();\ng.next();\n// { value: 42, done: false }\ng.throw(new Error('Something went wrong'));\n// \"Error caught!\"\n// { value: 42, done: false }\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-generator.prototype.throw\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Generator.prototype.throw' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-generator.prototype.throw\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Generator.prototype.throw' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>   <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 39</td>\n<td class=\"bc-supports-yes\"> 13</td>\n<td class=\"bc-supports-yes\"> 26</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 10</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 13</td>\n<td class=\"bc-supports-yes\"> 26</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 10</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes bc-has-history\"> 4.0.0\n<section class=\"bc-history\" id=\"sect1\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 4.0.0\n</dt>\n\n<dt class=\"bc-supports-yes bc-supports\"> 0.12<div class=\"bc-icons\">Disabled </div>\n</dt>\n<dd>Disabled From version 0.12: this feature is behind the <code>--harmony</code> runtime flag.</dd>\n</dl></section>\n</td>\n</tr></tbody>\n</table>\n</div>  <h2 id=\"See_also\">See also</h2> <ul> <li><code><a href=\"../../statements/function*\">function*</a></code></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Generator/throw$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Generator/throw\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Generator/throw</a>\n  </p>\n</div>\n","global_objects/boolean/prototype":"<h1>Boolean.prototype</h1> <p>The <code>Boolean.prototype</code> property represents the prototype for the <a href=\"../boolean\"><code>Boolean</code></a> constructor.</p> <div class=\"_table\"><table class=\"standard-table\"> <thead> <tr> <th colspan=\"2\" class=\"header\">Property attributes of <code>Boolean.prototype</code>\n</th> </tr> </thead> <tbody> <tr> <td>Writable</td> <td>no</td> </tr> <tr> <td>Enumerable</td> <td>no</td> </tr> <tr> <td>Configurable</td> <td>no</td> </tr> </tbody> </table></div> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/boolean-constructor.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Description\">Description</h2> <p><a href=\"../boolean\"><code>Boolean</code></a> instances inherit from <code>Boolean.prototype</code>. You can use the constructor's prototype object to add properties or methods to all <a href=\"../boolean\"><code>Boolean</code></a> instances.</p> <h2 id=\"Properties\">Properties</h2> <dl> <dt><code>Boolean.prototype.constructor</code></dt> <dd>Returns the function that created an instance's prototype. This is the <a href=\"../boolean\"><code>Boolean</code></a> function by default.</dd> </dl> <h2 id=\"Methods\">Methods</h2> <dl> <dt>\n<a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean/toSource\"><code>Boolean.prototype.toSource()</code></a> \n</dt> <dd>Returns a string containing the source of the <a href=\"../boolean\"><code>Boolean</code></a> object; you can use this string to create an equivalent object. Overrides the <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/toSource\"><code>Object.prototype.toSource()</code></a> method.</dd> <dt><a href=\"tostring\"><code>Boolean.prototype.toString()</code></a></dt> <dd>Returns a string of either <code>\"true\"</code> or <code>\"false\"</code> depending upon the value of the object. Overrides the <a href=\"../object/tostring\"><code>Object.prototype.toString()</code></a> method.</dd> <dt><a href=\"valueof\"><code>Boolean.prototype.valueOf()</code></a></dt> <dd>Returns the primitive value of the <a href=\"../boolean\"><code>Boolean</code></a> object. Overrides the <a href=\"../object/valueof\"><code>Object.prototype.valueOf()</code></a> method.</dd> </dl> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <thead> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> </thead> <tbody> <tr> <td><a href=\"https://www.ecma-international.org/publications/files/ECMA-ST-ARCH/ECMA-262,%201st%20edition,%20June%201997.pdf\" hreflang=\"en\">ECMAScript 1st Edition (ECMA-262)</a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition. Implemented in JavaScript 1.0.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/5.1/#sec-15.6.3.1\" hreflang=\"en\">ECMAScript 5.1 (ECMA-262)<br><small>The definition of 'Boolean.prototype' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-boolean.prototype\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Boolean.prototype' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-boolean.prototype\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Boolean.prototype' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean/prototype$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean/prototype\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean/prototype</a>\n  </p>\n</div>\n","global_objects/boolean/tostring":"<h1>boolean.toString</h1> <p>The <code><strong>toString()</strong></code> method returns a string representing the specified Boolean object.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/boolean-tostring.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\"><var>bool</var>.toString()</pre> <h3 id=\"Return_value\">Return value</h3> <p>A string representing the specified <a href=\"../boolean\"><code>Boolean</code></a> object.</p> <h2 id=\"Description\">Description</h2> <p>The <a href=\"../boolean\"><code>Boolean</code></a> object overrides the <code>toString</code> method of the <a href=\"../object\"><code>Object</code></a> object; it does not inherit <a href=\"../object/tostring\"><code>Object.prototype.toString()</code></a>. For Boolean objects, the <code>toString</code> method returns a string representation of the object.</p> <p>JavaScript calls the <code>toString</code> method automatically when a <a href=\"../boolean\"><code>Boolean</code></a> is to be represented as a text value or when a <a href=\"../boolean\"><code>Boolean</code></a> is referred to in a string concatenation.</p> <p>For <a href=\"../boolean\"><code>Boolean</code></a> objects and values, the built-in <code>toString</code> method returns the string \"<code>true</code>\" or \"<code>false</code>\" depending on the value of the boolean object.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Using_toString\">Using <code>toString</code>\n</h3> <p>In the following code, <code>flag.toString()</code> returns \"<code>true</code>\":</p> <pre data-language=\"js\">var flag = new Boolean(true);\nvar myVar = flag.toString();\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/publications/files/ECMA-ST-ARCH/ECMA-262,%201st%20edition,%20June%201997.pdf\" hreflang=\"en\">ECMAScript 1st Edition (ECMA-262)</a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/5.1/#sec-15.6.4.2\" hreflang=\"en\">ECMAScript 5.1 (ECMA-262)<br><small>The definition of 'Boolean.prototype.toString' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-boolean.prototype.tostring\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Boolean.prototype.toString' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-boolean.prototype.tostring\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Boolean.prototype.toString' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>   <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div>  <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"../object/tostring\"><code>Object.prototype.toString()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean/toString$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean/toString\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean/toString</a>\n  </p>\n</div>\n","global_objects/object/setprototypeof":"<h1>Object.setPrototypeOf</h1> <p>The <code><strong>Object.setPrototypeOf()</strong></code> method sets the prototype (i.e., the internal <code>[[Prototype]]</code> property) of a specified object to another object or <a href=\"../null\"><code>null</code></a>.</p> <div class=\"warning\"> <p><strong>Warning:</strong> Changing the <code>[[Prototype]]</code> of an object is, by the nature of how modern JavaScript engines optimize property accesses, a very slow operation, in <strong><em>every</em></strong> browser and JavaScript engine. The effects on performance of altering inheritance are subtle and far-flung, and are not limited to simply the time spent in the <code>Object.setPrototypeOf(...)</code> statement, but may extend to <strong><em>any</em></strong> code that has access to <strong><em>any</em></strong> object whose <code>[[Prototype]]</code> has been altered. If you care about performance you should avoid setting the <code>[[Prototype]]</code> of an object. Instead, create a new object with the desired <code>[[Prototype]]</code> using <a href=\"create\"><code>Object.create()</code></a>.</p> </div> <p>However, if a feature is part of the language, the burden of implementing that feature performantly is on the engine developers (ideally).</p> <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\">Object.setPrototypeOf(<var>obj</var>, <var>prototype</var>)</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><code>obj</code></dt> <dd>The object which is to have its prototype set.</dd> <dt><code>prototype</code></dt> <dd>The object's new prototype (an object or <a href=\"../null\"><code>null</code></a>).</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p>The specified object.</p> <h2 id=\"Description\">Description</h2> <p>Throws a <a href=\"../typeerror\"><code>TypeError</code></a> exception if the object whose <code>[[Prototype]]</code> is to be modified is non-extensible according to <a href=\"isextensible\"><code>Object.isExtensible()</code></a>. Does nothing if the <code>prototype</code> parameter isn't an object or <a href=\"../null\"><code>null</code></a> (i.e., number, string, boolean, or <a href=\"../undefined\"><code>undefined</code></a>). Otherwise, this method changes the <code>[[Prototype]]</code> of <code>obj</code> to the new value.</p> <p><code>Object.setPrototypeOf()</code> is in the ECMAScript 2015 specification. It is generally considered the proper way to set the prototype of an object, vs. the more controversial <a href=\"proto\"><code>Object.prototype.__proto__</code></a> property.</p> <h2 id=\"Examples\">Examples</h2> <pre data-language=\"js\">var dict = Object.setPrototypeOf({}, null);\n</pre> <h2 id=\"Polyfill\">Polyfill</h2> <p>Using the older <a href=\"proto\"><code>Object.prototype.__proto__</code></a> property, we can easily define <code>Object.setPrototypeOf</code> if it isn't available already:</p> <pre data-language=\"js\">// Only works in Chrome and FireFox, does not work in IE:\nObject.setPrototypeOf = Object.setPrototypeOf || function(obj, proto) {\n  obj.__proto__ = proto;\n  return obj; \n}\n</pre> <h2 id=\"Appending_Prototype_Chains\">Appending Prototype Chains</h2> <p>A combination of <code>Object.getPrototypeOf()</code> and <a href=\"proto\"><code>Object.prototype.__proto__</code></a> permits appending a whole prototype chain to a new prototype object:</p> <pre data-language=\"js\">/**\n*** Object.appendChain(@object, @prototype)\n*\n* Appends the first non-native prototype of a chain to a new prototype.\n* Returns @object (if it was a primitive value it will transformed into an object).\n*\n*** Object.appendChain(@object [, \"@arg_name_1\", \"@arg_name_2\", \"@arg_name_3\", \"...\"], \"@function_body\")\n*** Object.appendChain(@object [, \"@arg_name_1, @arg_name_2, @arg_name_3, ...\"], \"@function_body\")\n*\n* Appends the first non-native prototype of a chain to the native Function.prototype object, then appends a\n* new Function([\"@arg\"(s)], \"@function_body\") to that chain.\n* Returns the function.\n*\n**/\n\nObject.appendChain = function(oChain, oProto) {\n  if (arguments.length &lt; 2) { \n    throw new TypeError('Object.appendChain - Not enough arguments');\n  }\n  if (typeof oProto !== 'object' &amp;&amp; typeof oProto !== 'string') {\n    throw new TypeError('second argument to Object.appendChain must be an object or a string');\n  }\n\n  var oNewProto = oProto,\n      oReturn = o2nd = oLast = oChain instanceof this ? oChain : new oChain.constructor(oChain);\n\n  for (var o1st = this.getPrototypeOf(o2nd);\n    o1st !== Object.prototype &amp;&amp; o1st !== Function.prototype;\n    o1st = this.getPrototypeOf(o2nd)\n  ) {\n    o2nd = o1st;\n  }\n\n  if (oProto.constructor === String) {\n    oNewProto = Function.prototype;\n    oReturn = Function.apply(null, Array.prototype.slice.call(arguments, 1));\n    this.setPrototypeOf(oReturn, oLast);\n  }\n\n  this.setPrototypeOf(o2nd, oNewProto);\n  return oReturn;\n}\n</pre> <h3 id=\"Usage\">Usage</h3> <h4 id=\"First_example_Appending_a_chain_to_a_prototype\">First example: Appending a chain to a prototype</h4> <pre data-language=\"js\">function Mammal() {\n  this.isMammal = 'yes';\n}\n\nfunction MammalSpecies(sMammalSpecies) {\n  this.species = sMammalSpecies;\n}\n\nMammalSpecies.prototype = new Mammal();\nMammalSpecies.prototype.constructor = MammalSpecies;\n\nvar oCat = new MammalSpecies('Felis');\n\nconsole.log(oCat.isMammal); // 'yes'\n\nfunction Animal() {\n  this.breathing = 'yes';\n}\n\nObject.appendChain(oCat, new Animal());\n\nconsole.log(oCat.breathing); // 'yes'\n</pre> <h4 id=\"Second_example_Transforming_a_primitive_value_into_an_instance_of_its_constructor_and_append_its_chain_to_a_prototype\">Second example: Transforming a primitive value into an instance of its constructor and append its chain to a prototype</h4> <pre data-language=\"js\">function MySymbol() {\n  this.isSymbol = 'yes';\n}\n\nvar nPrime = 17;\n\nconsole.log(typeof nPrime); // 'number'\n\nvar oPrime = Object.appendChain(nPrime, new MySymbol());\n\nconsole.log(oPrime); // '17'\nconsole.log(oPrime.isSymbol); // 'yes'\nconsole.log(typeof oPrime); // 'object'\n</pre> <h4 id=\"Third_example_Appending_a_chain_to_the_Function.prototype_object_and_appending_a_new_function_to_that_chain\">Third example: Appending a chain to the Function.prototype object and appending a new function to that chain</h4> <pre data-language=\"js\">function Person(sName) {\n  this.identity = sName;\n}\n\nvar george = Object.appendChain(new Person('George'),\n                                'console.log(\"Hello guys!!\");');\n\nconsole.log(george.identity); // 'George'\ngeorge(); // 'Hello guys!!'\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <thead> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> </thead> <tbody> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-object.setprototypeof\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Object.setPrototypeOf' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-object.setprototypeof\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Object.setPrototypeOf' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>   <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 34</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 31</td>\n<td class=\"bc-supports-yes\"> 11</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 9</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 31</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 0.12</td>\n</tr></tbody>\n</table>\n</div>  <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"../reflect/setprototypeof\"><code>Reflect.setPrototypeOf()</code></a></li> <li><a href=\"isprototypeof\"><code>Object.prototype.isPrototypeOf()</code></a></li> <li><a href=\"getprototypeof\"><code>Object.getPrototypeOf()</code></a></li> <li><a href=\"proto\"><code>Object.prototype.__proto__</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/setPrototypeOf$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/setPrototypeOf\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/setPrototypeOf</a>\n  </p>\n</div>\n","global_objects/generator/next":"<h1>generator.next</h1> <p>The <code><strong>next</strong></code><code>()</code> method returns an object with two properties <code>done</code> and <code>value</code>. You can also provide a parameter to the <code>next</code> method to send a value to the generator.</p> <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\"><var>gen</var>.next(value)</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><code>value</code></dt> <dd>The value to send to the generator. The value will be assigned as a result of a yield expression. i.e in [variable] = yield [expression], the value passed to the .next function will be assigned to [variable]</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p>An <code><a href=\"../object\">Object</a></code> with two properties:</p> <ul> <li>\n<code>done</code> (boolean) <ul> <li>Has the value <code>true</code> if the iterator is past the end of the iterated sequence. In this case <code>value</code> optionally specifies the <em>return value</em> of the iterator.</li> <li>Has the value <code>false</code> if the iterator was able to produce the next value in the sequence. This is equivalent of not specifying the <code>done</code> property altogether.</li> </ul> </li> <li>\n<code>value</code> - any JavaScript value returned by the iterator. Can be omitted when <code>done</code> is <code>true</code>.</li> </ul> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Using_next()\">Using <code>next()</code>\n</h3> <p>The following example shows a simple generator and the object that the <code>next</code> method returns:</p> <pre data-language=\"js\">function* gen() { \n  yield 1;\n  yield 2;\n  yield 3;\n}\n\nvar g = gen(); // \"Generator { }\"\ng.next();      // \"Object { value: 1, done: false }\"\ng.next();      // \"Object { value: 2, done: false }\"\ng.next();      // \"Object { value: 3, done: false }\"\ng.next();      // \"Object { value: undefined, done: true }\"\n</pre> <h3 id=\"Sending_values_to_the_generator\">Sending values to the generator</h3> <p>In this example, <code>next</code> is called with a value. Note that the first call did not log anything, because the generator was not yielding anything initially.</p> <pre data-language=\"js\">function* gen() {\n  while(true) {\n    var value = yield null;\n    console.log(value);\n  }\n}\n\nvar g = gen();\ng.next(1); \n// \"{ value: null, done: false }\"\ng.next(2); \n// 2\n// \"{ value: null, done: false }\"\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-generator.prototype.next\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Generator.prototype.next' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-generator.prototype.next\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Generator.prototype.next' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>   <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 39</td>\n<td class=\"bc-supports-yes\"> 13</td>\n<td class=\"bc-supports-yes\"> 26</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 10</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 13</td>\n<td class=\"bc-supports-yes\"> 26</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 10</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div>  <h2 id=\"See_also\">See also</h2> <ul> <li><code><a href=\"../../statements/function*\">function*</a></code></li> <li><a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Iterators_and_Generators\">Iterators and generators</a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Generator/next$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Generator/next\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Generator/next</a>\n  </p>\n</div>\n","global_objects/arraybuffer/bytelength":"<h1>arrayBuffer.byteLength</h1> <p>The <code><strong>byteLength</strong></code> accessor property represents the length of an <a href=\"../arraybuffer\"><code>ArrayBuffer</code></a> in bytes.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/arraybuffer-bytelength.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\"><var>arr</var>aybuffer.byteLength</pre> <h2 id=\"Description\">Description</h2> <p>The <code>byteLength</code> property is an accessor property whose set accessor function is <code>undefined</code>, meaning that you can only read this property. The value is established when the array is constructed and cannot be changed. This property returns 0 if this <code>ArrayBuffer</code> has been detached.</p> <h2 id=\"Examples\">Examples</h2> <pre data-language=\"js\">var buffer = new ArrayBuffer(8);\nbuffer.byteLength; // 8\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.khronos.org/registry/typedarray/specs/latest/\" hreflang=\"en\">Typed Array Specification</a></td> <td><span class=\"spec-Obsolete\">Obsolete</span></td> <td>Superseded by ECMAScript 2015.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-get-arraybuffer.prototype.bytelength\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'ArrayBuffer.prototype.byteLength' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition in an ECMA standard.</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-get-arraybuffer.prototype.bytelength\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'ArrayBuffer.prototype.byteLength' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 7</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> 10</td>\n<td class=\"bc-supports-yes\"> 11.6</td>\n<td class=\"bc-supports-yes\"> 5.1</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> 11.6</td>\n<td class=\"bc-supports-yes\"> 4.2</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"../arraybuffer\"><code>ArrayBuffer</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer/byteLength$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer/byteLength\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer/byteLength</a>\n  </p>\n</div>\n","global_objects/object/hasownproperty":"<h1>object.hasOwnProperty</h1> <p>The <code><strong>hasOwnProperty()</strong></code> method returns a boolean indicating whether the object has the specified property as its own property (as opposed to inheriting it).</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/object-prototype-hasownproperty.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\"><var>obj</var>.hasOwnProperty(<var>prop</var>)</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><code>prop</code></dt> <dd>The <a href=\"../string\"><code>String</code></a> name or <a href=\"https://developer.mozilla.org/en-US/docs/Glossary/Symbol\">symbol</a> of the property to test.</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p>A <a href=\"../boolean\"><code>Boolean</code></a> indicating whether or not the object has the specified property as own property.</p> <h2 id=\"Description\">Description</h2> <p>Every object descended from <a href=\"../object\"><code>Object</code></a> inherits the <code>hasOwnProperty</code> method. This method can be used to determine whether an object has the specified property as a direct property of that object; unlike the <a href=\"../../operators/in\"><code>in</code></a> operator, this method does not check down the object's prototype chain.</p> <h2 id=\"Note\">Note</h2> <p><code>hasOwnProperty</code> returns true even if the value of the property is <code>null</code> or <code>undefined</code>.</p> <pre data-language=\"js\">o = new Object();\no.propOne = null;\no.hasOwnProperty('propOne');   // returns true\no.propTwo = undefined;  \no.hasOwnProperty('propTwo');   // returns true\n</pre> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Using_hasOwnProperty_to_test_for_a_property's_existence\">Using <code>hasOwnProperty</code> to test for a property's existence</h3> <p>The following example determines whether the <code>o</code> object contains a property named <code>prop</code>:</p> <pre data-language=\"js\">o = new Object();\no.hasOwnProperty('prop');   // returns false\no.prop = 'exists';  \no.hasOwnProperty('prop');   // returns true\n</pre> <h3 id=\"Direct_vs._inherited_properties\">Direct vs. inherited properties</h3> <p>The following example differentiates between direct properties and properties inherited through the prototype chain:</p> <pre data-language=\"js\">o = new Object();\no.prop = 'exists';\no.hasOwnProperty('prop');             // returns true\no.hasOwnProperty('toString');         // returns false\no.hasOwnProperty('hasOwnProperty');   // returns false\n</pre> <h3 id=\"Iterating_over_the_properties_of_an_object\">Iterating over the properties of an object</h3> <p>The following example shows how to iterate over the properties of an object without executing on inherited properties. Note that the <a href=\"../../statements/for...in\"><code>for...in</code></a> loop is already only iterating enumerable items, so one should not assume based on the lack of non-enumerable properties shown in the loop that <code>hasOwnProperty</code> itself is confined strictly to enumerable items (as with <a href=\"getownpropertynames\"><code>Object.getOwnPropertyNames()</code></a>).</p> <pre data-language=\"js\">var buz = {\n  fog: 'stack'\n};\n\nfor (var name in buz) {\n  if (buz.hasOwnProperty(name)) {\n    console.log('this is fog (' + \n      name + ') for sure. Value: ' + buz[name]);\n  }\n  else {\n    console.log(name); // toString or something else\n  }\n}\n</pre> <h3 id=\"Using_hasOwnProperty_as_a_property_name\">Using <code>hasOwnProperty</code> as a property name</h3> <p>JavaScript does not protect the property name <code>hasOwnProperty</code>; thus, if the possibility exists that an object might have a property with this name, it is necessary to use an <em>external</em> <code>hasOwnProperty</code> to get correct results:</p> <pre data-language=\"js\">var foo = {\n  hasOwnProperty: function() {\n    return false;\n  },\n  bar: 'Here be dragons'\n};\n\nfoo.hasOwnProperty('bar'); // always returns false\n\n// Use another Object's hasOwnProperty\n// and call it with 'this' set to foo\n({}).hasOwnProperty.call(foo, 'bar'); // true\n\n// It's also possible to use the hasOwnProperty property\n// from the Object prototype for this purpose\nObject.prototype.hasOwnProperty.call(foo, 'bar'); // true\n</pre> <p>Note that in the last case there are no newly created objects.</p> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/publications/files/ECMA-ST-ARCH/ECMA-262,%203rd%20edition,%20December%201999.pdf\" hreflang=\"en\">ECMAScript 3rd Edition (ECMA-262)</a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition. Implemented in JavaScript 1.5.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/5.1/#sec-15.2.4.5\" hreflang=\"en\">ECMAScript 5.1 (ECMA-262)<br><small>The definition of 'Object.prototype.hasOwnProperty' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-object.prototype.hasownproperty\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Object.prototype.hasOwnProperty' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-object.prototype.hasownproperty\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Object.prototype.hasOwnProperty' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div>   <h2 id=\"Polyfill\">Polyfill</h2> <pre data-language=\"js\">//github FabioVergani / js-Polyfill_Object-hasOwnProperty\n\n//#Polyfill\n\n/*\nsimple:\nObject.prototype.hasOwnProperty||(Object.prototype.hasOwnProperty=function(x){var o,e=this,p=String(x);return p in e &amp;&amp; (o=e.__proto__||e.constructor.prototype,(p in o ===false)||e[p]!== o[p])});\n*/\n\n//Advanced:\n(function(w){\n    var isFunction=w.isFunction||(w.isFunction=function(x){return typeof(x)==='function'}),\n    has=w.has||(w.has=function(o,p){var e=p in o;return {value:e &amp;&amp; (e=o[p]) &amp;&amp; true,refer:e,valueOf:function(){return this.value}}}),\n    Polyfill=w.PolyfillMethod||(w.PolyfillMethod=function(o,p,x){var e=has(o,p);if(e &amp;&amp; (e=isFunction(e.refer))===false){o[p]=x};return e}),\n    theProto=w.Object.prototype;\n\n    Polyfill(theProto,'hasOwnProperty',function(x){var o,e=this,p=String(x);return p in e &amp;&amp; (o=e.__proto__||e.constructor.prototype,(p in o ===false)||e[p]!== o[p])});\n\n})(window);\n\n\n\n\n/*\nvar obj1={a:1,b:false}, obj2=Object.create(obj1);\nobj2.a=2;\nobj2.c='yeah';\n//Polyfilled &amp; Native:\nconsole.dir([\nobj1.hasOwnProperty('a'),//true\nobj1.hasOwnProperty('b'),//true\nobj1.hasOwnProperty('c'),//false\nobj2.hasOwnProperty('a'),//true\nobj2.hasOwnProperty('b'),//false\nobj2.hasOwnProperty('c')//true\n]);\nObject.prototype.hasOwnProperty.call(Object.create(null),'a')//false\n*/\n</pre>  <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"https://developer.mozilla.org/en-US/docs/Enumerability_and_ownership_of_properties\">Enumerability and ownership of properties</a></li> <li><a href=\"getownpropertynames\"><code>Object.getOwnPropertyNames()</code></a></li> <li><a href=\"../../statements/for...in\"><code>for...in</code></a></li> <li><a href=\"../../operators/in\"><code>in</code></a></li> <li><a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Inheritance_Revisited\">JavaScript Guide: Inheritance revisited</a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/hasOwnProperty$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/hasOwnProperty\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/hasOwnProperty</a>\n  </p>\n</div>\n","global_objects/error/message":"<h1>error.message</h1> <p>The <code><strong>message</strong></code> property is a human-readable description of the error.</p> <h2 id=\"Description\">Description</h2> <p>This property contains a brief description of the error if one is available or has been set. <a href=\"https://developer.mozilla.org/en-US/docs/Mozilla/Projects/SpiderMonkey\">SpiderMonkey</a> makes extensive use of the <code>message</code> property for exceptions. The <code>message</code> property combined with the <a href=\"name\"><code>name</code></a> property is used by the <a href=\"tostring\"><code>Error.prototype.toString()</code></a> method to create a string representation of the Error.</p> <p>By default, the <code>message</code> property is an empty string, but this behavior can be overridden for an instance by specifying a message as the first argument to the <a href=\"../error\"><code>Error constructor</code></a>.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Throwing_a_custom_error\">Throwing a custom error</h3> <pre data-language=\"js\">var e = new Error('Could not parse input'); \n// e.message is 'Could not parse input'\nthrow e;\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/publications/files/ECMA-ST-ARCH/ECMA-262,%201st%20edition,%20June%201997.pdf\" hreflang=\"en\">ECMAScript 1st Edition (ECMA-262)</a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/5.1/#sec-15.11.4.3\" hreflang=\"en\">ECMAScript 5.1 (ECMA-262)<br><small>The definition of 'Error.prototype.message' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-error.prototype.message\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Error.prototype.message' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-error.prototype.message\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Error.prototype.message' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>    <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> 6</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div>   <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"name\"><code>Error.prototype.name</code></a></li> <li><a href=\"tostring\"><code>Error.prototype.toString()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/message$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/message\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/message</a>\n  </p>\n</div>\n","global_objects/boolean/valueof":"<h1>boolean.valueOf</h1> <p>The <code><strong>valueOf()</strong></code> method returns the primitive value of a <a href=\"../boolean\"><code>Boolean</code></a> object.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/boolean-valueof.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\"><var>bool</var>.valueOf()</pre> <h3 id=\"Return_value\">Return value</h3> <p>The primitive value of the given <a href=\"../boolean\"><code>Boolean</code></a> object</p> <h2 id=\"Description\">Description</h2> <p>The <code>valueOf</code> method of <a href=\"../boolean\"><code>Boolean</code></a> returns the primitive value of a <a href=\"../boolean\"><code>Boolean</code></a> object or literal <a href=\"../boolean\"><code>Boolean</code></a> as a Boolean data type.</p> <p>This method is usually called internally by JavaScript and not explicitly in code.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Using_valueOf\">Using <code>valueOf</code>\n</h3> <pre data-language=\"js\">x = new Boolean();\nmyVar = x.valueOf(); // assigns false to myVar\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/publications/files/ECMA-ST-ARCH/ECMA-262,%201st%20edition,%20June%201997.pdf\" hreflang=\"en\">ECMAScript 1st Edition (ECMA-262)</a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition. Implemented in JavaScript 1.1.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/5.1/#sec-15.6.4.3\" hreflang=\"en\">ECMAScript 5.1 (ECMA-262)<br><small>The definition of 'Boolean.prototype.valueOf' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-boolean.prototype.valueof\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Boolean.prototype.valueOf' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-boolean.prototype.valueof\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Boolean.prototype.valueOf' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>   <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div>  <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"../object/valueof\"><code>Object.prototype.valueOf()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean/valueOf$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean/valueOf\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean/valueOf</a>\n  </p>\n</div>\n","global_objects/arraybuffer/isview":"<h1>ArrayBuffer.isView</h1> <p>The <code><strong>ArrayBuffer.isView()</strong></code> method returns <code>true</code> if <code>arg</code> is one of the <code>ArrayBuffer</code> views, such as <a href=\"../typedarray\">typed array objects</a> or a <a href=\"../dataview\"><code>DataView</code></a>; <code>false</code> otherwise.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/arraybuffer-isview.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\">ArrayBuffer.isView(<var>arg</var>)</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><code>arg</code></dt> <dd>The argument to be checked.</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p><code>true</code> if the given argument is one of the <code>ArrayBuffer</code> views; otherwise, <code>false</code>.</p> <h2 id=\"Examples\">Examples</h2> <pre data-language=\"js\">ArrayBuffer.isView();                    // false              \nArrayBuffer.isView([]);                  // false\nArrayBuffer.isView({});                  // false\nArrayBuffer.isView(null);                // false\nArrayBuffer.isView(undefined);           // false\nArrayBuffer.isView(new ArrayBuffer(10)); // false\n \nArrayBuffer.isView(new Uint8Array());    // true\nArrayBuffer.isView(new Float32Array());  // true\nArrayBuffer.isView(new Int8Array(10).subarray(0, 3)); // true\n\nvar buffer = new ArrayBuffer(2);\nvar dv = new DataView(buffer);\nArrayBuffer.isView(dv); // true\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.khronos.org/registry/typedarray/specs/latest/\" hreflang=\"en\">Typed Array Specification</a></td> <td><span class=\"spec-Obsolete\">Obsolete</span></td> <td>Superseded by ECMAScript 2015.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-arraybuffer.isview\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'ArrayBuffer.isView' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition in an ECMA standard.</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-arraybuffer.isview\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'ArrayBuffer.isView' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 29</td>\n<td class=\"bc-supports-yes\"> 11</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 29</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Typed_arrays\">JavaScript typed arrays</a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer/isView$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer/isView\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer/isView</a>\n  </p>\n</div>\n","global_objects/arraybuffer/@@species":"<h1>ArrayBuffer.@@species</h1> <p>The <code><strong>ArrayBuffer[@@species]</strong></code> accessor property returns the <code>ArrayBuffer</code> constructor.</p> <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\">ArrayBuffer[Symbol.species]\n</pre> <h2 id=\"Description\">Description</h2> <p>The species accessor property returns the default constructor for <code>ArrayBuffer</code> objects. Subclass constructors may over-ride it to change the constructor assignment.</p> <h2 id=\"Examples\">Examples</h2> <p>The species property returns the default constructor function, which is the <code>ArrayBuffer</code> constructor for <code>ArrayBuffer</code> objects:</p> <pre data-language=\"js\">ArrayBuffer[Symbol.species]; // function ArrayBuffer()</pre> <p>In a derived collection object (e.g. your custom array buffer <code>MyArrayBuffer</code>), the <code>MyArrayBuffer</code> species is the <code>MyArrayBuffer</code> constructor. However, you might want to overwrite this, in order to return parent <code>ArrayBuffer</code> objects in your derived class methods:</p> <pre data-language=\"js\">class MyArrayBuffer extends ArrayBuffer {\n  // Overwrite MyArrayBuffer species to the parent ArrayBuffer constructor\n  static get [Symbol.species]() { return ArrayBuffer; }\n}</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-get-arraybuffer-@@species\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'get ArrayBuffer [ @@species ]' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-get-arraybuffer-@@species\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'get ArrayBuffer [ @@species ]' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>   <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td> ? </td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 48</td>\n<td> ? </td>\n<td> ? </td>\n<td> ? </td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td> ? </td>\n<td> ? </td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 48</td>\n<td> ? </td>\n<td> ? </td>\n<td> ? </td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes bc-has-history\"> 6.5.0\n<section class=\"bc-history\" id=\"sect1\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 6.5.0\n</dt>\n\n<dt class=\"bc-supports-yes bc-supports\"> 6.0.0<div class=\"bc-icons\">Disabled </div>\n</dt>\n<dd>Disabled From version 6.0.0: this feature is behind the <code>--harmony</code> runtime flag.</dd>\n</dl></section>\n</td>\n</tr></tbody>\n</table>\n</div>  <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"../arraybuffer\"><code>ArrayBuffer</code></a></li> <li><a href=\"../symbol/species\"><code>Symbol.species</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer/@@species$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer/@@species\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer/@@species</a>\n  </p>\n</div>\n","global_objects/arraybuffer/slice":"<h1>arrayBuffer.slice</h1> <p>The <code><strong>slice()</strong></code> method returns a new <code>ArrayBuffer</code> whose contents are a copy of this <code>ArrayBuffer</code>'s bytes from <code>begin</code>, inclusive, up to <code>end</code>, exclusive.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/arraybuffer-slice.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\">arraybuffer.slice(begin[, end])</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><code>begin</code></dt> <dd>Zero-based byte index at which to begin slicing.</dd> </dl> <dl> <dt><code>end</code></dt> <dd>Byte index before which to end slicing. If end is unspecified, the new <code>ArrayBuffer</code> contains all bytes from begin to the end of this <code>ArrayBuffer</code>. The range specified by the begin and end values is clamped to the valid index range for the current array. If the computed length of the new <code>ArrayBuffer</code> would be negative, it is clamped to zero.</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p>A new <code>ArrayBuffer</code> object.</p> <h2 id=\"Description\">Description</h2> <p>The <code>slice</code> method copies up to, but not including, the byte indicated by the <code>end</code> parameter. If either <code>begin</code> or <code>end</code> is negative, it refers to an index from the end of the array, as opposed to from the beginning.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Copying_an_ArrayBuffer\">Copying an <code>ArrayBuffer</code>\n</h3> <pre data-language=\"js\">var buf1 = new ArrayBuffer(8);\nvar buf2 = buf1.slice(0);\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.khronos.org/registry/typedarray/specs/latest/\" hreflang=\"en\">Typed Array Specification</a></td> <td><span class=\"spec-Obsolete\">Obsolete</span></td> <td>Superseded by EMCAScript 6.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-arraybuffer.prototype.slice\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'ArrayBuffer.prototype.slice' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition in an ECMA standard.</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-arraybuffer.prototype.slice\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'ArrayBuffer.prototype.slice' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes bc-has-history\"> 12\n<section class=\"bc-history\" id=\"sect1\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 12\n</dt>\n<dd> The non-standard <code>ArrayBuffer.slice()</code> method has been removed in Firefox 53 (but the standardized version <code>ArrayBuffer.prototype.slice()</code> is kept.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-yes\"> 11</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 6</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes bc-has-history\"> 14\n<section class=\"bc-history\" id=\"sect2\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 14\n</dt>\n<dd> The non-standard <code>ArrayBuffer.slice()</code> method has been removed in Firefox 53 (but the standardized version <code>ArrayBuffer.prototype.slice()</code> is kept.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 6</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"../arraybuffer\"><code>ArrayBuffer</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer/slice$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer/slice\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer/slice</a>\n  </p>\n</div>\n","global_objects/arraybuffer/transfer":"<h1>arrayBuffer.transfer</h1> <div class=\"blockIndicator experimental indicator-warning\"> <p> <strong>This is an <a href=\"https://developer.mozilla.org/en-US/docs/MDN/Contribute/Guidelines/Conventions_definitions#Experimental\">experimental technology</a></strong><br>Check the <a href=\"#Browser_compatibility\">Browser compatibility table</a> carefully before using this in production.</p> </div> <p>The static <code><strong>ArrayBuffer.transfer()</strong></code> method returns a new <code>ArrayBuffer</code> whose contents have been taken from the <code>oldBuffer</code>'s data and then is either truncated or zero-extended by <code>newByteLength</code>. If <code>newByteLength</code> is <code>undefined</code>, the <code>byteLength</code> of the <code>oldBuffer</code> is used. This operation leaves <code>oldBuffer</code> in a detached state.</p> <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\">ArrayBuffer.transfer(oldBuffer [, newByteLength]);</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><code>oldBuffer</code></dt> <dd>An <a href=\"../arraybuffer\"><code>ArrayBuffer</code></a> object from which to transfer.</dd> <dt>newByteLength</dt> <dd>The byte length of the new <code>ArrayBuffer</code> object.</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p>A new <code>ArrayBuffer</code> object.</p> <h2 id=\"Description\">Description</h2> <p>The <code>ArrayBuffer.transfer()</code> method allows you to grow and detach <code>ArrayBuffer</code> objects. The ability to grow an <code>ArrayBuffer</code> without copying has the advantage of being much faster for large buffers (similar to realloc). The ability to detach an <code>ArrayBuffer</code> gives the developer explicit control over when the underlying memory is released. This avoids having to drop all references and wait for garbage collection.</p> <h2 id=\"Examples\">Examples</h2> <pre data-language=\"js\">var buf1 = new ArrayBuffer(40);\nnew Int32Array(buf1)[0] = 42;\n\nvar buf2 = ArrayBuffer.transfer(buf1, 80);\nbuf1.byteLength; // 0 but if you use the polyfill then the value is still 40\nbuf2.byteLength; // 80\nnew Int32Array(buf2)[0]; // 42\n\nvar buf3 = ArrayBuffer.transfer(buf2, 0);\nbuf2.byteLength; // 0 but if you use the polyfill then the value is still 80\nbuf3.byteLength; // 0\n</pre> <h2 id=\"Polyfill\">Polyfill</h2> <p>You can partially work around this by inserting the following code at the beginning of your scripts, allowing use of much of the functionality of transfer<font face=\"Consolas, Liberation Mono, Courier, monospace\">()</font> in browsers that do not natively support it. This is not the exact equivalent of this API because browsers that natively support it are be able to internally use the C++ function <font face=\"consolas, Liberation Mono, courier, monospace\"><span style=\"background-color: rgba(220, 220, 220, 0.5);\">realloc()</span></font> which extends the length of the memory and only copies it to a new location as-needed as opposed to the following pollyfill which always copies the whole thing to a new space of memory, but this function transfers data from one ArrayBuffer to another ArrayBuffer.</p> <pre data-language=\"js\">if (!ArrayBuffer.transfer) {\n    ArrayBuffer.transfer = function(source, length) {\n        if (!(source instanceof ArrayBuffer))\n            throw new TypeError('Source must be an instance of ArrayBuffer');\n        if (length &lt;= source.byteLength)\n            return source.slice(0, length);\n        var sourceView = new Uint8Array(source),\n            destView = new Uint8Array(new ArrayBuffer(length));\n        destView.set(sourceView);\n        return destView.buffer;\n    };\n}</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <thead> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> </thead> <tbody> <tr> <td>\n<code><a href=\"https://github.com/domenic/proposal-arraybuffer-transfer/#arraybufferprototypetransfer\">ArrayBuffer.prototype.transfer</a></code> proposal</td> <td>Draft</td> <td>Stage 2 Draft</td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support \n</th>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support \n</th>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support \n</th>\n<td class=\"bc-supports-no\"> No</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Typed_arrays\">JavaScript typed arrays</a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer/transfer$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer/transfer\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer/transfer</a>\n  </p>\n</div>\n","global_objects/number/max_safe_integer":"<h1>Number.MAX_SAFE_INTEGER</h1> <p>The <code>Number.MAX_SAFE_INTEGER</code> constant represents the maximum safe integer in JavaScript (<code>2<sup>53</sup> - 1</code>).</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/number-maxsafeinteger.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <div class=\"_table\"><table class=\"standard-table\"> <thead> <tr> <th colspan=\"2\" class=\"header\">Property attributes of <code>Number.MAX_SAFE_INTEGER</code>\n</th> </tr> </thead> <tbody> <tr> <td>Writable</td> <td>no</td> </tr> <tr> <td>Enumerable</td> <td>no</td> </tr> <tr> <td>Configurable</td> <td>no</td> </tr> </tbody> </table></div> <h2 id=\"Description\">Description</h2> <p>The <code>MAX_SAFE_INTEGER</code> constant has a value of <code>9007199254740991</code> (9,007,199,254,740,991 or ~9 quadrillion). The reasoning behind that number is that JavaScript uses <a href=\"http://en.wikipedia.org/wiki/Double_precision_floating-point_format\">double-precision floating-point format numbers</a> as specified in <a href=\"http://en.wikipedia.org/wiki/IEEE_floating_point\">IEEE 754</a> and can only safely represent numbers between <code>-(2<sup>53</sup> - 1)</code> and <code>2<sup>53</sup> - 1</code>.</p> <p>Safe in this context refers to the ability to represent integers exactly and to correctly compare them. For example, <code>Number.MAX_SAFE_INTEGER + 1 === Number.MAX_SAFE_INTEGER + 2</code> will evaluate to true, which is mathematically incorrect. See <a href=\"issafeinteger\"><code>Number.isSafeInteger()</code></a> for more information.</p> <p>Because <code>MAX_SAFE_INTEGER</code> is a static property of <a href=\"../number\"><code>Number</code></a>, you always use it as <code>Number.MAX_SAFE_INTEGER</code>, rather than as a property of a <a href=\"../number\"><code>Number</code></a> object you created.</p> <h2 id=\"Examples\">Examples</h2> <pre data-language=\"js\">Number.MAX_SAFE_INTEGER // 9007199254740991\nNumber.MAX_SAFE_INTEGER * Number.EPSILON // 2 because in floating points, the value is actually the decimal trailing \"1\"\n                                         // except for in subnormal precision cases such as zero\n</pre> <h2 id=\"Polyfill\">Polyfill</h2> <pre data-language=\"js\">if (!Number.MAX_SAFE_INTEGER) {\n    Number.MAX_SAFE_INTEGER = Math.pow(2, 53) - 1; // 9007199254740991\n}\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-number.max_safe_integer\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Number.MAX_SAFE_INTEGER' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-number.max_safe_integer\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Number.MAX_SAFE_INTEGER' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 34</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 31</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 9</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 31</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 9</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 0.12</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"min_safe_integer\"><code>Number.MIN_SAFE_INTEGER</code></a></li> <li><a href=\"issafeinteger\"><code>Number.isSafeInteger()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/MAX_SAFE_INTEGER$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/MAX_SAFE_INTEGER\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/MAX_SAFE_INTEGER</a>\n  </p>\n</div>\n","global_objects/typedarray/bytes_per_element":"<h1>TypedArray.BYTES_PER_ELEMENT</h1> <p>The <code><strong>TypedArray.BYTES_PER_ELEMENT</strong></code> property represents the size in bytes of each element in an typed array.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/typedarray-bytes-per-element.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <div class=\"_table\"><table class=\"standard-table\"> <thead> <tr> <th colspan=\"2\" class=\"header\">Property attributes of <code>TypedArray.BYTES_PER_ELEMENT</code>\n</th> </tr> </thead> <tbody> <tr> <td>Writable</td> <td>no</td> </tr> <tr> <td>Enumerable</td> <td>no</td> </tr> <tr> <td>Configurable</td> <td>no</td> </tr> </tbody> </table></div> <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\">TypedArray.BYTES_PER_ELEMENT;</pre> <h2 id=\"Description\">Description</h2> <p>TypedArray objects differ from each other in the number of bytes per element and in the way the bytes are interpreted. The <code>BYTES_PER_ELEMENT</code> constant contains the number of bytes each element in the given TypedArray has.</p> <h2 id=\"Examples\">Examples</h2> <pre data-language=\"js\">Int8Array.BYTES_PER_ELEMENT;         // 1\nUint8Array.BYTES_PER_ELEMENT;        // 1\nUint8ClampedArray.BYTES_PER_ELEMENT; // 1\nInt16Array.BYTES_PER_ELEMENT;        // 2\nUint16Array.BYTES_PER_ELEMENT;       // 2\nInt32Array.BYTES_PER_ELEMENT;        // 4\nUint32Array.BYTES_PER_ELEMENT;       // 4\nFloat32Array.BYTES_PER_ELEMENT;      // 4\nFloat64Array.BYTES_PER_ELEMENT;      // 8</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.khronos.org/registry/typedarray/specs/latest/\" hreflang=\"en\">Typed Array Specification</a></td> <td><span class=\"spec-Obsolete\">Obsolete</span></td> <td>Superseded by ECMAScript 6.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-typedarray.bytes_per_element\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'TypedArray.BYTES_PER_ELEMENT' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition in an ECMA standard.</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-typedarray.bytes_per_element\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'TypedArray.BYTES_PER_ELEMENT' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 7</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> 10</td>\n<td class=\"bc-supports-yes\"> 11.6</td>\n<td class=\"bc-supports-yes\"> 5.1</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> 11.6</td>\n<td class=\"bc-supports-yes\"> 4.2</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Typed_arrays\">JavaScript typed arrays</a></li> <li><a href=\"../typedarray\"><code>TypedArray</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/BYTES_PER_ELEMENT$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/BYTES_PER_ELEMENT\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/BYTES_PER_ELEMENT</a>\n  </p>\n</div>\n","global_objects/typedarray/byteoffset":"<h1>typedArray.byteOffset</h1> <p>The <code>byteOffset</code> accessor property represents the offset (in bytes) of a typed array from the start of its <a href=\"../arraybuffer\"><code>ArrayBuffer</code></a>.</p> <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\"><var>typedarray</var>.byteOffset</pre> <h2 id=\"Description\">Description</h2> <p>The <code>byteOffset</code> property is an accessor property whose set accessor function is <code>undefined</code>, meaning that you can only read this property. The value is established when a <em>TypedArray</em> is constructed and cannot be changed.<em> TypedArray</em> is one of the <a href=\"../typedarray#TypedArray_objects\">TypedArray objects</a>.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Using_the_byteOffset_property\">Using the <code>byteOffset</code> property</h3> <pre data-language=\"js\">var buffer = new ArrayBuffer(8);\n\nvar uint8 = new Uint8Array(buffer);\nuint8.byteOffset; // 0 (no offset specified)\n\nvar uint8 = new Uint8Array(buffer, 3);\nuint8.byteOffset; // 3 (as specified when constructing Uint8Array)\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"#\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'TypedArray.prototype.byteOffset' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"#\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'TypedArray.prototype.byteOffset' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 7</td>\n<td class=\"bc-supports-yes\"> 14</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> 10</td>\n<td class=\"bc-supports-yes\"> 11.6</td>\n<td class=\"bc-supports-yes\"> 5.1</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> 11.6</td>\n<td class=\"bc-supports-yes\"> 4.2</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Typed_arrays\">JavaScript typed arrays</a></li> <li><a href=\"../typedarray\"><code>TypedArray</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/byteOffset$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/byteOffset\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/byteOffset</a>\n  </p>\n</div>\n","global_objects/typedarray/bytelength":"<h1>typedArray.byteLength</h1> <p>The <code>byteLength</code> accessor property represents the length (in bytes) of a typed array.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/typedarray-bytelength.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\"><var>typedarray</var>.byteLength</pre> <h2 id=\"Description\">Description</h2> <p>The <code>byteLength</code> property is an accessor property whose set accessor function is <code>undefined</code>, meaning that you can only read this property. The value is established when a <em>TypedArray</em> is constructed and cannot be changed. If the <em>TypedArray</em> is not specifying an <code>byteOffset</code> or a <code>length</code>, the <code>length</code> of the referenced <code>ArrayBuffer</code> will be returned. <em>TypedArray</em> is one of the <a href=\"../typedarray#TypedArray_objects\">TypedArray objects</a>.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Using_the_byteLength_property\">Using the <code>byteLength</code> property</h3> <pre data-language=\"js\">var buffer = new ArrayBuffer(8);\n\nvar uint8 = new Uint8Array(buffer);\nuint8.byteLength; // 8 (matches the byteLength of the buffer)\n\nvar uint8 = new Uint8Array(buffer, 1, 5);\nuint8.byteLength; // 5 (as specified when constructing the Uint8Array)\n\nvar uint8 = new Uint8Array(buffer, 2);\nuint8.byteLength; // 6 (due to the offset of the constructed Uint8Array)\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"#\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'TypedArray.prototype.byteLength' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"#\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'TypedArray.prototype.byteLength' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 7</td>\n<td class=\"bc-supports-yes\"> 14</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> 10</td>\n<td class=\"bc-supports-yes\"> 11.6</td>\n<td class=\"bc-supports-yes\"> 5.1</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> 11.6</td>\n<td class=\"bc-supports-yes\"> 4.2</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Typed_arrays\">JavaScript typed arrays</a></li> <li><a href=\"../typedarray\"><code>TypedArray</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/byteLength$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/byteLength\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/byteLength</a>\n  </p>\n</div>\n","lexical_grammar":"<h1>Lexical grammar</h1> <p>This page describes JavaScript's lexical grammar. The source text of ECMAScript scripts gets scanned from left to right and is converted into a sequence of input elements which are tokens, control characters, line terminators, comments or white space. ECMAScript also defines certain keywords and literals and has rules for automatic insertion of semicolons to end statements.</p> <h2 id=\"Control_characters\">Control characters</h2> <p>Control characters have no visual representation but are used to control the interpretation of the text.</p> <div class=\"_table\"><table class=\"standard-table\"> <caption>Unicode format-control characters</caption> <tbody> <tr> <th>Code point</th> <th>Name</th> <th>Abbreviation</th> <th>Description</th> </tr> <tr> <td><code>U+200C</code></td> <td>Zero width non-joiner</td> <td>&lt;ZWNJ&gt;</td> <td>Placed between characters to prevent being connected into ligatures in certain languages (<a href=\"http://en.wikipedia.org/wiki/Zero-width_non-joiner\">Wikipedia</a>).</td> </tr> <tr> <td><code>U+200D</code></td> <td>Zero width joiner</td> <td>&lt;ZWJ&gt;</td> <td>Placed between characters that would not normally be connected in order to cause the characters to be rendered using their connected form in certain languages (<a href=\"http://en.wikipedia.org/wiki/Zero-width_joiner\">Wikipedia</a>).</td> </tr> <tr> <td><code>U+FEFF</code></td> <td>Byte order mark</td> <td>&lt;BOM&gt;</td> <td>Used at the start of the script to mark it as Unicode and the text's byte order (<a href=\"http://en.wikipedia.org/wiki/Byte_order_mark\">Wikipedia</a>).</td> </tr> </tbody> </table></div> <h2 id=\"White_space\">White space</h2> <p>White space characters improve the readability of source text and separate tokens from each other. These characters are usually unnecessary for the functionality of the code. <a href=\"http://en.wikipedia.org/wiki/Minification_%28programming%29\">Minification tools</a> are often used to remove whitespace in order to reduce the amount of data that needs to be transferred.</p> <div class=\"_table\"><table class=\"standard-table\"> <caption>White space characters</caption> <tbody> <tr> <th>Code point</th> <th>Name</th> <th>Abbreviation</th> <th>Description</th> <th>Escape sequence</th> </tr> <tr> <td>U+0009</td> <td>Character tabulation</td> <td>&lt;HT&gt;</td> <td>Horizontal tabulation</td> <td>\\t</td> </tr> <tr> <td>U+000B</td> <td>Line tabulation</td> <td>&lt;VT&gt;</td> <td>Vertical tabulation</td> <td>\\v</td> </tr> <tr> <td>U+000C</td> <td>Form feed</td> <td>&lt;FF&gt;</td> <td>Page breaking control character (<a href=\"http://en.wikipedia.org/wiki/Page_break#Form_feed\">Wikipedia</a>).</td> <td>\\f</td> </tr> <tr> <td>U+0020</td> <td>Space</td> <td>&lt;SP&gt;</td> <td>Normal space</td> <td> </td> </tr> <tr> <td>U+00A0</td> <td>No-break space</td> <td>&lt;NBSP&gt;</td> <td>Normal space, but no point at which a line may break</td> <td> </td> </tr> <tr> <td>Others</td> <td>Other Unicode space characters</td> <td>&lt;USP&gt;</td> <td><a href=\"http://en.wikipedia.org/wiki/Space_%28punctuation%29#Spaces_in_Unicode\">Spaces in Unicode on Wikipedia</a></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Line_terminators\">Line terminators</h2> <p>In addition to white space characters, line terminator characters are used to improve the readability of the source text. However, in some cases, line terminators can influence the execution of JavaScript code as there are a few places where they are forbidden. Line terminators also affect the process of <a href=\"#Automatic_semicolon_insertion\">automatic semicolon insertion</a>. Line terminators are matched by the <strong>\\s</strong> class in <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions\">regular expressions</a>.</p> <p>Only the following Unicode code points are treated as line terminators in ECMAScript, other line breaking characters are treated as white space (for example, Next Line, NEL, U+0085 is considered as white space).</p> <div class=\"_table\"><table class=\"standard-table\"> <caption>Line terminator characters</caption> <tbody> <tr> <th>Code point</th> <th>Name</th> <th>Abbreviation</th> <th>Description</th> <th>Escape sequence</th> </tr> <tr> <td>U+000A</td> <td>Line Feed</td> <td>&lt;LF&gt;</td> <td>New line character in UNIX systems.</td> <td>\\n</td> </tr> <tr> <td>U+000D</td> <td>Carriage Return</td> <td>&lt;CR&gt;</td> <td>New line character in Commodore and early Mac systems.</td> <td>\\r</td> </tr> <tr> <td>U+2028</td> <td>Line Separator</td> <td>&lt;LS&gt;</td> <td><a href=\"http://en.wikipedia.org/wiki/Newline\">Wikipedia</a></td> <td> </td> </tr> <tr> <td>U+2029</td> <td>Paragraph Separator</td> <td>&lt;PS&gt;</td> <td><a href=\"http://en.wikipedia.org/wiki/Newline\">Wikipedia</a></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Comments\">Comments</h2> <p>Comments are used to add hints, notes, suggestions, or warnings to JavaScript code. This can make it easier to read and understand. They can also be used to disable code to prevent it from being executed; this can be a valuable debugging tool.</p> <p>JavaScript has two ways of assigning comments in its code.</p> <p>The first way is the <code>//</code> comment; this makes all text following it on the same line into a comment. For example:</p> <pre data-language=\"js\">function comment() {\n  // This is a one line JavaScript comment\n  console.log('Hello world!');\n}\ncomment();\n</pre> <p>The second way is the <code>/* */</code> style, which is much more flexible.</p> <p>For example, you can use it on a single line:</p> <pre data-language=\"js\">function comment() {\n  /* This is a one line JavaScript comment */\n  console.log('Hello world!');\n}\ncomment();</pre> <p>You can also make multiple-line comments, like this:</p> <pre data-language=\"js\">function comment() {\n  /* This comment spans multiple lines. Notice\n     that we don't need to end the comment until we're done. */\n  console.log('Hello world!');\n}\ncomment();</pre> <p>You can also use it in the middle of a line, if you wish, although this can make your code harder to read so it should be used with caution:</p> <pre data-language=\"js\">function comment(x) {\n  console.log('Hello ' + x /* insert the value of x */ + ' !');\n}\ncomment('world');</pre> <p>In addition, you can use it to disable code to prevent it from running, by wrapping code in a comment, like this:</p> <pre data-language=\"js\">function comment() {\n  /* console.log('Hello world!'); */\n}\ncomment();</pre> <p>In this case, the <code>console.log()</code> call is never issued, since it's inside a comment. Any number of lines of code can be disabled this way.</p> <h2 id=\"Keywords\">Keywords</h2> <h3 id=\"Reserved_keywords_as_of_ECMAScript_2015\">Reserved keywords as of ECMAScript 2015</h3> <ul class=\"threecolumns\"> <li><a href=\"statements/break\"><code>break</code></a></li> <li><a href=\"statements/switch\"><code>case</code></a></li> <li><a href=\"statements/try...catch\"><code>catch</code></a></li> <li><a href=\"statements/class\"><code>class</code></a></li> <li><a href=\"statements/const\"><code>const</code></a></li> <li><a href=\"statements/continue\"><code>continue</code></a></li> <li><a href=\"statements/debugger\"><code>debugger</code></a></li> <li><a href=\"statements/default\"><code>default</code></a></li> <li><a href=\"operators/delete\"><code>delete</code></a></li> <li><a href=\"statements/do...while\"><code>do</code></a></li> <li><a href=\"statements/if...else\"><code>else</code></a></li> <li><a href=\"statements/export\"><code>export</code></a></li> <li><a href=\"statements/class\"><code>extends</code></a></li> <li><a href=\"statements/try...catch\"><code>finally</code></a></li> <li><a href=\"statements/for\"><code>for</code></a></li> <li><a href=\"statements/function\"><code>function</code></a></li> <li><a href=\"statements/if...else\"><code>if</code></a></li> <li><a href=\"statements/import\"><code>import</code></a></li> <li><a href=\"operators/in\"><code>in</code></a></li> <li><a href=\"operators/instanceof\"><code>instanceof</code></a></li> <li><a href=\"operators/new\"><code>new</code></a></li> <li><a href=\"statements/return\"><code>return</code></a></li> <li><a href=\"operators/super\"><code>super</code></a></li> <li><a href=\"statements/switch\"><code>switch</code></a></li> <li><a href=\"operators/this\"><code>this</code></a></li> <li><a href=\"statements/throw\"><code>throw</code></a></li> <li><a href=\"statements/try...catch\"><code>try</code></a></li> <li><a href=\"operators/typeof\"><code>typeof</code></a></li> <li><a href=\"statements/var\"><code>var</code></a></li> <li><a href=\"operators/void\"><code>void</code></a></li> <li><a href=\"statements/while\"><code>while</code></a></li> <li><a href=\"statements/with\"><code>with</code></a></li> <li><a href=\"operators/yield\"><code>yield</code></a></li> </ul> <h3 id=\"Future_reserved_keywords\">Future reserved keywords</h3> <p>The following are reserved as future keywords by the ECMAScript specification. They have no special functionality at present, but they might at some future time, so they cannot be used as identifiers.</p> <p>These are always reserved:</p> <ul> <li><code>enum</code></li> </ul> <p>The following are only reserved when they are found in strict mode code:</p> <ul class=\"threecolumns\"> <li><code>implements</code></li> <li><code>interface</code></li> <li><a href=\"statements/let\"><code>let</code></a></li> <li><code>package</code></li> <li><code>private</code></li> <li><code>protected</code></li> <li><code>public</code></li> <li><code>static</code></li> </ul> <p>The following are only reserved when they are found in module code:</p> <ul> <li><code>await</code></li> </ul> <h4 id=\"Future_reserved_keywords_in_older_standards\">Future reserved keywords in older standards</h4> <p>The following are reserved as future keywords by older ECMAScript specifications (ECMAScript 1 till 3).</p> <ul class=\"threecolumns\"> <li><code>abstract</code></li> <li><code>boolean</code></li> <li><code>byte</code></li> <li><code>char</code></li> <li><code>double</code></li> <li><code>final</code></li> <li><code>float</code></li> <li><code>goto</code></li> <li><code>int</code></li> <li><code>long</code></li> <li><code>native</code></li> <li><code>short</code></li> <li><code>synchronized</code></li> <li><code>throws</code></li> <li><code>transient</code></li> <li><code>volatile</code></li> </ul> <p>Additionally, the literals <code>null</code>, <code>true</code>, and <code>false</code> cannot be used as identifiers in ECMAScript.</p> <h3 id=\"Reserved_word_usage\">Reserved word usage</h3> <p>Reserved words actually only apply to Identifiers (vs. <code>IdentifierNames</code>) . As described in <a href=\"http://es5.github.com/#A.1\">es5.github.com/#A.1</a>, these are all <code>IdentifierNames</code> which do not exclude <code>ReservedWords</code>.</p> <pre data-language=\"js\">a.import\na['import']\na = { import: 'test' }.\n</pre> <p>On the other hand the following is illegal because it's an Identifier, which is an <code>IdentifierName</code> without the reserved words. Identifiers are used for <code>FunctionDeclaration, FunctionExpression, VariableDeclaration</code> and so on. <code>IdentifierNames </code>are used for<code> MemberExpression, CallExpression</code> and so on.</p> <pre data-language=\"js\">function import() {} // Illegal.</pre> <h2 id=\"Literals\">Literals</h2> <h3 id=\"Null_literal\">Null literal</h3> <p>See also <a href=\"global_objects/null\"><code>null</code></a> for more information.</p> <pre data-language=\"js\">null</pre> <h3 id=\"Boolean_literal\">Boolean literal</h3> <p>See also <a href=\"global_objects/boolean\"><code>Boolean</code></a> for more information.</p> <pre data-language=\"js\">true\nfalse</pre> <h3 id=\"Numeric_literals\">Numeric literals</h3> <h4 id=\"Decimal\">Decimal</h4> <pre data-language=\"js\">1234567890\n42\n\n// Caution when using with a leading zero:\n0888 // 888 parsed as decimal\n0777 // parsed as octal, 511 in decimal\n</pre> <p>Note that decimal literals can start with a zero (<code>0</code>) followed by another decimal digit, but If all digits after the leading <code>0</code> are smaller than 8, the number is interpreted as an octal number. This won't throw in JavaScript, see <a href=\"https://bugzilla.mozilla.org/show_bug.cgi?id=957513\">bug 957513</a>. See also the page about <a href=\"global_objects/parseint#Octal_interpretations_with_no_radix\"><code>parseInt()</code></a>.</p> <h4 id=\"Binary\">Binary</h4> <p>Binary number syntax uses a leading zero followed by a lowercase or uppercase Latin letter \"B\" (<code>0b</code> or <code>0B</code>). Because this syntax is new in ECMAScript 2015, see the browser compatibility table, below. If the digits after the <code>0b</code> are not 0 or 1, the following <code><a href=\"global_objects/syntaxerror\">SyntaxError</a></code> is thrown: \"Missing binary digits after 0b\".</p> <pre data-language=\"js\">var FLT_SIGNBIT  = 0b10000000000000000000000000000000; // 2147483648\nvar FLT_EXPONENT = 0b01111111100000000000000000000000; // 2139095040\nvar FLT_MANTISSA = 0B00000000011111111111111111111111; // 8388607</pre> <h4 id=\"Octal\">Octal</h4> <p>Octal number syntax uses a leading zero followed by a lowercase or uppercase Latin letter \"O\" (<code>0o</code> or <code>0O)</code>. Because this syntax is new in ECMAScript 2015, see the browser compatibility table, below. If the digits after the <code>0o</code> are outside the range (01234567), the following <code><a href=\"global_objects/syntaxerror\">SyntaxError</a></code> is thrown: \"Missing octal digits after 0o\".</p> <pre data-language=\"js\">var n = 0O755; // 493\nvar m = 0o644; // 420\n\n// Also possible with just a leading zero (see note about decimals above)\n0755\n0644\n</pre> <h4 id=\"Hexadecimal\">Hexadecimal</h4> <p>Hexadecimal number syntax uses a leading zero followed by a lowercase or uppercase Latin letter \"X\" (<code>0x</code> or <code>0X)</code>. If the digits after 0x are outside the range (0123456789ABCDEF), the following <code><a href=\"global_objects/syntaxerror\">SyntaxError</a></code> is thrown: \"Identifier starts immediately after numeric literal\".</p> <pre data-language=\"js\">0xFFFFFFFFFFFFFFFFF // 295147905179352830000\n0x123456789ABCDEF   // 81985529216486900\n0XA                 // 10\n</pre> <h3 id=\"Object_literals\">Object literals</h3> <p>See also <a href=\"global_objects/object\"><code>Object</code></a> and <a href=\"operators/object_initializer\">Object initializer</a> for more information.</p> <pre data-language=\"js\">var o = { a: 'foo', b: 'bar', c: 42 };\n\n// shorthand notation. New in ES2015\nvar a = 'foo', b = 'bar', c = 42;\nvar o = {a, b, c};\n\n// instead of\nvar o = { a: a, b: b, c: c };\n</pre> <h3 id=\"Array_literals\">Array literals</h3> <p>See also <a href=\"global_objects/array\"><code>Array</code></a> for more information.</p> <pre data-language=\"js\">[1954, 1974, 1990, 2014]</pre> <h3 id=\"String_literals\">String literals</h3> <p>A string literal is zero or more Unicode code points enclosed in single or double quotes. Unicode code points may also be represented by an escape sequence. All code points may appear literally in a string literal except for these closing quote code points:</p> <ul> <li>U+005C (backslash),</li> <li>U+000D &lt;CR&gt;,</li> <li>and U+000A &lt;LF&gt;.</li> </ul> <p>Prior to the <a href=\"https://github.com/tc39/proposal-json-superset\">proposal to make all JSON text valid ECMA-262</a>, U+2028 &lt;LS&gt; and U+2029 &lt;PS&gt;, were also disallowed from appearing unescaped in string literals.</p> <p>Any code points may appear in the form of an escape sequence. String literals evaluate to ECMAScript String values. When generating these String values Unicode code points are UTF-16 encoded.</p> <pre data-language=\"js\">'foo'\n\"bar\"</pre> <h4 id=\"Hexadecimal_escape_sequences\">Hexadecimal escape sequences</h4> <p>Hexadecimal escape sequences consist of <code>\\x</code> followed by exactly two hexadecimal digits representing a code unit or code point in the range 0x0000 to 0x00FF.</p> <pre data-language=\"js\">'\\xA9' // \"©\"\n</pre> <h4 id=\"Unicode_escape_sequences\">Unicode escape sequences</h4> <p>A Unicode escape sequence consists of exactly four hexadecimal digits following <code>\\u</code>. It represents a code unit in the UTF-16 encoding. For code points U+0000 to U+FFFF, the code unit is equal to the code point. Code points U+10000 to U+10FFFF require two escape sequences representing the two code units (a surrogate pair) used to encode the character; the surrogate pair is distinct from the code point.</p> <p>See also <a href=\"global_objects/string/fromcharcode\"><code>String.fromCharCode()</code></a> and <a href=\"global_objects/string/charcodeat\"><code>String.prototype.charCodeAt()</code></a>.</p> <pre data-language=\"js\">'\\u00A9' // \"©\" (U+A9)</pre> <h4 id=\"Unicode_code_point_escapes\">Unicode code point escapes</h4> <p>A Unicode code point escape consists of <code>\\u{</code>, followed by a code point in hexadecimal base, followed by <code>}</code>. The value of the hexadecimal digits must be in the range 0 and 0x10FFFF inclusive. Code points in the range U+10000 to U+10FFFF do not need to be represented as a surrogate pair. Code point escapes were added to JavaScript in ECMAScript 2015 (ES6).</p> <p>See also <a href=\"global_objects/string/fromcodepoint\"><code>String.fromCodePoint()</code></a> and <a href=\"global_objects/string/codepointat\"><code>String.prototype.codePointAt()</code></a>.</p> <pre data-language=\"js\">'\\u{2F804}' // CJK COMPATIBILITY IDEOGRAPH-2F804 (U+2F804)\n\n// the same character represented as a surrogate pair\n'\\uD87E\\uDC04'</pre> <h3 id=\"Regular_expression_literals\">Regular expression literals</h3> <p>See also <a href=\"global_objects/regexp\"><code>RegExp</code></a> for more information.</p> <pre data-language=\"js\">/ab+c/g\n\n// An \"empty\" regular expression literal\n// The empty non-capturing group is necessary \n// to avoid ambiguity with single-line comments.\n/(?:)/</pre> <h3 id=\"Template_literals\">Template literals</h3> <p>See also <a href=\"template_literals\">template strings</a> for more information.</p> <pre data-language=\"js\">`string text`\n\n`string text line 1\n string text line 2`\n\n`string text ${expression} string text`\n\ntag `string text ${expression} string text`</pre> <h2 id=\"Automatic_semicolon_insertion\">Automatic semicolon insertion</h2> <p>Some <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements\">JavaScript statements</a> must be terminated with semicolons and are therefore affected by automatic semicolon insertion (ASI):</p> <ul> <li>Empty statement</li> <li>\n<code>let</code>, <code>const</code>, variable statement</li> <li>\n<code>import</code>, <code>export</code>, module declaration</li> <li>Expression statement</li> <li><code>debugger</code></li> <li>\n<code>continue</code>, <code>break</code>, <code>throw</code>\n</li> <li><code>return</code></li> </ul> <p>The ECMAScript specification mentions<a href=\"https://tc39.github.io/ecma262/#sec-rules-of-automatic-semicolon-insertion\"> three rules of semicolon insertion</a>.</p> <p>1. A semicolon is inserted before, when a <a href=\"#Line_terminators\">Line terminator</a> or \"}\" is encountered that is not allowed by the grammar.</p> <pre data-language=\"js\">{ 1 2 } 3 \n\n// is transformed by ASI into \n\n{ 1 2 ;} 3;</pre> <p>2. A semicolon is inserted at the end, when the end of the input stream of tokens is detected and the parser is unable to parse the single input stream as a complete program.</p> <p>Here <code>++</code> is not treated as a <a href=\"operators/arithmetic_operators#Increment\">postfix operator</a> applying to variable <code>b</code>, because a line terminator occurs between <code>b</code> and <code>++</code>.</p> <pre data-language=\"js\">a = b\n++c\n\n// is transformend by ASI into\n\na = b;\n++c;\n</pre> <p>3. A semicolon is inserted at the end, when a statement with restricted productions in the grammar is followed by a line terminator. These statements with \"no LineTerminator here\" rules are:</p> <ul> <li>PostfixExpressions (<code>++</code> and <code>--</code>)</li> <li><code>continue</code></li> <li><code>break</code></li> <li><code>return</code></li> <li>\n<code>yield</code>, <code>yield*</code>\n</li> <li><code>module</code></li> </ul> <pre data-language=\"js\">return\na + b\n\n// is transformed by ASI into\n\nreturn;\na + b;\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/publications/files/ECMA-ST-ARCH/ECMA-262,%201st%20edition,%20June%201997.pdf\" hreflang=\"en\">ECMAScript 1st Edition (ECMA-262)</a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/5.1/#sec-7\" hreflang=\"en\">ECMAScript 5.1 (ECMA-262)<br><small>The definition of 'Lexical Conventions' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-ecmascript-language-lexical-grammar\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Lexical Grammar' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Added: Binary and Octal Numeric literals, Unicode code point escapes, Templates</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-ecmascript-language-lexical-grammar\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Lexical Grammar' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Lexical_grammar#Array_literals\">Array literals (<code>[1, 2, 3]</code>)</a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Lexical_grammar#Binary\">Binary numeric literals (<code>0b</code>)</a></th>\n<td class=\"bc-supports-yes\"> 41</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 25</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 28</td>\n<td class=\"bc-supports-yes\"> 9</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Lexical_grammar#Boolean_literal\">Boolean literals (<code>true</code>/<code>false</code>)</a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Lexical_grammar#Decimal\">Decimal numeric literals (<code>1234567890</code>)</a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Lexical_grammar#Hexadecimal_escape_sequences\">Hexadecimal escape sequences (<code>'\\0xA9'</code>)</a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Lexical_grammar#Hexadecimal\">Hexadecimal numeric literals (<code>0xAF</code>)</a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Lexical_grammar#Null_literal\">Null literal (<code>null</code>)</a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Lexical_grammar#Octal\">Octal numeric literals (<code>0o</code>)</a></th>\n<td class=\"bc-supports-yes\"> 41</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 25</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 28</td>\n<td class=\"bc-supports-yes\"> 9</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Lexical_grammar#Regular_expression_literals\">Regular expression literals (<code>/ab+c/g</code>)</a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Lexical_grammar#String_literals\">String literals (<code>'Hello world'</code>)</a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Lexical_grammar#Unicode_escape_sequences\">Unicode escape sequences (<code>'\\u00A9'</code>)</a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Lexical_grammar#Unicode_code_point_escapes\">Unicode point escapes (<code>\\u{}</code>)</a></th>\n<td class=\"bc-supports-yes\"> 44</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 40</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 31</td>\n<td class=\"bc-supports-yes\"> 9</td>\n</tr>\n<tr>\n<th scope=\"row\">Shorthand notation for object literals</th>\n<td class=\"bc-supports-yes\"> 43</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 33</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 30</td>\n<td class=\"bc-supports-yes\"> 9</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Template_literals\">Template literals</a></th>\n<td class=\"bc-supports-yes\"> 41</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 34</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 28</td>\n<td class=\"bc-supports-yes\"> 9</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Trailing_commas\">Trailing commas</a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n</tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Lexical_grammar#Array_literals\">Array literals (<code>[1, 2, 3]</code>)</a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Lexical_grammar#Binary\">Binary numeric literals (<code>0b</code>)</a></th>\n<td class=\"bc-supports-yes\"> 41</td>\n<td class=\"bc-supports-yes\"> 41</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 25</td>\n<td class=\"bc-supports-yes\"> 28</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4.0</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Lexical_grammar#Boolean_literal\">Boolean literals (<code>true</code>/<code>false</code>)</a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Lexical_grammar#Decimal\">Decimal numeric literals (<code>1234567890</code>)</a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Lexical_grammar#Hexadecimal_escape_sequences\">Hexadecimal escape sequences (<code>'\\0xA9'</code>)</a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Lexical_grammar#Hexadecimal\">Hexadecimal numeric literals (<code>0xAF</code>)</a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Lexical_grammar#Null_literal\">Null literal (<code>null</code>)</a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Lexical_grammar#Octal\">Octal numeric literals (<code>0o</code>)</a></th>\n<td class=\"bc-supports-yes\"> 41</td>\n<td class=\"bc-supports-yes\"> 41</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 25</td>\n<td class=\"bc-supports-yes\"> 28</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4.0</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Lexical_grammar#Regular_expression_literals\">Regular expression literals (<code>/ab+c/g</code>)</a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Lexical_grammar#String_literals\">String literals (<code>'Hello world'</code>)</a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Lexical_grammar#Unicode_escape_sequences\">Unicode escape sequences (<code>'\\u00A9'</code>)</a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Lexical_grammar#Unicode_code_point_escapes\">Unicode point escapes (<code>\\u{}</code>)</a></th>\n<td class=\"bc-supports-yes\"> 44</td>\n<td class=\"bc-supports-yes\"> 44</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 40</td>\n<td class=\"bc-supports-yes\"> 31</td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 4.0</td>\n</tr>\n<tr>\n<th scope=\"row\">Shorthand notation for object literals</th>\n<td class=\"bc-supports-yes\"> 43</td>\n<td class=\"bc-supports-yes\"> 43</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 33</td>\n<td class=\"bc-supports-yes\"> 30</td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 4.0</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Template_literals\">Template literals</a></th>\n<td class=\"bc-supports-yes\"> 41</td>\n<td class=\"bc-supports-yes\"> 41</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 34</td>\n<td class=\"bc-supports-yes\"> 28</td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 4.0</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Trailing_commas\">Trailing commas</a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n</tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Lexical_grammar#Array_literals\">Array literals (<code>[1, 2, 3]</code>)</a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Lexical_grammar#Binary\">Binary numeric literals (<code>0b</code>)</a></th>\n<td class=\"bc-supports-yes bc-has-history\"> 4.0.0\n<section class=\"bc-history\" id=\"sect1\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 4.0.0\n</dt>\n\n<dt class=\"bc-supports-yes bc-supports\"> 0.12<div class=\"bc-icons\">Disabled </div>\n</dt>\n<dd>Disabled From version 0.12: this feature is behind the <code>--harmony</code> runtime flag.</dd>\n</dl></section>\n</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Lexical_grammar#Boolean_literal\">Boolean literals (<code>true</code>/<code>false</code>)</a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Lexical_grammar#Decimal\">Decimal numeric literals (<code>1234567890</code>)</a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Lexical_grammar#Hexadecimal_escape_sequences\">Hexadecimal escape sequences (<code>'\\0xA9'</code>)</a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Lexical_grammar#Hexadecimal\">Hexadecimal numeric literals (<code>0xAF</code>)</a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Lexical_grammar#Null_literal\">Null literal (<code>null</code>)</a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Lexical_grammar#Octal\">Octal numeric literals (<code>0o</code>)</a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Lexical_grammar#Regular_expression_literals\">Regular expression literals (<code>/ab+c/g</code>)</a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Lexical_grammar#String_literals\">String literals (<code>'Hello world'</code>)</a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Lexical_grammar#Unicode_escape_sequences\">Unicode escape sequences (<code>'\\u00A9'</code>)</a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Lexical_grammar#Unicode_code_point_escapes\">Unicode point escapes (<code>\\u{}</code>)</a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">Shorthand notation for object literals</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Template_literals\">Template literals</a></th>\n<td class=\"bc-supports-yes\"> 4.0.0</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Trailing_commas\">Trailing commas</a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n</tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"http://whereswalden.com/2013/08/12/micro-feature-from-es6-now-in-firefox-aurora-and-nightly-binary-and-octal-numbers/\">Jeff Walden: Binary and octal numbers</a></li> <li><a href=\"http://mathiasbynens.be/notes/javascript-escapes\">Mathias Bynens: JavaScript character escape sequences</a></li> <li><a href=\"global_objects/boolean\"><code>Boolean</code></a></li> <li><a href=\"global_objects/number\"><code>Number</code></a></li> <li><a href=\"global_objects/regexp\"><code>RegExp</code></a></li> <li><a href=\"global_objects/string\"><code>String</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Lexical_grammar$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Lexical_grammar\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Lexical_grammar</a>\n  </p>\n</div>\n","global_objects/typedarray/name":"<h1>TypedArray.name</h1> <p>The <code><strong><em>TypedArray</em>.name</strong></code> property represents a string value of the typed array constructor name.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/typedarray-name.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <div class=\"_table\"><table class=\"standard-table\"> <thead> <tr> <th colspan=\"2\" class=\"header\">Property attributes of <code>TypedArray.name</code>\n</th> </tr> </thead> <tbody> <tr> <td>Writable</td> <td>no</td> </tr> <tr> <td>Enumerable</td> <td>no</td> </tr> <tr> <td>Configurable</td> <td>no</td> </tr> </tbody> </table></div> <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\">TypedArray.name;</pre> <h2 id=\"Description\">Description</h2> <p>TypedArray objects differ from each other in the number of bytes per element and in the way the bytes are interpreted. The <code>name</code> property describes of what data type the array consists. The first part can be <code>Int</code> for \"integer\" or <code>Uint</code> for an \"unsigned integer\", also <code>Float</code> for \"floating point\" is used. The second part is a number describing the bit-size of the array. Finally, the object type is <code>Array</code>, with <code>ClampedArray</code> as a special case. Please see <a href=\"../uint8clampedarray\"><code>Uint8ClampedArray</code></a> for more details.</p> <h2 id=\"Examples\">Examples</h2> <pre data-language=\"js\">Int8Array.name;         // \"Int8Array\"\nUint8Array.name;        // \"Uint8Array\"\nUint8ClampedArray.name; // \"Uint8ClampedArray\"\nInt16Array.name;        // \"Int16Array\"\nUint16Array.name;       // \"Uint16Array\"\nInt32Array.name;        // \"Int32Array\"\nUint32Array.name;       // \"Uint32Array\"\nFloat32Array.name;      // \"Float32Array\"\nFloat64Array.name;      // \"Float64Array\"</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-properties-of-the-typedarray-constructors\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'TypedArray.name' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-properties-of-the-typedarray-constructors\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'TypedArray.name' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 7</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> 10</td>\n<td class=\"bc-supports-yes\"> 11.6</td>\n<td class=\"bc-supports-yes\"> 5.1</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> 11.6</td>\n<td class=\"bc-supports-yes\"> 4.2</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Typed_arrays\">JavaScript typed arrays</a></li> <li><a href=\"../typedarray\"><code>TypedArray</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/name$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/name\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/name</a>\n  </p>\n</div>\n","global_objects/typedarray/buffer":"<h1>typedArray.buffer</h1> <p>The <code>buffer</code> accessor property represents the <a href=\"../arraybuffer\"><code>ArrayBuffer</code></a> referenced by a <em>TypedArray</em> at construction time.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/typedarray-buffer.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\"><var>typedArray</var>.buffer</pre> <h2 id=\"Description\">Description</h2> <p>The <code>buffer</code> property is an accessor property whose set accessor function is <code>undefined</code>, meaning that you can only read this property. The value is established when the <em>TypedArray</em> is constructed and cannot be changed. <em>TypedArray</em> is one of the <a href=\"../typedarray#TypedArray_objects\">TypedArray objects</a>.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Using_the_buffer_property\">Using the <code>buffer</code> property</h3> <pre data-language=\"js\">var buffer = new ArrayBuffer(8);\nvar uint16 = new Uint16Array(buffer);\nuint16.buffer; // ArrayBuffer { byteLength: 8 }\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"#\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'TypedArray.prototype.buffer' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"#\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'TypedArray.prototype.buffer' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 7</td>\n<td class=\"bc-supports-yes\"> 14</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> 10</td>\n<td class=\"bc-supports-yes\"> 11.6</td>\n<td class=\"bc-supports-yes\"> 5.1</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> 11.6</td>\n<td class=\"bc-supports-yes\"> 4.2</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Typed_arrays\">JavaScript typed arrays</a></li> <li><a href=\"../typedarray\"><code>TypedArray</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/buffer$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/buffer\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/buffer</a>\n  </p>\n</div>\n","global_objects/typedarray/of":"<h1>TypedArray.of</h1> <p>The <code><strong><em>TypedArray</em>.of()</strong></code> method creates a new <a href=\"../typedarray#TypedArray_objects\">typed array</a> with a variable number of arguments. This method is nearly the same as <a href=\"../array/of\"><code>Array.of()</code></a>.</p> <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\"><em>TypedArray</em>.of(<var>element0</var>[, <var>element1</var>[, ...[, <var>elementN</var>]]])\n\nwhere <em>TypedArray</em> is one of:\n\nInt8Array\nUint8Array\nUint8ClampedArray\nInt16Array\nUint16Array\nInt32Array\nUint32Array\nFloat32Array\nFloat64Array</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><code>element<em>N</em></code></dt> <dd>Elements of which to create the typed array.</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p>A new <a href=\"../typedarray\"><code>TypedArray</code></a> instance.</p> <h2 id=\"Description\">Description</h2> <p>Some subtle distinctions between <a href=\"../array/of\"><code>Array.of()</code></a> and <code><em>TypedArray</em>.of()</code>:</p> <ul> <li>If the <code>this</code> value passed to <code><em>TypedArray</em>.of</code> is not a constructor, <code><em>TypedArray</em>.of</code> will throw a <a href=\"../typeerror\"><code>TypeError</code></a>, where <code>Array.of</code> defaults to creating a new <a href=\"../array\"><code>Array</code></a>.</li> <li>\n<code><em>TypedArray</em>.of</code> uses <code>[[Put]]</code> where <code>Array.of</code> uses <code>[[DefineProperty]]</code>. Hence, when working with <a href=\"../proxy\"><code>Proxy</code></a> objects, it calls <a href=\"../proxy/handler/set\"><code>handler.set</code></a> to create new elements rather than <a href=\"../proxy/handler/defineproperty\"><code>handler.defineProperty</code></a>.</li> </ul> <h2 id=\"Examples\">Examples</h2> <pre data-language=\"js\">Uint8Array.of(1);            // Uint8Array [ 1 ]\nInt8Array.of('1', '2', '3'); // Int8Array [ 1, 2, 3 ]\nFloat32Array.of(1, 2, 3);    // Float32Array [ 1, 2, 3 ]\nInt16Array.of(undefined);    // IntArray [ 0 ]\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"#\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of '%TypedArray%.of' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"#\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of '%TypedArray%.of' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>   <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 45</td>\n<td class=\"bc-supports-yes\"> 14</td>\n<td class=\"bc-supports-yes\"> 38</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 38</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 4.0.0</td>\n</tr></tbody>\n</table>\n</div>  <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"from\"><code>TypedArray.from()</code></a></li> <li><a href=\"../array/of\"><code>Array.of()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/of$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/of\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/of</a>\n  </p>\n</div>\n","global_objects/typedarray/length":"<h1>typedArray.length</h1> <p>The <code>length</code> accessor property represents the length (in elements) of a typed array.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/typedarray-length.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\"><var>typedarray</var>.length</pre> <h2 id=\"Description\">Description</h2> <p>The <code>length</code> property is an accessor property whose set accessor function is <code>undefined</code>, meaning that you can only read this property. The value is established when a <em>TypedArray</em> is constructed and cannot be changed. If the <em>TypedArray</em> is not specifying an <code>byteOffset</code> or a <code>length</code>, the length of the referenced <a href=\"../arraybuffer\"><code>ArrayBuffer</code></a> will be returned. <em>TypedArray</em> is one of the <a href=\"../typedarray#TypedArray_objects\">TypedArray objects</a>.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Using_the_length_property\">Using the <code>length</code> property</h3> <pre data-language=\"js\">var buffer = new ArrayBuffer(8);\n\nvar uint8 = new Uint8Array(buffer);\nuint8.length; // 8 (matches the length of the buffer)\n\nvar uint8 = new Uint8Array(buffer, 1, 5);\nuint8.length; // 5 (as specified when constructing the Uint8Array)\n\nvar uint8 = new Uint8Array(buffer, 2);\nuint8.length; // 6 (due to the offset of the constructed Uint8Array)\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"#\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'TypedArray.prototype.length' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"#\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'TypedArray.prototype.length' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 7</td>\n<td class=\"bc-supports-yes\"> 14</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> 10</td>\n<td class=\"bc-supports-yes\"> 11.6</td>\n<td class=\"bc-supports-yes\"> 5.1</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> 11.6</td>\n<td class=\"bc-supports-yes\"> 4.2</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Typed_arrays\">JavaScript typed arrays</a></li> <li><a href=\"../typedarray\"><code>TypedArray</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/length$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/length\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/length</a>\n  </p>\n</div>\n","global_objects/typedarray/@@species":"<h1>TypedArray.@@species</h1> <p>The <code><strong>TypedArray[@@species]</strong></code> accessor property returns the constructor of a <a href=\"../typedarray#TypedArray_objects\">typed array</a>.</p> <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\"><em>TypedArray</em>[Symbol.species]\n\nwhere <em>TypedArray</em> is one of:\n\nInt8Array\nUint8Array\nUint8ClampedArray\nInt16Array\nUint16Array\nInt32Array\nUint32Array\nFloat32Array\nFloat64Array\n</pre> <h2 id=\"Description\">Description</h2> <p>The <code>species</code> accessor property returns the default constructor for <a href=\"../typedarray#TypedArray_objects\">typed array</a> objects. Subclass constructors may over-ride it to change the constructor assignment.</p> <h2 id=\"Examples\">Examples</h2> <p>The <code>species</code> property returns the default constructor function, which is one of the typed array constructors for a given <a href=\"../typedarray#TypedArray_objects\">typed array</a> object:</p> <pre data-language=\"js\">Int8Array[Symbol.species];    // function Int8Array()\nUint8Array[Symbol.species];   // function Uint8Array()\nFloat32Array[Symbol.species]; // function Float32Array()\n</pre> <p>In a derived collection object (e.g. your custom typed array <code>MyTypedArray</code>), the <code>MyTypedArray</code> species is the <code>MyTypedArray</code> constructor. However, you might want to overwrite this, in order to return a parent <a href=\"../typedarray#TypedArray_objects\">typed array</a> object in your derived class methods:</p> <pre data-language=\"js\">class MyTypedArray extends Uint8Array {\n  // Overwrite MyTypedArray species to the parent Uint8Array constructor\n  static get [Symbol.species]() { return Uint8Array; }\n}</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"#\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'get %TypedArray% [ @@species ]' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"#\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'get %TypedArray% [ @@species ]' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>   <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 48</td>\n<td class=\"bc-supports-no\"> No</td>\n<td> ? </td>\n<td> ? </td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td> ? </td>\n<td> ? </td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 48</td>\n<td> ? </td>\n<td> ? </td>\n<td> ? </td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes bc-has-history\"> 6.5.0\n<section class=\"bc-history\" id=\"sect1\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 6.5.0\n</dt>\n\n<dt class=\"bc-supports-yes bc-supports\"> 6.0.0<div class=\"bc-icons\">Disabled </div>\n</dt>\n<dd>Disabled From version 6.0.0: this feature is behind the <code>--harmony</code> runtime flag.</dd>\n</dl></section>\n</td>\n</tr></tbody>\n</table>\n</div>  <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"../typedarray\"><code>TypedArray</code></a></li> <li><a href=\"../symbol/species\"><code>Symbol.species</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/@@species$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/@@species\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/@@species</a>\n  </p>\n</div>\n","global_objects/typedarray/from":"<h1>TypedArray.from</h1> <p>The <code><strong><em>TypedArray</em>.from()</strong></code> method creates a new <a href=\"../typedarray#TypedArray_objects\">typed array</a> from an array-like or iterable object. This method is nearly the same as <a href=\"../array/from\"><code>Array.from()</code></a>.</p> <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\"><em>TypedArray</em>.from(source[, mapFn[, thisArg]])\n\nwhere <em>TypedArray</em> is one of:\n\nInt8Array\nUint8Array\nUint8ClampedArray\nInt16Array\nUint16Array\nInt32Array\nUint32Array\nFloat32Array\nFloat64Array\n</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><code>source</code></dt> <dd>An array-like or iterable object to convert to a typed array.</dd> <dt><code>mapFn</code></dt> <dd>Optional. Map function to call on every element of the typed array.</dd> <dt><code>thisArg</code></dt> <dd>Optional. Value to use as <code>this</code> when executing <code>mapFn</code>.</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p>A new <a href=\"../typedarray\"><code>TypedArray</code></a> instance.</p> <h2 id=\"Description\">Description</h2> <p><code><em>TypedArray</em>.from()</code> lets you create typed arrays from:</p> <ul> <li>array-like objects (objects with a <code>length</code> property and indexed elements) or</li> <li>\n<a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/iterable\">iterable objects</a> (objects where you can get its elements, such as <a href=\"../map\"><code>Map</code></a> and <a href=\"../set\"><code>Set</code></a>).</li> </ul> <p><code><em>TypedArray</em>.from()</code> has an optional parameter <code>mapFn</code>, which allows you to execute a <a href=\"../array/map\"><code>map</code></a> function on each element of the typed array (or subclass object) that is being created. More clearly, <code><em>TypedArray</em>.from(obj, mapFn, thisArg)</code> is the same as <code><em>TypedArray</em>.from(Array.prototype.map.call(obj, mapFn, thisArg))</code>.</p> <p>The <code>length</code> property of the <code>from()</code> method is 1.</p> <p>Some subtle distinctions between <a href=\"../array/from\"><code>Array.from()</code></a> and <code><em>TypedArray</em>.from()</code>:</p> <ul> <li>If the <code>|this|</code> value passed to <code><em>TypedArray</em>.from</code> is not a constructor, <code><em>TypedArray</em>.from</code> will throw a <a href=\"../typeerror\"><code>TypeError</code></a>, where <code>Array.from</code> defaults to creating a new <a href=\"../array\"><code>Array</code></a>.</li> <li>\n<code><em>TypedArray</em>.from</code> uses <code>[[Put]]</code> where <code>Array.from</code> uses <code>[[DefineProperty]]</code>. Hence, when working with <a href=\"../proxy\"><code>Proxy</code></a> objects, it calls <a href=\"../proxy/handler/set\"><code>handler.set</code></a> to create new elements rather than <a href=\"../proxy/handler/defineproperty\"><code>handler.defineProperty</code></a>.</li> <li>When <code>from</code> gets an iterator, the <code><em>TypedArray</em></code> version first collects all the values from the iterator, then creates an instance of <code>|this|</code> using the count, then sets the values on the instance. <code>Array.from</code> sets each value as it gets them from the iterator then sets the length at the end.</li> <li>When <code>Array.from</code> gets an array-like which isn't an iterator, it respects holes, where <code><em>TypedArray</em>.from</code> will ensure the result is dense.</li> </ul> <h2 id=\"Examples\">Examples</h2> <pre data-language=\"js\">// Set (iterable object)\nvar s = new Set([1, 2, 3]);\nUint8Array.from(s);\n// Uint8Array [ 1, 2, 3 ]\n\n\n// String\nInt16Array.from('123');                      \n// Int16Array [ 1, 2, 3 ]\n\n\n// Using an arrow function as the map function to\n// manipulate the elements\nFloat32Array.from([1, 2, 3], x =&gt; x + x);      \n// Float32Array [ 2, 4, 6 ]\n\n\n// Generate a sequence of numbers\nUint8Array.from({length: 5}, (v, k) =&gt; k);    \n// Uint8Array [ 0, 1, 2, 3, 4 ]\n</pre> <h2 id=\"Polyfill\">Polyfill</h2> <p>You can partially work around this by inserting the following code at the beginning of your scripts, allowing use of much of the functionality of <font face=\"Consolas, Liberation Mono, Courier, monospace\">from()</font> in implementations that do not natively support it.</p> <pre data-language=\"js\">if (!Int8Array.__proto__.from) {\n    (function () {\n        Int8Array.__proto__.from = function (obj, func, thisObj) {\n\n            var typedArrayClass = Int8Array.__proto__;\n            if(typeof this !== 'function') {\n                throw new TypeError('# is not a constructor');\n            }\n            if (this.__proto__ !== typedArrayClass) {\n                throw new TypeError('this is not a typed array.');\n            }\n \n            func = func || function (elem) {\n                    return elem;\n                };\n\n            if (typeof func !== 'function') {\n                throw new TypeError('specified argument is not a function');\n            }\n\n            obj = Object(obj);\n            if (!obj['length']) {\n                return new this(0);\n            }\n            var copy_data = [];\n            for(var i = 0; i &lt; obj.length; i++) {\n                copy_data.push(obj[i]);\n            }\n\n            copy_data = copy_data.map(func, thisObj);\n\n            var typed_array = new this(copy_data.length);\n            for(var i = 0; i &lt; typed_array.length; i++) {\n                typed_array[i] = copy_data[i];\n            }\n            return typed_array;\n        }\n    })();\n}</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"#\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of '%TypedArray%.from' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"#\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of '%TypedArray%.from' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>   <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 45</td>\n<td class=\"bc-supports-yes\"> 14</td>\n<td class=\"bc-supports-yes\"> 38</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 10</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 38</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 10</td>\n<td class=\"bc-supports-no\"> No</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 4.0.0</td>\n</tr></tbody>\n</table>\n</div>  <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"of\"><code>TypedArray.of()</code></a></li> <li><a href=\"../array/from\"><code>Array.from()</code></a></li> <li><a href=\"../array/map\"><code>Array.prototype.map()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/from$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/from\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/from</a>\n  </p>\n</div>\n","global_objects/typedarray/copywithin":"<h1>typedArray.copyWithin</h1> <p>The <code><strong>copyWithin()</strong></code> method copies the sequence of array elements within the array to the position starting at <code>target</code>. The copy is taken from the index positions of the second and third arguments <code>start</code> and <code>end</code>. The <code>end</code> argument is optional and defaults to the length of the array. This method has the same algorithm as <a href=\"../array/copywithin\"><code>Array.prototype.copyWithin</code></a><em>.</em> <em>TypedArray</em> is one of the <a href=\"../typedarray#TypedArray_objects\">typed array types</a> here.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/typedarray-copywithin.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\"><var>typedarray</var>.copyWithin(<var>target</var>, <var>start</var>[, <var>end</var> = this.length])</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><code>target</code></dt> <dd>Target start index position where to copy the elements to.</dd> <dt><code>start</code></dt> <dd>Source start index position where to start copying elements from.</dd> <dt><code>end <span class=\"inlineIndicator optional optionalInline\">Optional</span></code></dt> <dd>Optional. Source end index position where to end copying elements from.</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p>The modified array.</p> <h2 id=\"Description\">Description</h2> <p>See <a href=\"../array/copywithin\"><code>Array.prototype.copyWithin</code></a> for more details.</p> <p>This method replaces the experimental <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/move\"><code>TypedArray.prototype.move()</code></a>.</p> <h2 id=\"Examples\">Examples</h2> <pre data-language=\"js\">var buffer = new ArrayBuffer(8);\nvar uint8 = new Uint8Array(buffer);\nuint8.set([1,2,3]);\nconsole.log(uint8); // Uint8Array [ 1, 2, 3, 0, 0, 0, 0, 0 ]\nuint8.copyWithin(3,0,3);\nconsole.log(uint8); // Uint8Array [ 1, 2, 3, 1, 2, 3, 0, 0 ]\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"#\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'TypedArray.prototype.copyWithin' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"#\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'TypedArray.prototype.copyWithin' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>   <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 45</td>\n<td class=\"bc-supports-yes\"> 14</td>\n<td class=\"bc-supports-yes\"> 34</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 36</td>\n<td class=\"bc-supports-no\"> No</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 34</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 4.0.0</td>\n</tr></tbody>\n</table>\n</div>  <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"../typedarray\"><code>TypedArray</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/copyWithin$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/copyWithin\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/copyWithin</a>\n  </p>\n</div>\n","global_objects/typedarray/filter":"<h1>typedArray.filter</h1> <p>The <code><strong>filter()</strong></code> method creates a new typed array with all elements that pass the test implemented by the provided function. This method has the same algorithm as <a href=\"../array/filter\"><code>Array.prototype.filter()</code></a><em>.</em> <em>TypedArray</em> is one of the <a href=\"../typedarray#TypedArray_objects\">typed array types</a> here.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/typedarray-filter.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\"><var>typedarray</var>.filter(<var>callback</var>[, <var>thisArg</var>])</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><code>callback</code></dt> <dd>Function to test each element of the typed array. Invoked with arguments <code>(element, index, typedarray)</code>. Return <code>true</code> to keep the element, <code>false</code> otherwise.</dd> <dt><code>thisArg <span class=\"inlineIndicator optional optionalInline\">Optional</span></code></dt> <dd>Value to use as <code>this</code> when executing <code>callback</code>.</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p>A new typed array with the elements that pass the test.</p> <h2 id=\"Description\">Description</h2> <p>The <code>filter()</code> method calls a provided <code>callback</code> function once for each element in a typed array, and constructs a new typed array of all the values for which <code>callback</code> returns a true value. <code>callback</code> is invoked only for indexes of the typed array which have assigned values; it is not invoked for indexes which have been deleted or which have never been assigned values. Typed array elements which do not pass the <code>callback</code> test are simply skipped, and are not included in the new typed array.</p> <p><code>callback</code> is invoked with three arguments:</p> <ol> <li>the value of the element</li> <li>the index of the element</li> <li>the typed array object being traversed</li> </ol> <p>If a <code>thisArg</code> parameter is provided to <code>filter</code>, it will be passed to <code>callback</code> when invoked, for use as its <code>this</code> value. Otherwise, the value <code>undefined</code> will be passed for use as its <code>this</code> value. The <code>this</code> value ultimately observable by <code>callback</code> is determined according to <a href=\"../../operators/this\">the usual rules for determining the <code>this</code> seen by a function</a>.</p> <p><code>filter()</code> does not mutate the typed array on which it is called.</p> <p>The range of elements processed by <code>filter()</code> is set before the first invocation of <code>callback</code>. Elements which are appended to the typed array after the call to <code>filter()</code> begins will not be visited by <code>callback</code>. If existing elements of the typed array are changed, or deleted, their value as passed to <code>callback</code> will be the value at the time <code>filter()</code> visits them; elements that are deleted are not visited.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Filtering_out_all_small_values\">Filtering out all small values</h3> <p>The following example uses <code>filter()</code> to create a filtered typed array that has all elements with values less than 10 removed.</p> <pre data-language=\"js\">function isBigEnough(element, index, array) {\n  return element &gt;= 10;\n}\nnew Uint8Array([12, 5, 8, 130, 44]).filter(isBigEnough); \n// Uint8Array [ 12, 130, 44 ]\n</pre> <h3 id=\"Filtering_typed_array_elements_using_arrow_functions\">Filtering typed array elements using arrow functions</h3> <p><a href=\"../../functions/arrow_functions\">Arrow functions</a> provide a shorter syntax for the same test.</p> <pre data-language=\"js\">new Uint8Array([12, 5, 8, 130, 44]).filter(elem =&gt; elem &gt;= 10); \n// Uint8Array [ 12, 130, 44 ]</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"#\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'TypedArray.prototype.filter' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"#\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'TypedArray.prototype.filter' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>   <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 45</td>\n<td class=\"bc-supports-yes\"> 14</td>\n<td class=\"bc-supports-yes\"> 38</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 38</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 4.0.0</td>\n</tr></tbody>\n</table>\n</div>  <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"every\"><code>TypedArray.prototype.every()</code></a></li> <li><a href=\"some\"><code>TypedArray.prototype.some()</code></a></li> <li><a href=\"../array/filter\"><code>Array.prototype.filter()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/filter$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/filter\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/filter</a>\n  </p>\n</div>\n","global_objects/typedarray/every":"<h1>typedArray.every</h1> <p>The <code><strong>every()</strong></code> method tests whether all elements in the typed array pass the test implemented by the provided function. This method has the same algorithm as <a href=\"../array/every\"><code>Array.prototype.every()</code></a><em>.</em> <em>TypedArray</em> is one of the <a href=\"../typedarray#TypedArray_objects\">typed array types</a> here.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/typedarray-every.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\"><var>typedarray</var>.every(<var>callback</var>[, <var>thisArg</var>])</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><code>callback</code></dt> <dd>Function to test for each element, taking three arguments: <dl> <dt><code>currentValue</code></dt> <dd>The current element being processed in the typed array.</dd> <dt><code>index</code></dt> <dd>The index of the current element being processed in the typed array.</dd> <dt><code>array</code></dt> <dd>The typed array <code>every</code> was called upon.</dd> </dl> </dd> <dt><code>thisArg</code></dt> <dd>Optional. Value to use as <code>this</code> when executing <code>callback</code>.</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p><code><strong>true</strong></code> if the callback function returns a <a href=\"https://developer.mozilla.org/en-US/docs/Glossary/truthy\">truthy</a> value for every array element; otherwise, <code><strong>false</strong></code>.</p> <h2 id=\"Description\">Description</h2> <p>The <code>every</code> method executes the provided <code>callback</code> function once for each element present in the typed array until it finds one where <code>callback</code> returns a <em>falsy</em> value (a value that becomes false when converted to a Boolean). If such an element is found, the <code>every</code> method immediately returns <code>false</code>. Otherwise, if <code>callback</code> returned a true value for all elements, <code>every</code> will return <code>true</code>.</p> <p><code>callback</code> is invoked with three arguments: the value of the element, the index of the element, and the array object being traversed.</p> <p>If a <code>thisArg</code> parameter is provided to <code>every</code>, it will be passed to <code>callback</code> when invoked, for use as its <code>this</code> value. Otherwise, the value <code>undefined</code> will be passed for use as its <code>this</code> value. The <code>this</code> value ultimately observable by <code>callback</code> is determined according to <a href=\"../../operators/this\">the usual rules for determining the <code>this</code> seen by a function</a>.</p> <p><code>every</code> does not mutate the typed array on which it is called.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Testing_size_of_all_typed_array_elements\">Testing size of all typed array elements</h3> <p>The following example tests whether all elements in the typed array are bigger than 10.</p> <pre data-language=\"js\">function isBigEnough(element, index, array) {\n  return element &gt;= 10;\n}\nnew Uint8Array([12, 5, 8, 130, 44]).every(isBigEnough);   // false\nnew Uint8Array([12, 54, 18, 130, 44]).every(isBigEnough); // true</pre> <h3 id=\"Testing_typed_array_elements_using_arrow_functions\">Testing typed array elements using arrow functions</h3> <p><a href=\"../../functions/arrow_functions\">Arrow functions</a> provide a shorter syntax for the same test.</p> <pre data-language=\"js\">new Uint8Array([12, 5, 8, 130, 44]).every(elem =&gt; elem &gt;= 10); // false\nnew Uint8Array([12, 54, 18, 130, 44]).every(elem =&gt; elem &gt;= 10); // true</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"#\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'TypedArray.prototype.every' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"#\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'TypedArray.prototype.every' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>   <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 45</td>\n<td class=\"bc-supports-yes\"> 14</td>\n<td class=\"bc-supports-yes\"> 37</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 36</td>\n<td class=\"bc-supports-no\"> No</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 37</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 4.0.0</td>\n</tr></tbody>\n</table>\n</div>  <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"some\"><code>TypedArray.prototype.some()</code></a></li> <li><a href=\"../array/every\"><code>Array.prototype.every()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/every$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/every\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/every</a>\n  </p>\n</div>\n","global_objects/typedarray/fill":"<h1>typedArray.fill</h1> <p>The <code><strong>fill()</strong></code> method fills all the elements of a typed array from a start index to an end index with a static value. This method has the same algorithm as <a href=\"../array/fill\"><code>Array.prototype.fill()</code></a><em>.</em> <em>TypedArray</em> is one of the <a href=\"../typedarray#TypedArray_objects\">typed array types</a> here.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/typedarray-fill.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\"><var>typedarray</var>.fill(<var>value</var>[, <var>start<var> = 0[, <var>end</var> = this.length]])</var></var></pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><code>value</code></dt> <dd>Value to fill the typed array with.</dd> <dt><code>start</code></dt> <dd>Optional. Start index. Defaults to 0.</dd> <dt><code>end</code></dt> <dd>Optional. End index (not included). Defaults to this.length.</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p>The modified array.</p> <h2 id=\"Description\">Description</h2> <p>The elements interval to fill is [<code>start</code>, <code>end</code>).</p> <p>The <code>fill</code> method takes up to three arguments <code>value</code>, <code>start</code> and <code>end</code>. The <code>start</code> and <code>end</code> arguments are optional with default values of <code>0</code> and the <code>length</code> of the <code>this</code> object.</p> <p>If <code>start</code> is negative, it is treated as <code>length+start</code> where <code>length</code> is the length of the array. If <code>end</code> is negative, it is treated as <code>length+end</code>.</p> <h2 id=\"Examples\">Examples</h2> <pre data-language=\"js\">new Uint8Array([1, 2, 3]).fill(4);         // Uint8Array [4, 4, 4]\nnew Uint8Array([1, 2, 3]).fill(4, 1);      // Uint8Array [1, 4, 4]\nnew Uint8Array([1, 2, 3]).fill(4, 1, 2);   // Uint8Array [1, 4, 3]\nnew Uint8Array([1, 2, 3]).fill(4, 1, 1);   // Uint8Array [1, 2, 3]\nnew Uint8Array([1, 2, 3]).fill(4, -3, -2); // Uint8Array [4, 2, 3]\n</pre> <h2 id=\"Polyfill\">Polyfill</h2> <p>Since there is no global object with the name <em>TypedArray</em>, polyfilling must be done on an \"as needed\" basis. Use the following \"polyfill\" along with the <a href=\"../array/fill\"><code>Array.prototype.fill()</code></a> polyfill.</p> <pre data-language=\"js\">// https://tc39.github.io/ecma262/#sec-%typedarray%.prototype.fill\nif (!Uint8Array.prototype.fill) {\n  Uint8Array.prototype.fill = Array.prototype.fill;\n}\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"#\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'TypedArray.prototype.fill' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"#\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'TypedArray.prototype.fill' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>   <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 45</td>\n<td class=\"bc-supports-yes\"> 14</td>\n<td class=\"bc-supports-yes\"> 37</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 36</td>\n<td class=\"bc-supports-no\"> No</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 37</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 4.0.0</td>\n</tr></tbody>\n</table>\n</div>  <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"../array/fill\"><code>Array.prototype.fill()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/fill$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/fill\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/fill</a>\n  </p>\n</div>\n","global_objects/typedarray/prototype":"<h1>TypedArray.prototype</h1> <p>The <code><strong>TypedArray</strong></code><code>.prototype</code> property represents the prototype for <a href=\"../typedarray\"><code>TypedArray</code></a> constructors.</p> <div class=\"_table\"><table class=\"standard-table\"> <thead> <tr> <th colspan=\"2\" class=\"header\">Property attributes of <code>TypedArray.prototype</code>\n</th> </tr> </thead> <tbody> <tr> <td>Writable</td> <td>no</td> </tr> <tr> <td>Enumerable</td> <td>no</td> </tr> <tr> <td>Configurable</td> <td>no</td> </tr> </tbody> </table></div> <h2 id=\"Description\">Description</h2> <p><a href=\"../typedarray\"><code>TypedArray</code></a> instances inherit from <a href=\"prototype\"><code>TypedArray.prototype</code></a>. You can use the constructor's prototype object to add properties or methods to all <em>TypedArray</em> instances, where <em>TypedArray</em> is one of the <a href=\"../typedarray#TypedArray_objects\">typed array types</a>.</p> <p>See also the description about <a href=\"../typedarray#Description\"><em>TypedArray</em></a> for more information about inheritance.</p> <h2 id=\"Properties\">Properties</h2> <dl> <dt><code>TypedArray.prototype.constructor</code></dt> <dd>Returns the function that created an instance's prototype. This is one the corresponding <a href=\"../typedarray#TypedArray_objects\">typed array type</a> functions by default.</dd> <dt>\n<a href=\"buffer\"><code>TypedArray.prototype.buffer</code></a> <span class=\"inlineIndicator readOnly readOnlyInline\">Read only </span>\n</dt> <dd>Returns the <a href=\"../arraybuffer\"><code>ArrayBuffer</code></a> referenced by the typed array. Fixed at construction time and thus <strong>read only</strong>.</dd> <dt>\n<a href=\"bytelength\"><code>TypedArray.prototype.byteLength</code></a> <span class=\"inlineIndicator readOnly readOnlyInline\">Read only </span>\n</dt> <dd>Returns the length (in bytes) of the typed array. Fixed at construction time and thus <strong>read only.</strong>\n</dd> <dt>\n<a href=\"byteoffset\"><code>TypedArray.prototype.byteOffset</code></a> <span class=\"inlineIndicator readOnly readOnlyInline\">Read only </span>\n</dt> <dd>Returns the offset (in bytes) of the typed array from the start of its <a href=\"../arraybuffer\"><code>ArrayBuffer</code></a>. Fixed at construction time and thus <strong>read only.</strong>\n</dd> <dt>\n<a href=\"length\"><code>TypedArray.prototype.length</code></a> <span class=\"inlineIndicator readOnly readOnlyInline\">Read only </span>\n</dt> <dd>Returns the number of elements held in the typed array. Fixed at construction time and thus <strong>read only.</strong>\n</dd> </dl> <h2 id=\"Methods\">Methods</h2> <dl> <dt><a href=\"copywithin\"><code>TypedArray.prototype.copyWithin()</code></a></dt> <dd>Copies a sequence of array elements within the array. See also <a href=\"../array/copywithin\"><code>Array.prototype.copyWithin()</code></a>.</dd> <dt><a href=\"entries\"><code>TypedArray.prototype.entries()</code></a></dt> <dd>Returns a new <code>Array Iterator</code> object that contains the key/value pairs for each index in the array. See also <a href=\"../array/entries\"><code>Array.prototype.entries()</code></a>.</dd> <dt><a href=\"every\"><code>TypedArray.prototype.every()</code></a></dt> <dd>Tests whether all elements in the array pass the test provided by a function. See also <a href=\"../array/every\"><code>Array.prototype.every()</code></a>.</dd> <dt><a href=\"fill\"><code>TypedArray.prototype.fill()</code></a></dt> <dd>Fills all the elements of an array from a start index to an end index with a static value. See also <a href=\"../array/fill\"><code>Array.prototype.fill()</code></a>.</dd> <dt><a href=\"filter\"><code>TypedArray.prototype.filter()</code></a></dt> <dd>Creates a new array with all of the elements of this array for which the provided filtering function returns true. See also <a href=\"../array/filter\"><code>Array.prototype.filter()</code></a>.</dd> <dt><a href=\"find\"><code>TypedArray.prototype.find()</code></a></dt> <dd>Returns the found value in the array, if an element in the array satisfies the provided testing function or <code>undefined</code> if not found. See also <a href=\"../array/find\"><code>Array.prototype.find()</code></a>.</dd> <dt><a href=\"findindex\"><code>TypedArray.prototype.findIndex()</code></a></dt> <dd>Returns the found index in the array, if an element in the array satisfies the provided testing function or -1 if not found. See also <a href=\"../array/findindex\"><code>Array.prototype.findIndex()</code></a>.</dd> <dt><a href=\"foreach\"><code>TypedArray.prototype.forEach()</code></a></dt> <dd>Calls a function for each element in the array. See also <a href=\"../array/foreach\"><code>Array.prototype.forEach()</code></a>.</dd> <dt>\n<a href=\"includes\"><code>TypedArray.prototype.includes()</code></a> \n</dt> <dd>Determines whether a typed array includes a certain element, returning <code>true</code> or <code>false</code> as appropriate. See also <a href=\"../array/includes\"><code>Array.prototype.includes()</code></a>.</dd> <dt><a href=\"indexof\"><code>TypedArray.prototype.indexOf()</code></a></dt> <dd>Returns the first (least) index of an element within the array equal to the specified value, or -1 if none is found. See also <a href=\"../array/indexof\"><code>Array.prototype.indexOf()</code></a>.</dd> <dt><a href=\"join\"><code>TypedArray.prototype.join()</code></a></dt> <dd>Joins all elements of an array into a string. See also <a href=\"../array/join\"><code>Array.prototype.join()</code></a>.</dd> <dt><a href=\"keys\"><code>TypedArray.prototype.keys()</code></a></dt> <dd>Returns a new <code>Array Iterator</code> that contains the keys for each index in the array. See also <a href=\"../array/keys\"><code>Array.prototype.keys()</code></a>.</dd> <dt><a href=\"lastindexof\"><code>TypedArray.prototype.lastIndexOf()</code></a></dt> <dd>Returns the last (greatest) index of an element within the array equal to the specified value, or -1 if none is found. See also <a href=\"../array/lastindexof\"><code>Array.prototype.lastIndexOf()</code></a>.</dd> <dt><a href=\"map\"><code>TypedArray.prototype.map()</code></a></dt> <dd>Creates a new array with the results of calling a provided function on every element in this array. See also <a href=\"../array/map\"><code>Array.prototype.map()</code></a>.</dd> <dt>\n<a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/move\"><code>TypedArray.prototype.move()</code></a>  <span class=\"inlineIndicator unimplemented unimplementedInline\">Unimplemented</span>\n</dt> <dd>Former non-standard version of <a href=\"copywithin\"><code>TypedArray.prototype.copyWithin()</code></a>.</dd> <dt><a href=\"reduce\"><code>TypedArray.prototype.reduce()</code></a></dt> <dd>Apply a function against an accumulator and each value of the array (from left-to-right) as to reduce it to a single value. See also <a href=\"../array/reduce\"><code>Array.prototype.reduce()</code></a>.</dd> <dt><a href=\"reduceright\"><code>TypedArray.prototype.reduceRight()</code></a></dt> <dd>Apply a function against an accumulator and each value of the array (from right-to-left) as to reduce it to a single value. See also <a href=\"../array/reduceright\"><code>Array.prototype.reduceRight()</code></a>.</dd> <dt><a href=\"reverse\"><code>TypedArray.prototype.reverse()</code></a></dt> <dd>Reverses the order of the elements of an array — the first becomes the last, and the last becomes the first. See also <a href=\"../array/reverse\"><code>Array.prototype.reverse()</code></a>.</dd> <dt><a href=\"set\"><code>TypedArray.prototype.set()</code></a></dt> <dd>Stores multiple values in the typed array, reading input values from a specified array.</dd> <dt><a href=\"slice\"><code>TypedArray.prototype.slice()</code></a></dt> <dd>Extracts a section of an array and returns a new array. See also <a href=\"../array/slice\"><code>Array.prototype.slice()</code></a>.</dd> <dt><a href=\"some\"><code>TypedArray.prototype.some()</code></a></dt> <dd>Returns true if at least one element in this array satisfies the provided testing function. See also <a href=\"../array/some\"><code>Array.prototype.some()</code></a>.</dd> <dt><a href=\"sort\"><code>TypedArray.prototype.sort()</code></a></dt> <dd>Sorts the elements of an array in place and returns the array. See also <a href=\"../array/sort\"><code>Array.prototype.sort()</code></a>.</dd> <dt><a href=\"subarray\"><code>TypedArray.prototype.subarray()</code></a></dt> <dd>Returns a new TypedArray from the given start and end element index.</dd> <dt><a href=\"values\"><code>TypedArray.prototype.values()</code></a></dt> <dd>Returns a new <code>Array Iterator</code> object that contains the values for each index in the array. See also <a href=\"../array/values\"><code>Array.prototype.values()</code></a>.</dd> <dt><a href=\"tolocalestring\"><code>TypedArray.prototype.toLocaleString()</code></a></dt> <dd>Returns a localized string representing the array and its elements. See also <a href=\"../array/tolocalestring\"><code>Array.prototype.toLocaleString()</code></a>.</dd> <dt><a href=\"tostring\"><code>TypedArray.prototype.toString()</code></a></dt> <dd>Returns a string representing the array and its elements. See also <a href=\"../array/tostring\"><code>Array.prototype.toString()</code></a>.</dd> <dt><a href=\"@@iterator\"><code>TypedArray.prototype[@@iterator]()</code></a></dt> <dd>Returns a new <code>Array Iterator</code> object that contains the values for each index in the array.</dd> </dl> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"#\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'TypedArray prototype' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"#\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'TypedArray prototype' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 7</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> 10</td>\n<td class=\"bc-supports-yes\"> 11.6</td>\n<td class=\"bc-supports-yes\"> 5.1</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> 11.6</td>\n<td class=\"bc-supports-yes\"> 4.2</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Typed_arrays\">JavaScript typed arrays</a></li> <li><a href=\"../typedarray\"><code>TypedArray</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/prototype$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/prototype\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/prototype</a>\n  </p>\n</div>\n","global_objects/typedarray/entries":"<h1>typedArray.entries</h1> <p>The <code>entries()</code> method returns a new <code>Array Iterator</code> object that contains the key/value pairs for each index in the array.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/typedarray-entries.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\"><var>arr</var>.entries()</pre> <h3 id=\"Return_value\">Return value</h3> <p>A new <code><strong>Array Iterator</strong></code> object.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Iteration_using_for...of_loop\">Iteration using <code>for...of</code> loop</h3> <pre data-language=\"js\">var arr = new Uint8Array([10, 20, 30, 40, 50]);\nvar eArray = arr.entries();\n// your browser must support for..of loop\n// and let-scoped variables in for loops\nfor (let n of eArray) {\n  console.log(n);\n}\n</pre> <h3 id=\"Alternative_iteration\">Alternative iteration</h3> <pre data-language=\"js\">var arr = new Uint8Array([10, 20, 30, 40, 50]);\nvar eArr = arr.entries();\nconsole.log(eArr.next().value); // [0, 10]\nconsole.log(eArr.next().value); // [1, 20]\nconsole.log(eArr.next().value); // [2, 30]\nconsole.log(eArr.next().value); // [3, 40]\nconsole.log(eArr.next().value); // [4, 50]\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"#\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of '%TypedArray%.prototype.entries()' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"#\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of '%TypedArray%.prototype.entries()' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>   <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 45</td>\n<td class=\"bc-supports-yes\"> 14</td>\n<td class=\"bc-supports-yes\"> 37</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 36</td>\n<td class=\"bc-supports-no\"> No</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 37</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 0.12</td>\n</tr></tbody>\n</table>\n</div>  <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Typed_arrays\">JavaScript typed arrays</a></li> <li><a href=\"../typedarray\"><code>TypedArray</code></a></li> <li><a href=\"keys\"><code>TypedArray.prototype.keys()</code></a></li> <li><a href=\"values\"><code>TypedArray.prototype.values()</code></a></li> <li><a href=\"@@iterator\"><code>TypedArray.prototype[@@iterator]()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/entries$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/entries\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/entries</a>\n  </p>\n</div>\n","global_objects/typedarray/foreach":"<h1>typedArray.forEach</h1> <p>The <code><strong>forEach()</strong></code> method executes a provided function once per array element. This method has the same algorithm as <a href=\"../array/foreach\"><code>Array.prototype.forEach()</code></a>. <em>TypedArray</em> is one of the <a href=\"../typedarray#TypedArray_objects\">typed array types</a> here.</p> <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\"><var>typedarray</var>.forEach(<var>callback</var>[, <var>thisArg</var>])</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><code>callback</code></dt> <dd>Function that produces an element of the new typed array, taking three arguments: <dl> <dt><code>currentValue</code></dt> <dd>The current element being processed in the typed array.</dd> <dt><code>index</code></dt> <dd>The index of the current element being processed in the array.</dd> <dt><code>array</code></dt> <dd>The array <code>forEach()</code> was called upon.</dd> </dl> </dd> <dt><code>thisArg</code></dt> <dd>Optional. Value to use as <code>this</code> when executing <code>callback</code>.</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p><a href=\"../undefined\"><code>undefined</code></a>.</p> <h2 id=\"Description\">Description</h2> <p>The <code>forEach()</code> method executes the provided <code>callback</code> once for each element present in the typed array in ascending order. It is not invoked for indexes that have been deleted or elided. However, it is executed for elements that are present and have the value <a href=\"../undefined\"><code>undefined</code></a>.</p> <p><code>callback</code> is invoked with <strong>three arguments</strong>:</p> <ul> <li>the <strong>element value</strong>\n</li> <li>the <strong>element index</strong>\n</li> <li>the <strong>typed array being traversed</strong>\n</li> </ul> <p>If a <code>thisArg</code> parameter is provided to <code>forEach()</code>, it will be passed to <code>callback</code> when invoked, for use as its <code>this</code> value. Otherwise, the value <a href=\"../undefined\"><code>undefined</code></a> will be passed for use as its <code>this</code> value. The <code>this</code> value ultimately observable by <code>callback</code> is determined according to <a href=\"../../operators/this\">the usual rules for determining the <code>this</code> seen by a function</a>.</p> <p>The range of elements processed by <code>forEach()</code> is set before the first invocation of <code>callback</code>. Elements that are appended to the typed array after the call to <code>forEach()</code> begins will not be visited by <code>callback</code>. If the values of existing elements of the typed array are changed, the value passed to <code>callback</code> will be the value at the time <code>forEach()</code> visits them; elements that are deleted before being visited are not visited.</p> <p><code>forEach()</code> executes the <code>callback</code> function once for each typed array element; unlike <a href=\"every\"><code>every()</code></a> and <a href=\"some\"><code>some()</code></a> it, always returns the value <a href=\"../undefined\"><code>undefined</code></a>.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Logging_the_contents_of_a_typed_array\">Logging the contents of a typed array</h3> <p>The following code logs a line for each element in a typed array:</p> <pre data-language=\"js\">function logArrayElements(element, index, array) {\n  console.log('a[' + index + '] = ' + element);\n}\n\nnew Uint8Array([0, 1, 2, 3]).forEach(logArrayElements);\n// logs:\n// a[0] = 0\n// a[1] = 1\n// a[2] = 2\n// a[3] = 3\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"#\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of '%TypedArray%.prototype.forEach' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"#\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of '%TypedArray%.prototype.forEach' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>   <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 14</td>\n<td class=\"bc-supports-yes\"> 38</td>\n<td class=\"bc-supports-no\"> No</td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 10</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 38</td>\n<td> ? </td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 4.0.0</td>\n</tr></tbody>\n</table>\n</div>  <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"map\"><code>TypedArray.prototype.map()</code></a></li> <li><a href=\"every\"><code>TypedArray.prototype.every()</code></a></li> <li><a href=\"some\"><code>TypedArray.prototype.some()</code></a></li> <li><a href=\"../array/foreach\"><code>Array.prototype.forEach()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/forEach$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/forEach\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/forEach</a>\n  </p>\n</div>\n","global_objects/typedarray/join":"<h1>typedArray.join</h1> <p>The <code><strong>join()</strong></code> method joins all elements of an array into a string. This method has the same algorithm as <a href=\"../array/join\"><code>Array.prototype.join()</code></a><em>.</em> <em>TypedArray</em> is one of the <a href=\"../typedarray#TypedArray_objects\">typed array types</a> here.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/typedarray-join.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\"><var>typedarray</var>.join([<var>separator</var> = ',']);</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><code>separator</code></dt> <dd>Optional. Specifies a string to separate each element. The separator is converted to a string if necessary. If omitted, the typed array elements are separated with a comma (\",\").</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p>A string with all array elements joined.</p> <h2 id=\"Examples\">Examples</h2> <pre data-language=\"js\">var uint8 = new Uint8Array([1,2,3]);\nuint8.join();      // '1,2,3'\nuint8.join(' / '); // '1 / 2 / 3'\nuint8.join('');    // '123'\n</pre> <h2 id=\"Polyfill\">Polyfill</h2> <p>Since there is no global object with the name <em>TypedArray</em>, polyfilling must be done on an \"as needed\" basis.</p> <pre data-language=\"js\">// https://tc39.github.io/ecma262/#sec-%typedarray%.prototype.join\nif (!Uint8Array.prototype.join) {\n  Object.defineProperty(Uint8Array.prototype, 'join', {\n    value: Array.prototype.join\n  });\n}\n</pre> <p>If you need to support truly obsolete JavaScript engines that don't support <code><a href=\"../object/defineproperty\">Object.defineProperty</a></code>, it's best not to polyfill <code>Array.prototype</code> methods at all, as you can't make them non-enumerable.</p> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"#\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'TypedArray.prototype.join' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"#\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'TypedArray.prototype.join' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>   <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 14</td>\n<td class=\"bc-supports-yes\"> 37</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 37</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 4.0.0</td>\n</tr></tbody>\n</table>\n</div>  <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"../typedarray\"><code>TypedArray</code></a></li> <li><a href=\"../array/join\"><code>Array.prototype.join()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/join$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/join\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/join</a>\n  </p>\n</div>\n","global_objects/typedarray/sort":"<h1>typedArray.sort</h1> <p>The <code><strong>sort()</strong></code> method sorts the elements of a typed array numerically <em>in place</em> and returns the typed array. This method has the same algorithm as <a href=\"../array/sort\"><code>Array.prototype.sort()</code></a>, except that sorts the values numerically instead of as strings<em>.</em> <em>TypedArray</em> is one of the <a href=\"../typedarray#TypedArray_objects\">typed array types</a> here.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/typedarray-sort.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\"><var>typedarray</var>.sort([<var>compareFunction</var>])</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt>\n<code>compareFunction</code> <span class=\"inlineIndicator optional optionalInline\">Optional</span>\n</dt> <dd>Specifies a function that defines the sort order.</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p>The sorted typed array.</p> <h2 id=\"Examples\">Examples</h2> <p>For more examples, see also the <a href=\"../array/sort\"><code>Array.prototype.sort()</code></a> method.</p> <pre data-language=\"js\">let numbers = new Uint8Array([40, 1, 5, 200]);\nnumbers.sort();\n// Uint8Array [ 1, 5, 40, 200 ] \n// Unlike plain Arrays, a compare function is not required\n// to sort the numbers numerically.\n\n// Regular Arrays require a compare function to sort numerically:\nnumbers = [40, 1, 5, 200];\nnumbers.sort();\n// [1, 200, 40, 5]\n\nnumbers.sort((a, b) =&gt; a - b); // compare numbers\n// [ 1, 5, 40, 200 ]\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"#\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'TypedArray.prototype.sort' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"#\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'TypedArray.prototype.sort' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>   <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 14</td>\n<td class=\"bc-supports-yes\"> 46</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td> ? </td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td> ? </td>\n<td> ? </td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 46</td>\n<td> ? </td>\n<td> ? </td>\n<td> ? </td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 4.0.0</td>\n</tr></tbody>\n</table>\n</div>  <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"../array/sort\"><code>Array.prototype.sort()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/sort$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/sort\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/sort</a>\n  </p>\n</div>\n","global_objects/typedarray/findindex":"<h1>typedArray.findIndex</h1> <p>The <code><strong>findIndex()</strong></code> method returns an <strong>index</strong> in the typed array, if an element in the typed array satisfies the provided testing function. Otherwise -1 is returned.</p> <p>See also the <a href=\"find\"><code>find()</code></a> method, which returns the <strong>value</strong> of a found element in the typed array instead of its index.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/typedarray-findindex.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\"><var>typedarray</var>.findIndex(<var>callback</var>[, <var>thisArg</var>])</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><code>callback</code></dt> <dd>Function to execute on each value in the typed array, taking three arguments: <dl> <dt><code>element</code></dt> <dd>The current element being processed in the typed array.</dd> <dt><code>index</code></dt> <dd>The index of the current element being processed in the typed array.</dd> <dt><code>array</code></dt> <dd>The typed array <code>findIndex</code> was called upon.</dd> </dl> </dd> <dt><code>thisArg</code></dt> <dd>Optional. Object to use as <code>this</code> when executing <code>callback</code>.</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p>An index in the array if an element passes the test; otherwise, <strong>-1</strong>.</p> <h2 id=\"Description\">Description</h2> <p>The <code>findIndex</code> method executes the <code>callback</code> function once for each element present in the typed array until it finds one where <code>callback</code> returns a true value. If such an element is found, <code>findIndex</code> immediately returns the index of that element. Otherwise, <code>findIndex</code> returns -1. <code>callback</code> is invoked only for indexes of the typed array which have assigned values; it is not invoked for indexes which have been deleted or which have never been assigned values.</p> <p><code>callback</code> is invoked with three arguments: the value of the element, the index of the element, and the typed array object being traversed.</p> <p>If a <code>thisArg</code> parameter is provided to <code>findIndex</code>, it will be used as the <code>this</code> for each invocation of the <code>callback</code>. If it is not provided, then <a href=\"../undefined\"><code>undefined</code></a> is used.</p> <p><code>findIndex</code> does not mutate the typed array on which it is called.</p> <p>The range of elements processed by <code>findIndex</code> is set before the first invocation of <code>callback</code>. Elements that are appended to the typed array after the call to <code>findIndex</code> begins will not be visited by <code>callback</code>. If an existing, unvisited element of the typed array is changed by <code>callback</code>, its value passed to the visiting <code>callback</code> will be the value at the time that <code>findIndex</code> visits that element's index; elements that are deleted are not visited.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Find_the_index_of_a_prime_number_in_a_typed_array\">Find the index of a prime number in a typed array</h3> <p>The following example finds the index of an element in the typed array that is a prime number (or returns -1 if there is no prime number).</p> <pre data-language=\"js\">function isPrime(element, index, array) {\n  var start = 2;\n  while (start &lt;= Math.sqrt(element)) {\n    if (element % start++ &lt; 1) {\n      return false;\n    }\n  }\n  return element &gt; 1;\n}\n\nvar uint8 = new Uint8Array([4, 6, 8, 12]);\nvar uint16 = new Uint16Array([4, 6, 7, 12]);\n\nconsole.log(uint8.findIndex(isPrime)); // -1, not found\nconsole.log(uint16.findIndex(isPrime)); // 2\n</pre> <h2 id=\"Polyfill\">Polyfill</h2> <pre data-language=\"js\">TypedArray.prototype.findIndex = Array.prototype.findIndex = Array.prototype.findIndex || function(evaluator, thisArg) {\n        'use strict';\n        if (!this) {\n          throw new TypeError('Array.prototype.some called on null or undefined');\n        }\n    \n        if (typeof(evaluator) !== 'function') {\n            if (typeof(evaluator) === 'string') {\n                // Attempt to convert it to a function\n                if ( ! (evaluator = eval(evaluator)) ){\n                    throw new TypeError();\n                }\n            } else {\n                throw new TypeError();\n            }\n        }\n        \n        var i;\n        if (thisArg === undefined) {  // Optimize for thisArg\n            for (i in this) {\n                if (evaluator(this[i], i, this)) {\n                    return i;\n                }\n            }\n            return -1;\n        }\n        for (i in this) {\n            if (evaluator.call(thisArg, this[i], i, this)) {\n                return i;\n            }\n        }\n        return -1;\n};</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"#\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of '%TypedArray%.prototype.findIndex' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"#\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of '%TypedArray%.prototype.findIndex' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>   <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 14</td>\n<td class=\"bc-supports-yes\"> 37</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 37</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 4.0.0</td>\n</tr></tbody>\n</table>\n</div>  <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"find\"><code>TypedArray.prototype.find()</code></a></li> <li><a href=\"indexof\"><code>TypedArray.prototype.indexOf()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/findIndex$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/findIndex\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/findIndex</a>\n  </p>\n</div>\n","global_objects/typedarray/find":"<h1>typedArray.find</h1> <p>The <code><strong>find()</strong></code> method returns a <strong>value</strong> in the typed array, if an element satisfies the provided testing function. Otherwise <a href=\"../undefined\"><code>undefined</code></a> is returned. <em>TypedArray</em> is one of the <a href=\"../typedarray#TypedArray_objects\">typed array types</a> here.</p> <p>See also the <a href=\"findindex\"><code>findIndex()</code></a> method, which returns the <strong>index</strong> of a found element in the typed array instead of its value.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/typedarray-find.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\"><var>typedarray</var>.find(<var>callback</var>[, <var>thisArg</var>])</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><code>callback</code></dt> <dd>Function to execute on each value in the typed array, taking three arguments: <dl> <dt><code>element</code></dt> <dd>The current element being processed in the typed array.</dd> <dt><code>index</code></dt> <dd>The index of the current element being processed in the typed array.</dd> <dt><code>array</code></dt> <dd>The array <code>find</code> was called upon.</dd> </dl> </dd> <dt><code>thisArg</code></dt> <dd>Optional. Object to use as <code>this</code> when executing <code>callback</code>.</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p>A value in the array if an element passes the test; otherwise, <a href=\"../undefined\"><code>undefined</code></a>.</p> <h2 id=\"Description\">Description</h2> <p>The <code>find</code> method executes the <code>callback</code> function once for each element present in the typed array until it finds one where <code>callback</code> returns a true value. If such an element is found, <code>find</code> immediately returns the value of that element. Otherwise, <code>find</code> returns <a href=\"../undefined\"><code>undefined</code></a>. <code>callback</code> is invoked only for indexes of the typed array which have assigned values; it is not invoked for indexes which have been deleted or which have never been assigned values.</p> <p><code>callback</code> is invoked with three arguments: the value of the element, the index of the element, and the typed array object being traversed.</p> <p>If a <code>thisArg</code> parameter is provided to <code>find</code>, it will be used as the <code>this</code> for each invocation of the <code>callback</code>. If it is not provided, then <a href=\"../undefined\"><code>undefined</code></a> is used.</p> <p><code>find</code> does not mutate the typed array on which it is called.</p> <p>The range of elements processed by <code>find</code> is set before the first invocation of <code>callback</code>. Elements that are appended to the typed array after the call to <code>find</code> begins will not be visited by <code>callback</code>. If an existing, unvisited element of the typed array is changed by <code>callback</code>, its value passed to the visiting <code>callback</code> will be the value at the time that <code>find</code> visits that element's index; elements that are deleted are not visited.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Find_a_prime_number_in_a_typed_array\">Find a prime number in a typed array</h3> <p>The following example finds an element in the typed array that is a prime number (or returns <a href=\"../undefined\"><code>undefined</code></a> if there is no prime number).</p> <pre data-language=\"js\">function isPrime(element, index, array) {\n  var start = 2;\n  while (start &lt;= Math.sqrt(element)) {\n    if (element % start++ &lt; 1) {\n      return false;\n    }\n  }\n  return element &gt; 1;\n}\n\nvar uint8 = new Uint8Array([4, 5, 8, 12]);\nconsole.log(uint8.find(isPrime)); // 5</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"#\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of '%TypedArray%.prototype.find' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"#\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of '%TypedArray%.prototype.find' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>   <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 14</td>\n<td class=\"bc-supports-yes\"> 37</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 37</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 4.0.0</td>\n</tr></tbody>\n</table>\n</div>  <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"findindex\"><code>TypedArray.prototype.findIndex()</code></a></li> <li><a href=\"every\"><code>TypedArray.prototype.every()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/find$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/find\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/find</a>\n  </p>\n</div>\n","global_objects/typedarray/includes":"<h1>typedArray.includes</h1> <p>The <code><strong>includes()</strong></code> method determines whether a typed array includes a certain element, returning <code>true</code> or <code>false</code> as appropriate. This method has the same algorithm as <a href=\"../array/includes\"><code>Array.prototype.includes()</code></a><em>.</em> <em>TypedArray</em> is one of the <a href=\"../typedarray#TypedArray_objects\">typed array types</a> here.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/typedarray-includes.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\"><var>typedarray</var>.includes(<var>searchElement</var>[, <var>fromIndex</var>]);</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><code>searchElement</code></dt> <dd>The element to search for.</dd> <dt><code>fromIndex</code></dt> <dd>Optional. The position in this array at which to begin searching for <code>searchElement</code>; defaults to 0.</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p>A <a href=\"../boolean\"><code>Boolean</code></a>.</p> <h2 id=\"Examples\">Examples</h2> <pre data-language=\"js\">var uint8 = new Uint8Array([1,2,3]);\nuint8.includes(2);     // true\nuint8.includes(4);     // false\nuint8.includes(3, 3);  // false\n\n// NaN handling (only true for Float32 and Float64)\nnew Uint8Array([NaN]).includes(NaN); // false, since the NaN passed to the constructor gets converted to 0\nnew Float32Array([NaN]).includes(NaN); // true;\nnew Float64Array([NaN]).includes(NaN); // true;\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"#\" hreflang=\"en\">ECMAScript 2016 (ECMA-262)<br><small>The definition of 'TypedArray.prototype.includes' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"#\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'TypedArray.prototype.includes' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>   <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 47</td>\n<td class=\"bc-supports-yes\"> 14</td>\n<td class=\"bc-supports-yes\"> 43</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 34</td>\n<td class=\"bc-supports-yes\"> 10</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 47</td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 43</td>\n<td class=\"bc-supports-yes\"> 34</td>\n<td class=\"bc-supports-yes\"> 10</td>\n<td class=\"bc-supports-yes\"> 5.0</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes bc-has-history\"> 6.0.0\n<section class=\"bc-history\" id=\"sect1\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 6.0.0\n</dt>\n\n<dt class=\"bc-supports-yes bc-supports\"> 5.0.0<div class=\"bc-icons\">Disabled </div>\n</dt>\n<dd>Disabled From version 5.0.0: this feature is behind the <code>--harmony</code> runtime flag.</dd>\n</dl></section>\n</td>\n</tr></tbody>\n</table>\n</div>  <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"../array/includes\"><code>Array.prototype.includes()</code></a></li> <li><a href=\"../string/includes\"><code>String.prototype.includes()</code></a></li> <li><a href=\"indexof\"><code>TypedArray.prototype.indexOf()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/includes$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/includes\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/includes</a>\n  </p>\n</div>\n","global_objects/typedarray/indexof":"<h1>typedArray.indexOf</h1> <p>The <code><strong>indexOf()</strong></code> method returns the first index at which a given element can be found in the typed array, or -1 if it is not present. This method has the same algorithm as <a href=\"../array/indexof\"><code>Array.prototype.indexOf()</code></a><em>.</em> <em>TypedArray</em> is one of the <a href=\"../typedarray#TypedArray_objects\">typed array types</a> here.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/typedarray-indexof.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\"><var>typedarray</var>.<var>indexOf(<var>searchElement</var>[, <var>fromIndex</var> = 0])</var></pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><code>searchElement</code></dt> <dd>Element to locate in the typed array.</dd> <dt><code>fromIndex</code></dt> <dd>The index to start the search at. If the index is greater than or equal to the typed array's length, -1 is returned, which means the typed array will not be searched. If the provided index value is a negative number, it is taken as the offset from the end of the typed array. Note: if the provided index is negative, the typed array is still searched from front to back. If the calculated index is less than 0, then the whole typed array will be searched. Default: 0 (entire typed array is searched).</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p>The first index of the element in the array; <strong>-1</strong> if not found.</p> <h2 id=\"Description\">Description</h2> <p><code>indexOf</code> compares <code>searchElement</code> to elements of the typed array using <a href=\"../../operators/comparison_operators#Using_the_Equality_Operators\">strict equality</a> (the same method used by the ===, or triple-equals, operator).</p> <h2 id=\"Examples\">Examples</h2> <pre data-language=\"js\">var uint8 = new Uint8Array([2, 5, 9]);\nuint8.indexOf(2);     // 0\nuint8.indexOf(7);     // -1\nuint8.indexOf(9, 2);  // 2\nuint8.indexOf(2, -1); // -1\nuint8.indexOf(2, -3); // 0\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"#\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'TypedArray.prototype.indexOf' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"#\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'TypedArray.prototype.indexOf' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>   <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 45</td>\n<td class=\"bc-supports-yes\"> 14</td>\n<td class=\"bc-supports-yes bc-has-history\"> 37\n<section class=\"bc-history\" id=\"sect1\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 37\n</dt>\n<dd> Starting with Firefox 47, this method will no longer return <code>-0</code>. For example, <code>new Uint8Array([0]).indexOf(0, -0)</code> will now always return <code>+0</code>.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 32</td>\n<td class=\"bc-supports-no\"> No</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 45</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes bc-has-history\"> 37\n<section class=\"bc-history\" id=\"sect2\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 37\n</dt>\n<dd> Starting with Firefox 47, this method will no longer return <code>-0</code>. For example, <code>new Uint8Array([0]).indexOf(0, -0)</code> will now always return <code>+0</code>.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-yes\"> 32</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 5.0</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 4.0.0</td>\n</tr></tbody>\n</table>\n</div>  <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"lastindexof\"><code>TypedArray.prototype.lastIndexOf()</code></a></li> <li><a href=\"../array/indexof\"><code>Array.prototype.indexOf()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/indexOf$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/indexOf\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/indexOf</a>\n  </p>\n</div>\n","global_objects/typedarray/keys":"<h1>typedArray.keys</h1> <p>The <code>keys()</code> method returns a new <code>Array Iterator</code> object that contains the keys for each index in the array.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/typedarray-keys.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\"><var>arr</var>.keys()</pre> <h3 id=\"Return_value\">Return value</h3> <p>A new <code><strong>Array Iterator</strong></code> object.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Iteration_using_for...of_loop\">Iteration using <code>for...of</code> loop</h3> <pre data-language=\"js\">var arr = new Uint8Array([10, 20, 30, 40, 50]);\nvar eArray = arr.keys();\n// your browser must support for..of loop\n// and let-scoped variables in for loops\nfor (let n of eArray) {\n  console.log(n);\n}\n</pre> <h3 id=\"Alternative_iteration\">Alternative iteration</h3> <pre data-language=\"js\">var arr = new Uint8Array([10, 20, 30, 40, 50]);\nvar eArr = arr.keys();\nconsole.log(eArr.next().value); // 0\nconsole.log(eArr.next().value); // 1\nconsole.log(eArr.next().value); // 2\nconsole.log(eArr.next().value); // 3\nconsole.log(eArr.next().value); // 4\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"#\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of '%TypedArray%.prototype.keys()' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"#\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of '%TypedArray%.prototype.keys()' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>   <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 14</td>\n<td class=\"bc-supports-yes\"> 37</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 10</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 37</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 10</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 0.12</td>\n</tr></tbody>\n</table>\n</div>  <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Typed_arrays\">JavaScript typed arrays</a></li> <li><a href=\"../typedarray\"><code>TypedArray</code></a></li> <li><a href=\"entries\"><code>TypedArray.prototype.entries()</code></a></li> <li><a href=\"values\"><code>TypedArray.prototype.values()</code></a></li> <li><a href=\"@@iterator\"><code>TypedArray.prototype[@@iterator]()</code></a></li> <li><a href=\"../../statements/for...of\">for...of</a></li> <li><a href=\"../../iteration_protocols\">Iteration protocols</a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/keys$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/keys\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/keys</a>\n  </p>\n</div>\n","global_objects/typedarray/reduce":"<h1>typedArray.reduce</h1> <p>The <code><strong>reduce()</strong></code> method applies a function against an accumulator and each value of the typed array (from left-to-right) has to reduce it to a single value. This method has the same algorithm as <a href=\"../array/reduce\"><code>Array.prototype.reduce()</code></a>. <em>TypedArray</em> is one of the <a href=\"../typedarray#TypedArray_objects\">typed array types</a> here.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/typedarray-reduce.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\"><var>typedarray</var>.reduce(<var>callback</var>[, <var>initialValue</var>])</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><code>callback</code></dt> <dd>Function to execute on each value in the typed array, taking four arguments: <dl> <dt><code>previousValue</code></dt> <dd>The value previously returned in the last invocation of the callback, or <code>initialValue</code>, if supplied (see below).</dd> <dt><code>currentValue</code></dt> <dd>The current element being processed in the typed array.</dd> <dt><code>index</code></dt> <dd>The index of the current element being processed in the typed array.</dd> <dt><code>array</code></dt> <dd>The typed array <code>reduce</code> was called upon.</dd> </dl> </dd> <dt><code>initialValue</code></dt> <dd>Optional. Object to use as the first argument to the first call of the <code>callback</code>.</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p>The value that results from the reduction.</p> <h2 id=\"Description\">Description</h2> <p>The <code>reduce</code> method executes the <code>callback</code> function once for each element present in the typed array, excluding holes in the typed array, receiving four arguments: the initial value (or value from the previous <code>callback</code> call), the value of the current element, the current index, and the typed array over which iteration is occurring.</p> <p>The first time the callback is called, <code>previousValue</code> and <code>currentValue</code> can be one of two values. If <code>initialValue</code> is provided in the call to <code>reduce</code>, then <code>previousValue</code> will be equal to <code>initialValue</code> and <code>currentValue</code> will be equal to the first value in the typed array. If no <code>initialValue</code> was provided, then <code>previousValue</code> will be equal to the first value in the typed array and <code>currentValue</code> will be equal to the second.</p> <p>If the typed array is empty and no <code>initialValue</code> was provided, <a href=\"../typeerror\"><code>TypeError</code></a> would be thrown. If the typed array has only one element (regardless of position) and no <code>initialValue</code> was provided, or if <code>initialValue</code> is provided but the typed array is empty, the solo value would be returned without calling <code>callback</code>.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Sum_up_all_values_within_an_array\">Sum up all values within an array</h3> <pre data-language=\"js\">var total = new Uint8Array([0, 1, 2, 3]).reduce(function(a, b) {\n  return a + b;\n});\n// total == 6\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"#\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of '%TypedArray%.prototype.reduce' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"#\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of '%TypedArray%.prototype.reduce' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>   <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 45</td>\n<td class=\"bc-supports-yes\"> 14</td>\n<td class=\"bc-supports-yes\"> 37</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 32</td>\n<td class=\"bc-supports-yes\"> 10</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td> ? </td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 37</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 10</td>\n<td> ? </td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 4.0.0</td>\n</tr></tbody>\n</table>\n</div>  <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"reduceright\"><code>TypedArray.prototype.reduceRight()</code></a></li> <li><a href=\"../array/reduce\"><code>Array.prototype.reduce()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/reduce$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/reduce\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/reduce</a>\n  </p>\n</div>\n","global_objects/typedarray/lastindexof":"<h1>typedArray.lastIndexOf</h1> <p>The <code><strong>lastIndexOf()</strong></code> method returns the last index at which a given element can be found in the typed array, or -1 if it is not present. The typed array is searched backwards, starting at <code>fromIndex</code>. This method has the same algorithm as <a href=\"../array/lastindexof\"><code>Array.prototype.lastIndexOf()</code></a><em>.</em> <em>TypedArray</em> is one of the <a href=\"../typedarray#TypedArray_objects\">typed array types</a> here.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/typedarray-lastindexof.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\"><var>typedarray</var>.<var>lastIndexOf(<var>searchElement</var>[, <var>fromIndex</var> = typedarray.length])</var></pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><code>searchElement</code></dt> <dd>Element to locate in the typed array.</dd> <dt><code>fromIndex</code></dt> <dd>Optional. The index at which to start searching backwards. Defaults to the typed array's length, i.e. the whole typed array will be searched. If the index is greater than or equal to the length of the typed array, the whole typed array will be searched. If negative, it is taken as the offset from the end of the typed array. Note that even when the index is negative, the typed array is still searched from back to front. If the calculated index is less than 0, -1 is returned, i.e. the typed array will not be searched.</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p>The last index of the element in the array; <strong>-1</strong> if not found.</p> <h2 id=\"Description\">Description</h2> <p><code>lastIndexOf</code> compares <code>searchElement</code> to elements of the typed array using <a href=\"../../operators/comparison_operators#Using_the_Equality_Operators\">strict equality</a> (the same method used by the ===, or triple-equals, operator).</p> <h2 id=\"Examples\">Examples</h2> <pre data-language=\"js\">var uint8 = new Uint8Array([2, 5, 9, 2]);\nuint8.lastIndexOf(2);     // 3\nuint8.lastIndexOf(7);     // -1\nuint8.lastIndexOf(2, 3);  // 3\nuint8.lastIndexOf(2, 2);  // 0\nuint8.lastIndexOf(2, -2); // 0\nuint8.lastIndexOf(2, -1); // 3\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"#\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'TypedArray.prototype.lastIndexOf' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"#\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'TypedArray.prototype.lastIndexOf' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>   <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 14</td>\n<td class=\"bc-supports-yes bc-has-history\"> 37\n<section class=\"bc-history\" id=\"sect1\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 37\n</dt>\n<dd> Starting with Firefox 47, this method will no longer return <code>-0</code>. For example, <code>new Uint8Array([0]).lastIndexOf(0, -0)</code> will now always return <code>+0</code>.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 10</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes bc-has-history\"> 37\n<section class=\"bc-history\" id=\"sect2\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 37\n</dt>\n<dd> Starting with Firefox 47, this method will no longer return <code>-0</code>. For example, <code>new Uint8Array([0]).lastIndexOf(0, -0)</code> will now always return <code>+0</code>.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 10</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 4.0.0</td>\n</tr></tbody>\n</table>\n</div>  <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"indexof\"><code>TypedArray.prototype.indexOf()</code></a></li> <li><a href=\"../array/lastindexof\"><code>Array.prototype.lastIndexOf()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/lastIndexOf$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/lastIndexOf\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/lastIndexOf</a>\n  </p>\n</div>\n","global_objects/typedarray/reduceright":"<h1>typedArray.reduceRight</h1> <p>The <code><strong>reduceRight()</strong></code> method applies a function against an accumulator and each value of the typed array (from right-to-left) has to reduce it to a single value. This method has the same algorithm as <a href=\"../array/reduceright\"><code>Array.prototype.reduceRight()</code></a>. <em>TypedArray</em> is one of the <a href=\"../typedarray#TypedArray_objects\">typed array types</a> here.</p> <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\"><var>typedarray</var>.reduceRight(<var>callback</var>[, <var>initialValue</var>])</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><code>callback</code></dt> <dd>Function to execute on each value in the typed array, taking four arguments: <dl> <dt><code>previousValue</code></dt> <dd>The value previously returned in the last invocation of the callback, or <code>initialValue</code>, if supplied (see below).</dd> <dt><code>currentValue</code></dt> <dd>The current element being processed in the typed array.</dd> <dt><code>index</code></dt> <dd>The index of the current element being processed in the typed array.</dd> <dt><code>array</code></dt> <dd>The typed array <code>reduce</code> was called upon.</dd> </dl> </dd> <dt><code>initialValue</code></dt> <dd>Optional. Object to use as the first argument to the first call of the <code>callback</code>.</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p>The value that results from the reduction.</p> <h2 id=\"Description\">Description</h2> <p>The <code>reduceRight</code> method executes the callback function once for each element present in the typed array, excluding holes in the typed array, receiving four arguments: the initial value (or value from the previous callback call), the value of the current element, the current index, and the typed array over which iteration is occurring.</p> <p>The call to the <code>reduceRight</code> callback would look something like this:</p> <pre data-language=\"js\">typedarray.reduceRight(function(previousValue, currentValue, index, typedarray) {\n  // ...\n});\n</pre> <p>The first time the function is called, the <code>previousValue</code> and <code>currentValue</code> can be one of two values. If an <code>initialValue</code> was provided in the call to <code>reduceRight</code>, then <code>previousValue</code> will be equal to <code>initialValue</code> and <code>currentValue</code> will be equal to the last value in the typed array. If no <code>initialValue</code> was provided, then <code>previousValue</code> will be equal to the last value in the typed array and <code>currentValue</code> will be equal to the second-to-last value.</p> <p>If the typed array is empty and no <code>initialValue </code>was provided, <a href=\"../typeerror\"><code>TypeError</code></a> would be thrown. If the typed array has only one element (regardless of position) and no <code>initialValue </code>was provided, or if <code>initialValue</code> is provided but the typed array is empty, the solo value would be returned without calling <code>callback</code>.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Sum_up_all_values_within_an_array\">Sum up all values within an array</h3> <pre data-language=\"js\">var total = new Uint8Array([0, 1, 2, 3]).reduceRight(function(a, b) {\n  return a + b;\n});\n// total == 6\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"#\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of '%TypedArray%.prototype.reduceRight' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"#\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of '%TypedArray%.prototype.reduceRight' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>   <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 45</td>\n<td class=\"bc-supports-yes\"> 14</td>\n<td class=\"bc-supports-yes\"> 37</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 32</td>\n<td class=\"bc-supports-yes\"> 10</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td> ? </td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 37</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 10</td>\n<td> ? </td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 4.0.0</td>\n</tr></tbody>\n</table>\n</div>  <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"reduce\"><code>TypedArray.prototype.reduce()</code></a></li> <li><a href=\"../array/reduceright\"><code>Array.prototype.reduceRight()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/reduceRight$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/reduceRight\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/reduceRight</a>\n  </p>\n</div>\n","global_objects/typedarray/reverse":"<h1>typedArray.reverse</h1> <p>The <code><strong>reverse()</strong></code> method reverses a typed array in place. The first typed array element becomes the last and the last becomes the first. This method has the same algorithm as <a href=\"../array/reverse\"><code>Array.prototype.reverse()</code></a><em>.</em> <em>TypedArray</em> is one of the <a href=\"../typedarray#TypedArray_objects\">typed array types</a> here.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/typedarray-reverse.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\"><var>typedarray</var>.reverse();</pre> <h3 id=\"Return_value\">Return value</h3> <p>The reversed array.</p> <h2 id=\"Examples\">Examples</h2> <pre data-language=\"js\">var uint8 = new Uint8Array([1, 2, 3]);\nuint8.reverse();\n\nconsole.log(uint8); // Uint8Array [3, 2, 1]\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"#\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'TypedArray.prototype.reverse' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"#\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'TypedArray.prototype.reverse' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>   <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 45</td>\n<td class=\"bc-supports-yes\"> 14</td>\n<td class=\"bc-supports-yes\"> 37</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 32</td>\n<td class=\"bc-supports-yes\"> 10</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td> ? </td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 37</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 10</td>\n<td> ? </td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 4.0.0</td>\n</tr></tbody>\n</table>\n</div>  <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"../array/reverse\"><code>Array.prototype.reverse()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/reverse$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/reverse\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/reverse</a>\n  </p>\n</div>\n","functions":"<h1>Functions</h1> <p>Generally speaking, a function is a \"subprogram\" that can be <em>called</em> by code external (or internal in the case of recursion) to the function. Like the program itself, a function is composed of a sequence of statements called the <em>function body</em>. Values can be <em>passed</em> to a function, and the function will <em>return</em> a value.</p> <p>In JavaScript, functions are first-class objects, because they can have properties and methods just like any other object. What distinguishes them from other objects is that functions can be called. In brief, they are <code><a href=\"global_objects/function\">Function</a></code> objects.</p> <p>For more examples and explanations, see also the <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Functions\">JavaScript guide about functions</a>.</p> <h2 id=\"Description\">Description</h2> <p>Every function in JavaScript is a <code>Function</code> object. See <a href=\"global_objects/function\"><code>Function</code></a> for information on properties and methods of <code>Function</code> objects.</p> <p>To return a value other than the default, a function must have a <code><a href=\"statements/return\">return</a></code> statement that specifies the value to return. A function without a return statement will return a default value. In the case of a <a href=\"global_objects/object/constructor\">constructor</a> called with the <code><a href=\"operators/new\">new</a></code> keyword, the default value is the value of its <code>this</code> parameter. For all other functions, the default return value is <a href=\"global_objects/undefined\"><code>undefined</code></a>.</p> <p>The parameters of a function call are the function's <em>arguments</em>. Arguments are passed to functions <em>by value</em>. If the function changes the value of an argument, this change is not reflected globally or in the calling function. However, object references are values, too, and they are special: if the function changes the referred object's properties, that change is visible outside the function, as shown in the following example:</p> <pre data-language=\"js\">/* Declare the function 'myFunc' */\nfunction myFunc(theObject) {\n  theObject.brand = \"Toyota\";\n}\n\n/*\n * Declare variable 'mycar';\n * create and initialize a new Object;\n * assign reference to it to 'mycar'\n */\nvar mycar = {\n  brand: \"Honda\",\n  model: \"Accord\",\n  year: 1998\n};\n\n/* Logs 'Honda' */\nconsole.log(mycar.brand);\n\n/* Pass object reference to the function */\nmyFunc(mycar);\n\n/*\n * Logs 'Toyota' as the value of the 'brand' property\n * of the object, as changed to by the function.\n */\nconsole.log(mycar.brand);\n</pre> <p>The <a href=\"operators/this\"><code>this</code> keyword</a> does not refer to the currently executing function, so you must refer to <code>Function</code> objects by name, even within the function body.</p> <h2 id=\"Defining_functions\">Defining functions</h2> <p>There are several ways to define functions:</p> <h3 id=\"The_function_declaration_(function_statement)\">The function declaration (<code>function</code> statement)</h3> <p>There is a special syntax for declaring functions (see <a href=\"statements/function\">function statement</a> for details):</p> <pre class=\"syntaxbox\">function <em>name</em>([<em>param</em>[, <em>param</em>[, ... <em>param</em>]]]) {\n   <em>statements</em>\n}\n</pre> <dl> <dt><code>name</code></dt> <dd>The function name.</dd> </dl> <dl> <dt><code>param</code></dt> <dd>The name of an argument to be passed to the function.</dd> </dl> <dl> <dt><code>statements</code></dt> <dd>The statements comprising the body of the function.</dd> </dl> <h3 id=\"The_function_expression_(function_expression)\">The function expression (<code>function</code> expression)</h3> <p>A function expression is similar to and has the same syntax as a function declaration (see <a href=\"operators/function\">function expression</a> for details). A function expression may be a part of a larger expression. One can define \"named\" function expressions (where the name of the expression might be used in the call stack for example) or \"anonymous\" function expressions. Function expressions are not <em>hoisted</em> onto the beginning of the scope, therefore they cannot be used before they appear in the code.</p> <pre class=\"syntaxbox\">function [<em>name</em>]([<em>param</em>[, <em>param</em>[, ... <em>param</em>]]]) {\n   <em>statements</em>\n}\n</pre> <dl> <dt><code>name</code></dt> <dd>The function name. Can be omitted, in which case the function becomes known as an anonymous function.</dd> </dl> <dl> <dt><code>param</code></dt> <dd>The name of an argument to be passed to the function.</dd> <dt><code>statements</code></dt> <dd>The statements comprising the body of the function.</dd> </dl> <p>Here is an example of an <strong>anonymous</strong> function expression (the <code>name</code> is not used):</p> <pre data-language=\"js\">var myFunction = function() {\n    statements\n}</pre> <p>It is also possible to provide a name inside the definition in order to create a <strong>named</strong> function expression:</p> <pre data-language=\"js\">var myFunction = function namedFunction(){\n    statements\n}\n</pre> <p>One of the benefits of creating a named function expression is that in case we encountered an error, the stack trace will contain the name of the function, making it easier to find the origin of the error.</p> <p>As we can see, both examples do not start with the <code>function</code> keyword. Statements involving functions which do not start with <code>function</code> are function expressions.</p> <p>When functions are used only once, a common pattern is an <a href=\"https://developer.mozilla.org/en-US/docs/Glossary/IIFE\">IIFE (Immediately Invokable Function Expression)</a>.</p> <pre data-language=\"js\">(function() {\n    statements\n})();</pre> <p>IIFE are function expressions that are invoked as soon as the function is declared.</p> <h3 id=\"The_generator_function_declaration_(function*_statement)\">The generator function declaration (<code>function*</code> statement)</h3> <p>There is a special syntax for generator function declarations (see <a href=\"statements/function*\"><code>function* statement</code></a> for details):</p> <pre class=\"syntaxbox\">function* <em>name</em>([<em>param</em>[, <em>param</em>[, ... <em>param</em>]]]) {\n   <em>statements</em>\n}\n</pre> <dl> <dt><code>name</code></dt> <dd>The function name.</dd> </dl> <dl> <dt><code>param</code></dt> <dd>The name of an argument to be passed to the function.</dd> </dl> <dl> <dt><code>statements</code></dt> <dd>The statements comprising the body of the function.</dd> </dl> <h3 id=\"The_generator_function_expression_(function*_expression)\">The generator function expression (<code>function*</code> expression)</h3> <p>A generator function expression is similar to and has the same syntax as a generator function declaration (see <a href=\"operators/function*\"><code>function* expression</code></a> for details):</p> <pre class=\"syntaxbox\">function* [<em>name</em>]([<em>param</em>[, <em>param</em>[, ... <em>param</em>]]]) {\n   <em>statements</em>\n}\n</pre> <dl> <dt><code>name</code></dt> <dd>The function name. Can be omitted, in which case the function becomes known as an anonymous function.</dd> </dl> <dl> <dt><code>param</code></dt> <dd>The name of an argument to be passed to the function.</dd> <dt><code>statements</code></dt> <dd>The statements comprising the body of the function.</dd> </dl> <h3 id=\"The_arrow_function_expression_(&gt;)\">The arrow function expression (=&gt;)</h3> <p>An arrow function expression has a shorter syntax and lexically binds its <code>this</code> value (see <a href=\"functions/arrow_functions\">arrow functions</a> for details):</p> <pre class=\"syntaxbox\">([param[, param]]) =&gt; {\n   statements\n}\n\nparam =&gt; expression\n</pre> <dl> <dt><code>param</code></dt> <dd>The name of an argument. Zero arguments need to be indicated with <code>()</code>. For only one argument, the parentheses are not required. (like <code>foo =&gt; 1</code>)</dd> <dt><code>statements or expression</code></dt> <dd>Multiple statements need to be enclosed in brackets. A single expression requires no brackets. The expression is also the implicit return value of the function.</dd> </dl> <h3 id=\"The_Function_constructor\">The <code>Function</code> constructor</h3> <div class=\"note\"> <p><strong>Note:</strong> Using the <code>Function</code> constructor to create functions is not recommended since it needs the function body as a string which may prevent some JS engine optimizations and can also cause other problems.</p> </div> <p>As all other objects, <a href=\"global_objects/function\"><code>Function</code></a> objects can be created using the <code>new</code> operator:</p> <pre class=\"syntaxbox\">new Function (<em>arg1</em>, <em>arg2</em>, ... <em>argN</em>, <em>functionBody</em>)\n</pre> <dl> <dt><code>arg1, arg2, ... arg<em>N</em></code></dt> <dd>Zero or more names to be used by the function as formal parameters. Each must be a proper JavaScript identifier.</dd> </dl> <dl> <dt><code>functionBody</code></dt> <dd>A string containing the JavaScript statements comprising the function body.</dd> </dl> <p>Invoking the <code>Function</code> constructor as a function (without using the <code>new</code> operator) has the same effect as invoking it as a constructor.</p> <h3 id=\"The_GeneratorFunction_constructor\">The <code>GeneratorFunction</code> constructor</h3> <div class=\"note\"> <p><strong>Note:</strong> <code>GeneratorFunction</code> is not a global object, but could be obtained from generator function instance (see <a href=\"global_objects/generatorfunction\"><code>GeneratorFunction</code></a> for more detail).</p> </div> <div class=\"note\"> <p><strong>Note:</strong> Using the <code>GeneratorFunction</code> constructor to create functions is not recommended since it needs the function body as a string which may prevent some JS engine optimizations and can also cause other problems.</p> </div> <p>As all other objects, <a href=\"global_objects/generatorfunction\"><code>GeneratorFunction</code></a> objects can be created using the <code>new</code> operator:</p> <pre class=\"syntaxbox\">new GeneratorFunction (<em>arg1</em>, <em>arg2</em>, ... <em>argN</em>, <em>functionBody</em>)\n</pre> <dl> <dt><code>arg1, arg2, ... arg<em>N</em></code></dt> <dd>Zero or more names to be used by the function as formal argument names. Each must be a string that conforms to the rules for a valid JavaScript identifier or a list of such strings separated with a comma; for example \"<code>x</code>\", \"<code>theValue</code>\", or \"<code>a,b</code>\".</dd> </dl> <dl> <dt><code>functionBody</code></dt> <dd>A string containing the JavaScript statements comprising the function definition.</dd> </dl> <p>Invoking the <code>Function</code> constructor as a function (without using the <code>new</code> operator) has the same effect as invoking it as a constructor.</p> <h2 id=\"Function_parameters\">Function parameters</h2> <h3 id=\"Default_parameters\">Default parameters</h3> <p>Default function parameters allow formal parameters to be initialized with default values if no value or <code>undefined</code> is passed. For more details, see<a href=\"functions/default_parameters\"> default parameters</a>.</p> <h3 id=\"Rest_parameters\">Rest parameters</h3> <p>The rest parameter syntax allows representing an indefinite number of arguments as an array. For more details, see <a href=\"functions/rest_parameters\">rest parameters</a>.</p> <h2 id=\"The_arguments_object\">The <code>arguments</code> object</h2> <p>You can refer to a function's arguments within the function by using the <code>arguments</code> object. See <a href=\"functions/arguments\">arguments</a>.</p> <ul> <li>\n<code><a href=\"functions/arguments\">arguments</a></code>: An array-like object containing the arguments passed to the currently executing function.</li> <li>\n<code><a href=\"functions/arguments/callee\">arguments.callee</a></code> : The currently executing function.</li> <li>\n<code><a href=\"functions/arguments/caller\">arguments.caller</a></code>  : The function that invoked the currently executing function.</li> <li>\n<code><a href=\"functions/arguments/length\">arguments.length</a></code>: The number of arguments passed to the function.</li> </ul> <h2 id=\"Defining_method_functions\">Defining method functions</h2> <h3 id=\"Getter_and_setter_functions\">Getter and setter functions</h3> <p>You can define getters (accessor methods) and setters (mutator methods) on any standard built-in object or user-defined object that supports the addition of new properties. The syntax for defining getters and setters uses the object literal syntax.</p> <dl> <dt><a href=\"functions/get\">get</a></dt> <dd> <p>Binds an object property to a function that will be called when that property is looked up.</p> </dd> <dt><a href=\"functions/set\">set</a></dt> <dd>Binds an object property to a function to be called when there is an attempt to set that property.</dd> </dl> <h3 id=\"Method_definition_syntax\">Method definition syntax</h3> <p>Starting with ECMAScript 2015, you are able to define own methods in a shorter syntax, similar to the getters and setters. See <a href=\"functions/method_definitions\">method definitions</a> for more information.</p> <pre data-language=\"js\">var obj = {\n  foo() {},\n  bar() {}\n};</pre> <h2 id=\"Constructor_vs._declaration_vs._expression\">Constructor vs. declaration vs. expression</h2> <p>Compare the following:</p> <p>A function defined with the <code>Function</code> <em>constructor</em> assigned to the variable <code>multiply:</code></p> <pre data-language=\"js\">var multiply = new Function('x', 'y', 'return x * y');</pre> <p>A <em>function declaration</em> of a function named <code>multiply</code>:</p> <pre data-language=\"js\">function multiply(x, y) {\n   return x * y;\n} // there is no semicolon here\n</pre> <p>A <em>function expression</em> of an anonymous function assigned to the variable <code>multiply:</code></p> <pre data-language=\"js\">var multiply = function(x, y) {\n   return x * y;\n};\n</pre> <p>A <em>function expression</em> of a function named <code>func_name</code> assigned to the variable <code>multiply:</code></p> <pre data-language=\"js\">var multiply = function func_name(x, y) {\n   return x * y;\n};\n</pre> <h3 id=\"Differences\">Differences</h3> <p>All do approximately the same thing, with a few subtle differences:</p> <p>There is a distinction between the function name and the variable the function is assigned to. The function name cannot be changed, while the variable the function is assigned to can be reassigned. The function name can be used only within the function's body. Attempting to use it outside the function's body results in an error (or <code>undefined</code> if the function name was previously declared via a <code>var</code> statement). For example:</p> <pre data-language=\"js\">var y = function x() {};\nalert(x); // throws an error\n</pre> <p>The function name also appears when the function is serialized via <a href=\"global_objects/function/tostring\"><code>Function</code>'s toString method</a>.</p> <p>On the other hand, the variable the function is assigned to is limited only by its scope, which is guaranteed to include the scope in which the function is declared.</p> <p>As the 4th example shows, the function name can be different from the variable the function is assigned to. They have no relation to each other. A function declaration also creates a variable with the same name as the function name. Thus, unlike those defined by function expressions, functions defined by function declarations can be accessed by their name in the scope they were defined in:</p> <p>A function defined by '<code>new Function'</code> does not have a function name. However, in the <a href=\"https://developer.mozilla.org/en-US/docs/Mozilla/Projects/SpiderMonkey\">SpiderMonkey</a> JavaScript engine, the serialized form of the function shows as if it has the name \"anonymous\". For example, <code>alert(new Function())</code> outputs:</p> <pre data-language=\"js\">function anonymous() {\n}\n</pre> <p>Since the function actually does not have a name, <code>anonymous</code> is not a variable that can be accessed within the function. For example, the following would result in an error:</p> <pre data-language=\"js\">var foo = new Function(\"alert(anonymous);\");\nfoo();\n</pre> <p>Unlike functions defined by function expressions or by the <code>Function</code> constructor, a function defined by a function declaration can be used before the function declaration itself. For example:</p> <pre data-language=\"js\">foo(); // alerts FOO!\nfunction foo() {\n   alert('FOO!');\n}\n</pre> <p>A function defined by a function expression or by a function declaration inherits the current scope. That is, the function forms a closure. On the other hand, a function defined by a <code>Function</code> constructor does not inherit any scope other than the global scope (which all functions inherit).</p> <pre data-language=\"js\">/*\n * Declare and initialize a variable 'p' (global)\n * and a function 'myFunc' (to change the scope) inside which\n * declare a varible with same name 'p' (current) and\n * define three functions using three different ways:-\n *     1. function declaration\n *     2. function expression\n *     3. function constructor\n * each of which will log 'p'\n */\nvar p = 5;\nfunction myFunc() {\n    var p = 9;\n\n    function decl() {\n        console.log(p);\n    }\n    var expr = function() {\n        console.log(p);\n    };\n    var cons = new Function('\\tconsole.log(p);');\n\n    decl();\n    expr();\n    cons();\n}\nmyFunc();\n\n/*\n * Logs:-\n * 9  - for 'decl' by function declaration (current scope)\n * 9  - for 'expr' by function expression (current scope)\n * 5  - for 'cons' by Function constructor (global scope)\n */\n</pre> <p>Functions defined by function expressions and function declarations are parsed only once, while those defined by the <code>Function</code> constructor are not. That is, the function body string passed to the <code>Function</code> constructor must be parsed each and every time the constructor is called. Although a function expression creates a closure every time, the function body is not reparsed, so function expressions are still faster than \"<code>new Function(...)</code>\". Therefore the <code>Function</code> constructor should generally be avoided whenever possible.</p> <p>It should be noted, however, that function expressions and function declarations nested within the function generated by parsing a <code>Function constructor</code> 's string aren't parsed repeatedly. For example:</p> <pre data-language=\"js\">var foo = (new Function(\"var bar = \\'FOO!\\';\\nreturn(function() {\\n\\talert(bar);\\n});\"))();\nfoo(); // The segment \"function() {\\n\\talert(bar);\\n}\" of the function body string is not re-parsed.</pre> <p>A function declaration is very easily (and often unintentionally) turned into a function expression. A function declaration ceases to be one when it either:</p> <ul> <li>becomes part of an expression</li> <li>is no longer a \"source element\" of a function or the script itself. A \"source element\" is a non-nested statement in the script or a function body:</li> </ul> <pre data-language=\"js\">var x = 0;               // source element\nif (x === 0) {           // source element\n   x = 10;               // not a source element\n   function boo() {}     // not a source element\n}\nfunction foo() {         // source element\n   var y = 20;           // source element\n   function bar() {}     // source element\n   while (y === 10) {    // source element\n      function blah() {} // not a source element\n      y++;               // not a source element\n   }\n}\n</pre> <h3 id=\"Examples\">Examples</h3> <pre data-language=\"js\">// function declaration\nfunction foo() {}\n\n// function expression\n(function bar() {})\n\n// function expression\nx = function hello() {}\n\n\nif (x) {\n   // function expression\n   function world() {}\n}\n\n\n// function declaration\nfunction a() {\n   // function declaration\n   function b() {}\n   if (0) {\n      // function expression\n      function c() {}\n   }\n}\n</pre> <h2 id=\"Block-level_functions\">Block-level functions</h2> <p>In <a href=\"strict_mode\">strict mode</a>, starting with ES2015, functions inside blocks are now scoped to that block. Prior to ES2015, block-level functions were forbidden in strict mode.</p> <pre data-language=\"js\">'use strict';\n\nfunction f() { \n  return 1; \n}\n\n{  \n  function f() { \n    return 2; \n  }\n}\n\nf() === 1; // true\n\n// f() === 2 in non-strict mode\n</pre> <h3 id=\"Block-level_functions_in_non-strict_code\">Block-level functions in non-strict code</h3> <p>In a word: Don't.</p> <p>In non-strict code, function declarations inside blocks behave strangely. For example:</p> <pre data-language=\"js\">if (shouldDefineZero) {\n   function zero() {     // DANGER: compatibility risk\n      console.log(\"This is zero.\");\n   }\n}\n</pre> <p>ES2015 says that if <code>shouldDefineZero</code> is false, then <code>zero</code> should never be defined, since the block never executes. However, it's a new part of the standard. Historically, this was left unspecified, and some browsers would define <code>zero</code> whether the block executed or not.</p> <p>In <a href=\"strict_mode\">strict mode</a>, all browsers that support ES2015 handle this the same way: <code>zero</code> is defined only if <code>shouldDefineZero</code> is true, and only in the scope of the <code>if</code>-block.</p> <p>A safer way to define functions conditionally is to assign a function expression to a variable:</p> <pre data-language=\"js\">var zero;\nif (shouldDefineZero) {\n   zero = function() {\n      console.log(\"This is zero.\");\n   };\n}\n</pre> <h2 id=\"Examples_2\">Examples</h2> <h3 id=\"Returning_a_formatted_number\">Returning a formatted number</h3> <p>The following function returns a string containing the formatted representation of a number padded with leading zeros.</p> <pre data-language=\"js\">// This function returns a string padded with leading zeros\nfunction padZeros(num, totalLen) {\n   var numStr = num.toString();             // Initialize return value as string\n   var numZeros = totalLen - numStr.length; // Calculate no. of zeros\n   for (var i = 1; i &lt;= numZeros; i++) {\n      numStr = \"0\" + numStr;\n   }\n   return numStr;\n}\n</pre> <p>The following statements call the padZeros function.</p> <pre data-language=\"js\">var result;\nresult = padZeros(42,4); // returns \"0042\"\nresult = padZeros(42,2); // returns \"42\"\nresult = padZeros(5,4);  // returns \"0005\" \n</pre> <h3 id=\"Determining_whether_a_function_exists\">Determining whether a function exists</h3> <p>You can determine whether a function exists by using the <code>typeof</code> operator. In the following example, a test is performed to determine if the <code>window</code> object has a property called <code>noFunc</code> that is a function. If so, it is used; otherwise, some other action is taken.</p> <pre data-language=\"js\"> if ('function' === typeof window.noFunc) {\n   // use noFunc()\n } else {\n   // do something else\n }\n</pre> <p>Note that in the <code>if</code> test, a reference to <code>noFunc</code> is used—there are no brackets \"()\" after the function name so the actual function is not called.</p> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/publications/files/ECMA-ST-ARCH/ECMA-262,%201st%20edition,%20June%201997.pdf\" hreflang=\"en\">ECMAScript 1st Edition (ECMA-262)</a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition. Implemented in JavaScript 1.0</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/5.1/#sec-13\" hreflang=\"en\">ECMAScript 5.1 (ECMA-262)<br><small>The definition of 'Function Definition' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-function-definitions\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Function definitions' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>New: Arrow functions, Generator functions, default parameters, rest parameters.</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-function-definitions\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Function definitions' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Functions/arguments\"><code>arguments</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Functions/Arrow_functions\">Arrow functions</a></th>\n<td class=\"bc-supports-yes\"> 45</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes bc-has-history\"> 22\n<section class=\"bc-history\" id=\"sect1\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 22\n</dt>\n<dd> The initial implementation of arrow functions in Firefox made them automatically strict. This has been changed as of Firefox 24. The use of <code>'use strict';</code> is now required.</dd>\n<dd> Prior to Firefox 39, a line terminator (<code>\\n</code>) was incorrectly allowed after arrow function arguments. This has been fixed to conform to the ES2015 specification and code like <code>() \\n =&gt; {}</code> will now throw a <code>SyntaxError</code> in this and later versions.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 32</td>\n<td class=\"bc-supports-yes\"> 10</td>\n</tr>\n<tr>\n<th scope=\"row\">Block-level functions</th>\n<td> ? </td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 46</td>\n<td> ? </td>\n<td> ? </td>\n<td> ? </td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Functions/Default_parameters\">Default parameters</a></th>\n<td class=\"bc-supports-yes\"> 49</td>\n<td class=\"bc-supports-yes\"> 14</td>\n<td class=\"bc-supports-yes\"> 15</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 36</td>\n<td class=\"bc-supports-yes\"> 10</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Functions/Method_definitions\">Method definitions</a></th>\n<td class=\"bc-supports-yes\"> 39</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 34</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 26</td>\n<td class=\"bc-supports-no\"> No</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Functions/rest_parameters\">Rest parameters</a></th>\n<td class=\"bc-supports-yes\"> 47</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 15</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 34</td>\n<td class=\"bc-supports-yes\"> 10</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Functions/get\"><code>get</code></a></th>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 2</td>\n<td class=\"bc-supports-yes\"> 9</td>\n<td class=\"bc-supports-yes\"> 9.5</td>\n<td class=\"bc-supports-yes\"> 3</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Functions/set\"><code>set</code></a></th>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 2</td>\n<td class=\"bc-supports-yes\"> 9</td>\n<td class=\"bc-supports-yes\"> 9.5</td>\n<td class=\"bc-supports-yes\"> 3</td>\n</tr>\n</tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Functions/arguments\"><code>arguments</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Functions/Arrow_functions\">Arrow functions</a></th>\n<td class=\"bc-supports-yes\"> 45</td>\n<td class=\"bc-supports-yes\"> 45</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes bc-has-history\"> 22\n<section class=\"bc-history\" id=\"sect2\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 22\n</dt>\n<dd> The initial implementation of arrow functions in Firefox made them automatically strict. This has been changed as of Firefox 24. The use of <code>'use strict';</code> is now required.</dd>\n<dd> Prior to Firefox 39, a line terminator (<code>\\n</code>) was incorrectly allowed after arrow function arguments. This has been fixed to conform to the ES2015 specification and code like <code>() \\n =&gt; {}</code> will now throw a <code>SyntaxError</code> in this and later versions.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-yes\"> 32</td>\n<td class=\"bc-supports-yes\"> 10</td>\n<td class=\"bc-supports-yes\"> 5.0</td>\n</tr>\n<tr>\n<th scope=\"row\">Block-level functions</th>\n<td> ? </td>\n<td> ? </td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 46</td>\n<td> ? </td>\n<td> ? </td>\n<td> ? </td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Functions/Default_parameters\">Default parameters</a></th>\n<td class=\"bc-supports-yes\"> 49</td>\n<td class=\"bc-supports-yes\"> 49</td>\n<td class=\"bc-supports-yes\"> 14</td>\n<td class=\"bc-supports-yes\"> 15</td>\n<td class=\"bc-supports-yes\"> 36</td>\n<td class=\"bc-supports-yes\"> 10</td>\n<td class=\"bc-supports-yes\"> 5.0</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Functions/Method_definitions\">Method definitions</a></th>\n<td class=\"bc-supports-yes\"> 39</td>\n<td class=\"bc-supports-yes\"> 39</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 34</td>\n<td class=\"bc-supports-yes\"> 26</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 4.0</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Functions/rest_parameters\">Rest parameters</a></th>\n<td class=\"bc-supports-yes\"> 47</td>\n<td class=\"bc-supports-yes\"> 47</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 15</td>\n<td class=\"bc-supports-yes\"> 34</td>\n<td class=\"bc-supports-yes\"> 10</td>\n<td class=\"bc-supports-yes\"> 5.0</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Functions/get\"><code>get</code></a></th>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> 18</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Functions/set\"><code>set</code></a></th>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> 18</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n</tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Functions/arguments\"><code>arguments</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Functions/Arrow_functions\">Arrow functions</a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">Block-level functions</th>\n<td> ? </td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Functions/Default_parameters\">Default parameters</a></th>\n<td class=\"bc-supports-yes\"> 6.0.0</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Functions/Method_definitions\">Method definitions</a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Functions/rest_parameters\">Rest parameters</a></th>\n<td class=\"bc-supports-yes bc-has-history\"> 6.0.0\n<section class=\"bc-history\" id=\"sect3\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 6.0.0\n</dt>\n\n<dt class=\"bc-supports-yes bc-supports\"> 4.0.0<div class=\"bc-icons\">Disabled </div>\n</dt>\n<dd>Disabled From version 4.0.0: this feature is behind the <code>--harmony</code> runtime flag.</dd>\n</dl></section>\n</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Functions/get\"><code>get</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Functions/set\"><code>set</code></a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n</tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"statements/function\"><code>function statement</code></a></li> <li><a href=\"operators/function\"><code>function expression</code></a></li> <li><a href=\"statements/function*\"><code>function* statement</code></a></li> <li><a href=\"operators/function*\"><code>function* expression</code></a></li> <li><a href=\"global_objects/function\"><code>Function</code></a></li> <li><a href=\"global_objects/generatorfunction\"><code>GeneratorFunction</code></a></li> <li><a href=\"functions/arrow_functions\"><code>Arrow functions</code></a></li> <li><a href=\"functions/default_parameters\"><code>Default parameters</code></a></li> <li><a href=\"functions/rest_parameters\"><code>Rest parameters</code></a></li> <li><a href=\"functions/arguments\"><code>Arguments object</code></a></li> <li><a href=\"functions/get\"><code>getter</code></a></li> <li><a href=\"functions/set\"><code>setter</code></a></li> <li><a href=\"functions/method_definitions\"><code>Method definitions</code></a></li> <li><a href=\"functions\">Functions and function scope</a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions</a>\n  </p>\n</div>\n","global_objects/typedarray/set":"<h1>typedArray.set</h1> <p>The <code>set()</code> method stores multiple values in the typed array, reading input values from a specified array.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/typedarray-set.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\"><var>typedarray</var>.set(array[, offset])\n<em>typedarray</em>.set(typedarray[, offset])\n</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt>array</dt> <dd>The array from which to copy values. All values from the source array are copied into the target array, unless the length of the source array plus the offset exceeds the length of the target array, in which case an exception is thrown.</dd> <dt>typedarray</dt> <dd>If the source array is a typed array, the two arrays may share the same underlying <a href=\"../arraybuffer\"><code>ArrayBuffer</code></a>; the JavaScript engine will intelligently <strong>copy</strong> the source range of the buffer to the destination range.</dd> <dt>offset <span class=\"inlineIndicator optional optionalInline\">Optional</span>\n</dt> <dd>The offset into the target array at which to begin writing values from the source <code>array</code>. If you omit this value, 0 is assumed (that is, the source <code>array</code> will overwrite values in the target array starting at index 0).</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p><a href=\"../undefined\"><code>undefined</code></a>.</p> <h3 id=\"Errors_thrown\">Errors thrown</h3> <dl> <dt><a href=\"../rangeerror\"><code>RangeError</code></a></dt> <dd>Thrown if the <code>offset</code> is set such as it would store beyond the end of the typed array.</dd> </dl> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Using_the_set_method\">Using the <code>set</code> method</h3> <pre data-language=\"js\">var buffer = new ArrayBuffer(8);\nvar uint8 = new Uint8Array(buffer);\n\nuint8.set([1, 2, 3], 3);\n\nconsole.log(uint8); // Uint8Array [ 0, 0, 0, 1, 2, 3, 0, 0 ]\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.khronos.org/registry/typedarray/specs/latest/\" hreflang=\"en\">Typed Array Specification</a></td> <td><span class=\"spec-Obsolete\">Obsolete</span></td> <td>Superseded by ECMAScript 6.</td> </tr> <tr> <td><a href=\"#\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'TypedArray.prototype.set' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition in an ECMA standard.</td> </tr> <tr> <td><a href=\"#\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'TypedArray.prototype.set' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 7</td>\n<td class=\"bc-supports-yes\"> 14</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> 10</td>\n<td class=\"bc-supports-yes\"> 11.6</td>\n<td class=\"bc-supports-yes\"> 5.1</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> 11.6</td>\n<td class=\"bc-supports-yes\"> 4.2</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td> ? </td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Typed_arrays\">JavaScript typed arrays</a></li> <li><a href=\"../typedarray\"><code>TypedArray</code></a></li> <li><a href=\"../arraybuffer\"><code>ArrayBuffer</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/set$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/set\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/set</a>\n  </p>\n</div>\n","global_objects/typedarray/slice":"<h1>typedArray.slice</h1> <p>The <code><strong>slice()</strong></code> method returns a shallow copy of a portion of a typed array into a new typed array object. This method has the same algorithm as <a href=\"../array/slice\"><code>Array.prototype.slice()</code></a><em>.</em> <em>TypedArray</em> is one of the <a href=\"../typedarray#TypedArray_objects\">typed array types</a> here.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/typedarray-slice.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\"><var>typedarr</var>ay.slice([<var>begin</var>[, <var>end</var>]])</pre> <h2 id=\"Parameters\">Parameters</h2> <dl> <dt>\n<code>begin</code> <span class=\"inlineIndicator optional optionalInline\">Optional</span>\n</dt> <dd>Zero-based index at which to begin extraction.</dd> <dd>A negative index can be used, indicating an offset from the end of the sequence. <code>slice(-2)</code> extracts the last two elements in the sequence.</dd> <dd>If <code>begin</code> is undefined, <code>slice</code> begins from index <code>0</code>.</dd> <dt>\n<code>end</code> <span class=\"inlineIndicator optional optionalInline\">Optional</span>\n</dt> <dd>Zero-based index <em>before</em> which to end extraction. <code>slice</code> extracts up to but not including <code>end</code>.</dd> <dd>For example, <code>slice(1,4)</code> extracts the second element through the fourth element (elements indexed 1, 2, and 3).</dd> <dd>A negative index can be used, indicating an offset from the end of the sequence. <code>slice(2,-1)</code> extracts the third element through the second-to-last element in the sequence.</dd> <dd>If <code>end</code> is omitted, <code>slice</code> extracts through the end of the sequence (<code>typedarray.length</code>).</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p>A new typed array containing the extracted elements.</p> <h2 id=\"Description\">Description</h2> <p>The <code>slice</code> method does not alter. It returns a shallow copy of elements from the original typed array.</p> <p>If a new element is added to either typed array, the other typed array is not affected.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Return_a_portion_of_an_existing_typed_array\">Return a portion of an existing typed array</h3> <pre data-language=\"js\">var uint8 = new Uint8Array([1,2,3]);\nuint8.slice(1);   // Uint8Array [ 2, 3 ]\nuint8.slice(2);   // Uint8Array [ 3 ]\nuint8.slice(-2);  // Uint8Array [ 2, 3 ]\nuint8.slice(0,1); // Uint8Array [ 1 ]\n</pre> <h2 id=\"Polyfill\">Polyfill</h2> <p>Since there is no global object with the name <em>TypedArray</em>, polyfilling must be done on an \"as needed\" basis.</p> <pre data-language=\"js\">// https://tc39.github.io/ecma262/#sec-%typedarray%.prototype.slice\nif (!Uint8Array.prototype.slice) {\n  Object.defineProperty(Uint8Array.prototype, 'slice', {\n    value: Array.prototype.slice\n  });\n}\n</pre> <p>This is not a complete polyfill, since it returns an instance of Array, and not Uint8Array, so it lacks properties that would normally exist on TypedArrays.</p> <p>If you need to support truly obsolete JavaScript engines that don't support <code><a href=\"../object/defineproperty\">Object.defineProperty</a></code>, it's best not to polyfill <code>Array.prototype</code> methods at all, as you can't make them non-enumerable.</p> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"#\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of '%TypedArray%.prototype.slice' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"#\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of '%TypedArray%.prototype.slice' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>   <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 45</td>\n<td class=\"bc-supports-yes\"> 14</td>\n<td class=\"bc-supports-yes\"> 38</td>\n<td class=\"bc-supports-no\"> No</td>\n<td> ? </td>\n<td> ? </td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td> ? </td>\n<td> ? </td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 38</td>\n<td> ? </td>\n<td> ? </td>\n<td> ? </td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 4.0.0</td>\n</tr></tbody>\n</table>\n</div>  <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"../array/slice\"><code>Array.prototype.slice()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/slice$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/slice\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/slice</a>\n  </p>\n</div>\n","global_objects/typedarray/subarray":"<h1>typedArray.subarray</h1> <p>The <code>subarray()</code> method returns a new <em>TypedArray</em> on the same <a href=\"../arraybuffer\"><code>ArrayBuffer</code></a> store and with the same element types as for this <em>TypedArray</em> object. The <code>begin</code> offset is <strong>inclusive</strong> and the <code>end</code> offset is <strong>exclusive</strong>. <em>TypedArray</em> is one of the <a href=\"../typedarray#TypedArray_objects\">typed array types</a>.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/typedarray-subarray.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\"><var>typedarr</var>ay.subarray([begin [,end]])\n</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt>begin <span class=\"inlineIndicator optional optionalInline\">Optional</span>\n</dt> <dd>Element to begin at. The offset is inclusive. The whole array will be included in the new view if this value is not specified.</dd> <dt>end <span class=\"inlineIndicator optional optionalInline\">Optional</span>\n</dt> <dd>Element to end at. The offset is exclusive. If not specified, all elements from the one specified by <code>begin</code> to the end of the array are included in the new view.</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p>A new <a href=\"../typedarray\"><code>TypedArray</code></a> object.</p> <h2 id=\"Description\">Description</h2> <p>The range specified by <code>begin</code> and <code>end</code> is clamped to the valid index range for the current array; if the computed length of the new array would be negative, it's clamped to zero. If either <code>begin</code> or <code>end</code> is negative, it refers to an index from the end of the array instead of from the beginning.</p> <p>Also note that this is creating a new view on the existing buffer; changes to the new object's contents will impact the original object and vice versa.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Using_the_subarray_method\">Using the <code>subarray</code> method</h3> <pre data-language=\"js\">var buffer = new ArrayBuffer(8);\nvar uint8 = new Uint8Array(buffer);\nuint8.set([1,2,3]);\n\nconsole.log(uint8); // Uint8Array [ 1, 2, 3, 0, 0, 0, 0, 0 ]\n\nvar sub = uint8.subarray(0,4);\n\nconsole.log(sub);   // Uint8Array [ 1, 2, 3, 0 ]\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.khronos.org/registry/typedarray/specs/latest/\" hreflang=\"en\">Typed Array Specification</a></td> <td><span class=\"spec-Obsolete\">Obsolete</span></td> <td>Superseded by ECMAScript 6.</td> </tr> <tr> <td><a href=\"#\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'TypedArray.prototype.subarray' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition in an ECMA standard.</td> </tr> <tr> <td><a href=\"#\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'TypedArray.prototype.subarray' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 7</td>\n<td class=\"bc-supports-yes\"> 14</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> 10</td>\n<td class=\"bc-supports-yes\"> 11.6</td>\n<td class=\"bc-supports-yes\"> 5.1</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> 11.6</td>\n<td class=\"bc-supports-yes\"> 4.2</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 0.12</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Typed_arrays\">JavaScript typed arrays</a></li> <li><a href=\"../typedarray\"><code>TypedArray</code></a></li> <li><a href=\"../arraybuffer\"><code>ArrayBuffer</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/subarray$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/subarray\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/subarray</a>\n  </p>\n</div>\n","global_objects/typedarray/tostring":"<h1>typedArray.toString</h1> <p>The <code><strong>toString()</strong></code> method returns a string representing the specified array and its elements. This method has the same algorithm as <a href=\"../array/tostring\"><code>Array.prototype.toString()</code></a><em>.</em> <em>TypedArray</em> is one of the <a href=\"../typedarray#TypedArray_objects\">typed array types</a> here.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/typedarray-tostring.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\"><var>typedarray</var>.toString()</pre> <h3 id=\"Return_value\">Return value</h3> <p>A string representing the elements of the typed array.</p> <h2 id=\"Description\">Description</h2> <p>The <a href=\"../typedarray\"><code>TypedArray</code></a> objects override the <code>toString</code> method of <a href=\"../object\"><code>Object</code></a>. For TypedArray objects, the <code>toString</code> method joins the array and returns one string containing each typed array element separated by commas. For example, the following code creates a typed array and uses <code>toString</code> to convert the array to a string.</p> <pre data-language=\"js\">var numbers = new Uint8Array([2, 5, 8, 1, 4])\nnumbers.toString(); // \"2,5,8,1,4\"\n</pre> <p>JavaScript calls the <code>toString</code> method automatically when a typed array is to be represented as a text value or when an array is referred to in a string concatenation.</p> <h3 id=\"Compatibility\">Compatibility</h3> <p>If a browser doesn't support the <code>TypedArray.prototype.toString()</code> method yet, JavaScript will call the <code>toString</code> method of <a href=\"../object\"><code>Object</code></a>:</p> <pre data-language=\"js\">var numbers = new Uint8Array([2, 5, 8, 1, 4])\nnumbers.toString(); // \"[object Uint8Array]\"\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"#\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'TypedArray.prototype.toString' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"#\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Array.prototype.toString' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>   <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 51</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 51</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td> ? </td>\n</tr></tbody>\n</table>\n</div>  <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"join\"><code>TypedArray.prototype.join()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/toString$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/toString\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/toString</a>\n  </p>\n</div>\n","global_objects/typedarray/some":"<h1>typedArray.some</h1> <p>The <code><strong>some()</strong></code> method tests whether some element in the typed array passes the test implemented by the provided function. This method has the same algorithm as <a href=\"../array/some\"><code>Array.prototype.some()</code></a><em>.</em> <em>TypedArray</em> is one of the <a href=\"../typedarray#TypedArray_objects\">typed array types</a> here.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/typedarray-some.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\"><var>typedarray</var>.some(<var>callback</var>[, <var>thisArg</var>])</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><code>callback</code></dt> <dd>Function to test for each element, taking three arguments: <dl> <dt><code>currentValue</code></dt> <dd>The current element being processed in the typed array.</dd> <dt><code>index</code></dt> <dd>The index of the current element being processed in the typed array.</dd> <dt><code>array</code></dt> <dd>The typed array <code>every</code> was called upon.</dd> </dl> </dd> <dt><code>thisArg</code></dt> <dd>Optional. Value to use as <code>this</code> when executing <code>callback</code>.</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p><code><strong>true</strong></code> if the callback function returns a <a href=\"https://developer.mozilla.org/en-US/docs/Glossary/truthy\">truthy</a> value for any array element; otherwise, <code><strong>false</strong></code>.</p> <h2 id=\"Description\">Description</h2> <p>The <code>some</code> method executes the <code>callback</code> function once for each element present in the typed array until it finds one where <code>callback</code> returns a true value. If such an element is found, <code>some</code> immediately returns <code>true</code>. Otherwise, <code>some</code> returns <code>false</code>.</p> <p><code>callback</code> is invoked with three arguments: the value of the element, the index of the element, and the array object being traversed.</p> <p>If a <code>thisArg</code> parameter is provided to <code>some</code>, it will be passed to <code>callback</code> when invoked, for use as its <code>this</code> value. Otherwise, the value <code>undefined</code> will be passed for use as its <code>this</code> value. The <code>this</code> value ultimately observable by <code>callback</code> is determined according to <a href=\"../../operators/this\">the usual rules for determining the <code>this</code> seen by a function</a>.</p> <p><code>some</code> does not mutate the typed array on which it is called.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Testing_size_of_all_typed_array_elements\">Testing size of all typed array elements</h3> <p>The following example tests whether any element in the typed array is bigger than 10.</p> <pre data-language=\"js\">function isBiggerThan10(element, index, array) {\n  return element &gt; 10;\n}\nnew Uint8Array([2, 5, 8, 1, 4]).some(isBiggerThan10); // false\nnew Uint8Array([12, 5, 8, 1, 4]).some(isBiggerThan10); // true\n</pre> <h3 id=\"Testing_typed_array_elements_using_arrow_functions\">Testing typed array elements using arrow functions</h3> <p><a href=\"../../functions/arrow_functions\">Arrow functions</a> provide a shorter syntax for the same test.</p> <pre data-language=\"js\">new Uint8Array([2, 5, 8, 1, 4]).some(elem =&gt; elem &gt; 10); // false\nnew Uint8Array([12, 5, 8, 1, 4]).some(elem =&gt; elem &gt; 10); // true</pre> <h2 id=\"Polyfill\">Polyfill</h2> <p>Since there is no global object with the name <em>TypedArray</em>, polyfilling must be done on an \"as needed\" basis.</p> <pre data-language=\"js\">// https://tc39.github.io/ecma262/#sec-%typedarray%.prototype.some\nif (!Uint8Array.prototype.some) {\n  Object.defineProperty(Uint8Array.prototype, 'some', {\n    value: Array.prototype.some\n  });\n}\n</pre> <p>If you need to support truly obsolete JavaScript engines that don't support <code><a href=\"../object/defineproperty\">Object.defineProperty</a></code>, it's best not to polyfill <code>Array.prototype</code> methods at all, as you can't make them non-enumerable.</p> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"#\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'TypedArray.prototype.some' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"#\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'TypedArray.prototype.some' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>   <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 45</td>\n<td class=\"bc-supports-yes\"> 14</td>\n<td class=\"bc-supports-yes\"> 37</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 32</td>\n<td class=\"bc-supports-yes\"> 10</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td> ? </td>\n<td> ? </td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 37</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 10</td>\n<td> ? </td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 4.0.0</td>\n</tr></tbody>\n</table>\n</div>  <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"every\"><code>TypedArray.prototype.every()</code></a></li> <li><a href=\"../array/some\"><code>Array.prototype.some()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/some$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/some\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/some</a>\n  </p>\n</div>\n","global_objects/typedarray/map":"<h1>typedArray.map</h1> <p>The <code><strong>map()</strong></code> method creates a new typed array with the results of calling a provided function on every element in this typed array. This method has the same algorithm as <a href=\"../array/map\"><code>Array.prototype.map()</code></a><em>.</em> <em>TypedArray</em> is one of the <a href=\"../typedarray#TypedArray_objects\">typed array types</a> here.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/typedarray-map.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\"><var>typedarray</var>.map(<var>callback</var>[, <var>thisArg</var>])</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><code>callback</code></dt> <dd>Function that produces an element of the new typed array, taking three arguments: <dl> <dt><code>currentValue</code></dt> <dd>The current element being processed in the typed array.</dd> <dt><code>index</code></dt> <dd>The index of the current element being processed in the typed array.</dd> <dt><code>array</code></dt> <dd>The typed array <code>map</code> was called upon.</dd> </dl> </dd> <dt><code>thisArg</code></dt> <dd>Optional. Value to use as <code>this</code> when executing <code>callback</code>.</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p>A new typed array.</p> <h2 id=\"Description\">Description</h2> <p>The <code>map</code> method calls a provided <code>callback</code> function once for each element in a typed array, in order, and constructs a new typed array from the results. <code>callback</code> is invoked only for indexes of the typed array which have assigned values; it is not invoked for indexes that are undefined, those which have been deleted or which have never been assigned values.</p> <p><code>callback</code> is invoked with three arguments: the value of the element, the index of the element, and the typed array object being traversed.</p> <p>If a <code>thisArg</code> parameter is provided to <code>map</code>, it will be passed to <code>callback</code> when invoked, for use as its <code>this</code> value. Otherwise, the value <a href=\"../undefined\"><code>undefined</code></a> will be passed for use as its <code>this</code> value. The <code>this</code> value ultimately observable by <code>callback</code> is determined according to <a href=\"../../operators/this\">the usual rules for determining the <code>this</code> seen by a function</a>.</p> <p><code>map</code> does not mutate the typed array on which it is called (although <code>callback</code>, if invoked, may do so).</p> <p>The range of elements processed by <code>map</code> is set before the first invocation of <code>callback</code>. Elements which are appended to the array after the call to <code>map</code> begins will not be visited by <code>callback</code>. If existing elements of the typed array are changed, or deleted, their value as passed to <code>callback</code> will be the value at the time <code>map</code> visits them; elements that are deleted are not visited.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Mapping_a_typed_array_to_a_typed_array_of_square_roots\">Mapping a typed array to a typed array of square roots</h3> <p>The following code takes a typed array and creates a new typed array containing the square roots of the numbers in the first typed array.</p> <pre data-language=\"js\">var numbers = new Uint8Array([1, 4, 9]);\nvar roots = numbers.map(Math.sqrt);\n// roots is now: Uint8Array [1, 2, 3], \n// numbers is still Uint8Array [1, 4, 9]\n</pre> <h3 id=\"Mapping_a_typed_array_of_numbers_using_a_function_containing_an_argument\">Mapping a typed array of numbers using a function containing an argument</h3> <p>The following code shows how map works when a function requiring one argument is used with it. The argument will automatically be assigned to each element of the typed array as map loops through the original typed array.</p> <pre data-language=\"js\">var numbers = new Uint8Array([1, 4, 9]);\nvar doubles = numbers.map(function(num) {\n  return num * 2;\n});\n// doubles is now Uint8Array [2, 8, 18]\n// numbers is still Uint8Array [1, 4, 9]\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"#\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'TypedArray.prototype.map' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"#\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'TypedArray.prototype.map' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>   <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 14</td>\n<td class=\"bc-supports-yes\"> 38</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 38</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 4.0.0</td>\n</tr></tbody>\n</table>\n</div>  <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"filter\"><code>TypedArray.prototype.filter()</code></a></li> <li><a href=\"../array/map\"><code>Array.prototype.map()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/map$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/map\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/map</a>\n  </p>\n</div>\n","global_objects/typedarray/values":"<h1>typedArray.values</h1> <p>The <code>values()</code> method returns a new <code>Array Iterator</code> object that contains the values for each index in the array.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/typedarray-values.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\"><var>arr</var>.values()</pre> <h3 id=\"Return_value\">Return value</h3> <p>A new <code><strong>Array Iterator</strong></code> object.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Iteration_using_for...of_loop\">Iteration using <code>for...of</code> loop</h3> <pre data-language=\"js\">var arr = new Uint8Array([10, 20, 30, 40, 50]);\nvar eArray = arr.values();\n// your browser must support for..of loop\n// and let-scoped variables in for loops\nfor (let n of eArray) {\n  console.log(n);\n}\n</pre> <h3 id=\"Alternative_iteration\">Alternative iteration</h3> <pre data-language=\"js\">var arr = new Uint8Array([10, 20, 30, 40, 50]);\nvar eArr = arr.values();\nconsole.log(eArr.next().value); // 10\nconsole.log(eArr.next().value); // 20\nconsole.log(eArr.next().value); // 30\nconsole.log(eArr.next().value); // 40\nconsole.log(eArr.next().value); // 50\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"#\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of '%TypedArray%.prototype.values()' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"#\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of '%TypedArray%.prototype.values()' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>   <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 14</td>\n<td class=\"bc-supports-yes\"> 37</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 26</td>\n<td class=\"bc-supports-yes\"> 10</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 37</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 10</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 0.12</td>\n</tr></tbody>\n</table>\n</div>  <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Typed_arrays\">JavaScript typed arrays</a></li> <li><a href=\"../typedarray\"><code>TypedArray</code></a></li> <li><a href=\"entries\"><code>TypedArray.prototype.entries()</code></a></li> <li><a href=\"keys\"><code>TypedArray.prototype.keys()</code></a></li> <li><a href=\"@@iterator\"><code>TypedArray.prototype[@@iterator]()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/values$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/values\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/values</a>\n  </p>\n</div>\n","global_objects/typedarray/@@iterator":"<h1>typedArray.@@iterator</h1> <p>The initial value of the @@iterator property is the same function object as the initial value of the <a href=\"values\"><code>values</code></a> property.</p> <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\"><var>arr</var>[Symbol.iterator]()</pre> <h3 id=\"Return_value\">Return value</h3> <p>The array <strong>iterator</strong> function, which is the <a href=\"values\"><code>values()</code></a> function by default.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Iteration_using_for...of_loop\">Iteration using <code>for...of</code> loop</h3> <pre data-language=\"js\">var arr = new Uint8Array([10, 20, 30, 40, 50]);\n// your browser must support for..of loop\n// and let-scoped variables in for loops\nfor (let n of arr) {\n  console.log(n);\n}\n</pre> <h3 id=\"Alternative_iteration\">Alternative iteration</h3> <pre data-language=\"js\">var arr = new Uint8Array([10, 20, 30, 40, 50]);\nvar eArr = arr[Symbol.iterator]();\nconsole.log(eArr.next().value); // 10\nconsole.log(eArr.next().value); // 20\nconsole.log(eArr.next().value); // 30\nconsole.log(eArr.next().value); // 40\nconsole.log(eArr.next().value); // 50\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"#\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of '%TypedArray%.prototype[@@iterator]()' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"#\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of '%TypedArray%.prototype[@@iterator]()' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>   <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td> ? </td>\n<td class=\"bc-supports-yes bc-has-history\"> 36\n<section class=\"bc-history\" id=\"sect1\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 36\n</dt>\n\n<dt class=\"bc-supports-no bc-supports\">27 — 36\n</dt>\n<dd> A placeholder property named <code>@@iterator</code> is used.</dd>\n<dd> Uses the non-standard name: <code>@@iterator</code>\n</dd>\n<dt class=\"bc-supports-no bc-supports\">17 — 27\n</dt>\n<dd> A placeholder property named <code>iterator</code> is used.</dd>\n<dd> Uses the non-standard name: <code>iterator</code>\n</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td> ? </td>\n<td class=\"bc-supports-yes bc-has-history\"> 36\n<section class=\"bc-history\" id=\"sect2\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 36\n</dt>\n\n<dt class=\"bc-supports-no bc-supports\">27 — 36\n</dt>\n<dd> A placeholder property named <code>@@iterator</code> is used.</dd>\n<dd> Uses the non-standard name: <code>@@iterator</code>\n</dd>\n<dt class=\"bc-supports-no bc-supports\">17 — 27\n</dt>\n<dd> A placeholder property named <code>iterator</code> is used.</dd>\n<dd> Uses the non-standard name: <code>iterator</code>\n</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 0.12</td>\n</tr></tbody>\n</table>\n</div>  <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Typed_arrays\">JavaScript typed arrays</a></li> <li><a href=\"../typedarray\"><code>TypedArray</code></a></li> <li><a href=\"entries\"><code>TypedArray.prototype.entries()</code></a></li> <li><a href=\"keys\"><code>TypedArray.prototype.keys()</code></a></li> <li><a href=\"values\"><code>TypedArray.prototype.values()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/@@iterator$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/@@iterator\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/@@iterator</a>\n  </p>\n</div>\n","global_objects/array/of":"<h1>Array.of</h1> <p>The <code><strong>Array.of()</strong></code> method creates a new <code>Array</code> instance with a variable number of arguments, regardless of number or type of the arguments.</p> <p>The difference between <code><strong>Array.of()</strong></code> and the <code><strong>Array</strong></code> constructor is in the handling of integer arguments: <code><strong>Array.of(7)</strong></code> creates an array with a single element, <code>7</code>, whereas <code><strong>Array(7)</strong></code> creates an empty array with a <code>length</code> property of 7 (<strong>Note:</strong> this implies an array of <code>7</code> empty slots, not slots with actual <code>undefined</code> values).</p> <pre data-language=\"js\">Array.of(7);       // [7] \nArray.of(1, 2, 3); // [1, 2, 3]\n\nArray(7);          // [ , , , , , , ]\nArray(1, 2, 3);    // [1, 2, 3]\n</pre> <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\">Array.of(<var>element0</var>[, <var>element1</var>[, ...[, <var>elementN</var>]]])</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><code>element<em>N</em></code></dt> <dd>Elements of which to create the array.</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p>A new <a href=\"../array\"><code>Array</code></a> instance.</p> <h2 id=\"Description\">Description</h2> <p>This function is part of the ECMAScript 2015 standard. For more information see <a href=\"https://gist.github.com/rwaldron/1074126\"><code>Array.of</code> and <code>Array.from</code> proposal</a> and <a href=\"https://gist.github.com/rwaldron/3186576\"><code>Array.of</code> polyfill</a>.</p> <h2 id=\"Examples\">Examples</h2> <pre data-language=\"js\">Array.of(1);         // [1]\nArray.of(1, 2, 3);   // [1, 2, 3]\nArray.of(undefined); // [undefined]\n</pre> <h2 id=\"Polyfill\">Polyfill</h2> <p>Running the following code before any other code will create <code>Array.of()</code> if it's not natively available.</p> <pre data-language=\"js\">if (!Array.of) {\n  Array.of = function() {\n    return Array.prototype.slice.call(arguments);\n  };\n}\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-array.of\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Array.of' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-array.of\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Array.of' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>   <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 45</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 25</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 9</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 39</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 25</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4.0</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 4.0.0</td>\n</tr></tbody>\n</table>\n</div>  <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"../array\"><code>Array</code></a></li> <li><a href=\"from\"><code>Array.from()</code></a></li> <li><a href=\"../typedarray/of\"><code>TypedArray.of()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/of$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/of\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/of</a>\n  </p>\n</div>\n","global_objects/array/copywithin":"<h1>array.copyWithin</h1> <p>The <code><strong>copyWithin()</strong></code> method shallow copies part of an array to another location in the same array and returns it, without modifying its size.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/array-copywithin.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\"><var>arr</var>.copyWithin(<var>target[, start[, end]]</var>)\n</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><code>target</code></dt> <dd>Zero based index at which to copy the sequence to. If negative, <code>target</code> will be counted from the end.</dd> <dd>If <code>target</code> is at or greater than <code>arr.length</code>, nothing will be copied. If <code>target</code> is positioned after <code>start</code>, the copied sequence will be trimmed to fit <code>arr.length</code>.</dd> <dt>\n<code>start</code> <span class=\"inlineIndicator optional optionalInline\">Optional</span>\n</dt> <dd>Zero based index at which to start copying elements from. If negative, <code>start</code> will be counted from the end.</dd> <dd>If <code>start</code> is omitted, <code>copyWithin</code> will copy from the start (defaults to 0).</dd> <dt>\n<code>end</code> <span class=\"inlineIndicator optional optionalInline\">Optional</span>\n</dt> <dd>Zero based index at which to end copying elements from. <code>copyWithin</code> copies up to but not including <code>end</code>. If negative, <code>end</code> will be counted from the end.</dd> <dd>If <code>end</code> is omitted, <code>copyWithin</code> will copy until the end (default to <code>arr.length</code>).</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p>The modified array.</p> <h2 id=\"Description\">Description</h2> <p>The <code>copyWithin</code> works like C and C++'s <code>memmove</code>, and is a high-performance method to shift the data of an <a href=\"../array\"><code>Array</code></a>. This especially applies to the <a href=\"../typedarray/copywithin\"><code>TypedArray</code></a> method of the same name. The sequence is copied and pasted as one operation; pasted sequence will have the copied values even when the copy and paste region overlap.</p> <p>The <code>copyWithin</code> function is intentionally <em>generic</em>, it does not require that its <code>this</code> value be an <a href=\"../array\"><code>Array</code></a> object.</p> <p>The <code>copyWithin</code> method is a mutable method. It does not alter the length of <code>this</code>, but will change its content and create new properties if necessary.</p> <h2 id=\"Examples\">Examples</h2> <pre data-language=\"js\">[1, 2, 3, 4, 5].copyWithin(-2);\n// [1, 2, 3, 1, 2]\n\n[1, 2, 3, 4, 5].copyWithin(0, 3);\n// [4, 5, 3, 4, 5]\n\n[1, 2, 3, 4, 5].copyWithin(0, 3, 4);\n// [4, 2, 3, 4, 5]\n\n[1, 2, 3, 4, 5].copyWithin(-2, -3, -1);\n// [1, 2, 3, 3, 4]\n\n[].copyWithin.call({length: 5, 3: 1}, 0, 3);\n// {0: 1, 3: 1, length: 5}\n\n// ES2015 Typed Arrays are subclasses of Array\nvar i32a = new Int32Array([1, 2, 3, 4, 5]);\n\ni32a.copyWithin(0, 2);\n// Int32Array [3, 4, 5, 4, 5]\n\n// On platforms that are not yet ES2015 compliant: \n[].copyWithin.call(new Int32Array([1, 2, 3, 4, 5]), 0, 3, 4);\n// Int32Array [4, 2, 3, 4, 5]\n</pre> <h2 id=\"Polyfill\">Polyfill</h2> <pre>if (!Array.prototype.copyWithin) {\n  Array.prototype.copyWithin = function(target, start/*, end*/) {\n    // Steps 1-2.\n    if (this == null) {\n      throw new TypeError('this is null or not defined');\n    }\n\n    var O = Object(this);\n\n    // Steps 3-5.\n    var len = O.length &gt;&gt;&gt; 0;\n\n    // Steps 6-8.\n    var relativeTarget = target &gt;&gt; 0;\n\n    var to = relativeTarget &lt; 0 ?\n      Math.max(len + relativeTarget, 0) :\n      Math.min(relativeTarget, len);\n\n    // Steps 9-11.\n    var relativeStart = start &gt;&gt; 0;\n\n    var from = relativeStart &lt; 0 ?\n      Math.max(len + relativeStart, 0) :\n      Math.min(relativeStart, len);\n\n    // Steps 12-14.\n    var end = arguments[2];\n    var relativeEnd = end === undefined ? len : end &gt;&gt; 0;\n\n    var final = relativeEnd &lt; 0 ?\n      Math.max(len + relativeEnd, 0) :\n      Math.min(relativeEnd, len);\n\n    // Step 15.\n    var count = Math.min(final - from, len - to);\n\n    // Steps 16-17.\n    var direction = 1;\n\n    if (from &lt; to &amp;&amp; to &lt; (from + count)) {\n      direction = -1;\n      from += count - 1;\n      to += count - 1;\n    }\n\n    // Step 18.\n    while (count &gt; 0) {\n      if (from in O) {\n        O[to] = O[from];\n      } else {\n        delete O[to];\n      }\n\n      from += direction;\n      to += direction;\n      count--;\n    }\n\n    // Step 19.\n    return O;\n  };\n}</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-array.prototype.copywithin\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Array.prototype.copyWithin' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/7.0/#sec-array.prototype.copywithin\" hreflang=\"en\">ECMAScript 2016 (ECMA-262)<br><small>The definition of 'Array.prototype.copyWithin' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-array.prototype.copywithin\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Array.prototype.copyWithin' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>   <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 45</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 32</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 32</td>\n<td class=\"bc-supports-yes\"> 9</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 32</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 4.0.0</td>\n</tr></tbody>\n</table>\n</div>  <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"../array\"><code>Array</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/copyWithin$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/copyWithin\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/copyWithin</a>\n  </p>\n</div>\n","global_objects/array/entries":"<h1>array.entries</h1> <p>The <code><strong>entries()</strong></code> method returns a new <code><strong>Array Iterator</strong></code> object that contains the key/value pairs for each index in the array.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/array-entries.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\"><var>array</var>.entries()</pre> <h3 id=\"Return_value\">Return value</h3> <p>A new <a href=\"../array\"><code>Array</code></a> iterator object.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Using_a_for…of_loop\">Using a <a href=\"../../statements/for...of\">for…of</a> loop</h3> <pre data-language=\"js\">var a = ['a', 'b', 'c'];\nvar iterator = a.entries();\n\nfor (let e of iterator) {\n  console.log(e);\n}\n// [0, 'a']\n// [1, 'b']\n// [2, 'c'] \n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-array.prototype.entries\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Array.prototype.entries' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-array.prototype.entries\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Array.prototype.entries' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>   <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 38</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 28</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 25</td>\n<td class=\"bc-supports-yes\"> 8</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 28</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 8</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 0.12</td>\n</tr></tbody>\n</table>\n</div>  <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"keys\"><code>Array.prototype.keys()</code></a></li> <li><a href=\"values\"><code>Array.prototype.values()</code></a></li> <li><a href=\"foreach\"><code>Array.prototype.forEach()</code></a></li> <li><a href=\"every\"><code>Array.prototype.every()</code></a></li> <li><a href=\"some\"><code>Array.prototype.some()</code></a></li> <li><a href=\"../../statements/for...of\">for...of</a></li> <li><a href=\"../../iteration_protocols\">Iteration protocols</a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/entries$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/entries\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/entries</a>\n  </p>\n</div>\n","global_objects/array/fill":"<h1>array.fill</h1> <p>The <code><strong>fill()</strong></code> method fills all the elements of an array from a start index to an end index with a static value. The end index is not included.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/array-fill.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\"><var>arr</var>.fill(<var>value[</var>, <var>start[<var>, <var>end]]</var>)</var></var>\n</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><code>value</code></dt> <dd>Value to fill an array.</dd> <dt>\n<code>start</code> <span class=\"inlineIndicator optional optionalInline\">Optional</span>\n</dt> <dd>Start index, defaults to 0.</dd> <dt>\n<code>end</code> <span class=\"inlineIndicator optional optionalInline\">Optional</span>\n</dt> <dd>End index, defaults to <code>this.length</code>.</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p>The modified array.</p> <h2 id=\"Description\">Description</h2> <p>The <code>fill</code> method takes up to three arguments <code>value</code>, <code>start</code> and <code>end</code>. The <code>start</code> and <code>end</code> arguments are optional with default values of <code>0</code> and the <code>length</code> of the <code>this</code> object.</p> <p>If <code>start</code> is negative, it is treated as <code>length+start</code> where <code>length</code> is the length of the array. If <code>end</code> is negative, it is treated as <code>length+end</code>.</p> <p><code>fill</code> is intentionally generic, it does not require that its <code>this</code> value be an Array object.</p> <p><code>fill</code> is a mutable method, it will change <code>this</code> object itself, and return it, not just return a copy of it.</p> <p>When <code>fill</code> gets passed an object, it will copy the reference and fill the array with references to that object.</p> <h2 id=\"Examples\">Examples</h2> <pre data-language=\"js\">[1, 2, 3].fill(4);               // [4, 4, 4]\n[1, 2, 3].fill(4, 1);            // [1, 4, 4]\n[1, 2, 3].fill(4, 1, 2);         // [1, 4, 3]\n[1, 2, 3].fill(4, 1, 1);         // [1, 2, 3]\n[1, 2, 3].fill(4, 3, 3);         // [1, 2, 3]\n[1, 2, 3].fill(4, -3, -2);       // [4, 2, 3]\n[1, 2, 3].fill(4, NaN, NaN);     // [1, 2, 3]\n[1, 2, 3].fill(4, 3, 5);         // [1, 2, 3]\nArray(3).fill(4);                // [4, 4, 4]\n[].fill.call({ length: 3 }, 4);  // {0: 4, 1: 4, 2: 4, length: 3}\n\n// Objects by reference.\nvar arr = Array(3).fill({}) // [{}, {}, {}];\narr[0].hi = \"hi\"; // [{ hi: \"hi\" }, { hi: \"hi\" }, { hi: \"hi\" }]\n</pre> <h2 id=\"Polyfill\">Polyfill</h2> <pre data-language=\"js\">if (!Array.prototype.fill) {\n  Object.defineProperty(Array.prototype, 'fill', {\n    value: function(value) {\n\n      // Steps 1-2.\n      if (this == null) {\n        throw new TypeError('this is null or not defined');\n      }\n\n      var O = Object(this);\n\n      // Steps 3-5.\n      var len = O.length &gt;&gt;&gt; 0;\n\n      // Steps 6-7.\n      var start = arguments[1];\n      var relativeStart = start &gt;&gt; 0;\n\n      // Step 8.\n      var k = relativeStart &lt; 0 ?\n        Math.max(len + relativeStart, 0) :\n        Math.min(relativeStart, len);\n\n      // Steps 9-10.\n      var end = arguments[2];\n      var relativeEnd = end === undefined ?\n        len : end &gt;&gt; 0;\n\n      // Step 11.\n      var final = relativeEnd &lt; 0 ?\n        Math.max(len + relativeEnd, 0) :\n        Math.min(relativeEnd, len);\n\n      // Step 12.\n      while (k &lt; final) {\n        O[k] = value;\n        k++;\n      }\n\n      // Step 13.\n      return O;\n    }\n  });\n}\n</pre> <p>If you need to support truly obsolete JavaScript engines that don't support <code><a href=\"../object/defineproperty\">Object.defineProperty</a></code>, it's best not to polyfill <code>Array.prototype</code> methods at all, as you can't make them non-enumerable.</p> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-array.prototype.fill\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Array.prototype.fill' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-array.prototype.fill\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Array.prototype.fill' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>   <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 45</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 31</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 8</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 31</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 8</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes bc-has-history\"> 4.0.0\n<section class=\"bc-history\" id=\"sect1\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 4.0.0\n</dt>\n\n<dt class=\"bc-supports-yes bc-supports\"> 0.12<div class=\"bc-icons\">Disabled </div>\n</dt>\n<dd>Disabled From version 0.12: this feature is behind the <code>--harmony</code> runtime flag.</dd>\n</dl></section>\n</td>\n</tr></tbody>\n</table>\n</div>  <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"../array\"><code>Array</code></a></li> <li><a href=\"../typedarray/fill\"><code>TypedArray.prototype.fill()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/fill$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/fill\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/fill</a>\n  </p>\n</div>\n","global_objects/array/filter":"<h1>array.filter</h1> <p>The <code><strong>filter()</strong></code> method creates a new array with all elements that pass the test implemented by the provided function.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/array-filter.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\"><var>var newArray = arr</var>.filter(<var>callback(element[, index[, array]])</var>[, <var>thisArg</var>])</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><code>callback</code></dt> <dd>Function is a predicate, to test each element of the array. Return <code>true</code> to keep the element, <code>false</code> otherwise. It accepts three arguments:</dd> <dd> <dl> <dt><code>element</code></dt> <dd>The current element being processed in the array.</dd> <dt>\n<code>index</code><span class=\"inlineIndicator optional optionalInline\">Optional</span>\n</dt> <dd>The index of the current element being processed in the array.</dd> <dt>\n<code>array</code><span class=\"inlineIndicator optional optionalInline\">Optional</span>\n</dt> <dd>The array <code>filter</code> was called upon.</dd> </dl> </dd> <dt>\n<code>thisArg</code><span class=\"inlineIndicator optional optionalInline\">Optional</span>\n</dt> <dd>Optional. Value to use as <code>this</code> when executing <code>callback</code>.</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p>A new array with the elements that pass the test. If no elements pass the test, an empty array will be returned.</p> <h2 id=\"Description\">Description</h2> <p><code>filter()</code> calls a provided <code>callback</code> function once for each element in an array, and constructs a new array of all the values for which <code>callback</code> returns <a href=\"https://developer.mozilla.org/en-US/docs/Glossary/Truthy\">a value that coerces to <code>true</code></a>. <code>callback</code> is invoked only for indexes of the array which have assigned values; it is not invoked for indexes which have been deleted or which have never been assigned values. Array elements which do not pass the <code>callback</code> test are simply skipped, and are not included in the new array.</p> <p><code>callback</code> is invoked with three arguments:</p> <ol> <li>the value of the element</li> <li>the index of the element</li> <li>the Array object being traversed</li> </ol> <p>If a <code>thisArg</code> parameter is provided to <code>filter</code>, it will be used as the callback's <code>this</code> value. Otherwise, the value <code>undefined</code> will be used as its <code>this</code> value. The <code>this</code> value ultimately observable by <code>callback</code> is determined according to <a href=\"../../operators/this\">the usual rules for determining the <code>this</code> seen by a function</a>.</p> <p><code>filter()</code> does not mutate the array on which it is called.</p> <p>The range of elements processed by <code>filter()</code> is set before the first invocation of <code>callback</code>. Elements which are appended to the array after the call to <code>filter()</code> begins will not be visited by <code>callback</code>. If existing elements of the array are changed, or deleted, their value as passed to <code>callback</code> will be the value at the time <code>filter()</code> visits them; elements that are deleted are not visited.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Filtering_out_all_small_values\">Filtering out all small values</h3> <p>The following example uses <code>filter()</code> to create a filtered array that has all elements with values less than 10 removed.</p> <pre data-language=\"js\">function isBigEnough(value) {\n  return value &gt;= 10;\n}\n\nvar filtered = [12, 5, 8, 130, 44].filter(isBigEnough);\n// filtered is [12, 130, 44]\n</pre> <h3 id=\"Filtering_invalid_entries_from_JSON\">Filtering invalid entries from JSON</h3> <p>The following example uses <code>filter()</code> to create a filtered json of all elements with non-zero, numeric <code>id</code>.</p> <pre data-language=\"js\">var arr = [\n  { id: 15 },\n  { id: -1 },\n  { id: 0 },\n  { id: 3 },\n  { id: 12.2 },\n  { },\n  { id: null },\n  { id: NaN },\n  { id: 'undefined' }\n];\n\nvar invalidEntries = 0;\n\nfunction isNumber(obj) {\n  return obj !== undefined &amp;&amp; typeof(obj) === 'number' &amp;&amp; !isNaN(obj);\n}\n\nfunction filterByID(item) {\n  if (isNumber(item.id) &amp;&amp; item.id !== 0) {\n    return true;\n  } \n  invalidEntries++;\n  return false; \n}\n\nvar arrByID = arr.filter(filterByID);\n\nconsole.log('Filtered Array\\n', arrByID); \n// Filtered Array\n// [{ id: 15 }, { id: -1 }, { id: 3 }, { id: 12.2 }]\n\nconsole.log('Number of Invalid Entries = ', invalidEntries); \n// Number of Invalid Entries = 5\n</pre> <h3 id=\"Searching_in_array\">Searching in array</h3> <p>Following example uses filter() to filter array content based on search criteria</p> <pre data-language=\"js\">var fruits = ['apple', 'banana', 'grapes', 'mango', 'orange'];\n\n/**\n * Array filters items based on search criteria (query)\n */\nfunction filterItems(query) {\n  return fruits.filter(function(el) {\n      return el.toLowerCase().indexOf(query.toLowerCase()) &gt; -1;\n  })\n}\n\nconsole.log(filterItems('ap')); // ['apple', 'grapes']\nconsole.log(filterItems('an')); // ['banana', 'mango', 'orange']</pre> <h3 id=\"ES2015_Implementation\">ES2015 Implementation</h3> <pre data-language=\"js\">const fruits = ['apple', 'banana', 'grapes', 'mango', 'orange'];\n\n/**\n * Array filters items based on search criteria (query)\n */\nconst filterItems = (query) =&gt; {\n  return fruits.filter((el) =&gt;\n    el.toLowerCase().indexOf(query.toLowerCase()) &gt; -1\n  );\n}\n\nconsole.log(filterItems('ap')); // ['apple', 'grapes']\nconsole.log(filterItems('an')); // ['banana', 'mango', 'orange']\n\n</pre> <h2 id=\"Polyfill\">Polyfill</h2> <p><code>filter()</code> was added to the ECMA-262 standard in the 5th edition; as such it may not be present in all implementations of the standard. You can work around this by inserting the following code at the beginning of your scripts, allowing use of <code>filter()</code> in ECMA-262 implementations which do not natively support it. This algorithm is exactly equivalent to the one specified in ECMA-262, 5th edition, assuming that <code>fn.call</code> evaluates to the original value of <a href=\"../function/bind\"><code>Function.prototype.bind()</code></a>, and that <a href=\"push\"><code>Array.prototype.push()</code></a> has its original value.</p> <pre data-language=\"js\">if (!Array.prototype.filter){\n  Array.prototype.filter = function(func, thisArg) {\n    'use strict';\n    if ( ! ((typeof func === 'Function' || typeof func === 'function') &amp;&amp; this) )\n        throw new TypeError();\n   \n    var len = this.length &gt;&gt;&gt; 0,\n        res = new Array(len), // preallocate array\n        t = this, c = 0, i = -1;\n    if (thisArg === undefined){\n      while (++i !== len){\n        // checks to see if the key was set\n        if (i in this){\n          if (func(t[i], i, t)){\n            res[c++] = t[i];\n          }\n        }\n      }\n    }\n    else{\n      while (++i !== len){\n        // checks to see if the key was set\n        if (i in this){\n          if (func.call(thisArg, t[i], i, t)){\n            res[c++] = t[i];\n          }\n        }\n      }\n    }\n   \n    res.length = c; // shrink down array to proper size\n    return res;\n  };\n}</pre>  <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/5.1/#sec-15.4.4.20\" hreflang=\"en\">ECMAScript 5.1 (ECMA-262)<br><small>The definition of 'Array.prototype.filter' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition. Implemented in JavaScript 1.6.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-array.prototype.filter\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Array.prototype.filter' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-array.prototype.filter\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Array.prototype.filter' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>   <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1.5</td>\n<td class=\"bc-supports-yes\"> 9</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div>  <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"foreach\"><code>Array.prototype.forEach()</code></a></li> <li><a href=\"every\"><code>Array.prototype.every()</code></a></li> <li><a href=\"some\"><code>Array.prototype.some()</code></a></li> <li><a href=\"reduce\"><code>Array.prototype.reduce()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/filter$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/filter\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/filter</a>\n  </p>\n</div>\n","global_objects/array/find":"<h1>array.find</h1> <p>The <code><strong>find()</strong></code> method returns the <strong>value</strong> of the <strong>first element</strong> in the array that satisfies the provided testing function. Otherwise <a href=\"../undefined\"><code>undefined</code></a> is returned.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/array-find.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <p>See also the <a href=\"findindex\"><code>findIndex()</code></a> method, which returns the <strong>index</strong> of a found element in the array instead of its value.</p> <p>If you need to find the position of an element or whether an element exists in an array, use <a href=\"indexof\"><code>Array.prototype.indexOf()</code></a> or <a href=\"includes\"><code>Array.prototype.includes()</code></a>.</p> <h2 id=\"Syntax\">Syntax</h2> <pre><var>arr</var>.find(callback(element[, index[, array]])[, thisArg])</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><code>callback</code></dt> <dd>Function to execute on each value in the array, taking three arguments: <dl> <dt><code>element</code></dt> <dd>The current element being processed in the array.</dd> <dt>\n<code>index</code><span class=\"inlineIndicator optional optionalInline\">Optional</span>\n</dt> <dd>The index of the current element being processed in the array.</dd> <dt>\n<code>array</code><span class=\"inlineIndicator optional optionalInline\">Optional</span>\n</dt> <dd>The array <code>find</code> was called upon.</dd> </dl> </dd> <dt>\n<code>thisArg</code> <span class=\"inlineIndicator optional optionalInline\">Optional</span>\n</dt> <dd>Object to use as <code>this</code> when executing <code>callback</code>.</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p>The <strong>value</strong> of the <strong>first element</strong> in the array that satisfies the provided testing function; otherwise, <a href=\"../undefined\"><code>undefined</code></a> is returned.</p> <h2 id=\"Description\">Description</h2> <p>The <code>find</code> method executes the <code>callback</code> function once for each index of the array until it finds one where <code>callback</code> returns a true value. If such an element is found, <code>find</code> immediately returns the value of that element. Otherwise, <code>find</code> returns <a href=\"../undefined\"><code>undefined</code></a>. <code>callback</code> is invoked for every index of the array from <code>0</code> to <code>length - 1</code> and is invoked for all indexes, not just those that have been assigned values. This may mean that it's less efficient for sparse arrays than other methods that only visit indexes that have been assigned a value.</p> <p><code>callback</code> is invoked with three arguments: the value of the element, the index of the element, and the Array object being traversed.</p> <p>If a <code>thisArg</code> parameter is provided to <code>find</code>, it will be used as the <code>this</code> for each invocation of the <code>callback</code>. If it is not provided, then <a href=\"../undefined\"><code>undefined</code></a> is used.</p> <p><code>find</code> does not mutate the array on which it is called.</p> <p>The range of elements processed by <code>find</code> is set before the first invocation of <code>callback</code>. Elements that are appended to the array after the call to <code>find</code> begins will not be visited by <code>callback</code>. If an existing, unvisited element of the array is changed by <code>callback</code>, its value passed to the visiting <code>callback</code> will be the value at the time that <code>find</code> visits that element's index; elements that are deleted are still visited.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Find_an_object_in_an_array_by_one_of_its_properties\">Find an object in an array by one of its properties</h3> <pre data-language=\"js\">var inventory = [\n    {name: 'apples', quantity: 2},\n    {name: 'bananas', quantity: 0},\n    {name: 'cherries', quantity: 5}\n];\n\nfunction isCherries(fruit) { \n    return fruit.name === 'cherries';\n}\n\nconsole.log(inventory.find(isCherries)); \n// { name: 'cherries', quantity: 5 }</pre> <h4 id=\"Using_ES2015_arrow_function\">Using ES2015 arrow function</h4> <pre data-language=\"js\">const inventory = [\n    {name: 'apples', quantity: 2},\n    {name: 'bananas', quantity: 0},\n    {name: 'cherries', quantity: 5}\n];\n\nconst result = inventory.find( fruit =&gt; fruit.name === 'cherries' );\n\nconsole.log(result) // { name: 'cherries', quantity: 5 }</pre> <h3 id=\"Find_a_prime_number_in_an_array\">Find a prime number in an array</h3> <p>The following example finds an element in the array that is a prime number (or returns <a href=\"../undefined\"><code>undefined</code></a> if there is no prime number).</p> <pre data-language=\"js\">function isPrime(element, index, array) {\n  var start = 2;\n  while (start &lt;= Math.sqrt(element)) {\n    if (element % start++ &lt; 1) {\n      return false;\n    }\n  }\n  return element &gt; 1;\n}\n\nconsole.log([4, 6, 8, 12].find(isPrime)); // undefined, not found\nconsole.log([4, 5, 8, 12].find(isPrime)); // 5\n</pre> <p>The following examples show that non-existent and deleted elements are visited and that the value passed to the callback is their value when visited.</p> <pre data-language=\"js\">// Declare array with no element at index 2, 3 and 4\nvar array = [0,1,,,,5,6];\n\n// Shows all indexes, not just those that have been assigned values\narray.find(function(value, index) {\n  console.log('Visited index ' + index + ' with value ' + value); \n});\n\n// Shows all indexes, including deleted\narray.find(function(value, index) {\n\n  // Delete element 5 on first iteration\n  if (index == 0) {\n    console.log('Deleting array[5] with value ' + array[5]);\n    delete array[5];\n  }\n  // Element 5 is still visited even though deleted\n  console.log('Visited index ' + index + ' with value ' + value); \n});\n// expected output:\n// Deleting array[5] with value 5 \n// Visited index 0 with value 0 \n// Visited index 1 with value 1 \n// Visited index 2 with value undefined \n// Visited index 3 with value undefined \n// Visited index 4 with value undefined \n// Visited index 5 with value undefined \n// Visited index 6 with value 6\n</pre> <h2 id=\"Polyfill\">Polyfill</h2> <p>This method has been added to the ECMAScript 2015 specification and may not be available in all JavaScript implementations yet. However, you can polyfill <code>Array.prototype.find</code> with the following snippet:</p> <pre data-language=\"js\">// https://tc39.github.io/ecma262/#sec-array.prototype.find\nif (!Array.prototype.find) {\n  Object.defineProperty(Array.prototype, 'find', {\n    value: function(predicate) {\n     // 1. Let O be ? ToObject(this value).\n      if (this == null) {\n        throw new TypeError('\"this\" is null or not defined');\n      }\n\n      var o = Object(this);\n\n      // 2. Let len be ? ToLength(? Get(O, \"length\")).\n      var len = o.length &gt;&gt;&gt; 0;\n\n      // 3. If IsCallable(predicate) is false, throw a TypeError exception.\n      if (typeof predicate !== 'function') {\n        throw new TypeError('predicate must be a function');\n      }\n\n      // 4. If thisArg was supplied, let T be thisArg; else let T be undefined.\n      var thisArg = arguments[1];\n\n      // 5. Let k be 0.\n      var k = 0;\n\n      // 6. Repeat, while k &lt; len\n      while (k &lt; len) {\n        // a. Let Pk be ! ToString(k).\n        // b. Let kValue be ? Get(O, Pk).\n        // c. Let testResult be ToBoolean(? Call(predicate, T, « kValue, k, O »)).\n        // d. If testResult is true, return kValue.\n        var kValue = o[k];\n        if (predicate.call(thisArg, kValue, k, o)) {\n          return kValue;\n        }\n        // e. Increase k by 1.\n        k++;\n      }\n\n      // 7. Return undefined.\n      return undefined;\n    },\n    configurable: true,\n    writable: true\n  });\n}\n</pre> <p>If you need to support truly obsolete JavaScript engines that don't support <code><a href=\"../object/defineproperty\">Object.defineProperty</a></code>, it's best not to polyfill <code>Array.prototype</code> methods at all, as you can't make them non-enumerable.</p> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-array.prototype.find\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Array.prototype.find' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-array.prototype.find\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Array.prototype.find' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>   <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 45</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 25</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 32</td>\n<td class=\"bc-supports-yes\"> 8</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 8</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes bc-has-history\"> 4.0.0\n<section class=\"bc-history\" id=\"sect1\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 4.0.0\n</dt>\n\n<dt class=\"bc-supports-yes bc-supports\"> 0.12<div class=\"bc-icons\">Disabled </div>\n</dt>\n<dd>Disabled From version 0.12: this feature is behind the <code>--harmony</code> runtime flag.</dd>\n</dl></section>\n</td>\n</tr></tbody>\n</table>\n</div>  <h2 id=\"See_also\">See also</h2> <ul> <li>\n<a href=\"findindex\"><code>Array.prototype.findIndex()</code></a> – find and return an index</li> <li>\n<a href=\"includes\"><code>Array.prototype.includes()</code></a> – test whether a value exists in the array</li> <li>\n<a href=\"filter\"><code>Array.prototype.filter()</code></a> – find all matching elements</li> <li>\n<a href=\"every\"><code>Array.prototype.every()</code></a> – test all elements together</li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/find$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/find\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/find</a>\n  </p>\n</div>\n","global_objects/array/keys":"<h1>array.keys</h1> <p>The <code><strong>keys()</strong></code> method returns a new <code><strong>Array Iterator</strong></code> object that contains the keys for each index in the array.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/array-keys.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\"><var>arr</var>.keys()</pre> <h3 id=\"Return_value\">Return value</h3> <p>A new <a href=\"../array\"><code>Array</code></a> iterator object.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Key_iterator_doesn't_ignore_holes\">Key iterator doesn't ignore holes</h3> <pre data-language=\"js\">var arr = ['a', , 'c'];\nvar sparseKeys = Object.keys(arr);\nvar denseKeys = [...arr.keys()];\nconsole.log(sparseKeys); // ['0', '2']\nconsole.log(denseKeys);  // [0, 1, 2]\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-array.prototype.keys\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Array.prototype.keys' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-array.prototype.keys\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Array.prototype.keys' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>   <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 38</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 28</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 25</td>\n<td class=\"bc-supports-yes\"> 8</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 28</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 8</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 0.12</td>\n</tr></tbody>\n</table>\n</div>  <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"values\"><code>Array.prototype.values()</code></a></li> <li><a href=\"entries\"><code>Array.prototype.entries()</code></a></li> <li><a href=\"../../iteration_protocols\">Iteration protocols</a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/keys$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/keys\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/keys</a>\n  </p>\n</div>\n","global_objects/array/findindex":"<h1>array.findIndex</h1> <p>The <code><strong>findIndex()</strong></code> method returns the <strong>index</strong> of the first element in the array <strong>that satisfies the provided testing function</strong>. Otherwise, it returns -1, indicating no element passed the test.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/array-findindex.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <p>See also the <a href=\"find\"><code>find()</code></a> method, which returns the <strong>value</strong> of an array element, instead of that element's index.</p> <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\"><var>arr</var>.findIndex(callback(element[, index[, array]])[, thisArg])</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><code>callback</code></dt> <dd>A function to execute on each value in the array until the function returns <code>true</code>, indicating the desired element was found. It takes 3 arguments: <dl> <dt><code>element</code></dt> <dd>The current element being processed in the array.</dd> <dt>\n<code>index</code><span class=\"inlineIndicator optional optionalInline\">Optional</span>\n</dt> <dd>The index of the current element being processed in the array.</dd> <dt>\n<code>array</code><span class=\"inlineIndicator optional optionalInline\">Optional</span>\n</dt> <dd>The array <code>findIndex</code> was called upon.</dd> </dl> </dd> <dt>\n<code>thisArg</code><span class=\"inlineIndicator optional optionalInline\">Optional</span>\n</dt> <dd>Optional. Object to use as <code>this</code> when executing <code>callback</code>.</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p>An index in the array if an element passes the test; otherwise, <strong>-1</strong>.</p> <h2 id=\"Description\">Description</h2> <p>The <code>findIndex</code> method executes the <code>callback</code> function once for every array index <code>0..length-1</code> (inclusive) in the array until it finds one where <code>callback</code> returns a truthy value (a value that <a href=\"https://developer.mozilla.org/en-US/docs/Glossary/Type_Conversion\">coerces</a> to <code>true</code>).</p> <p>If such an element is found, <code>findIndex</code> immediately returns that found element's index. If the callback never returns a truthy value or the array's <code>length</code> is 0, <code>findIndex</code> returns -1. Unlike some other array methods such as <a href=\"some\"><code>Array.some</code></a>, in sparse arrays the <code>callback</code> <strong>is called</strong> even for indexes of entries not present in the array.</p> <p><code>callback</code> is invoked with 3 arguments:</p> <ol> <li>The value of the element</li> <li>The index of the element</li> <li>The Array object being traversed</li> </ol> <p>If a <code>thisArg</code> parameter is passed to <code>findIndex</code>, it will be used as the <code>this</code> inside each invocation of the <code>callback</code>. If it is not provided, then <a href=\"../undefined\"><code>undefined</code></a> is used.</p> <p>The range of elements processed by <code>findIndex</code> is set before the first invocation of <code>callback</code>. Elements appended to the array after the call to <code>findIndex</code> begins will not be processed by <code>callback</code>. If an existing, unvisited element of the array is changed by <code>callback</code>, its value passed to the <code>callback</code> will be the value at the time that <code>findIndex</code> visits that element's index; elements that are <a href=\"../../operators/delete\">deleted</a> are still visited.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Find_the_index_of_a_prime_number_in_an_array\">Find the index of a prime number in an array</h3> <p>The following example returns the index of an element in the array that is a prime number, or -1 if there is no prime number.</p> <pre data-language=\"js\">function isPrime(element, index, array) {\n  var start = 2;\n  while (start &lt;= Math.sqrt(element)) {\n    if (element % start &lt; 1) {\n      return false;\n    } else {\n      start++;\n    }\n  }\n  return element &gt; 1;\n}\n\nconsole.log([4, 6, 8, 12].findIndex(isPrime)); // -1, not found\nconsole.log([4, 6, 7, 12].findIndex(isPrime)); // 2 (array[2] is 7)\n</pre> <h3 id=\"Find_index_using_arrow_function\">Find index using arrow function</h3> <p>The following example finds the index of a fruit using an arrow function:</p> <pre data-language=\"js\">const fruits = [\"apple\", \"banana\", \"cantaloupe\", \"blueberries\", \"grapefruit\"];\n\nconst index = fruits.findIndex(fruit =&gt; fruit === \"blueberries\");\n\nconsole.log(index); // 3\nconsole.log(fruits[index]); // blueberries\n</pre> <h2 id=\"Polyfill\">Polyfill</h2> <pre data-language=\"js\">// https://tc39.github.io/ecma262/#sec-array.prototype.findindex\nif (!Array.prototype.findIndex) {\n  Object.defineProperty(Array.prototype, 'findIndex', {\n    value: function(predicate) {\n     // 1. Let O be ? ToObject(this value).\n      if (this == null) {\n        throw new TypeError('\"this\" is null or not defined');\n      }\n\n      var o = Object(this);\n\n      // 2. Let len be ? ToLength(? Get(O, \"length\")).\n      var len = o.length &gt;&gt;&gt; 0;\n\n      // 3. If IsCallable(predicate) is false, throw a TypeError exception.\n      if (typeof predicate !== 'function') {\n        throw new TypeError('predicate must be a function');\n      }\n\n      // 4. If thisArg was supplied, let T be thisArg; else let T be undefined.\n      var thisArg = arguments[1];\n\n      // 5. Let k be 0.\n      var k = 0;\n\n      // 6. Repeat, while k &lt; len\n      while (k &lt; len) {\n        // a. Let Pk be ! ToString(k).\n        // b. Let kValue be ? Get(O, Pk).\n        // c. Let testResult be ToBoolean(? Call(predicate, T, « kValue, k, O »)).\n        // d. If testResult is true, return k.\n        var kValue = o[k];\n        if (predicate.call(thisArg, kValue, k, o)) {\n          return k;\n        }\n        // e. Increase k by 1.\n        k++;\n      }\n\n      // 7. Return -1.\n      return -1;\n    },\n    configurable: true,\n    writable: true\n  });\n}\n</pre> <p>If you need to support truly obsolete JavaScript engines that don't support <code><a href=\"../object/defineproperty\">Object.defineProperty</a></code>, it's best not to polyfill <code>Array.prototype</code> methods at all, as you can't make them non-enumerable.</p> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-array.prototype.findindex\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Array.prototype.findIndex' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-array.prototype.findIndex\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Array.prototype.findIndex' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>   <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 45</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 25</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 32</td>\n<td class=\"bc-supports-yes\"> 8</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 8</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes bc-has-history\"> 4.0.0\n<section class=\"bc-history\" id=\"sect1\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 4.0.0\n</dt>\n\n<dt class=\"bc-supports-yes bc-supports\"> 0.12<div class=\"bc-icons\">Disabled </div>\n</dt>\n<dd>Disabled From version 0.12: this feature is behind the <code>--harmony</code> runtime flag.</dd>\n</dl></section>\n</td>\n</tr></tbody>\n</table>\n</div>  <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"find\"><code>Array.prototype.find()</code></a></li> <li><a href=\"indexof\"><code>Array.prototype.indexOf()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/findIndex$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/findIndex\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/findIndex</a>\n  </p>\n</div>\n","global_objects/typedarray/tolocalestring":"<h1>typedArray.toLocaleString</h1> <p>The <code><strong>toLocaleString()</strong></code> method returns a string representing the elements of the typed array. The elements are converted to strings and are separated by a locale-specific string (such as a comma “,”). This method has the same algorithm as <a href=\"../array/tolocalestring\"><code>Array.prototype.toLocaleString()</code></a> and, as the typed array elements are numbers, the same algorithm as <a href=\"../number/tolocalestring\"><code>Number.prototype.toLocaleString()</code></a> applies for each element. <em>TypedArray</em> is one of the <a href=\"../typedarray#TypedArray_objects\">typed array types</a> here.</p> <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\"><var>typedarr</var>ay.toLocaleString([locales [, options]]);</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><code>locales</code></dt> <dd> <p>Optional. A string with a BCP 47 language tag, or an array of such strings. For the general form and interpretation of the <code>locales</code> argument, see the <a href=\"../intl#Locale_identification_and_negotiation\">Intl page</a>. The following Unicode extension key is allowed:</p> <dl> <dt><code>nu</code></dt> <dd>The numbering system to be used. Possible values include: <code>\"arab\"</code>, <code>\"arabext\"</code>, <code>\"bali\"</code>, <code>\"beng\"</code>, <code>\"deva\"</code>, <code>\"fullwide\"</code>, <code>\"gujr\"</code>, <code>\"guru\"</code>, <code>\"hanidec\"</code>, <code>\"khmr\"</code>, <code>\"knda\"</code>, <code>\"laoo\"</code>, <code>\"latn\"</code>, <code>\"limb\"</code>, <code>\"mlym\"</code>, <code>\"mong\"</code>, <code>\"mymr\"</code>, <code>\"orya\"</code>, <code>\"tamldec\"</code>, <code>\"telu\"</code>, <code>\"thai\"</code>, <code>\"tibt\"</code>.</dd> </dl> </dd> <dt><code>options</code></dt> <dd> <p>Optional. An object with some or all of the following properties:</p> <dl> <dt><code>localeMatcher</code></dt> <dd>The locale matching algorithm to use. Possible values are <code>\"lookup\"</code> and <code>\"best fit\"</code>; the default is <code>\"best fit\"</code>. For information about this option, see the <a href=\"../intl#Locale_negotiation\">Intl page</a>.</dd> <dt><code>style</code></dt> <dd>The formatting style to use. Possible values are <code>\"decimal\"</code> for plain number formatting, <code>\"currency\"</code> for currency formatting, and <code>\"percent\"</code> for percent formatting; the default is <code>\"decimal\"</code>.</dd> <dt><code>currency</code></dt> <dd>The currency to use in currency formatting. Possible values are the ISO 4217 currency codes, such as <code>\"USD\"</code> for the US dollar, <code>\"EUR\"</code> for the euro, or <code>\"CNY\"</code> for the Chinese RMB — see the <a href=\"http://www.currency-iso.org/en/home/tables/table-a1.html\">Current currency &amp; funds code list</a>. There is no default value; if the <code>style</code> is <code>\"currency\"</code>, the <code>currency</code> property must be provided.</dd> <dt><code>currencyDisplay</code></dt> <dd>How to display the currency in currency formatting. Possible values are <code>\"symbol\"</code> to use a localized currency symbol such as €, <code>\"code\"</code> to use the ISO currency code, <code>\"name\"</code> to use a localized currency name such as <code>\"dollar\"</code>; the default is <code>\"symbol\"</code>.</dd> <dt><code>useGrouping</code></dt> <dd>Whether to use grouping separators, such as thousands separators or thousand/lakh/crore separators. Possible values are <code>true</code> and <code>false</code>; the default is <code>true</code>.</dd> </dl> <p>The following properties fall into two groups: <code>minimumIntegerDigits</code>, <code>minimumFractionDigits</code>, and <code>maximumFractionDigits</code> in one group, <code>minimumSignificantDigits</code> and <code>maximumSignificantDigits</code> in the other. If at least one property from the second group is defined, then the first group is ignored.</p> <dl> <dt><code>minimumIntegerDigits</code></dt> <dd>The minimum number of integer digits to use. Possible values are from 1 to 21; the default is 1.</dd> <dt><code>minimumFractionDigits</code></dt> <dd>The minimum number of fraction digits to use. Possible values are from 0 to 20; the default for plain number and percent formatting is 0; the default for currency formatting is the number of minor unit digits provided by the <a href=\"http://www.currency-iso.org/en/home/tables/table-a1.html\">ISO 4217 currency code list</a> (2 if the list doesn't provide that information).</dd> <dt><code>maximumFractionDigits</code></dt> <dd>The maximum number of fraction digits to use. Possible values are from 0 to 20; the default for plain number formatting is the larger of <code>minimumFractionDigits</code> and 3; the default for currency formatting is the larger of <code>minimumFractionDigits</code> and the number of minor unit digits provided by the <a href=\"http://www.currency-iso.org/en/home/tables/table-a1.html\">ISO 4217 currency code list</a> (2 if the list doesn't provide that information); the default for percent formatting is the larger of <code>minimumFractionDigits</code> and 0.</dd> <dt><code>minimumSignificantDigits</code></dt> <dd>The minimum number of significant digits to use. Possible values are from 1 to 21; the default is 1.</dd> <dt><code>maximumSignificantDigits</code></dt> <dd>The maximum number of significant digits to use. Possible values are from 1 to 21; the default is 21.</dd> </dl> </dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p>A string representing the elements of the typed array.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Using_toLocaleString\">Using <code>toLocaleString</code>\n</h3> <pre data-language=\"js\">var uint = new Uint32Array([2000, 500, 8123, 12, 4212]);\n\nuint.toLocaleString(); \n// if run in a de-DE locale\n// \"2.000,500,8.123,12,4.212\"\n\nuint.toLocaleString('en-US');\n// \"2,000,500,8,123,12,4,212\"\n\nuint.toLocaleString('ja-JP', { style: 'currency', currency: 'JPY' });\n// \"￥2,000,￥500,￥8,123,￥12,￥4,212\"\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"#\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'TypedArray.prototype.toLocaleString' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"#\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'TypedArray.prototype.toLocaleString' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>   <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 51</td>\n<td class=\"bc-supports-yes\"> 10</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 51</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td> ? </td>\n</tr></tbody>\n</table>\n</div>  <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"../array/tolocalestring\"><code>Array.prototype.toLocaleString()</code></a></li> <li><a href=\"../number/tolocalestring\"><code>Number.prototype.toLocaleString()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/toLocaleString$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/toLocaleString\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/toLocaleString</a>\n  </p>\n</div>\n","global_objects/array/every":"<h1>array.every</h1> <p>The <code><strong>every()</strong></code> method tests whether all elements in the array pass the test implemented by the provided function.</p> <div class=\"note\"> <p><strong>Note</strong>: This method returns <code>true</code> for any condition put on an empty array.</p> </div> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/array-every.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\"><var>arr</var>.ev<var>ery</var>(<var>callback(element[, index[, array]])</var>[, <var>thisArg</var>])</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><code>callback</code></dt> <dd>Function to test for each element, taking three arguments: <dl> <dt><code>element</code></dt> <dd>The current element being processed in the array.</dd> <dt>\n<code>index</code><span class=\"inlineIndicator optional optionalInline\">Optional</span>\n</dt> <dd>The index of the current element being processed in the array.</dd> <dt>\n<code>array</code><span class=\"inlineIndicator optional optionalInline\">Optional</span>\n</dt> <dd>The array <code>every</code> was called upon.</dd> </dl> </dd> <dt>\n<code>thisArg</code><span class=\"inlineIndicator optional optionalInline\">Optional</span>\n</dt> <dd>Optional. Value to use as <code>this</code> when executing <code>callback</code>.</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p><code><strong>true</strong></code> if the callback function returns a <a href=\"https://developer.mozilla.org/en-US/docs/Glossary/truthy\">truthy</a> value for every array element; otherwise, <code><strong>false</strong></code>.</p> <h2 id=\"Description\">Description</h2> <p>The <code>every</code> method executes the provided <code>callback</code> function once for each element present in the array until it finds one where <code>callback</code> returns a <a href=\"https://developer.mozilla.org/en-US/docs/Glossary/falsy\">falsy</a> value. If such an element is found, the <code>every</code> method immediately returns <code>false</code>. Otherwise, if <code>callback</code> returns a <a href=\"https://developer.mozilla.org/en-US/docs/Glossary/truthy\">truthy</a> value for all elements, <code>every</code> returns <code>true</code>. <code>callback</code> is invoked only for indexes of the array which have assigned values; it is not invoked for indexes which have been deleted or which have never been assigned values.</p> <p><code>callback</code> is invoked with three arguments: the value of the element, the index of the element, and the Array object being traversed.</p> <p>If a <code>thisArg</code> parameter is provided to <code>every</code>, it will be used as callback's <code>this</code> value. Otherwise, the value <code>undefined</code> will be used as its <code>this</code> value. The <code>this</code> value ultimately observable by <code>callback</code> is determined according to <a href=\"../../operators/this\">the usual rules for determining the <code>this</code> seen by a function</a>.</p> <p><code>every</code> does not mutate the array on which it is called.</p> <p>The range of elements processed by <code>every</code> is set before the first invocation of <code>callback</code>. Elements which are appended to the array after the call to <code>every</code> begins will not be visited by <code>callback</code>. If existing elements of the array are changed, their value as passed to <code>callback</code> will be the value at the time <code>every</code> visits them; elements that are deleted are not visited.</p> <p><code>every</code> acts like the \"for all\" quantifier in mathematics. In particular, for an empty array, it returns true. (It is <a href=\"http://en.wikipedia.org/wiki/Vacuous_truth\">vacuously true</a> that all elements of the <a href=\"https://en.wikipedia.org/wiki/Empty_set#Properties\">empty set</a> satisfy any given condition.)</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Testing_size_of_all_array_elements\">Testing size of all array elements</h3> <p>The following example tests whether all elements in the array are bigger than 10.</p> <pre data-language=\"js\">function isBigEnough(element, index, array) {\n  return element &gt;= 10;\n}\n[12, 5, 8, 130, 44].every(isBigEnough);   // false\n[12, 54, 18, 130, 44].every(isBigEnough); // true\n</pre> <h3 id=\"Testing_every_object_of_an_array_for_a_value\">Testing every object of an array for a value</h3> <pre data-language=\"js\">[{a:1, b:2, c:3, d:4}, {a:1, x:2, y:3, z:4}, {a:1, x:2, y:3, z:4}].every(obj =&gt; obj.a === 1); //true\n[{a:1, b:2, c:3, d:4}, {a:1, x:2, y:3, z:4}, {a:2, x:2, y:3, z:4}].every(obj =&gt; obj.a === 1); //false</pre> <h3 id=\"Using_arrow_functions\">Using arrow functions</h3> <p><a href=\"../../functions/arrow_functions\">Arrow functions</a> provide a shorter syntax for the same test.</p> <pre data-language=\"js\">[12, 5, 8, 130, 44].every(x =&gt; x &gt;= 10); // false\n[12, 54, 18, 130, 44].every(x =&gt; x &gt;= 10); // true</pre> <h2 id=\"Polyfill\">Polyfill</h2> <p><code>every</code> was added to the ECMA-262 standard in the 5th edition; as such it may not be present in other implementations of the standard. You can work around this by inserting the following code at the beginning of your scripts, allowing use of <code>every</code> in implementations which do not natively support it. This algorithm is exactly the one specified in ECMA-262, 5th edition, assuming <code>Object</code> and <code>TypeError</code> have their original values and that <code>callbackfn.call</code> evaluates to the original value of <a href=\"../function/call\"><code>Function.prototype.call</code></a></p> <pre data-language=\"js\">if (!Array.prototype.every) {\n  Array.prototype.every = function(callbackfn, thisArg) {\n    'use strict';\n    var T, k;\n\n    if (this == null) {\n      throw new TypeError('this is null or not defined');\n    }\n\n    // 1. Let O be the result of calling ToObject passing the this \n    //    value as the argument.\n    var O = Object(this);\n\n    // 2. Let lenValue be the result of calling the Get internal method\n    //    of O with the argument \"length\".\n    // 3. Let len be ToUint32(lenValue).\n    var len = O.length &gt;&gt;&gt; 0;\n\n    // 4. If IsCallable(callbackfn) is false, throw a TypeError exception.\n    if (typeof callbackfn !== 'function') {\n      throw new TypeError();\n    }\n\n    // 5. If thisArg was supplied, let T be thisArg; else let T be undefined.\n    if (arguments.length &gt; 1) {\n      T = thisArg;\n    }\n\n    // 6. Let k be 0.\n    k = 0;\n\n    // 7. Repeat, while k &lt; len\n    while (k &lt; len) {\n\n      var kValue;\n\n      // a. Let Pk be ToString(k).\n      //   This is implicit for LHS operands of the in operator\n      // b. Let kPresent be the result of calling the HasProperty internal \n      //    method of O with argument Pk.\n      //   This step can be combined with c\n      // c. If kPresent is true, then\n      if (k in O) {\n\n        // i. Let kValue be the result of calling the Get internal method\n        //    of O with argument Pk.\n        kValue = O[k];\n\n        // ii. Let testResult be the result of calling the Call internal method\n        //     of callbackfn with T as the this value and argument list \n        //     containing kValue, k, and O.\n        var testResult = callbackfn.call(T, kValue, k, O);\n\n        // iii. If ToBoolean(testResult) is false, return false.\n        if (!testResult) {\n          return false;\n        }\n      }\n      k++;\n    }\n    return true;\n  };\n}\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/5.1/#sec-15.4.4.16\" hreflang=\"en\">ECMAScript 5.1 (ECMA-262)<br><small>The definition of 'Array.prototype.every' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition. Implemented in JavaScript 1.6.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-array.prototype.every\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Array.prototype.every' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-array.prototype.every\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Array.prototype.every' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>   <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1.5</td>\n<td class=\"bc-supports-yes\"> 9</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div>  <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"foreach\"><code>Array.prototype.forEach()</code></a></li> <li><a href=\"some\"><code>Array.prototype.some()</code></a></li> <li><a href=\"../typedarray/every\"><code>TypedArray.prototype.every()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/every$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/every\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/every</a>\n  </p>\n</div>\n","global_objects/array/includes":"<h1>array.includes</h1> <p>The <code><strong>includes()</strong></code> method determines whether an array includes a certain element, returning <code>true</code> or <code>false</code> as appropriate.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/array-includes.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\"><var>arr</var>.includes(<var>searchElement[</var>, <var>fromIndex]</var>)\n</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><code>searchElement</code></dt> <dd>The element to search for.</dd> <dt>\n<code>fromIndex</code> <span class=\"inlineIndicator optional optionalInline\">Optional</span>\n</dt> <dd>The position in this array at which to begin searching for <code>searchElement</code>. A negative value searches from the index of <code>array.length - fromIndex</code> by asc. Defaults to 0.</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p>A <a href=\"../boolean\"><code>Boolean</code></a> which is <code>true</code> if the value <code>searchElement</code> is found within the array (or the part of the array beginning at the index <code>fromIndex</code>, if specified). Values of zero are all considered to be equal regardless of sign (that is, -0 is considered to be equal to both 0 and +0), but <code>false</code> is not considered to be the same as 0.</p> <div class=\"note\"> <p><strong>Note:</strong> Technically speaking, <code>includes()</code> uses the <code><a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Equality_comparisons_and_sameness#Same-value-zero_equality\">sameValueZero</a></code> algorithm to determine whether the given element is found.</p> </div> <h2 id=\"Examples\">Examples</h2> <pre data-language=\"js\">[1, 2, 3].includes(2);     // true\n[1, 2, 3].includes(4);     // false\n[1, 2, 3].includes(3, 3);  // false\n[1, 2, 3].includes(3, -1); // true\n[1, 2, NaN].includes(NaN); // true\n</pre> <h3 id=\"fromIndex_is_greater_than_or_equal_to_the_array_length\">\n<code>fromIndex</code> is greater than or equal to the array length</h3> <p>If <code>fromIndex</code> is greater than or equal to the length of the array, <code>false</code> is returned. The array will not be searched.</p> <pre data-language=\"js\">var arr = ['a', 'b', 'c'];\n\narr.includes('c', 3);   // false\narr.includes('c', 100); // false</pre> <h3 id=\"Computed_index_is_less_than_0\">Computed index is less than 0</h3> <p>If <code>fromIndex</code> is negative, the computed index is calculated to be used as a position in the array at which to begin searching for <code>searchElement</code>. If the computed index is less or equal than <code>-1 * array.length</code>, the entire array will be searched.</p> <pre data-language=\"js\">// array length is 3\n// fromIndex is -100\n// computed index is 3 + (-100) = -97\n\nvar arr = ['a', 'b', 'c'];\n\narr.includes('a', -100); // true\narr.includes('b', -100); // true\narr.includes('c', -100); // true\narr.includes('a', -2); // false</pre> <h3 id=\"includes()_used_as_a_generic_method\">\n<code>includes()</code> used as a generic method</h3> <p><code>includes()</code> method is intentionally generic. It does not require <code>this</code> value to be an Array object, so it can be applied to other kinds of objects (e.g. array-like objects). The example below illustrates <code>includes()</code> method called on the function's <a href=\"../../functions/arguments\">arguments</a> object.</p> <pre data-language=\"js\">(function() {\n  console.log([].includes.call(arguments, 'a')); // true\n  console.log([].includes.call(arguments, 'd')); // false\n})('a','b','c');</pre> <h2 id=\"Polyfill\">Polyfill</h2> <pre data-language=\"js\">// https://tc39.github.io/ecma262/#sec-array.prototype.includes\nif (!Array.prototype.includes) {\n  Object.defineProperty(Array.prototype, 'includes', {\n    value: function(searchElement, fromIndex) {\n\n      if (this == null) {\n        throw new TypeError('\"this\" is null or not defined');\n      }\n\n      // 1. Let O be ? ToObject(this value).\n      var o = Object(this);\n\n      // 2. Let len be ? ToLength(? Get(O, \"length\")).\n      var len = o.length &gt;&gt;&gt; 0;\n\n      // 3. If len is 0, return false.\n      if (len === 0) {\n        return false;\n      }\n\n      // 4. Let n be ? ToInteger(fromIndex).\n      //    (If fromIndex is undefined, this step produces the value 0.)\n      var n = fromIndex | 0;\n\n      // 5. If n ≥ 0, then\n      //  a. Let k be n.\n      // 6. Else n &lt; 0,\n      //  a. Let k be len + n.\n      //  b. If k &lt; 0, let k be 0.\n      var k = Math.max(n &gt;= 0 ? n : len - Math.abs(n), 0);\n\n      function sameValueZero(x, y) {\n        return x === y || (typeof x === 'number' &amp;&amp; typeof y === 'number' &amp;&amp; isNaN(x) &amp;&amp; isNaN(y));\n      }\n\n      // 7. Repeat, while k &lt; len\n      while (k &lt; len) {\n        // a. Let elementK be the result of ? Get(O, ! ToString(k)).\n        // b. If SameValueZero(searchElement, elementK) is true, return true.\n        if (sameValueZero(o[k], searchElement)) {\n          return true;\n        }\n        // c. Increase k by 1. \n        k++;\n      }\n\n      // 8. Return false\n      return false;\n    }\n  });\n}\n</pre> <p>If you need to support truly obsolete JavaScript engines that don't support <code><a href=\"../object/defineproperty\">Object.defineProperty()</a></code>, it's best not to polyfill <code>Array.prototype</code> methods at all, as you can't make them non-enumerable.</p> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/7.0/#sec-array.prototype.includes\" hreflang=\"en\">ECMAScript 2016 (ECMA-262)<br><small>The definition of 'Array.prototype.includes' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-array.prototype.includes\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Array.prototype.includes' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>   <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 47</td>\n<td class=\"bc-supports-yes\"> 14</td>\n<td class=\"bc-supports-yes\"> 43</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 34</td>\n<td class=\"bc-supports-yes\"> 9</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 14</td>\n<td class=\"bc-supports-yes\"> 43</td>\n<td class=\"bc-supports-yes\"> 34</td>\n<td class=\"bc-supports-yes\"> 9</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes bc-has-history\"> 6.0.0\n<section class=\"bc-history\" id=\"sect1\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 6.0.0\n</dt>\n\n<dt class=\"bc-supports-yes bc-supports\"> 5.0.0<div class=\"bc-icons\">Disabled </div>\n</dt>\n<dd>Disabled From version 5.0.0: this feature is behind the <code>--harmony</code> runtime flag.</dd>\n</dl></section>\n</td>\n</tr></tbody>\n</table>\n</div>  <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"../typedarray/includes\"><code>TypedArray.prototype.includes()</code></a></li> <li><a href=\"../string/includes\"><code>String.prototype.includes()</code></a></li> <li><a href=\"indexof\"><code>Array.prototype.indexOf()</code></a></li> <li><a href=\"find\"><code>Array.prototype.find()</code></a></li> <li><a href=\"findindex\"><code>Array.prototype.findIndex()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/includes$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/includes\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/includes</a>\n  </p>\n</div>\n","global_objects/array/join":"<h1>array.join</h1> <p>The <code><strong>join()</strong></code> method creates and returns a new string by concatenating all of the elements in an array (or an <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Indexed_collections#Working_with_array-like_objects\">array-like object</a>), separated by commas or a specified separator string.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/array-join.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\"><var>arr</var>.join([<var>separator</var>])</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt>\n<code>separator</code> <span class=\"inlineIndicator optional optionalInline\">Optional</span>\n</dt> <dd>Specifies a string to separate each pair of adjacent elements of the array. The separator is converted to a string if necessary. If omitted, the array elements are separated with a comma (\",\"). If <code>separator</code> is an empty string, all elements are joined without any characters in between them.</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p>A string with all array elements joined. If <code><em>arr</em>.length</code> is <code>0</code>, the empty string is returned.</p> <h2 id=\"Description\">Description</h2> <p>The string conversions of all array elements are joined into one string.</p> <div class=\"warning\"> <p>If an element is <code>undefined</code> or <code>null</code>, it is converted to the empty string.</p> </div> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Joining_an_array_four_different_ways\">Joining an array four different ways</h3> <p>The following example creates an array, <code>a</code>, with three elements, then joins the array four times: using the default separator, then a comma and a space, then a plus and an empty string.</p> <pre data-language=\"js\">var a = ['Wind', 'Rain', 'Fire'];\na.join();      // 'Wind,Rain,Fire'\na.join(', ');  // 'Wind, Rain, Fire'\na.join(' + '); // 'Wind + Rain + Fire'\na.join('');    // 'WindRainFire'</pre> <h3 id=\"Joining_an_array-like_object\">Joining an array-like object</h3> <p>The following example joins array-like object (<code><a href=\"../../functions/arguments\">arguments</a></code>), by calling <a href=\"../function/call\"><code>Function.prototype.call</code></a> on <code>Array.prototype.join</code>.</p> <pre data-language=\"js\">function f(a, b, c) {\n  var s = Array.prototype.join.call(arguments);\n  console.log(s); // '<span class=\"message-body-wrapper\"><span class=\"message-flex-body\"><span class=\"devtools-monospace message-body\"><span class=\"objectBox objectBox-string\">1,a,true'</span></span></span></span>\n}\nf(1, 'a', true);\n//expected output: \"1,a,true\"\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <thead> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> </thead> <tbody> <tr> <td><a href=\"https://www.ecma-international.org/publications/files/ECMA-ST-ARCH/ECMA-262,%201st%20edition,%20June%201997.pdf\" hreflang=\"en\">ECMAScript 1st Edition (ECMA-262)</a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition. Implemented in JavaScript 1.1.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/5.1/#sec-15.4.4.5\" hreflang=\"en\">ECMAScript 5.1 (ECMA-262)<br><small>The definition of 'Array.prototype.join' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-array.prototype.join\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Array.prototype.join' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-array.prototype.join\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Array.prototype.join' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> 5.5</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"../string/split\"><code>String.prototype.split()</code></a></li> <li><a href=\"tostring\"><code>Array.prototype.toString()</code></a></li> <li><a href=\"../typedarray/join\"><code>TypedArray.prototype.join()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/join$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/join\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/join</a>\n  </p>\n</div>\n","global_objects/array/from":"<h1>Array.from</h1> <p>The <code><strong>Array.from()</strong></code> method creates a new, shallow-copied <code>Array</code> instance from an array-like or iterable object.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/array-from.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre>Array.from(arrayLike[, mapFn[, thisArg]])\n</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><code>arrayLike</code></dt> <dd>An array-like or iterable object to convert to an array.</dd> <dt>\n<code>mapFn</code><span class=\"inlineIndicator optional optionalInline\">Optional</span>\n</dt> <dd>Map function to call on every element of the array.</dd> <dt>\n<code>thisArg</code><span class=\"inlineIndicator optional optionalInline\">Optional</span>\n</dt> <dd>Value to use as <code>this</code> when executing <code>mapFn</code>.</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p>A new <a href=\"../array\"><code>Array</code></a> instance.</p> <h2 id=\"Description\">Description</h2> <p><code>Array.from()</code> lets you create <code>Arrays</code> from:</p> <ul> <li>array-like objects (objects with a <code>length</code> property and indexed elements) or</li> <li>\n<a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/iterable\">iterable objects</a> (objects where you can get its elements, such as <a href=\"../map\"><code>Map</code></a> and <a href=\"../set\"><code>Set</code></a>).</li> </ul> <p><code>Array.from()</code> has an optional parameter <code>mapFn</code>, which allows you to execute a <a href=\"map\"><code>map</code></a> function on each element of the array (or subclass object) that is being created. More clearly,<code> Array.from(obj, mapFn, thisArg)</code> has the same result as <code>Array.from(obj).map(mapFn, thisArg)</code>, except that it does not create an intermediate array. This is especially important for certain array subclasses, like <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Typed_arrays\">typed arrays</a>, since the intermediate array would necessarily have values truncated to fit into the appropriate type.</p> <p>The <code>length</code> property of the <code>from()</code> method is 1.</p> <p>In ES2015, the class syntax allows for sub-classing of both built-in and user defined classes; as a result, static methods such as <code>Array.from</code> are \"inherited\" by subclasses of <code>Array</code> and create new instances of the subclass, not <code>Array</code>.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Array_from_a_String\">Array from a <code>String</code>\n</h3> <pre data-language=\"js\">Array.from('foo'); \n// [\"f\", \"o\", \"o\"]</pre> <h3 id=\"Array_from_a_Set\">Array from a <code>Set</code>\n</h3> <pre data-language=\"js\">var s = new Set(['foo', window]); \nArray.from(s); \n// [\"foo\", window]</pre> <h3 id=\"Array_from_a_Map\">Array from a <code>Map</code>\n</h3> <pre data-language=\"js\">var m = new Map([[1, 2], [2, 4], [4, 8]]);\nArray.from(m);\n// [[1, 2], [2, 4], [4, 8]]\n\nvar mapper = new Map([['1', 'a'], ['2', 'b']]);\nArray.from(mapper.values());\n// ['a', 'b'];\n\nArray.from(mapper.keys());\n// ['1', '2'];\n</pre> <h3 id=\"Array_from_an_Array-like_object_(arguments)\">Array from an Array-like object (arguments)</h3> <pre data-language=\"js\">function f() {\n  return Array.from(arguments);\n}\n\nf(1, 2, 3);\n\n// [1, 2, 3]</pre> <h3 id=\"Using_arrow_functions_and_Array.from\">Using arrow functions and <code>Array.from</code>\n</h3> <pre data-language=\"js\">// Using an arrow function as the map function to\n// manipulate the elements\nArray.from([1, 2, 3], x =&gt; x + x);      \n// [2, 4, 6]\n\n\n// Generate a sequence of numbers\n// Since the array is initialized with `undefined` on each position,\n// the value of `v` below will be `undefined`\nArray.from({length: 5}, (v, i) =&gt; i);\n// [0, 1, 2, 3, 4]\n</pre> <h3 id=\"Sequence_generator_(range)\">Sequence generator (range)</h3> <pre data-language=\"js\">// Sequence generator function (commonly referred to as \"range\", e.g. Clojure, PHP etc)\nconst range = (start, stop, step) =&gt; Array.from({ length: (stop - start) / step }, (_, i) =&gt; start + (i * step));\n\n// Generate numbers range 0..4\nrange(0, 5, 1);\n// [0, 1, 2, 3, 4]\n\n// Generate the alphabet using Array.from making use of it being ordered as a sequence\nrange('A'.charCodeAt(0), 'Z'.charCodeAt(0) + 1, 1).map(x =&gt; String.fromCharCode(x));\n// [\"A\", \"B\", \"C\", \"D\", \"E\", \"F\", \"G\", \"H\", \"I\", \"J\", \"K\", \"L\", \"M\", \"N\", \"O\", \"P\", \"Q\", \"R\", \"S\", \"T\", \"U\", \"V\", \"W\", \"X\", \"Y\", \"Z\"]\n</pre>  <h2 id=\"Polyfill\">Polyfill</h2> <p><code>Array.from</code> was added to the ECMA-262 standard in the 6th edition (ES2015); as such it may not be present in other implementations of the standard. You can work around this by inserting the following code at the beginning of your scripts, allowing use of <code>Array.from</code> in implementations that don't natively support it. This algorithm is exactly the one specified in ECMA-262, 6th edition, assuming <code>Object</code> and <code>TypeError</code> have their original values and that <code>callback.call</code> evaluates to the original value of <a href=\"../function/call\"><code>Function.prototype.call</code></a>. In addition, since true iterables can not be polyfilled, this implementation does not support generic iterables as defined in the 6th edition of ECMA-262.</p> <pre data-language=\"js\">// Production steps of ECMA-262, Edition 6, 22.1.2.1\nif (!Array.from) {\n  Array.from = (function () {\n    var toStr = Object.prototype.toString;\n    var isCallable = function (fn) {\n      return typeof fn === 'function' || toStr.call(fn) === '[object Function]';\n    };\n    var toInteger = function (value) {\n      var number = Number(value);\n      if (isNaN(number)) { return 0; }\n      if (number === 0 || !isFinite(number)) { return number; }\n      return (number &gt; 0 ? 1 : -1) * Math.floor(Math.abs(number));\n    };\n\n    var toLength = function (value) {\n      var len = toInteger(value);\n      return len &gt;&gt;&gt; 0;\n    };\n\n    // The length property of the from method is 1.\n    return function from(arrayLike/*, mapFn, thisArg */) {\n      // 1. Let C be the this value.\n      var C = this;\n\n      // 2. Let items be ToObject(arrayLike).\n      var items = Object(arrayLike);\n\n      // 3. ReturnIfAbrupt(items).\n      if (arrayLike == null) {\n        throw new TypeError('Array.from requires an array-like object - not null or undefined');\n      }\n\n      // 4. If mapfn is undefined, then let mapping be false.\n      var mapFn = arguments.length &gt; 1 ? arguments[1] : void undefined;\n      var T;\n      if (typeof mapFn !== 'undefined') {\n        // 5. else\n        // 5. a If IsCallable(mapfn) is false, throw a TypeError exception.\n        if (!isCallable(mapFn)) {\n          throw new TypeError('Array.from: when provided, the second argument must be a function');\n        }\n\n        // 5. b. If thisArg was supplied, let T be thisArg; else let T be undefined.\n        if (arguments.length &gt; 2) {\n          T = arguments[2];\n        }\n      }\n\n      // 10. Let lenValue be Get(items, \"length\").\n      // 11. Let len be ToLength(lenValue).\n      var len = toLength(items.length);\n\n      // 13. If IsConstructor(C) is true, then\n      // 13. a. Let A be the result of calling the [[Construct]] internal method \n      // of C with an argument list containing the single item len.\n      // 14. a. Else, Let A be ArrayCreate(len).\n      var A = isCallable(C) ? Object(new C(len)) : new Array(len);\n\n      // 16. Let k be 0.\n      var k = 0;\n      // 17. Repeat, while k &lt; len… (also steps a - h)\n      var kValue;\n      while (k &lt; len) {\n        kValue = items[k];\n        if (mapFn) {\n          A[k] = typeof T === 'undefined' ? mapFn(kValue, k) : mapFn.call(T, kValue, k);\n        } else {\n          A[k] = kValue;\n        }\n        k += 1;\n      }\n      // 18. Let putStatus be Put(A, \"length\", len, true).\n      A.length = len;\n      // 20. Return A.\n      return A;\n    };\n  }());\n}\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-array.from\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Array.from' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-array.from\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Array.from' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>   <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 45</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 32</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 9</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 32</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 4.0.0</td>\n</tr></tbody>\n</table>\n</div>  <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"../array\"><code>Array</code></a></li> <li><a href=\"map\"><code>Array.prototype.map()</code></a></li> <li><a href=\"../typedarray/from\"><code>TypedArray.from()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/from$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/from\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/from</a>\n  </p>\n</div>\n","global_objects/array/foreach":"<h1>array.forEach</h1> <p>The <code><strong>forEach()</strong></code> method executes a provided function once for each array element.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/array-foreach.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\"><var>arr</var>.forEach(function <var>callback(currentValue[, index[, array]]) {\n    //your iterator\n}</var>[, <var>thisArg</var>]);</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><code>callback</code></dt> <dd>Function to execute for each element, taking three arguments: <dl> <dt><code>currentValue</code></dt> <dd>The value of the current element being processed in the array.</dd> <dt>\n<code>index</code><span class=\"inlineIndicator optional optionalInline\">Optional</span>\n</dt> <dd>The index of the current element being processed in the array.</dd> <dt>\n<code>array</code><span class=\"inlineIndicator optional optionalInline\">Optional</span>\n</dt> <dd>The array that <code>forEach()</code> is being applied to.</dd> </dl> </dd> <dt>\n<code>thisArg</code> <span class=\"inlineIndicator optional optionalInline\">Optional</span>\n</dt> <dd> <p>Value to use as <code><strong>this</strong></code> (i.e the reference <code>Object</code>) when executing <code>callback</code>.</p> </dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p><a href=\"../undefined\"><code>undefined</code></a>.</p> <h2 id=\"Description\">Description</h2> <p><code>forEach()</code> executes the provided <code>callback</code> once for each element present in the array in ascending order. It is not invoked for index properties that have been deleted or are uninitialized (i.e. on sparse arrays).</p> <p><code>callback</code> is invoked with <strong>three arguments</strong>:</p> <ul> <li>the <strong>element value</strong>\n</li> <li>the <strong>element index</strong>\n</li> <li>the <strong>array being traversed</strong>\n</li> </ul> <p>If a <code>thisArg</code> parameter is provided to <code>forEach()</code>, it will be used as callback's <code>this</code> value. Otherwise, the value <a href=\"../undefined\"><code>undefined</code></a> will be used as its <code>this</code> value. The <code>this</code> value ultimately observable by <code>callback</code> is determined according to <a href=\"../../operators/this\">the usual rules for determining the <code>this</code> seen by a function</a>.</p> <p>The range of elements processed by <code>forEach()</code> is set before the first invocation of <code>callback</code>. Elements that are appended to the array after the call to <code>forEach()</code> begins will not be visited by <code>callback</code>. If the values of existing elements of the array are changed, the value passed to <code>callback</code> will be the value at the time <code>forEach()</code> visits them; elements that are deleted before being visited are not visited. If elements that are already visited are removed (e.g. using <a href=\"shift\"><code>shift()</code></a>) during the iteration, later elements will be skipped - see example below.</p> <p><code>forEach()</code> executes the <code>callback</code> function once for each array element; unlike <a href=\"map\"><code>map()</code></a> or <a href=\"reduce\"><code>reduce()</code></a> it always returns the value <a href=\"../undefined\"><code>undefined</code></a> and is not chainable. The typical use case is to execute side effects at the end of a chain.</p> <p><code>forEach()</code> does not mutate the array on which it is called (although <code>callback</code>, if invoked, may do so).</p> <div class=\"note\"> <p>There is no way to stop or break a <code>forEach()</code> loop other than by throwing an exception. If you need such behavior, the <code>forEach()</code> method is the wrong tool.</p> <p>Early termination may be accomplished with:</p> <ul> <li>A simple loop</li> <li>A <a href=\"../../statements/for...of\">for...of</a> loop</li> <li><a href=\"every\"><code>Array.prototype.every()</code></a></li> <li><a href=\"some\"><code>Array.prototype.some()</code></a></li> <li><a href=\"find\"><code>Array.prototype.find()</code></a></li> <li><a href=\"findindex\"><code>Array.prototype.findIndex()</code></a></li> </ul> <p>The other Array methods: <a href=\"every\"><code>every()</code></a>, <a href=\"some\"><code>some()</code></a>, <a href=\"find\"><code>find()</code></a>, and <a href=\"findindex\"><code>findIndex()</code></a> test the array elements with a predicate returning a truthy value to determine if further iteration is required.</p> </div> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Converting_a_for_loop_to_forEach\">Converting a for loop to forEach</h3> <p>before</p> <pre data-language=\"js\">const items = ['item1', 'item2', 'item3'];\nconst copy = [];\n\nfor (let i=0; i&lt;items.length; i++) {\n  copy.push(items[i])\n}\n</pre> <p>after</p> <pre data-language=\"js\">const items = ['item1', 'item2', 'item3'];\nconst copy = [];\n\nitems.forEach(function(item){\n  copy.push(item)\n});\n\n</pre>  <h3 id=\"Printing_the_contents_of_an_array\">Printing the contents of an array</h3> <p>The following code logs a line for each element in an array:</p> <pre data-language=\"js\">function logArrayElements(element, index, array) {\n  console.log('a[' + index + '] = ' + element);\n}\n\n// Notice that index 2 is skipped since there is no item at\n// that position in the array.\n[2, 5, , 9].forEach(logArrayElements);\n// logs:\n// a[0] = 2\n// a[1] = 5\n// a[3] = 9\n</pre> <h3 id=\"Using_thisArg\">Using <code>thisArg</code>\n</h3> <p>The following (contrived) example updates an object's properties from each entry in the array:</p> <pre data-language=\"js\">function Counter() {\n  this.sum = 0;\n  this.count = 0;\n}\nCounter.prototype.add = function(array) {\n  array.forEach(function(entry) {\n    this.sum += entry;\n    ++this.count;\n  }, this);\n  // ^---- Note\n};\n\nconst obj = new Counter();\nobj.add([2, 5, 9]);\nobj.count;\n// 3 \nobj.sum;\n// 16\n</pre> <p>Since the <code>thisArg</code> parameter (<code>this</code>) is provided to <code>forEach()</code>, it is passed to <code>callback</code> each time it's invoked, for use as its <code>this</code> value.</p> <div class=\"note\"> <p>If passing the function argument using an <a href=\"../../functions/arrow_functions\">arrow function expression</a> the <code>thisArg</code> parameter can be omitted as arrow functions lexically bind the <a href=\"../../operators/this\"><code>this</code></a> value.</p> </div> <h3 id=\"An_object_copy_function\">An object copy function</h3> <p>The following code creates a copy of a given object. There are different ways to create a copy of an object; the following is just one way and is presented to explain how <code>Array.prototype.forEach()</code> works by using ECMAScript 5 <code>Object.*</code> meta property functions.</p> <pre data-language=\"js\">function copy(obj) {\n  const copy = Object.create(Object.getPrototypeOf(obj));\n  const propNames = Object.getOwnPropertyNames(obj);\n\n  propNames.forEach(function(name) {\n    const desc = Object.getOwnPropertyDescriptor(obj, name);\n    Object.defineProperty(copy, name, desc);\n  });\n\n  return copy;\n}\n\nconst obj1 = { a: 1, b: 2 };\nconst obj2 = copy(obj1); // obj2 looks like obj1 now\n</pre> <h3 id=\"If_the_array_is_modified_during_iteration_other_elements_might_be_skipped.\">If the array is modified during iteration, other elements might be skipped.</h3> <p>The following example logs \"one\", \"two\", \"four\". When the entry containing the value \"two\" is reached, the first entry of the whole array is shifted off, which results in all remaining entries moving up one position. Because element \"four\" is now at an earlier position in the array, \"three\" will be skipped. <code>forEach()</code> does not make a copy of the array before iterating.</p> <pre data-language=\"js\">var words = ['one', 'two', 'three', 'four'];\nwords.forEach(function(word) {\n  console.log(word);\n  if (word === 'two') {\n    words.shift();\n  }\n});\n// one\n// two\n// four\n</pre> <h2 id=\"Polyfill\">Polyfill</h2> <p><code>forEach()</code> was added to the ECMA-262 standard in the 5th edition; as such it may not be present in other implementations of the standard. You can work around this by inserting the following code at the beginning of your scripts, allowing use of <code>forEach()</code> in implementations that don't natively support it. This algorithm is exactly the one specified in ECMA-262, 5th edition, assuming <a href=\"../object\"><code>Object</code></a> and <a href=\"../typeerror\"><code>TypeError</code></a> have their original values and that <code>callback.call()</code> evaluates to the original value of <a href=\"../function/call\"><code>Function.prototype.call()</code></a>.</p> <pre data-language=\"js\">// Production steps of ECMA-262, Edition 5, 15.4.4.18\n// Reference: http://es5.github.io/#x15.4.4.18\nif (!Array.prototype.forEach) {\n\n  Array.prototype.forEach = function(callback/*, thisArg*/) {\n\n    var T, k;\n\n    if (this == null) {\n      throw new TypeError('this is null or not defined');\n    }\n\n    // 1. Let O be the result of calling toObject() passing the\n    // |this| value as the argument.\n    var O = Object(this);\n\n    // 2. Let lenValue be the result of calling the Get() internal\n    // method of O with the argument \"length\".\n    // 3. Let len be toUint32(lenValue).\n    var len = O.length &gt;&gt;&gt; 0;\n\n    // 4. If isCallable(callback) is false, throw a TypeError exception. \n    // See: http://es5.github.com/#x9.11\n    if (typeof callback !== 'function') {\n      throw new TypeError(callback + ' is not a function');\n    }\n\n    // 5. If thisArg was supplied, let T be thisArg; else let\n    // T be undefined.\n    if (arguments.length &gt; 1) {\n      T = arguments[1];\n    }\n\n    // 6. Let k be 0.\n    k = 0;\n\n    // 7. Repeat while k &lt; len.\n    while (k &lt; len) {\n\n      var kValue;\n\n      // a. Let Pk be ToString(k).\n      //    This is implicit for LHS operands of the in operator.\n      // b. Let kPresent be the result of calling the HasProperty\n      //    internal method of O with argument Pk.\n      //    This step can be combined with c.\n      // c. If kPresent is true, then\n      if (k in O) {\n\n        // i. Let kValue be the result of calling the Get internal\n        // method of O with argument Pk.\n        kValue = O[k];\n\n        // ii. Call the Call internal method of callback with T as\n        // the this value and argument list containing kValue, k, and O.\n        callback.call(T, kValue, k, O);\n      }\n      // d. Increase k by 1.\n      k++;\n    }\n    // 8. return undefined.\n  };\n}\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/5.1/#sec-15.4.4.18\" hreflang=\"en\">ECMAScript 5.1 (ECMA-262)<br><small>The definition of 'Array.prototype.forEach' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition. Implemented in JavaScript 1.6.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-array.prototype.foreach\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Array.prototype.forEach' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-array.prototype.foreach\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Array.prototype.forEach' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>   <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1.5</td>\n<td class=\"bc-supports-yes\"> 9</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div>  <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"find\"><code>Array.prototype.find()</code></a></li> <li><a href=\"findindex\"><code>Array.prototype.findIndex()</code></a></li> <li><a href=\"map\"><code>Array.prototype.map()</code></a></li> <li><a href=\"every\"><code>Array.prototype.every()</code></a></li> <li><a href=\"some\"><code>Array.prototype.some()</code></a></li> <li><a href=\"../map/foreach\"><code>Map.prototype.forEach()</code></a></li> <li><a href=\"../set/foreach\"><code>Set.prototype.forEach()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/forEach$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/forEach\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/forEach</a>\n  </p>\n</div>\n","global_objects/array/indexof":"<h1>array.indexOf</h1> <p>The <code><strong>indexOf()</strong></code> method returns the first index at which a given element can be found in the array, or -1 if it is not present.</p> <div class=\"note\"> <p><strong>Note:</strong> For the String method, see <a href=\"../string/indexof\"><code>String.prototype.indexOf()</code></a>.</p> </div> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/array-indexof.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\"><var>arr</var>.indexOf(<var>searchElement[</var>, <var>fromIndex]</var>)</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><code>searchElement</code></dt> <dd>Element to locate in the array.</dd> <dt>\n<code>fromIndex</code> <span class=\"inlineIndicator optional optionalInline\">Optional</span>\n</dt> <dd>The index to start the search at. If the index is greater than or equal to the array's length, -1 is returned, which means the array will not be searched. If the provided index value is a negative number, it is taken as the offset from the end of the array. Note: if the provided index is negative, the array is still searched from front to back. If the provided index is 0, then the whole array will be searched. Default: 0 (entire array is searched).</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p>The first index of the element in the array; <strong>-1</strong> if not found.</p> <h2 id=\"Description\">Description</h2> <p><code>indexOf()</code> compares <code>searchElement</code> to elements of the Array using <a href=\"../../operators/comparison_operators#Using_the_Equality_Operators\">strict equality</a> (the same method used by the <code>===</code> or triple-equals operator).</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Using_indexOf()\">Using <code>indexOf()</code>\n</h3> <p>The following example uses <code>indexOf()</code> to locate values in an array.</p> <pre data-language=\"js\">var array = [2, 9, 9];\narray.indexOf(2);     // 0\narray.indexOf(7);     // -1\narray.indexOf(9, 2);  // 2\narray.indexOf(2, -1); // -1\narray.indexOf(2, -3); // 0\n</pre> <h3 id=\"Finding_all_the_occurrences_of_an_element\">Finding all the occurrences of an element</h3> <pre data-language=\"js\">var indices = [];\nvar array = ['a', 'b', 'a', 'c', 'a', 'd'];\nvar element = 'a';\nvar idx = array.indexOf(element);\nwhile (idx != -1) {\n  indices.push(idx);\n  idx = array.indexOf(element, idx + 1);\n}\nconsole.log(indices);\n// [0, 2, 4]\n</pre> <h3 id=\"Finding_if_an_element_exists_in_the_array_or_not_and_updating_the_array\">Finding if an element exists in the array or not and updating the array</h3> <pre data-language=\"js\">function updateVegetablesCollection (veggies, veggie) {\n    if (veggies.indexOf(veggie) === -1) {\n        veggies.push(veggie);\n        console.log('New veggies collection is : ' + veggies);\n    } else if (veggies.indexOf(veggie) &gt; -1) {\n        console.log(veggie + ' already exists in the veggies collection.');\n    }\n}\n\nvar veggies = ['potato', 'tomato', 'chillies', 'green-pepper'];\n\nupdateVegetablesCollection(veggies, 'spinach'); \n// New veggies collection is : potato,tomato,chillies,green-pepper,spinach\nupdateVegetablesCollection(veggies, 'spinach'); \n// spinach already exists in the veggies collection.\n</pre> <h2 id=\"Polyfill\">Polyfill</h2> <p><code>indexOf()</code> was added to the ECMA-262 standard in the 5th edition; as such it may not be present in all browsers. You can work around this by utilizing the following code at the beginning of your scripts. This will allow you to use <code>indexOf()</code> when there is still no native support. This algorithm matches the one specified in ECMA-262, 5th edition, assuming <a href=\"../typeerror\"><code>TypeError</code></a> and <a href=\"../math/abs\"><code>Math.abs()</code></a> have their original values.</p> <pre data-language=\"js\">if (!Array.prototype.indexOf)  Array.prototype.indexOf = (function(Object, max, min){\n  \"use strict\";\n  return function indexOf(member, fromIndex) {\n    if(this===null||this===undefined)throw TypeError(\"Array.prototype.indexOf called on null or undefined\");\n    \n    var that = Object(this), Len = that.length &gt;&gt;&gt; 0, i = min(fromIndex | 0, Len);\n    if (i &lt; 0) i = max(0, Len+i); else if (i &gt;= Len) return -1;\n    \n    if(member===void 0){ for(; i !== Len; ++i) if(that[i]===void 0 &amp;&amp; i in that) return i; // undefined\n    }else if(member !== member){   for(; i !== Len; ++i) if(that[i] !== that[i]) return i; // NaN\n    }else                           for(; i !== Len; ++i) if(that[i] === member) return i; // all else\n\n    return -1; // if the value was not found, then return -1\n  };\n})(Object, Math.max, Math.min);\n</pre> <p>However, if you are more interested in all the little technical bits defined by the ECMA standard, and are less concerned about performance or conciseness, then you may find this more descriptive polyfill to be more useful.</p> <pre data-language=\"js\">// Production steps of ECMA-262, Edition 5, 15.4.4.14\n// Reference: http://es5.github.io/#x15.4.4.14\nif (!Array.prototype.indexOf) {\n  Array.prototype.indexOf = function(searchElement, fromIndex) {\n\n    var k;\n\n    // 1. Let o be the result of calling ToObject passing\n    //    the this value as the argument.\n    if (this == null) {\n      throw new TypeError('\"this\" is null or not defined');\n    }\n\n    var o = Object(this);\n\n    // 2. Let lenValue be the result of calling the Get\n    //    internal method of o with the argument \"length\".\n    // 3. Let len be ToUint32(lenValue).\n    var len = o.length &gt;&gt;&gt; 0;\n\n    // 4. If len is 0, return -1.\n    if (len === 0) {\n      return -1;\n    }\n\n    // 5. If argument fromIndex was passed let n be\n    //    ToInteger(fromIndex); else let n be 0.\n    var n = fromIndex | 0;\n\n    // 6. If n &gt;= len, return -1.\n    if (n &gt;= len) {\n      return -1;\n    }\n\n    // 7. If n &gt;= 0, then Let k be n.\n    // 8. Else, n&lt;0, Let k be len - abs(n).\n    //    If k is less than 0, then let k be 0.\n    k = Math.max(n &gt;= 0 ? n : len - Math.abs(n), 0);\n\n    // 9. Repeat, while k &lt; len\n    while (k &lt; len) {\n      // a. Let Pk be ToString(k).\n      //   This is implicit for LHS operands of the in operator\n      // b. Let kPresent be the result of calling the\n      //    HasProperty internal method of o with argument Pk.\n      //   This step can be combined with c\n      // c. If kPresent is true, then\n      //    i.  Let elementK be the result of calling the Get\n      //        internal method of o with the argument ToString(k).\n      //   ii.  Let same be the result of applying the\n      //        Strict Equality Comparison Algorithm to\n      //        searchElement and elementK.\n      //  iii.  If same is true, return k.\n      if (k in o &amp;&amp; o[k] === searchElement) {\n        return k;\n      }\n      k++;\n    }\n    return -1;\n  };\n}\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/5.1/#sec-15.4.4.14\" hreflang=\"en\">ECMAScript 5.1 (ECMA-262)<br><small>The definition of 'Array.prototype.indexOf' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition. Implemented in JavaScript 1.6.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-array.prototype.indexof\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Array.prototype.indexOf' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-array.prototype.indexof\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Array.prototype.indexOf' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>   <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1.5</td>\n<td class=\"bc-supports-yes\"> 9</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div>  <h2 id=\"Compatibility_notes\">Compatibility notes</h2> <ul> <li>Starting with Firefox 47 (Firefox 47 / Thunderbird 47 / SeaMonkey 2.44), this method will no longer return <code>-0</code>. For example, <code>[0].indexOf(0, -0)</code> will now always return <code>+0</code> (<a href=\"https://bugzilla.mozilla.org/show_bug.cgi?id=1242043\">bug 1242043</a>).</li> </ul> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"lastindexof\"><code>Array.prototype.lastIndexOf()</code></a></li> <li><a href=\"../typedarray/indexof\"><code>TypedArray.prototype.indexOf()</code></a></li> <li><a href=\"../string/indexof\"><code>String.prototype.indexOf()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/indexOf$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/indexOf\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/indexOf</a>\n  </p>\n</div>\n","global_objects/array/some":"<h1>array.some</h1> <p>The <code><strong>some()</strong></code> method tests whether at least one element in the array passes the test implemented by the provided function.</p> <div class=\"note\"> <p><strong>Note</strong>: This method returns <code>false</code> for any condition put on an empty array.</p> </div> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/array-some.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\"><var>arr</var>.some(<var>callback(element[, index[, array]])</var>[, <var>thisArg</var>])</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><code>callback</code></dt> <dd>Function to test for each element, taking three arguments: <dl> <dt><code>element</code></dt> <dd>The current element being processed in the array.</dd> <dt>\n<code>index</code> <span class=\"inlineIndicator optional optionalInline\">Optional</span>\n</dt> <dd>The index of the current element being processed in the array.</dd> <dt>\n<code>array</code><span class=\"inlineIndicator optional optionalInline\">Optional</span>\n</dt> <dd>The array <code>some()</code> was called upon.</dd> </dl> </dd> <dt>\n<code>thisArg</code><span class=\"inlineIndicator optional optionalInline\">Optional</span>\n</dt> <dd>Value to use as <code>this</code> when executing <code>callback</code>.</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p><code><strong>true</strong></code> if the callback function returns a <a href=\"https://developer.mozilla.org/en-US/docs/Glossary/truthy\">truthy</a> value for any array element; otherwise, <code><strong>false</strong></code>.</p> <h2 id=\"Description\">Description</h2> <p><code>some()</code> executes the <code>callback</code> function once for each element present in the array until it finds one where <code>callback</code> returns a <em>truthy</em> value (a value that becomes true when converted to a Boolean). If such an element is found, <code>some()</code> immediately returns <code>true</code>. Otherwise, <code>some()</code> returns <code>false</code>. <code>callback</code> is invoked only for indexes of the array which have assigned values; it is not invoked for indexes which have been deleted or which have never been assigned values.</p> <p><code>callback</code> is invoked with three arguments: the value of the element, the index of the element, and the array object being traversed.</p> <p>If a <code>thisArg</code> parameter is provided to <code>some()</code>, it will be used as callbacks' <code>this</code> value. Otherwise, the value <a href=\"../undefined\"><code>undefined</code></a> will be used as its <code>this</code> value. The <code>this</code> value ultimately observable by <code>callback</code> is determined according to <a href=\"../../operators/this\">the usual rules for determining the <code>this</code> seen by a function</a>.</p> <p><code>some()</code> does not mutate the array on which it is called.</p> <p>The range of elements processed by <code>some()</code> is set before the first invocation of <code>callback</code>. Elements that are appended to the array after the call to <code>some()</code> begins will not be visited by <code>callback</code>. If an existing, unvisited element of the array is changed by <code>callback</code>, its value passed to the visiting <code>callback</code> will be the value at the time that <code>some()</code> visits that element's index; elements that are deleted are not visited.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Testing_value_of_array_elements\">Testing value of array elements</h3> <p>The following example tests whether any element in the array is bigger than 10.</p> <pre data-language=\"js\">function isBiggerThan10(element, index, array) {\n  return element &gt; 10;\n}\n\n[2, 5, 8, 1, 4].some(isBiggerThan10);  // false\n[12, 5, 8, 1, 4].some(isBiggerThan10); // true\n</pre> <h3 id=\"Testing_array_elements_using_arrow_functions\">Testing array elements using arrow functions</h3> <p><a href=\"../../functions/arrow_functions\">Arrow functions</a> provide a shorter syntax for the same test.</p> <pre data-language=\"js\">[2, 5, 8, 1, 4].some(x =&gt; x &gt; 10);  // false\n[12, 5, 8, 1, 4].some(x =&gt; x &gt; 10); // true\n</pre> <h3 id=\"Checking_whether_a_value_exists_in_an_array\">Checking whether a value exists in an array</h3> <p>To mimic the function of the <code>includes()</code> method, this custom function returns <code>true</code> if the element exists in the array:</p> <pre data-language=\"js\">var fruits = ['apple', 'banana', 'mango', 'guava'];\n\nfunction checkAvailability(arr, val) {\n  return arr.some(function(arrVal) {\n    return val === arrVal;\n  });\n}\n\ncheckAvailability(fruits, 'kela');   // false\ncheckAvailability(fruits, 'banana'); // true</pre> <h3 id=\"Checking_whether_a_value_exists_using_an_arrow_function\">Checking whether a value exists using an arrow function</h3> <pre data-language=\"js\">var fruits = ['apple', 'banana', 'mango', 'guava'];\n\nfunction checkAvailability(arr, val) {\n  return arr.some(arrVal =&gt; val === arrVal);\n}\n\ncheckAvailability(fruits, 'kela');   // false\ncheckAvailability(fruits, 'banana'); // true</pre> <h3 id=\"Converting_any_value_to_Boolean\">Converting any value to Boolean</h3> <pre data-language=\"js\">var TRUTHY_VALUES = [true, 'true', 1];\n\nfunction getBoolean(value) {\n  'use strict';\n   \n  if (typeof value === 'string') { \n    value = value.toLowerCase().trim();\n  }\n\n  return TRUTHY_VALUES.some(function(t) {\n    return t === value;\n  });\n}\n\ngetBoolean(false);   // false\ngetBoolean('false'); // false\ngetBoolean(1);       // true\ngetBoolean('true');  // true</pre> <h2 id=\"Polyfill\">Polyfill</h2> <p><code>some()</code> was added to the ECMA-262 standard in the 5th edition; as such it may not be present in all implementations of the standard. You can work around this by inserting the following code at the beginning of your scripts, allowing use of <code>some()</code> in implementations which do not natively support it. This algorithm is exactly the one specified in ECMA-262, 5th edition, assuming <a href=\"../object\"><code>Object</code></a> and <a href=\"../typeerror\"><code>TypeError</code></a> have their original values and that <code>fun.call</code> evaluates to the original value of <a href=\"../function/call\"><code>Function.prototype.call()</code></a>.</p> <pre data-language=\"js\">// Production steps of ECMA-262, Edition 5, 15.4.4.17\n// Reference: http://es5.github.io/#x15.4.4.17\nif (!Array.prototype.some) {\n  Array.prototype.some = function(fun, thisArg) {\n    'use strict';\n\n    if (this == null) {\n      throw new TypeError('Array.prototype.some called on null or undefined');\n    }\n\n    if (typeof fun !== 'function') {\n      throw new TypeError();\n    }\n\n    var t = Object(this);\n    var len = t.length &gt;&gt;&gt; 0;\n\n    for (var i = 0; i &lt; len; i++) {\n      if (i in t &amp;&amp; fun.call(thisArg, t[i], i, t)) {\n        return true;\n      }\n    }\n\n    return false;\n  };\n}\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/5.1/#sec-15.4.4.17\" hreflang=\"en\">ECMAScript 5.1 (ECMA-262)<br><small>The definition of 'Array.prototype.some' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition. Implemented in JavaScript 1.6.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-array.prototype.some\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Array.prototype.some' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-array.prototype.some\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Array.prototype.some' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>   <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1.5</td>\n<td class=\"bc-supports-yes\"> 9</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div>  <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"find\"><code>Array.prototype.find()</code></a></li> <li><a href=\"foreach\"><code>Array.prototype.forEach()</code></a></li> <li><a href=\"every\"><code>Array.prototype.every()</code></a></li> <li><a href=\"../typedarray/some\"><code>TypedArray.prototype.some()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/some$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/some\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/some</a>\n  </p>\n</div>\n","global_objects/intl/getcanonicallocales":"<h1>Intl.getCanonicalLocales</h1> <p>The <code>Intl.getCanonicalLocales()</code> method returns an array containing the canonical locale names. Duplicates will be omitted and elements will be validated as structurally valid language tags.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/intl-getcanonicallocales.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\">Intl.getCanonicalLocales(locales)</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><code>locales</code></dt> <dd>A list of <a href=\"../string\"><code>String</code></a> values for which to get the canonical locale names.</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p>An array containing the canonical locale names.</p> <h2 id=\"Examples\">Examples</h2> <pre data-language=\"js\">Intl.getCanonicalLocales('EN-US'); // [\"en-US\"]\nIntl.getCanonicalLocales(['EN-US', 'Fr']); // [\"en-US\", \"fr\"]\n\nIntl.getCanonicalLocales('EN_US'); \n// RangeError:'EN_US' is not a structurally valid language tag\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma402/#sec-intl.getcanonicallocales\" hreflang=\"en\">ECMAScript Internationalization API 4.0 (ECMA-402)<br><small>The definition of 'Intl.getCanonicalLocales' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td>Initial definition</td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>   <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 54</td>\n<td class=\"bc-supports-yes\"> 16</td>\n<td class=\"bc-supports-yes\"> 48</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 11</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 56</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 11</td>\n<td class=\"bc-supports-no\"> No</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-no\"> No</td>\n</tr></tbody>\n</table>\n</div>  <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"../numberformat/supportedlocalesof\"><code>Intl.NumberFormat.supportedLocalesOf()</code></a></li> <li><a href=\"../datetimeformat/supportedlocalesof\"><code>Intl.DateTimeFormat.supportedLocalesOf()</code></a></li> <li><a href=\"../collator/supportedlocalesof\"><code>Intl.Collator.supportedLocalesOf()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/getCanonicalLocales$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/getCanonicalLocales\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/getCanonicalLocales</a>\n  </p>\n</div>\n","global_objects/array/lastindexof":"<h1>array.lastIndexOf</h1> <p>The <code><strong>lastIndexOf()</strong></code> method returns the last index at which a given element can be found in the array, or -1 if it is not present. The array is searched backwards, starting at <code>fromIndex</code>.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/array-lastindexof.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\"><var>arr</var>.lastIndexOf(<var>searchElement</var>)\n<var>arr</var>.lastIndexOf(<var>searchElement</var>, <var>fromIndex</var>)\n</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><code>searchElement</code></dt> <dd>Element to locate in the array.</dd> <dt>\n<code>fromIndex</code> <span class=\"inlineIndicator optional optionalInline\">Optional</span>\n</dt> <dd>The index at which to start searching backwards. Defaults to the array's length minus one (<code>arr.length - 1</code>), i.e. the whole array will be searched. If the index is greater than or equal to the length of the array, the whole array will be searched. If negative, it is taken as the offset from the end of the array. Note that even when the index is negative, the array is still searched from back to front. If the calculated index is less than 0, -1 is returned, i.e. the array will not be searched.</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p>The last index of the element in the array; <strong>-1</strong> if not found.</p> <h2 id=\"Description\">Description</h2> <p><code>lastIndexOf</code> compares <code>searchElement</code> to elements of the Array using <a href=\"../../operators/comparison_operators#Using_the_Equality_Operators\">strict equality</a> (the same method used by the ===, or triple-equals, operator).</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Using_lastIndexOf\">Using <code>lastIndexOf</code>\n</h3> <p>The following example uses <code>lastIndexOf</code> to locate values in an array.</p> <pre data-language=\"js\">var numbers = [2, 5, 9, 2];\nnumbers.lastIndexOf(2);     // 3\nnumbers.lastIndexOf(7);     // -1\nnumbers.lastIndexOf(2, 3);  // 3\nnumbers.lastIndexOf(2, 2);  // 0\nnumbers.lastIndexOf(2, -2); // 0\nnumbers.lastIndexOf(2, -1); // 3\n</pre> <h3 id=\"Finding_all_the_occurrences_of_an_element\">Finding all the occurrences of an element</h3> <p>The following example uses <code>lastIndexOf</code> to find all the indices of an element in a given array, using <a href=\"push\"><code>push</code></a> to add them to another array as they are found.</p> <pre data-language=\"js\">var indices = [];\nvar array = ['a', 'b', 'a', 'c', 'a', 'd'];\nvar element = 'a';\nvar idx = array.lastIndexOf(element);\nwhile (idx != -1) {\n  indices.push(idx);\n  idx = (idx &gt; 0 ? array.lastIndexOf(element, idx - 1) : -1);\n}\n\nconsole.log(indices);\n// [4, 2, 0]\n</pre> <p>Note that we have to handle the case <code>idx == 0</code> separately here because the element will always be found regardless of the <code>fromIndex</code> parameter if it is the first element of the array. This is different from the <a href=\"indexof\"><code>indexOf</code></a> method.</p> <h2 id=\"Polyfill\">Polyfill</h2> <p><code>lastIndexOf</code> was added to the ECMA-262 standard in the 5th edition; as such it may not be present in other implementations of the standard. You can work around this by inserting the following code at the beginning of your scripts, allowing use of <code>lastIndexOf</code> in implementations which do not natively support it. This algorithm is exactly the one specified in ECMA-262, 5th edition, assuming <a href=\"../object\"><code>Object</code></a>, <a href=\"../typeerror\"><code>TypeError</code></a>, <a href=\"../number\"><code>Number</code></a>, <a href=\"../math/floor\"><code>Math.floor</code></a>, <a href=\"../math/abs\"><code>Math.abs</code></a>, and <a href=\"../math/min\"><code>Math.min</code></a> have their original values.</p> <pre data-language=\"js\">// Production steps of ECMA-262, Edition 5, 15.4.4.15\n// Reference: http://es5.github.io/#x15.4.4.15\nif (!Array.prototype.lastIndexOf) {\n  Array.prototype.lastIndexOf = function(searchElement /*, fromIndex*/) {\n    'use strict';\n\n    if (this === void 0 || this === null) {\n      throw new TypeError();\n    }\n\n    var n, k,\n      t = Object(this),\n      len = t.length &gt;&gt;&gt; 0;\n    if (len === 0) {\n      return -1;\n    }\n\n    n = len - 1;\n    if (arguments.length &gt; 1) {\n      n = Number(arguments[1]);\n      if (n != n) {\n        n = 0;\n      }\n      else if (n != 0 &amp;&amp; n != (1 / 0) &amp;&amp; n != -(1 / 0)) {\n        n = (n &gt; 0 || -1) * Math.floor(Math.abs(n));\n      }\n    }\n\n    for (k = n &gt;= 0 ? Math.min(n, len - 1) : len - Math.abs(n); k &gt;= 0; k--) {\n      if (k in t &amp;&amp; t[k] === searchElement) {\n        return k;\n      }\n    }\n    return -1;\n  };\n}\n</pre> <p>Again, note that this implementation aims for absolute compatibility with <code>lastIndexOf</code> in Firefox and the SpiderMonkey JavaScript engine, including in several cases which are arguably edge cases. If you intend to use this in real-world applications, you may be able to calculate <code>from</code> with less complicated code if you ignore those cases.</p> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/5.1/#sec-15.4.4.15\" hreflang=\"en\">ECMAScript 5.1 (ECMA-262)<br><small>The definition of 'Array.prototype.lastIndexOf' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition. Implemented in JavaScript 1.6.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-array.prototype.lastindexof\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Array.prototype.lastIndexOf' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-array.prototype.lastindexof\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Array.prototype.lastIndexOf' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>   <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1.5</td>\n<td class=\"bc-supports-yes\"> 9</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div>  <h2 id=\"Compatibility_notes\">Compatibility notes</h2> <ul> <li>Starting with Firefox 47 (Firefox 47 / Thunderbird 47 / SeaMonkey 2.44), this method will no longer return <code>-0</code>. For example, <code>[0].lastIndexOf(0, -0)</code> will now always return <code>+0</code> (<a href=\"https://bugzilla.mozilla.org/show_bug.cgi?id=1242043\">bug 1242043</a>).</li> </ul> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"indexof\"><code>Array.prototype.indexOf()</code></a></li> <li><a href=\"../typedarray/lastindexof\"><code>TypedArray.prototype.lastIndexOf()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/lastIndexOf$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/lastIndexOf\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/lastIndexOf</a>\n  </p>\n</div>\n","global_objects/array/map":"<h1>array.map</h1> <p>The <code><strong>map()</strong></code> method creates a new array with the results of calling a provided function on every element in the calling array.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/array-map.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\"><var>var new_array = arr</var>.map(function <var>callback(currentValue[, index[, array]]) {\n    // Return element for new_array\n}</var>[, <var>thisArg</var>])</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><code>callback</code></dt> <dd>Function that produces an element of the new Array, taking three arguments: <dl>  <dt><code>currentValue</code></dt> <dd>The current element being processed in the array.</dd> <dt>\n<code>index</code><span class=\"inlineIndicator optional optionalInline\">Optional</span>\n</dt> <dd>The index of the current element being processed in the array.</dd> <dt>\n<code>array</code><span class=\"inlineIndicator optional optionalInline\">Optional</span>\n</dt> <dd>The array <code>map</code> was called upon.</dd> </dl> </dd> <dt>\n<code>thisArg</code><span class=\"inlineIndicator optional optionalInline\">Optional</span>\n</dt> <dd>Value to use as <code>this</code> when executing <code>callback</code>.</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p>A new array with each element being the result of the callback function.</p> <h2 id=\"Description\">Description</h2> <p><code>map</code> calls a provided <code>callback</code> function <strong>once for each element</strong> in an array, in order, and constructs a new array from the results. <code>callback</code> is invoked only for indexes of the array which have assigned values, including <a href=\"../undefined\">undefined</a>. It is not called for missing elements of the array (that is, indexes that have never been set, which have been deleted or which have never been assigned a value).</p> <p>Since <code>map</code> builds a new array, using it when you aren't using the returned array is an anti-pattern; use <a href=\"foreach\"><code>forEach</code></a> or <a href=\"../../statements/for...of\"><code>for-of</code></a> instead. Signs you shouldn't be using map: A) You're not using the array it returns, and/or B) You're not returning a value from the callback.</p> <p><code>callback</code> is invoked with three arguments: the value of the element, the index of the element, and the Array object being traversed.</p> <p>If a <code>thisArg</code> parameter is provided to <code>map</code>, it will be used as callback's <code>this</code> value. Otherwise, the value <a href=\"../undefined\"><code>undefined</code></a> will be used as its <code>this</code> value. The <code>this</code> value ultimately observable by <code>callback</code> is determined according to <a href=\"../../operators/this\">the usual rules for determining the <code>this</code> seen by a function</a>.</p> <p><code>map</code> does not mutate the array on which it is called (although <code>callback</code>, if invoked, may do so).</p> <p>The range of elements processed by <code>map</code> is set before the first invocation of <code>callback</code>. Elements which are appended to the array after the call to <code>map</code> begins will not be visited by <code>callback</code>. If existing elements of the array are changed, their value as passed to <code>callback</code> will be the value at the time <code>map</code> visits them. Elements that are deleted after the call to <code>map</code> begins and before being visited are not visited.<br> <br> Due to the algorithm defined in the specification if the array which map was called upon is sparse, resulting array will also be sparse keeping same indices blank.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Mapping_an_array_of_numbers_to_an_array_of_square_roots\">Mapping an array of numbers to an array of square roots</h3> <p>The following code takes an array of numbers and creates a new array containing the square roots of the numbers in the first array.</p> <pre data-language=\"js\">var numbers = [1, 4, 9];\nvar roots = numbers.map(Math.sqrt);\n// roots is now [1, 2, 3]\n// numbers is still [1, 4, 9]\n</pre> <h3 id=\"Using_map_to_reformat_objects_in_an_array\">Using map to reformat objects in an array</h3> <p>The following code takes an array of objects and creates a new array containing the newly reformatted objects.</p> <pre data-language=\"js\">var kvArray = [{key: 1, value: 10}, \n               {key: 2, value: 20}, \n               {key: 3, value: 30}];\n\nvar reformattedArray = kvArray.map(obj =&gt;{ \n   var rObj = {};\n   rObj[obj.key] = obj.value;\n   return rObj;\n});\n// reformattedArray is now [{1: 10}, {2: 20}, {3: 30}], \n\n// kvArray is still: \n// [{key: 1, value: 10}, \n//  {key: 2, value: 20}, \n//  {key: 3, value: 30}]\n</pre> <h3 id=\"Mapping_an_array_of_numbers_using_a_function_containing_an_argument\">Mapping an array of numbers using a function containing an argument</h3> <p>The following code shows how map works when a function requiring one argument is used with it. The argument will automatically be assigned from each element of the array as map loops through the original array.</p> <pre data-language=\"js\">var numbers = [1, 4, 9];\nvar doubles = numbers.map(function(num) {\n  return num * 2;\n});\n\n// doubles is now [2, 8, 18]\n// numbers is still [1, 4, 9]\n</pre> <h3 id=\"Using_map_generically\">Using <code>map</code> generically</h3> <p>This example shows how to use map on a <a href=\"../string\"><code>String</code></a> to get an array of bytes in the ASCII encoding representing the character values:</p> <pre data-language=\"js\">var map = Array.prototype.map;\nvar a = map.call('Hello World', function(x) { \n  return x.charCodeAt(0); \n});\n// a now equals [72, 101, 108, 108, 111, 32, 87, 111, 114, 108, 100]\n</pre> <h3 id=\"Using_map_generically_querySelectorAll\">Using <code>map</code> generically <code>querySelectorAll</code>\n</h3> <p>This example shows how to iterate through a collection of objects collected by <code>querySelectorAll</code>. In this case we get all selected options on the screen and printed on the console:</p> <pre data-language=\"js\">var elems = document.querySelectorAll('select option:checked');\nvar values = Array.prototype.map.call(elems, function(obj) {\n  return obj.value;\n});\n</pre> <p>Easier way would be using <a href=\"from\"><code>Array.from()</code></a> method.</p> <h3 id=\"Tricky_use_case\">Tricky use case</h3> <p><a href=\"http://www.wirfs-brock.com/allen/posts/166\">(inspired by this blog post)</a></p> <p>It is common to use the callback with one argument (the element being traversed). Certain functions are also commonly used with one argument, even though they take additional optional arguments. These habits may lead to confusing behaviors.</p> <pre dir=\"rtl\" data-language=\"js\">// Consider:\n['1', '2', '3'].map(parseInt);\n// While one could expect [1, 2, 3]\n// The actual result is [1, NaN, NaN]\n\n// parseInt is often used with one argument, but takes two.\n// The first is an expression and the second is the radix.\n// To the callback function, Array.prototype.map passes 3 arguments: \n// the element, the index, the array\n// The third argument is ignored by parseInt, but not the second one,\n// hence the possible confusion. See the blog post for more details\n// If the link doesn't work\n// here is concise example of the iteration steps:\n// parseInt(string, radix) -&gt; map(parseInt(value, index))\n// first iteration (index is 0): parseInt('1', 0) // results in parseInt('1', 0) -&gt; 1\n// second iteration (index is 1): parseInt('2', 1) // results in parseInt('2', 1) -&gt; NaN\n// third iteration (index is 2): parseInt('3', 2) // results in parseInt('3', 2) -&gt; NaN\n\nfunction returnInt(element) {\n  return parseInt(element, 10);\n}\n\n['1', '2', '3'].map(returnInt); // [1, 2, 3]\n// Actual result is an array of numbers (as expected)\n\n// Same as above, but using the concise arrow function syntax\n['1', '2', '3'].map( str =&gt; parseInt(str) );\n\n// A simpler way to achieve the above, while avoiding the \"gotcha\":\n['1', '2', '3'].map(Number); // [1, 2, 3]\n// but unlike `parseInt` will also return a float or (resolved) exponential notation:\n['1.1', '2.2e2', '3e300'].map(Number); // [1.1, 220, 3e+300]\n</pre> <p>One alternative output of the map method being called with parseInt as a parameter runs as follows:</p> <pre data-language=\"js\">var xs = ['10', '10', '10'];\n\nxs = xs.map(parseInt);\n\nconsole.log(xs);\n// Actual result of 10,NaN,2 may be unexpected based on the above description.</pre> <h2 id=\"Polyfill\">Polyfill</h2> <p><code>map</code> was added to the ECMA-262 standard in the 5th edition; as such it may not be present in all implementations of the standard. You can work around this by inserting the following code at the beginning of your scripts, allowing use of <code>map</code> in implementations which do not natively support it. This algorithm is exactly the one specified in ECMA-262, 5th edition, assuming <a href=\"../object\"><code>Object</code></a>, <a href=\"../typeerror\"><code>TypeError</code></a>, and <a href=\"../array\"><code>Array</code></a> have their original values and that <code>callback.call</code> evaluates to the original value of <code><a href=\"../function/call\"><code>Function.prototype.call</code></a></code>.</p> <pre data-language=\"js\">// Production steps of ECMA-262, Edition 5, 15.4.4.19\n// Reference: http://es5.github.io/#x15.4.4.19\nif (!Array.prototype.map) {\n\n  Array.prototype.map = function(callback/*, thisArg*/) {\n\n    var T, A, k;\n\n    if (this == null) {\n      throw new TypeError('this is null or not defined');\n    }\n\n    // 1. Let O be the result of calling ToObject passing the |this| \n    //    value as the argument.\n    var O = Object(this);\n\n    // 2. Let lenValue be the result of calling the Get internal \n    //    method of O with the argument \"length\".\n    // 3. Let len be ToUint32(lenValue).\n    var len = O.length &gt;&gt;&gt; 0;\n\n    // 4. If IsCallable(callback) is false, throw a TypeError exception.\n    // See: http://es5.github.com/#x9.11\n    if (typeof callback !== 'function') {\n      throw new TypeError(callback + ' is not a function');\n    }\n\n    // 5. If thisArg was supplied, let T be thisArg; else let T be undefined.\n    if (arguments.length &gt; 1) {\n      T = arguments[1];\n    }\n\n    // 6. Let A be a new array created as if by the expression new Array(len) \n    //    where Array is the standard built-in constructor with that name and \n    //    len is the value of len.\n    A = new Array(len);\n\n    // 7. Let k be 0\n    k = 0;\n\n    // 8. Repeat, while k &lt; len\n    while (k &lt; len) {\n\n      var kValue, mappedValue;\n\n      // a. Let Pk be ToString(k).\n      //   This is implicit for LHS operands of the in operator\n      // b. Let kPresent be the result of calling the HasProperty internal \n      //    method of O with argument Pk.\n      //   This step can be combined with c\n      // c. If kPresent is true, then\n      if (k in O) {\n\n        // i. Let kValue be the result of calling the Get internal \n        //    method of O with argument Pk.\n        kValue = O[k];\n\n        // ii. Let mappedValue be the result of calling the Call internal \n        //     method of callback with T as the this value and argument \n        //     list containing kValue, k, and O.\n        mappedValue = callback.call(T, kValue, k, O);\n\n        // iii. Call the DefineOwnProperty internal method of A with arguments\n        // Pk, Property Descriptor\n        // { Value: mappedValue,\n        //   Writable: true,\n        //   Enumerable: true,\n        //   Configurable: true },\n        // and false.\n\n        // In browsers that support Object.defineProperty, use the following:\n        // Object.defineProperty(A, k, {\n        //   value: mappedValue,\n        //   writable: true,\n        //   enumerable: true,\n        //   configurable: true\n        // });\n\n        // For best browser support, use the following:\n        A[k] = mappedValue;\n      }\n      // d. Increase k by 1.\n      k++;\n    }\n\n    // 9. return A\n    return A;\n  };\n}\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/5.1/#sec-15.4.4.19\" hreflang=\"en\">ECMAScript 5.1 (ECMA-262)<br><small>The definition of 'Array.prototype.map' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition. Implemented in JavaScript 1.6.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-array.prototype.map\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Array.prototype.map' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-array.prototype.map\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Array.prototype.map' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>   <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1.5</td>\n<td class=\"bc-supports-yes\"> 9</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div>  <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"foreach\"><code>Array.prototype.forEach()</code></a></li> <li>\n<a href=\"../map\"><code>Map</code></a> object</li> <li><a href=\"from\"><code>Array.from()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map</a>\n  </p>\n</div>\n","global_objects/array/sort":"<h1>array.sort</h1> <p>The <code><strong>sort()</strong></code> method sorts the elements of an array <em><a href=\"https://en.wikipedia.org/wiki/In-place_algorithm\">in place</a></em> and returns the array. The default sort order is built upon converting the elements into strings, then comparing their sequences of UTF-16 code units values.</p> <p>The time and space complexity of the sort cannot be guaranteed as it is implementation dependent.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/array-sort.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\"><var>arr</var>.sort(<var>[compareFunction]</var>)\n</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt>\n<code>compareFunction</code> <span class=\"inlineIndicator optional optionalInline\">Optional</span>\n</dt> <dd>Specifies a function that defines the sort order. If omitted, the array is sorted according to each character's <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Values,_variables,_and_literals#Unicode\">Unicode</a> code point value, according to the string conversion of each element.</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p>The sorted array. Note that the array is sorted <em><a href=\"https://en.wikipedia.org/wiki/In-place_algorithm\">in place</a></em>, and no copy is made.</p> <h2 id=\"Description\">Description</h2> <p>If <code>compareFunction</code> is not supplied, all non-<code>undefined</code> array elements are sorted by converting them to strings and comparing strings in UTF-16 code units order. For example, \"Banana\" comes before \"cherry\". In a numeric sort, 9 comes before 80, but because numbers are converted to strings, \"80\" comes before \"9\" in Unicode order. All <code>undefined</code> elements are sorted to the end of the array.</p> <div class=\"blockIndicator note\"> <p><strong>Note :</strong> In UTF-16, Unicode characters above <code>\\uFFFF</code> are encoded as two surrogate code units, of the range <code>\\uD800</code>-<code>\\uDFFF</code>. The value of each code unit is taken separately into account for the comparison. Thus the character formed by the surrogate pair <code>\\uD655\\uDE55</code> will be sorted before the character <code>\\uFF3A</code>.</p> </div> <p>If <code>compareFunction</code> is supplied, all non-<code>undefined</code> array elements are sorted according to the return value of the compare function (all <code>undefined</code> elements are sorted to the end of the array, with no call to <code>compareFunction</code>). If <code>a</code> and <code>b</code> are two elements being compared, then:</p> <ul> <li>If <code>compareFunction(a, b)</code> is less than 0, sort <code>a</code> to an index lower than <code>b</code>, i.e. <code>a</code> comes first.</li> <li>If <code>compareFunction(a, b)</code> returns 0, leave <code>a</code> and <code>b</code> unchanged with respect to each other, but sorted with respect to all different elements. Note: the ECMAscript standard does not guarantee this behaviour, and thus not all browsers (e.g. Mozilla versions dating back to at least 2003) respect this.</li> <li>If <code>compareFunction(a, b)</code> is greater than 0, sort <code>b</code> to an index lower than <code>a</code>, i.e. <code>b</code> comes first.</li> <li>\n<code>compareFunction(a, b)</code> must always return the same value when given a specific pair of elements a and b as its two arguments. If inconsistent results are returned then the sort order is undefined.</li> </ul> <p>So, the compare function has the following form:</p> <pre data-language=\"js\">function compare(a, b) {\n  if (a is less than b by some ordering criterion) {\n    return -1;\n  }\n  if (a is greater than b by the ordering criterion) {\n    return 1;\n  }\n  // a must be equal to b\n  return 0;\n}\n</pre> <p>To compare numbers instead of strings, the compare function can simply subtract <code>b</code> from <code>a</code>. The following function will sort the array ascending (if it doesn't contain <code>Infinity</code> and <code>NaN</code>):</p> <pre data-language=\"js\">function compareNumbers(a, b) {\n  return a - b;\n}\n</pre> <p>The <code>sort</code> method can be conveniently used with <a href=\"../../operators/function\">function expressions</a>:</p> <pre data-language=\"js\">var numbers = [4, 2, 5, 1, 3];\nnumbers.sort(function(a, b) {\n  return a - b;\n});\nconsole.log(numbers);\n\n// [1, 2, 3, 4, 5]\n</pre> <p>Objects can be sorted given the value of one of their properties.</p> <pre data-language=\"js\">var items = [\n  { name: 'Edward', value: 21 },\n  { name: 'Sharpe', value: 37 },\n  { name: 'And', value: 45 },\n  { name: 'The', value: -12 },\n  { name: 'Magnetic', value: 13 },\n  { name: 'Zeros', value: 37 }\n];\n\n// sort by value\nitems.sort(function (a, b) {\n  return a.value - b.value;\n});\n\n// sort by name\nitems.sort(function(a, b) {\n  var nameA = a.name.toUpperCase(); // ignore upper and lowercase\n  var nameB = b.name.toUpperCase(); // ignore upper and lowercase\n  if (nameA &lt; nameB) {\n    return -1;\n  }\n  if (nameA &gt; nameB) {\n    return 1;\n  }\n\n  // names must be equal\n  return 0;\n});</pre> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Creating_displaying_and_sorting_an_array\">Creating, displaying, and sorting an array</h3> <p>The following example creates four arrays and displays the original array, then the sorted arrays. The numeric arrays are sorted without, then with, a compare function.</p> <pre data-language=\"js\">var stringArray = ['Blue', 'Humpback', 'Beluga'];\nvar numericStringArray = ['80', '9', '700'];\nvar numberArray = [40, 1, 5, 200];\nvar mixedNumericArray = ['80', '9', '700', 40, 1, 5, 200];\n\nfunction compareNumbers(a, b) {\n  return a - b;\n}\n\nconsole.log('stringArray:', stringArray.join());\nconsole.log('Sorted:', stringArray.sort());\n\nconsole.log('numberArray:', numberArray.join());\nconsole.log('Sorted without a compare function:', numberArray.sort());\nconsole.log('Sorted with compareNumbers:', numberArray.sort(compareNumbers));\n\nconsole.log('numericStringArray:', numericStringArray.join());\nconsole.log('Sorted without a compare function:', numericStringArray.sort());\nconsole.log('Sorted with compareNumbers:', numericStringArray.sort(compareNumbers));\n\nconsole.log('mixedNumericArray:', mixedNumericArray.join());\nconsole.log('Sorted without a compare function:', mixedNumericArray.sort());\nconsole.log('Sorted with compareNumbers:', mixedNumericArray.sort(compareNumbers));\n</pre> <p>This example produces the following output. As the output shows, when a compare function is used, numbers sort correctly whether they are numbers or numeric strings.</p> <pre>stringArray: Blue,Humpback,Beluga\nSorted: Beluga,Blue,Humpback\n\nnumberArray: 40,1,5,200\nSorted without a compare function: 1,200,40,5\nSorted with compareNumbers: 1,5,40,200\n\nnumericStringArray: 80,9,700\nSorted without a compare function: 700,80,9\nSorted with compareNumbers: 9,80,700\n\nmixedNumericArray: 80,9,700,40,1,5,200\nSorted without a compare function: 1,200,40,5,700,80,9\nSorted with compareNumbers: 1,5,9,40,80,200,700\n</pre> <h3 id=\"Sorting_non-ASCII_characters\">Sorting non-ASCII characters</h3> <p>For sorting strings with non-ASCII characters, i.e. strings with accented characters (e, é, è, a, ä, etc.), strings from languages other than English: use <a href=\"../string/localecompare\"><code>String.localeCompare</code></a>. This function can compare those characters so they appear in the right order.</p> <pre data-language=\"js\">var items = ['réservé', 'premier', 'cliché', 'communiqué', 'café', 'adieu'];\nitems.sort(function (a, b) {\n  return a.localeCompare(b);\n});\n\n// items is ['adieu', 'café', 'cliché', 'communiqué', 'premier', 'réservé']\n</pre> <h3 id=\"Sorting_with_map\">Sorting with map</h3> <p>The <code>compareFunction</code> can be invoked multiple times per element within the array. Depending on the <code>compareFunction</code>'s nature, this may yield a high overhead. The more work a <code>compareFunction</code> does and the more elements there are to sort, the wiser it may be to consider using a <a href=\"map\">map</a> for sorting. The idea is to traverse the array once to extract the actual values used for sorting into a temporary array, sort the temporary array and then traverse the temporary array to achieve the right order.</p> <pre dir=\"rtl\" data-language=\"js\">// the array to be sorted\nvar list = ['Delta', 'alpha', 'CHARLIE', 'bravo'];\n\n// temporary array holds objects with position and sort-value\nvar mapped = list.map(function(el, i) {\n  return { index: i, value: el.toLowerCase() };\n})\n\n// sorting the mapped array containing the reduced values\nmapped.sort(function(a, b) {\n  if (a.value &gt; b.value) {\n    return 1;\n  }\n  if (a.value &lt; b.value) {\n    return -1;\n  }\n  return 0;\n});\n\n// container for the resulting order\nvar result = mapped.map(function(el){\n  return list[el.index];\n});\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/publications/files/ECMA-ST-ARCH/ECMA-262,%201st%20edition,%20June%201997.pdf\" hreflang=\"en\">ECMAScript 1st Edition (ECMA-262)</a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/5.1/#sec-15.4.4.11\" hreflang=\"en\">ECMAScript 5.1 (ECMA-262)<br><small>The definition of 'Array.prototype.sort' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-array.prototype.sort\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Array.prototype.sort' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-array.prototype.sort\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Array.prototype.sort' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>   <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> 5.5</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div>  <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"reverse\"><code>Array.prototype.reverse()</code></a></li> <li><a href=\"../string/localecompare\"><code>String.prototype.localeCompare()</code></a></li> <li><a href=\"https://v8.dev/blog/array-sort\">About the stability of the algorithm used by V8 engine</a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort</a>\n  </p>\n</div>\n","global_objects/array/values":"<h1>array.values</h1> <p>The <code>values()</code> method returns a new <code>Array Iterator</code> object that contains the values for each index in the array.</p> <p><iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/array-values.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe></p> <pre data-language=\"js\">var a = ['w', 'y', 'k', 'o', 'p']; \nvar iterator = a.values();\n\nconsole.log(iterator.next().value); // w \nconsole.log(iterator.next().value); // y \nconsole.log(iterator.next().value); // k \nconsole.log(iterator.next().value); // o \nconsole.log(iterator.next().value); // p</pre> <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\"><var>arr</var>.values()</pre> <h3 id=\"Return_value\">Return value</h3> <p>A new <a href=\"../array\"><code>Array</code></a> iterator object.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Iteration_using_for...of_loop\">Iteration using <code><a href=\"../../statements/for...of\">for...of</a></code> loop</h3> <pre data-language=\"js\">var arr = ['w', 'y', 'k', 'o', 'p'];\nvar iterator = arr.values();\n\nfor (let letter of iterator) {\n  console.log(letter);\n}\n</pre> <p><strong>Array.prototype.values</strong> is default implementation of <strong>Array.prototype[Symbol.iterator]</strong>.</p> <pre>Array.prototype.values === Array.prototype[Symbol.iterator]      //true</pre> <p>TODO please write about why we need it, usecases.</p> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-array.prototype.values\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Array.prototype.values' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-array.prototype.values\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Array.prototype.values' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>   <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 66</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 60</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 53</td>\n<td class=\"bc-supports-yes\"> 9</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 66</td>\n<td class=\"bc-supports-yes\"> 66</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 60</td>\n<td class=\"bc-supports-yes\"> 53</td>\n<td class=\"bc-supports-yes\"> 9</td>\n<td class=\"bc-supports-no\"> No</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes bc-has-history\"> 10.9.0\n<section class=\"bc-history\" id=\"sect1\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 10.9.0\n</dt>\n\n<dt class=\"bc-supports-yes bc-supports\"> 6.5.0<div class=\"bc-icons\"> Disabled </div>\n</dt>\n<dd> The <code>--harmony-array-prototype-values</code> flag is required; the <code>--harmony</code> flag is not sufficient in this case.</dd>\n<dd>Disabled From version 6.5.0: this feature is behind the <code>--harmony-array-prototype-values</code> runtime flag.</dd>\n<dt class=\"bc-supports-no bc-supports\">0.12 — 4.0.0\n</dt>\n\n</dl></section>\n</td>\n</tr></tbody>\n</table>\n</div>  <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"keys\"><code>Array.prototype.keys()</code></a></li> <li><a href=\"entries\"><code>Array.prototype.entries()</code></a></li> <li><a href=\"foreach\"><code>Array.prototype.forEach()</code></a></li> <li><a href=\"every\"><code>Array.prototype.every()</code></a></li> <li><a href=\"some\"><code>Array.prototype.some()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/values$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/values\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/values</a>\n  </p>\n</div>\n","global_objects/array/reduce":"<h1>array.reduce</h1> <p>The <code><strong>reduce()</strong></code> method executes a <strong>reducer</strong> function (that you provide) on each member of the array resulting in a single output value.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/array-reduce.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <p>The <strong>reducer</strong> function is fed four parameters:</p> <ol> <li>Accumulator (acc)</li> <li>Current Value (cur)</li> <li>Current Index (idx)</li> <li>Source Array (src)</li> </ol> <p>Your <strong>reducer</strong> function's returned value is assigned to the accumulator, whose value is remembered across each iteration throughout the array and ultimately becomes the final, single resulting value.</p> <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\"><var>arr</var>.reduce(<var>callback[, </var><var>initialValue]</var>)</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><code>callback</code></dt> <dd>Function to execute on each element in the array, taking four arguments: <dl> <dt><code>accumulator</code></dt> <dd>The accumulator accumulates the callback's return values; it is the accumulated value previously returned in the last invocation of the callback, or <code>initialValue</code>, if supplied (see below).</dd> <dt><code>currentValue</code></dt> <dd>The current element being processed in the array.</dd> <dt>\n<code>currentIndex</code><span class=\"inlineIndicator optional optionalInline\">Optional</span>\n</dt> <dd>The index of the current element being processed in the array. Starts at index 0, if an <code>initialValue</code> is provided, and at index 1 otherwise.</dd> <dt>\n<code>array</code><span class=\"inlineIndicator optional optionalInline\">Optional</span>\n</dt> <dd>The array <code>reduce()</code> was called upon.</dd> </dl> </dd> <dt>\n<code>initialValue</code><span class=\"inlineIndicator optional optionalInline\">Optional</span>\n</dt> <dd>Value to use as the first argument to the first call of the <code>callback</code>. If no initial value is supplied, the first element in the array will be used. Calling <code>reduce()</code> on an empty array without an initial value is an error.</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p>The value that results from the reduction.</p> <h2 id=\"Description\">Description</h2> <p><code>reduce()</code> executes the <code>callback</code> function once for each element present in the array, excluding holes in the array, receiving four arguments:</p> <ul> <li><code>accumulator</code></li> <li><code>currentValue</code></li> <li><code>currentIndex</code></li> <li><code>array</code></li> </ul> <p>The first time the callback is called, <code>accumulator</code> and <code>currentValue</code> can be one of two values. If <code>initialValue</code> is provided in the call to <code>reduce()</code>, then <code>accumulator</code> will be equal to <code>initialValue</code>, and <code>currentValue</code> will be equal to the first value in the array. If no <code>initialValue</code> is provided, then <code>accumulator</code> will be equal to the first value in the array, and <code>currentValue</code> will be equal to the second.</p> <div class=\"note\"> <p><strong>Note:</strong> If <code>initialValue</code> isn't provided, <code>reduce()</code> will execute the callback function starting at index 1, skipping the first index. If <code>initialValue</code> is provided, it will start at index 0.</p> </div> <p>If the array is empty and no <code>initialValue</code> is provided, <a href=\"../typeerror\"><code>TypeError</code></a> will be thrown. If the array has only one element (regardless of position) and no <code>initialValue</code> is provided, or if <code>initialValue</code> is provided but the array is empty, the solo value will be returned <em>without calling <code>callback</code>.</em></p> <p>It is usually safer to provide an initial value because there are three possible outputs without <code>initialValue</code>, as shown in the following example.</p> <pre data-language=\"js\">var maxCallback = ( acc, cur ) =&gt; Math.max( acc.x, cur.x );\nvar maxCallback2 = ( max, cur ) =&gt; Math.max( max, cur );\n\n// reduce() without initialValue\n[ { x: 22 }, { x: 42 } ].reduce( maxCallback ); // 42\n[ { x: 22 }            ].reduce( maxCallback ); // { x: 22 }\n[                      ].reduce( maxCallback ); // TypeError\n\n// map/reduce; better solution, also works for empty or larger arrays\n[ { x: 22 }, { x: 42 } ].map( el =&gt; el.x )\n                        .reduce( maxCallback2, -Infinity );\n</pre> <h3 id=\"How_reduce()_works\">How reduce() works</h3> <p>Suppose the following use of <code>reduce()</code> occurred:</p> <pre data-language=\"js\">[0, 1, 2, 3, 4].reduce(function(accumulator, currentValue, currentIndex, array) {\n  return accumulator + currentValue;\n});\n</pre> <p>The callback would be invoked four times, with the arguments and return values in each call being as follows:</p> <div class=\"_table\"><table> <thead> <tr> <th scope=\"col\"><code>callback</code></th> <th scope=\"col\"><code>accumulator</code></th> <th scope=\"col\"><code>currentValue</code></th> <th scope=\"col\"><code>currentIndex</code></th> <th scope=\"col\"><code>array</code></th> <th scope=\"col\">return value</th> </tr> </thead> <tbody> <tr> <th scope=\"row\">first call</th> <td><code>0</code></td> <td><code>1</code></td> <td>1</td> <td><code>[0, 1, 2, 3, 4]</code></td> <td><code>1</code></td> </tr> <tr> <th scope=\"row\">second call</th> <td><code>1</code></td> <td><code>2</code></td> <td>2</td> <td><code>[0, 1, 2, 3, 4]</code></td> <td><code>3</code></td> </tr> <tr> <th scope=\"row\">third call</th> <td><code>3</code></td> <td><code>3</code></td> <td>3</td> <td><code>[0, 1, 2, 3, 4]</code></td> <td><code>6</code></td> </tr> <tr> <th scope=\"row\">fourth call</th> <td><code>6</code></td> <td><code>4</code></td> <td>4</td> <td><code>[0, 1, 2, 3, 4]</code></td> <td><code>10</code></td> </tr> </tbody> </table></div> <p>The value returned by <code>reduce()</code> would be that of the last callback invocation (<code>10</code>).</p> <p>You can also provide an <a href=\"../../functions/arrow_functions\">Arrow Function</a> in lieu of a full function. The code below will produce the same output as the code in the block above:</p> <pre data-language=\"js\">[0, 1, 2, 3, 4].reduce( (accumulator, currentValue, currentIndex, array) =&gt; accumulator + currentValue );\n</pre> <p>If you were to provide an initial value as the second argument to <code>reduce()</code>, the result would look like this:</p> <pre data-language=\"js\">[0, 1, 2, 3, 4].reduce((accumulator, currentValue, currentIndex, array) =&gt; {\n    return accumulator + currentValue;\n}, 10);\n</pre> <div class=\"_table\"><table> <thead> <tr> <th scope=\"col\"><code>callback</code></th> <th scope=\"col\"><code>accumulator</code></th> <th scope=\"col\"><code>currentValue</code></th> <th scope=\"col\"><code>currentIndex</code></th> <th scope=\"col\"><code>array</code></th> <th scope=\"col\">return value</th> </tr> </thead> <tbody> <tr> <th scope=\"row\">first call</th> <td><code>10</code></td> <td><code>0</code></td> <td><code>0</code></td> <td><code>[0, 1, 2, 3, 4]</code></td> <td><code>10</code></td> </tr> <tr> <th scope=\"row\">second call</th> <td><code>10</code></td> <td><code>1</code></td> <td><code>1</code></td> <td><code>[0, 1, 2, 3, 4]</code></td> <td><code>11</code></td> </tr> <tr> <th scope=\"row\">third call</th> <td><code>11</code></td> <td><code>2</code></td> <td><code>2</code></td> <td><code>[0, 1, 2, 3, 4]</code></td> <td><code>13</code></td> </tr> <tr> <th scope=\"row\">fourth call</th> <td><code>13</code></td> <td><code>3</code></td> <td><code>3</code></td> <td><code>[0, 1, 2, 3, 4]</code></td> <td><code>16</code></td> </tr> <tr> <th scope=\"row\">fifth call</th> <td><code>16</code></td> <td><code>4</code></td> <td><code>4</code></td> <td><code>[0, 1, 2, 3, 4]</code></td> <td><code>20</code></td> </tr> </tbody> </table></div> <p>The value returned by <code>reduce()</code> in this case would be <code>20</code>.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Sum_all_the_values_of_an_array\">Sum all the values of an array</h3> <pre data-language=\"js\">var sum = [0, 1, 2, 3].reduce(function (accumulator, currentValue) {\n  return accumulator + currentValue;\n}, 0);\n// sum is 6\n\n</pre> <p>Alternatively, written with an arrow function:</p> <pre data-language=\"js\">var total = [ 0, 1, 2, 3 ].reduce(\n  ( accumulator, currentValue ) =&gt; accumulator + currentValue,\n  0\n);</pre> <h3 id=\"Sum_of_values_in_an_object_array\">Sum of values in an object array</h3> <p>To sum up values contained in an array of objects you <strong>must</strong> supply an initial value so that each item passes through your function.</p> <pre data-language=\"js\">var initialValue = 0;\nvar sum = [{x: 1}, {x:2}, {x:3}].reduce(function (accumulator, currentValue) {\n    return accumulator + currentValue.x;\n},initialValue)\n\nconsole.log(sum) // logs 6\n</pre> <p>Alternatively, written with an arrow function: </p> <pre data-language=\"js\">var initialValue = 0;\nvar sum = [{x: 1}, {x:2}, {x:3}].reduce(\n    (accumulator, currentValue) =&gt; accumulator + currentValue.x\n    ,initialValue\n);\n\nconsole.log(sum) // logs 6</pre> <h3 id=\"Flatten_an_array_of_arrays\">Flatten an array of arrays</h3> <pre data-language=\"js\">var flattened = [[0, 1], [2, 3], [4, 5]].reduce(\n  function(accumulator, currentValue) {\n    return accumulator.concat(currentValue);\n  },\n  []\n);\n// flattened is [0, 1, 2, 3, 4, 5]\n</pre> <p>Alternatively, written with an arrow function:</p> <pre data-language=\"js\">var flattened = [[0, 1], [2, 3], [4, 5]].reduce(\n  ( accumulator, currentValue ) =&gt; accumulator.concat(currentValue),\n  []\n);\n</pre> <h3 id=\"Counting_instances_of_values_in_an_object\">Counting instances of values in an object</h3> <pre data-language=\"js\">var names = ['Alice', 'Bob', 'Tiff', 'Bruce', 'Alice'];\n\nvar countedNames = names.reduce(function (allNames, name) { \n  if (name in allNames) {\n    allNames[name]++;\n  }\n  else {\n    allNames[name] = 1;\n  }\n  return allNames;\n}, {});\n// countedNames is:\n// { 'Alice': 2, 'Bob': 1, 'Tiff': 1, 'Bruce': 1 }\n</pre> <h3 id=\"Grouping_objects_by_a_property\">Grouping objects by a property</h3> <pre data-language=\"js\">var people = [\n  { name: 'Alice', age: 21 },\n  { name: 'Max', age: 20 },\n  { name: 'Jane', age: 20 }\n];\n\nfunction groupBy(objectArray, property) {\n  return objectArray.reduce(function (acc, obj) {\n    var key = obj[property];\n    if (!acc[key]) {\n      acc[key] = [];\n    }\n    acc[key].push(obj);\n    return acc;\n  }, {});\n}\n\nvar groupedPeople = groupBy(people, 'age');\n// groupedPeople is:\n// { \n//   20: [\n//     { name: 'Max', age: 20 }, \n//     { name: 'Jane', age: 20 }\n//   ], \n//   21: [{ name: 'Alice', age: 21 }] \n// }\n</pre> <h3 id=\"Bonding_arrays_contained_in_an_array_of_objects_using_the_spread_operator_and_initialValue\">Bonding arrays contained in an array of objects using the spread operator and initialValue</h3> <pre data-language=\"js\">// friends - an array of objects \n// where object field \"books\" - list of favorite books \nvar friends = [{\n  name: 'Anna',\n  books: ['Bible', 'Harry Potter'],\n  age: 21\n}, {\n  name: 'Bob',\n  books: ['War and peace', 'Romeo and Juliet'],\n  age: 26\n}, {\n  name: 'Alice',\n  books: ['The Lord of the Rings', 'The Shining'],\n  age: 18\n}];\n\n// allbooks - list which will contain all friends' books +  \n// additional list contained in initialValue\nvar allbooks = friends.reduce(function(accumulator, currentValue) {\n  return [...accumulator, ...currentValue.books];\n}, ['Alphabet']);\n\n// allbooks = [\n//   'Alphabet', 'Bible', 'Harry Potter', 'War and peace', \n//   'Romeo and Juliet', 'The Lord of the Rings',\n//   'The Shining'\n// ]</pre>  <h3 id=\"Remove_duplicate_items_in_array\">Remove duplicate items in array</h3> <pre data-language=\"js\">let arr = [1, 2, 1, 2, 3, 5, 4, 5, 3, 4, 4, 4, 4];\nlet result = arr.sort().reduce((accumulator, current) =&gt; {\n    const length = accumulator.length\n    if (length === 0 || accumulator[length - 1] !== current) {\n        accumulator.push(current);\n    }\n    return accumulator;\n}, []);\nconsole.log(result); //[1,2,3,4,5]\n</pre> <h3 id=\"Running_Promises_in_Sequence\">Running Promises in Sequence</h3> <pre data-language=\"js\">/**\n * Runs promises from array of functions that can return promises\n * in chained manner\n *\n * @param {array} arr - promise arr\n * @return {Object} promise object\n */\nfunction runPromiseInSequence(arr, input) {\n  return arr.reduce(\n    (promiseChain, currentFunction) =&gt; promiseChain.then(currentFunction),\n    Promise.resolve(input)\n  );\n}\n\n// promise function 1\nfunction p1(a) {\n  return new Promise((resolve, reject) =&gt; {\n    resolve(a * 5);\n  });\n}\n\n// promise function 2\nfunction p2(a) {\n  return new Promise((resolve, reject) =&gt; {\n    resolve(a * 2);\n  });\n}\n\n// function 3  - will be wrapped in a resolved promise by .then()\nfunction f3(a) {\n return a * 3;\n}\n\n// promise function 4\nfunction p4(a) {\n  return new Promise((resolve, reject) =&gt; {\n    resolve(a * 4);\n  });\n}\n\nconst promiseArr = [p1, p2, f3, p4];\nrunPromiseInSequence(promiseArr, 10)\n  .then(console.log);   // 1200\n</pre> <h3 id=\"Function_composition_enabling_piping\">Function composition enabling piping</h3> <pre data-language=\"js\">// Building-blocks to use for composition\nconst double = x =&gt; x + x;\nconst triple = x =&gt; 3 * x;\nconst quadruple = x =&gt; 4 * x;\n\n// Function composition enabling pipe functionality\nconst pipe = (...functions) =&gt; input =&gt; functions.reduce(\n    (acc, fn) =&gt; fn(acc),\n    input\n);\n\n// Composed functions for multiplication of specific values\nconst multiply6 = pipe(double, triple);\nconst multiply9 = pipe(triple, triple);\nconst multiply16 = pipe(quadruple, quadruple);\nconst multiply24 = pipe(double, triple, quadruple);\n\n// Usage\nmultiply6(6); // 36\nmultiply9(9); // 81\nmultiply16(16); // 256\nmultiply24(10); // 240\n\n</pre> <h3 id=\"write_map_using_reduce\">write map using reduce</h3> <pre data-language=\"js\">if (!Array.prototype.mapUsingReduce) {\n  Array.prototype.mapUsingReduce = function(callback, thisArg) {\n    return this.reduce(function(mappedArray, currentValue, index, array) {\n      mappedArray[index] = callback.call(thisArg, currentValue, index, array);\n      return mappedArray;\n    }, []);\n  };\n}\n\n[1, 2, , 3].mapUsingReduce(\n  (currentValue, index, array) =&gt; currentValue + index + array.length\n); // [5, 7, , 10]\n\n</pre> <h2 id=\"Polyfill\">Polyfill</h2> <pre data-language=\"js\">// Production steps of ECMA-262, Edition 5, 15.4.4.21\n// Reference: http://es5.github.io/#x15.4.4.21\n// https://tc39.github.io/ecma262/#sec-array.prototype.reduce\nif (!Array.prototype.reduce) {\n  Object.defineProperty(Array.prototype, 'reduce', {\n    value: function(callback /*, initialValue*/) {\n      if (this === null) {\n        throw new TypeError( 'Array.prototype.reduce ' + \n          'called on null or undefined' );\n      }\n      if (typeof callback !== 'function') {\n        throw new TypeError( callback +\n          ' is not a function');\n      }\n\n      // 1. Let O be ? ToObject(this value).\n      var o = Object(this);\n\n      // 2. Let len be ? ToLength(? Get(O, \"length\")).\n      var len = o.length &gt;&gt;&gt; 0; \n\n      // Steps 3, 4, 5, 6, 7      \n      var k = 0; \n      var value;\n\n      if (arguments.length &gt;= 2) {\n        value = arguments[1];\n      } else {\n        while (k &lt; len &amp;&amp; !(k in o)) {\n          k++; \n        }\n\n        // 3. If len is 0 and initialValue is not present,\n        //    throw a TypeError exception.\n        if (k &gt;= len) {\n          throw new TypeError( 'Reduce of empty array ' +\n            'with no initial value' );\n        }\n        value = o[k++];\n      }\n\n      // 8. Repeat, while k &lt; len\n      while (k &lt; len) {\n        // a. Let Pk be ! ToString(k).\n        // b. Let kPresent be ? HasProperty(O, Pk).\n        // c. If kPresent is true, then\n        //    i.  Let kValue be ? Get(O, Pk).\n        //    ii. Let accumulator be ? Call(\n        //          callbackfn, undefined,\n        //          « accumulator, kValue, k, O »).\n        if (k in o) {\n          value = callback(value, o[k], k, o);\n        }\n\n        // d. Increase k by 1.      \n        k++;\n      }\n\n      // 9. Return accumulator.\n      return value;\n    }\n  });\n}\n</pre> <p>If you need to support truly obsolete JavaScript engines that don't support <code><a href=\"../object/defineproperty\">Object.defineProperty()</a></code>, it's best not to polyfill <code>Array.prototype</code> methods at all, as you can't make them <strong>non-enumerable</strong>.</p> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/5.1/#sec-15.4.4.21\" hreflang=\"en\">ECMAScript 5.1 (ECMA-262)<br><small>The definition of 'Array.prototype.reduce()' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition. Implemented in JavaScript 1.8.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-array.prototype.reduce\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Array.prototype.reduce()' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-array.prototype.reduce\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Array.prototype.reduce()' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>   <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/reduce\">Basic support</a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 3</td>\n<td class=\"bc-supports-yes\"> 9</td>\n<td class=\"bc-supports-yes\"> 10.5</td>\n<td class=\"bc-supports-yes\"> 4</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/reduce\">Basic support</a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/reduce\">Basic support</a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div>  <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"reduceright\"><code>Array.prototype.reduceRight()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/reduce$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/reduce\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/reduce</a>\n  </p>\n</div>\n","global_objects/array/tostring":"<h1>array.toString</h1> <p>The <code><strong>toString()</strong></code> method returns a string representing the specified array and its elements.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/array-tostring.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe> <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\"><var>arr</var>.toString()</pre> <h3 id=\"Return_value\">Return value</h3> <p>A string representing the elements of the array.</p> <h2 id=\"Description\">Description</h2> <p>The <a href=\"../array\"><code>Array</code></a> object overrides the <code>toString</code> method of <a href=\"../object\"><code>Object</code></a>. For Array objects, the <code>toString</code> method joins the array and returns one string containing each array element separated by commas.</p> <p>JavaScript calls the <code>toString</code> method automatically when an array is to be represented as a text value or when an array is referred to in a string concatenation.</p> <h3 id=\"ECMAScript_5_semantics\">ECMAScript 5 semantics</h3> <p>Starting in JavaScript 1.8.5 (Firefox 4), and consistent with ECMAScript 5th edition semantics, the <code>toString()</code> method is generic and can be used with any object. <a href=\"../object/tostring\"><code>Object.prototype.toString()</code></a> will be called, and the resulting value will be returned.</p> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/publications/files/ECMA-ST-ARCH/ECMA-262,%201st%20edition,%20June%201997.pdf\" hreflang=\"en\">ECMAScript 1st Edition (ECMA-262)</a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition. Implemented in JavaScript 1.1.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/5.1/#sec-15.4.4.2\" hreflang=\"en\">ECMAScript 5.1 (ECMA-262)<br><small>The definition of 'Array.prototype.toString' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-array.prototype.tostring\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Array.prototype.toString' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-array.prototype.tostring\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Array.prototype.toString' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>   <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div>  <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"join\"><code>Array.prototype.join()</code></a></li> <li><a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/toSource\"><code>Object.prototype.toSource()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/toString$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/toString\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/toString</a>\n  </p>\n</div>\n","global_objects/collator/prototype":"<h1>Intl.Collator.prototype</h1> <p>The <code>Intl.Collator.prototype</code> property represents the prototype object for the <a href=\"../collator\"><code>Intl.Collator</code></a> constructor.</p> <div class=\"_table\"><table class=\"standard-table\"> <thead> <tr> <th colspan=\"2\" class=\"header\">Property attributes of <code>Intl.Collator.prototype</code>\n</th> </tr> </thead> <tbody> <tr> <td>Writable</td> <td>no</td> </tr> <tr> <td>Enumerable</td> <td>no</td> </tr> <tr> <td>Configurable</td> <td>no</td> </tr> </tbody> </table></div> <h2 id=\"Description\">Description</h2> <p>See <a href=\"../collator\"><code>Collator</code></a> for a description of <code>Intl.Collator</code> instances.</p> <p><a href=\"../collator\"><code>Intl.Collator</code></a> instances inherit from <code>Intl.Collator.prototype</code>. Modifications to the prototype object are inherited by all <a href=\"../collator\"><code>Intl.Collator</code></a> instances.</p> <h2 id=\"Properties\">Properties</h2> <dl> <dt><a href=\"compare\"><code>Intl.Collator.prototype.compare</code></a></dt> <dd>Getter; returns a function that compares two strings according to the sort order of this <a href=\"../collator\"><code>Intl.Collator</code></a> object.</dd> <dt><code>Intl.Collator.prototype.constructor</code></dt> <dd>A reference to <a href=\"../collator\"><code>Intl.Collator</code></a>.</dd> </dl> <h2 id=\"Methods\">Methods</h2> <dl> <dt><a href=\"resolvedoptions\"><code>Intl.Collator.prototype.resolvedOptions()</code></a></dt> <dd>Returns a new object with properties reflecting the locale and collation options computed during initialization of the object.</dd> </dl> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-402/1.0/#sec-10.2.1\" hreflang=\"en\">ECMAScript Internationalization API 1.0 (ECMA-402)<br><small>The definition of 'Intl.Collator.prototype' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-402/2.0/#sec-10.2.1\" hreflang=\"en\">ECMAScript Internationalization API 2.0 (ECMA-402)<br><small>The definition of 'Intl.Collator.prototype' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma402/#sec-Intl.Collator.prototype\" hreflang=\"en\">ECMAScript Internationalization API 4.0 (ECMA-402)<br><small>The definition of 'Intl.Collator.prototype' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>   <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 24</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 29</td>\n<td class=\"bc-supports-yes\"> 11</td>\n<td class=\"bc-supports-yes\"> 15</td>\n<td class=\"bc-supports-yes\"> 10</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 26</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 56</td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 10</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td> ? </td>\n</tr></tbody>\n</table>\n</div>  <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"../collator\"><code>Intl.Collator</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Collator/prototype$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Collator/prototype\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Collator/prototype</a>\n  </p>\n</div>\n","global_objects/collator/resolvedoptions":"<h1>Intl.collator.resolvedOptions</h1> <p>The <code>Intl.Collator.prototype.resolvedOptions()</code> method returns a new object with properties reflecting the locale and collation options computed during initialization of this <a href=\"../collator\"><code>Collator</code></a> object.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/intl-collator-prototype-resolvedoptions.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\"><var>collator</var>.resolvedOptions()</pre> <h3 id=\"Return_value\">Return value</h3> <p>A new object with properties reflecting the locale and collation options computed during the initialization of the given <a href=\"../collator\"><code>Collator</code></a> object.</p> <h2 id=\"Description\">Description</h2> <p>The resulting object has the following properties:</p> <dl> <dt><code>locale</code></dt> <dd>The BCP 47 language tag for the locale actually used. If any Unicode extension values were requested in the input BCP 47 language tag that led to this locale, the key-value pairs that were requested and are supported for this locale are included in <code>locale</code>.</dd> <dt><code>usage</code></dt> <dt><code>sensitivity</code></dt> <dt><code>ignorePunctuation</code></dt> <dd>The values provided for these properties in the <code>options</code> argument or filled in as defaults.</dd> <dt><code>collation</code></dt> <dd>The value requested using the Unicode extension key <code>\"co\"</code>, if it is supported for <code>locale</code>, or <code>\"default\"</code>.</dd> <dt><code>numeric</code></dt> <dt><code>caseFirst</code></dt> <dd>The values requested for these properties in the <code>options</code> argument or using the Unicode extension keys <code>\"kn\"</code> and <code>\"kf\"</code> or filled in as defaults. If the implementation does not support these properties, they are omitted.</dd> </dl> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Using_the_resolvedOptions_method\">Using the <code>resolvedOptions</code> method</h3> <pre data-language=\"js\">var de = new Intl.Collator('de', { sensitivity: 'base' })\nvar usedOptions = de.resolvedOptions();\n\nusedOptions.locale;            // \"de\"\nusedOptions.usage;             // \"sort\"\nusedOptions.sensitivity;       // \"base\"\nusedOptions.ignorePunctuation; // false\nusedOptions.collation;         // \"default\"\nusedOptions.numeric;           // false\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-402/1.0/#sec-10.3.3\" hreflang=\"en\">ECMAScript Internationalization API 1.0 (ECMA-402)<br><small>The definition of 'Intl.Collator.prototype.resolvedOptions' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-402/2.0/#sec-10.3.3\" hreflang=\"en\">ECMAScript Internationalization API 2.0 (ECMA-402)<br><small>The definition of 'Intl.Collator.prototype.resolvedOptions' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma402/#sec-Intl.Collator.prototype.resolvedOptions\" hreflang=\"en\">ECMAScript Internationalization API 4.0 (ECMA-402)<br><small>The definition of 'Intl.Collator.prototype.resolvedOptions' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>   <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 24</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 29</td>\n<td class=\"bc-supports-yes\"> 11</td>\n<td class=\"bc-supports-yes\"> 15</td>\n<td class=\"bc-supports-yes\"> 10</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 26</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 56</td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 10</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td> ? </td>\n</tr></tbody>\n</table>\n</div>  <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"../collator\"><code>Intl.Collator</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Collator/resolvedOptions$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Collator/resolvedOptions\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Collator/resolvedOptions</a>\n  </p>\n</div>\n","global_objects/array/reduceright":"<h1>array.reduceRight</h1> <p>The <code><strong>reduceRight()</strong></code> method applies a function against an accumulator and each value of the array (from right-to-left) to reduce it to a single value.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/array-reduce-right.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <p>See also <a href=\"reduce\"><code>Array.prototype.reduce()</code></a> for left-to-right.</p> <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\"><var>arr</var>.reduceRight(<var>callback</var>[, <var>initialValue</var>])</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><code>callback</code></dt> <dd>Function to execute on each value in the array, taking four arguments: <dl> <dt><code>accumulator</code></dt> <dd>The value previously returned in the last invocation of the callback, or <code>initialValue</code>, if supplied. (See below.)</dd> <dt><code>currentValue</code></dt> <dd>The current element being processed in the array.</dd> <dt>\n<code>index</code><span class=\"inlineIndicator optional optionalInline\">Optional</span>\n</dt> <dd>The index of the current element being processed in the array.</dd> <dt>\n<code>array</code><span class=\"inlineIndicator optional optionalInline\">Optional</span>\n</dt> <dd>The array <code>reduce</code> was called upon.</dd> </dl> </dd> <dt>\n<code>initialValue</code><span class=\"inlineIndicator optional optionalInline\">Optional</span>\n</dt> <dd>Object to use as the first argument to the first call of the <code>callback</code>. If no initial value is supplied, the last element in the array will be used. Calling reduce on an empty array without an initial value is an error.</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p>The value that results from the reduction.</p> <h2 id=\"Description\">Description</h2> <p><code>reduceRight</code> executes the callback function once for each element present in the array, excluding holes in the array, receiving four arguments: the initial value (or value from the previous callback call), the value of the current element, the current index, and the array over which iteration is occurring.</p> <p>The call to the reduceRight <code>callback</code> would look something like this:</p> <pre data-language=\"js\">array.reduceRight(function(accumulator, currentValue, index, array) {\n  // ...\n});\n</pre> <p>The first time the function is called, the <code>accumulator</code> and <code>currentValue</code> can be one of two values. If an <code>initialValue</code> was provided in the call to <code>reduceRight</code>, then <code>accumulator</code> will be equal to <code>initialValue</code> and <code>currentValue</code> will be equal to the last value in the array. If no <code>initialValue</code> was provided, then <code>accumulator</code> will be equal to the last value in the array and <code>currentValue</code> will be equal to the second-to-last value.</p> <p>If the array is empty and no <code>initialValue </code>was provided, <a href=\"../typeerror\"><code>TypeError</code></a> would be thrown. If the array has only one element (regardless of position) and no <code>initialValue </code>was provided, or if <code>initialValue</code> is provided but the array is empty, the solo value would be returned without calling <code>callback</code>.</p> <p>Some example run-throughs of the function would look like this:</p> <pre data-language=\"js\">[0, 1, 2, 3, 4].reduceRight(function(accumulator, currentValue, index, array) {\n  return accumulator + currentValue;\n});\n</pre> <p>The callback would be invoked four times, with the arguments and return values in each call being as follows:</p> <div class=\"_table\"><table> <thead> <tr> <th scope=\"col\"><code>callback</code></th> <th scope=\"col\"><code>accumulator</code></th> <th scope=\"col\"><code>currentValue</code></th> <th scope=\"col\"><code>index</code></th> <th scope=\"col\"><code>array</code></th> <th scope=\"col\">return value</th> </tr> </thead> <tbody> <tr> <th scope=\"row\">first call</th> <td><code>4</code></td> <td><code>3</code></td> <td><code>3</code></td> <td><code>[0, 1, 2, 3, 4]</code></td> <td><code>7</code></td> </tr> <tr> <th scope=\"row\">second call</th> <td><code>7</code></td> <td><code>2</code></td> <td><code>2</code></td> <td><code>[0, 1, 2, 3, 4]</code></td> <td><code>9</code></td> </tr> <tr> <th scope=\"row\">third call</th> <td><code>9</code></td> <td><code>1</code></td> <td><code>1</code></td> <td><code>[0, 1, 2, 3, 4]</code></td> <td><code>10</code></td> </tr> <tr> <th scope=\"row\">fourth call</th> <td><code>10</code></td> <td><code>0</code></td> <td><code>0</code></td> <td><code>[0, 1, 2, 3, 4]</code></td> <td><code>10</code></td> </tr> </tbody> </table></div> <p>The value returned by <code>reduceRight</code> would be that of the last callback invocation (<code>10</code>).</p> <p>And if you were to provide an <code>initialValue</code>, the result would look like this:</p> <pre data-language=\"js\">[0, 1, 2, 3, 4].reduceRight(function(accumulator, currentValue, index, array) {\n  return accumulator + currentValue;\n}, 10);\n</pre> <div class=\"_table\"><table> <thead> <tr> <th scope=\"col\"><code>callback</code></th> <th scope=\"col\"><code>accumulator</code></th> <th scope=\"col\"><code>currentValue</code></th> <th scope=\"col\"><code>index</code></th> <th scope=\"col\"><code>array</code></th> <th scope=\"col\">return value</th> </tr> </thead> <tbody> <tr> <th scope=\"row\">first call</th> <td><code>10</code></td> <td><code>4</code></td> <td><code>4</code></td> <td><code>[0, 1, 2, 3, 4]</code></td> <td><code>14</code></td> </tr> <tr> <th scope=\"row\">second call</th> <td><code>14</code></td> <td><code>3</code></td> <td><code>3</code></td> <td><code>[0, 1, 2, 3, 4]</code></td> <td><code>17</code></td> </tr> <tr> <th scope=\"row\">third call</th> <td><code>17</code></td> <td><code>2</code></td> <td><code>2</code></td> <td><code>[0, 1, 2, 3, 4]</code></td> <td><code>19</code></td> </tr> <tr> <th scope=\"row\">fourth call</th> <td><code>19</code></td> <td><code>1</code></td> <td><code>1</code></td> <td><code>[0, 1, 2, 3, 4]</code></td> <td><code>20</code></td> </tr> <tr> <th scope=\"row\">fifth call</th> <td><code>20</code></td> <td><code>0</code></td> <td><code>0</code></td> <td><code>[0, 1, 2, 3, 4]</code></td> <td><code>20</code></td> </tr> </tbody> </table></div> <p>The value returned by <code>reduceRight</code> this time would be, of course, <code>20</code>.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Sum_up_all_values_within_an_array\">Sum up all values within an array</h3> <pre data-language=\"js\">var sum = [0, 1, 2, 3].reduceRight(function(a, b) {\n  return a + b;\n});\n// sum is 6\n</pre> <h3 id=\"Flatten_an_array_of_arrays\">Flatten an array of arrays</h3> <pre data-language=\"js\">var flattened = [[0, 1], [2, 3], [4, 5]].reduceRight(function(a, b) {\n    return a.concat(b);\n}, []);\n// flattened is [4, 5, 2, 3, 0, 1]\n\n</pre> <h3 id=\"Run_a_list_of_asynchronous_functions_with_callbacks_in_series_each_passing_their_results_to_the_next\">Run a list of asynchronous functions with callbacks in series each passing their results to the next</h3> <pre data-language=\"js\">const waterfall = (...functions) =&gt; (callback, ...args) =&gt;\n  functions.reduceRight(\n    (composition, fn) =&gt; (...results) =&gt; fn(composition, ...results),\n    callback\n  )(...args);\n\nconst randInt = max =&gt; Math.floor(Math.random() * max)\n\nconst add5 = (callback, x) =&gt; {\n  setTimeout(callback, randInt(1000), x + 5);\n};\nconst mult3 = (callback, x) =&gt; {\n  setTimeout(callback, randInt(1000), x * 3);\n};\nconst sub2 = (callback, x) =&gt; {\n  setTimeout(callback, randInt(1000), x - 2);\n};\nconst split = (callback, x) =&gt; {\n  setTimeout(callback, randInt(1000), x, x);\n};\nconst add = (callback, x, y) =&gt; {\n  setTimeout(callback, randInt(1000), x + y);\n};\nconst div4 = (callback, x) =&gt; {\n  setTimeout(callback, randInt(1000), x / 4);\n};\n\nconst computation = waterfall(add5, mult3, sub2, split, add, div4);\ncomputation(console.log, 5) // -&gt; 14\n\n// same as:\n\nconst computation2 = (input, callback) =&gt; {\n  const f6 = x=&gt; div4(callback, x);\n  const f5 = (x, y) =&gt; add(f6, x, y);\n  const f4 = x =&gt; split(f5, x);\n  const f3 = x =&gt; sub2(f4, x);\n  const f2 = x =&gt; mult3(f3, x);\n  add5(f2, input);\n}</pre> <h3 id=\"​​​​​​Di_fference_between_reduce_and_reduceRight\">​​​​​​Difference between <code>reduce</code> and <code>reduceRight</code>\n</h3> <pre data-language=\"js\">var a = ['1', '2', '3', '4', '5']; \nvar left  = a.reduce(function(prev, cur)      { return prev + cur; }); \nvar right = a.reduceRight(function(prev, cur) { return prev + cur; }); \n\nconsole.log(left);  // \"12345\"\nconsole.log(right); // \"54321\"</pre> <h2 id=\"Polyfill\">Polyfill</h2> <p><code>reduceRight</code> was added to the ECMA-262 standard in the 5th edition; as such it may not be present in all implementations of the standard. You can work around this by inserting the following code at the beginning of your scripts, allowing use of <code>reduceRight</code> in implementations which do not natively support it.</p> <pre data-language=\"js\">// Production steps of ECMA-262, Edition 5, 15.4.4.22\n// Reference: http://es5.github.io/#x15.4.4.22\nif ('function' !== typeof Array.prototype.reduceRight) {\n  Array.prototype.reduceRight = function(callback /*, initialValue*/) {\n    'use strict';\n    if (null === this || 'undefined' === typeof this) {\n      throw new TypeError('Array.prototype.reduce called on null or undefined');\n    }\n    if ('function' !== typeof callback) {\n      throw new TypeError(callback + ' is not a function');\n    }\n    var t = Object(this), len = t.length &gt;&gt;&gt; 0, k = len - 1, value;\n    if (arguments.length &gt;= 2) {\n      value = arguments[1];\n    } else {\n      while (k &gt;= 0 &amp;&amp; !(k in t)) {\n        k--;\n      }\n      if (k &lt; 0) {\n        throw new TypeError('Reduce of empty array with no initial value');\n      }\n      value = t[k--];\n    }\n    for (; k &gt;= 0; k--) {\n      if (k in t) {\n        value = callback(value, t[k], k, t);\n      }\n    }\n    return value;\n  };\n}\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/5.1/#sec-15.4.4.22\" hreflang=\"en\">ECMAScript 5.1 (ECMA-262)<br><small>The definition of 'Array.prototype.reduceRight' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition. Implemented in JavaScript 1.8.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-array.prototype.reduceright\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Array.prototype.reduceRight' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-array.prototype.reduceright\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Array.prototype.reduceRight' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>   <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/reduceRight\">Basic support</a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 3</td>\n<td class=\"bc-supports-yes\"> 9</td>\n<td class=\"bc-supports-yes\"> 10.5</td>\n<td class=\"bc-supports-yes\"> 4</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/reduceRight\">Basic support</a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/reduceRight\">Basic support</a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div>  <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"reduce\"><code>Array.prototype.reduce()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/reduceRight$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/reduceRight\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/reduceRight</a>\n  </p>\n</div>\n","global_objects/array/reverse":"<h1>array.reverse</h1> <p>The <code><strong>reverse()</strong></code> method reverses an array <em><a href=\"https://en.wikipedia.org/wiki/In-place_algorithm\">in place</a></em>. The first array element becomes the last, and the last array element becomes the first.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/array-reverse.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\"><var>a</var>.reverse()</pre> <h3 id=\"Return_value\">Return value</h3> <p>The reversed array.</p> <h2 id=\"Description\">Description</h2> <p>The <code>reverse</code> method transposes the elements of the calling array object in place, mutating the array, and returning a reference to the array.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Reversing_the_elements_in_an_array\">Reversing the elements in an array</h3> <p>The following example creates an array <code>a</code>, containing three elements, then reverses the array. The call to <code>reverse()</code> returns a reference to the reversed array <code>a</code>.</p> <pre data-language=\"js\">const a = [1, 2, 3];\n\nconsole.log(a); // [1, 2, 3]\n\na.reverse();\n\nconsole.log(a); // [3, 2, 1]\n\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/publications/files/ECMA-ST-ARCH/ECMA-262,%201st%20edition,%20June%201997.pdf\" hreflang=\"en\">ECMAScript 1st Edition (ECMA-262)</a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition. Implemented in JavaScript 1.1.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/5.1/#sec-15.4.4.8\" hreflang=\"en\">ECMAScript 5.1 (ECMA-262)<br><small>The definition of 'Array.prototype.reverse' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-array.prototype.reverse\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Array.prototype.reverse' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-array.prototype.reverse\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Array.prototype.reverse' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>   <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> 5.5</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div>  <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"join\"><code>Array.prototype.join()</code></a></li> <li><a href=\"sort\"><code>Array.prototype.sort()</code></a></li> <li><a href=\"../typedarray/reverse\"><code>TypedArray.prototype.reverse()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/reverse$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/reverse\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/reverse</a>\n  </p>\n</div>\n","global_objects/array/slice":"<h1>array.slice</h1> <p>The <code><strong>slice()</strong></code> method returns a shallow copy of a portion of an array into a new array object selected from <code>begin</code> to <code>end</code> (<code>end</code> not included). The original array will not be modified.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/array-slice.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\"><var>arr</var>.slice(<em>[</em><var>begin[</var>, <var>end]]</var>)\n</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt>\n<code>begin</code> <span class=\"inlineIndicator optional optionalInline\">Optional</span>\n</dt> <dd>Zero-based index at which to begin extraction.</dd> <dd>A negative index can be used, indicating an offset from the end of the sequence. <code>slice(-2)</code> extracts the last two elements in the sequence.</dd> <dd>If <code>begin</code> is undefined, <code>slice</code> begins from index <code>0</code>.</dd> <dd>If <code>begin</code> is greater than the length of the sequence, an empty array is returned.</dd> <dt>\n<code>end</code> <span class=\"inlineIndicator optional optionalInline\">Optional</span>\n</dt> <dd>Zero-based index <em>before</em> which to end extraction. <code>slice</code> extracts up to but not including <code>end</code>.</dd> <dd>For example, <code>slice(1,4)</code> extracts the second element through the fourth element (elements indexed 1, 2, and 3).</dd> <dd>A negative index can be used, indicating an offset from the end of the sequence. <code>slice(2,-1)</code> extracts the third element through the second-to-last element in the sequence.</dd> <dd>If <code>end</code> is omitted, <code>slice</code> extracts through the end of the sequence (<code>arr.length</code>).</dd> <dd>If <code>end</code> is greater than the length of the sequence, <code>slice</code> extracts through to the end of the sequence (<code>arr.length</code>).</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p>A new array containing the extracted elements.</p> <h2 id=\"Description\">Description</h2> <p><code>slice</code> does not alter the original array. It returns a shallow copy of elements from the original array. Elements of the original array are copied into the returned array as follows:</p> <ul> <li>For object references (and not the actual object), <code>slice</code> copies object references into the new array. Both the original and new array refer to the same object. If a referenced object changes, the changes are visible to both the new and original arrays.</li> <li>For strings, numbers and booleans (not <a href=\"../string\"><code>String</code></a>, <a href=\"../number\"><code>Number</code></a> and <a href=\"../boolean\"><code>Boolean</code></a> objects), <code>slice</code> copies the values into the new array. Changes to the string, number or boolean in one array do not affect the other array.</li> </ul> <p>If a new element is added to either array, the other array is not affected.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Return_a_portion_of_an_existing_array\">Return a portion of an existing array</h3> <pre data-language=\"js\">var fruits = ['Banana', 'Orange', 'Lemon', 'Apple', 'Mango'];\nvar citrus = fruits.slice(1, 3);\n\n// fruits contains ['Banana', 'Orange', 'Lemon', 'Apple', 'Mango']\n// citrus contains ['Orange','Lemon']\n</pre> <h3 id=\"Using_slice\">Using <code>slice</code>\n</h3> <p>In the following example, <code>slice</code> creates a new array, <code>newCar</code>, from <code>myCar</code>. Both include a reference to the object <code>myHonda</code>. When the color of <code>myHonda</code> is changed to purple, both arrays reflect the change.</p> <pre data-language=\"js\">// Using slice, create newCar from myCar.\nvar myHonda = { color: 'red', wheels: 4, engine: { cylinders: 4, size: 2.2 } };\nvar myCar = [myHonda, 2, 'cherry condition', 'purchased 1997'];\nvar newCar = myCar.slice(0, 2);\n\n// Display the values of myCar, newCar, and the color of myHonda\n//  referenced from both arrays.\nconsole.log('myCar = ' + JSON.stringify(myCar));\nconsole.log('newCar = ' + JSON.stringify(newCar));\nconsole.log('myCar[0].color = ' + myCar[0].color);\nconsole.log('newCar[0].color = ' + newCar[0].color);\n\n// Change the color of myHonda.\nmyHonda.color = 'purple';\nconsole.log('The new color of my Honda is ' + myHonda.color);\n\n// Display the color of myHonda referenced from both arrays.\nconsole.log('myCar[0].color = ' + myCar[0].color);\nconsole.log('newCar[0].color = ' + newCar[0].color);\n</pre> <p>This script writes:</p> <pre data-language=\"js\">myCar = [{color: 'red', wheels: 4, engine: {cylinders: 4, size: 2.2}}, 2,\n         'cherry condition', 'purchased 1997']\nnewCar = [{color: 'red', wheels: 4, engine: {cylinders: 4, size: 2.2}}, 2]\nmyCar[0].color = red \nnewCar[0].color = red\nThe new color of my Honda is purple\nmyCar[0].color = purple\nnewCar[0].color = purple\n</pre> <h2 id=\"Array-like_objects\">Array-like objects</h2> <p><code>slice</code> method can also be called to convert Array-like objects / collections to a new Array. You just bind the method to the object. The <a href=\"../../functions/arguments\"><code>arguments</code></a> inside a function is an example of an 'array-like object'.</p> <pre data-language=\"js\">function list() {\n  return Array.prototype.slice.call(arguments);\n}\n\nvar list1 = list(1, 2, 3); // [1, 2, 3]\n</pre> <p>Binding can be done with the .<code>call</code> function of <a href=\"../function/prototype\"><code>Function.prototype</code></a> and it can also be reduced using <code>[].slice.call(arguments)</code> instead of <code>Array.prototype.slice.call</code>. Anyway, it can be simplified using <a href=\"../function/bind\"><code>bind</code></a>.</p> <pre data-language=\"js\">var unboundSlice = Array.prototype.slice;\nvar slice = Function.prototype.call.bind(unboundSlice);\n\nfunction list() {\n  return slice(arguments);\n}\n\nvar list1 = list(1, 2, 3); // [1, 2, 3]\n</pre> <h2 id=\"Streamlining_cross-browser_behavior\">Streamlining cross-browser behavior</h2> <p>Although host objects (such as DOM objects) are not required by spec to follow the Mozilla behavior when converted by <code>Array.prototype.slice</code> and IE &lt; 9 does not do so, versions of IE starting with version 9 do allow this. “Shimming” it can allow reliable cross-browser behavior. As long as other modern browsers continue to support this ability, as currently do IE, Mozilla, Chrome, Safari, and Opera, developers reading (DOM-supporting) slice code relying on this shim will not be misled by the semantics; they can safely rely on the semantics to provide the now apparently <em>de facto</em> standard behavior. (The shim also fixes IE to work with the second argument of <code>slice()</code> being an explicit <a href=\"../null\"><code>null</code></a>/<a href=\"../undefined\"><code>undefined</code></a> value as earlier versions of IE also did not allow but all modern browsers, including IE &gt;= 9, now do.)</p> <pre data-language=\"js\">/**\n * Shim for \"fixing\" IE's lack of support (IE &lt; 9) for applying slice\n * on host objects like NamedNodeMap, NodeList, and HTMLCollection\n * (technically, since host objects have been implementation-dependent,\n * at least before ES2015, IE hasn't needed to work this way).\n * Also works on strings, fixes IE &lt; 9 to allow an explicit undefined\n * for the 2nd argument (as in Firefox), and prevents errors when\n * called on other DOM objects.\n */\n(function () {\n  'use strict';\n  var _slice = Array.prototype.slice;\n\n  try {\n    // Can't be used with DOM elements in IE &lt; 9\n    _slice.call(document.documentElement);\n  } catch (e) { // Fails in IE &lt; 9\n    // This will work for genuine arrays, array-like objects, \n    // NamedNodeMap (attributes, entities, notations),\n    // NodeList (e.g., getElementsByTagName), HTMLCollection (e.g., childNodes),\n    // and will not fail on other DOM objects (as do DOM elements in IE &lt; 9)\n    Array.prototype.slice = function(begin, end) {\n      // IE &lt; 9 gets unhappy with an undefined end argument\n      end = (typeof end !== 'undefined') ? end : this.length;\n\n      // For native Array objects, we use the native slice function\n      if (Object.prototype.toString.call(this) === '[object Array]'){\n        return _slice.call(this, begin, end); \n      }\n\n      // For array like object we handle it ourselves.\n      var i, cloned = [],\n        size, len = this.length;\n\n      // Handle negative value for \"begin\"\n      var start = begin || 0;\n      start = (start &gt;= 0) ? start : Math.max(0, len + start);\n\n      // Handle negative value for \"end\"\n      var upTo = (typeof end == 'number') ? Math.min(end, len) : len;\n      if (end &lt; 0) {\n        upTo = len + end;\n      }\n\n      // Actual expected size of the slice\n      size = upTo - start;\n\n      if (size &gt; 0) {\n        cloned = new Array(size);\n        if (this.charAt) {\n          for (i = 0; i &lt; size; i++) {\n            cloned[i] = this.charAt(start + i);\n          }\n        } else {\n          for (i = 0; i &lt; size; i++) {\n            cloned[i] = this[start + i];\n          }\n        }\n      }\n\n      return cloned;\n    };\n  }\n}());\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/publications/files/ECMA-ST-ARCH/ECMA-262,%203rd%20edition,%20December%201999.pdf\" hreflang=\"en\">ECMAScript 3rd Edition (ECMA-262)</a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition. Implemented in JavaScript 1.2.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/5.1/#sec-15.4.4.10\" hreflang=\"en\">ECMAScript 5.1 (ECMA-262)<br><small>The definition of 'Array.prototype.slice' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-array.prototype.slice\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Array.prototype.slice' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-array.prototype.slice\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Array.prototype.slice' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>   <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div>  <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"splice\"><code>Array.prototype.splice()</code></a></li> <li><a href=\"../function/call\"><code>Function.prototype.call()</code></a></li> <li><a href=\"../function/bind\"><code>Function.prototype.bind()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/slice$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/slice\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/slice</a>\n  </p>\n</div>\n","global_objects/array/tolocalestring":"<h1>array.toLocaleString</h1> <p>The <code><strong>toLocaleString()</strong></code> method returns a string representing the elements of the array. The elements are converted to Strings using their <code>toLocaleString</code> methods and these Strings are separated by a locale-specific String (such as a comma “,”).</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/array-tolocalestring.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe> <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\"><var>arr</var>.toLocaleString([<var>locales[</var>, <var>options]]</var>);\n</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt>\n<code>locales</code> <span class=\"inlineIndicator optional optionalInline\">Optional</span>\n</dt> <dd>A string with a BCP 47 language tag, or an array of such strings. For the general form and interpretation of the <code>locales</code> argument, see the <a href=\"../intl\"><code>Intl</code></a> page.</dd> <dt>\n<code>options</code> <span class=\"inlineIndicator optional optionalInline\">Optional</span>\n</dt> <dd>An object with configuration properties, for numbers see <a href=\"../number/tolocalestring\"><code>Number.prototype.toLocaleString()</code></a>, and for dates see <a href=\"../date/tolocalestring\"><code>Date.prototype.toLocaleString()</code></a>.</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p>A string representing the elements of the array.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Using_locales_and_options\">Using <code>locales</code> and <code>options</code>\n</h3> <p>The elements of the array are converted to strings using their <code>toLocaleString</code> methods.</p> <ul> <li>\n<code>Object</code>: <a href=\"../object/tolocalestring\"><code>Object.prototype.toLocaleString()</code></a>\n</li> <li>\n<code>Number</code>: <a href=\"../number/tolocalestring\"><code>Number.prototype.toLocaleString()</code></a>\n</li> <li>\n<code>Date</code>: <a href=\"../date/tolocalestring\"><code>Date.prototype.toLocaleString()</code></a>\n</li> </ul> <p>Always display the currency for the strings and numbers in the <code>prices</code> array:</p> <pre data-language=\"js\">var prices = ['￥7', 500, 8123, 12]; \nprices.toLocaleString('ja-JP', { style: 'currency', currency: 'JPY' });\n\n// \"￥7,￥500,￥8,123,￥12\"\n</pre> <p>For more examples, see also the <a href=\"../intl\"><code>Intl</code></a>, <a href=\"../numberformat\"><code>NumberFormat</code></a>, and <a href=\"../datetimeformat\"><code>DateTimeFormat</code></a> pages.</p> <h2 id=\"Polyfill\">Polyfill</h2> <pre data-language=\"js\">// https://tc39.github.io/ecma402/#sup-array.prototype.tolocalestring\nif (!Array.prototype.toLocaleString) {\n  Object.defineProperty(Array.prototype, 'toLocaleString', {\n    value: function(locales, options) {\n      // 1. Let O be ? ToObject(this value).\n      if (this == null) {\n        throw new TypeError('\"this\" is null or not defined');\n      }\n\n      var a = Object(this);\n\n      // 2. Let len be ? ToLength(? Get(A, \"length\")).\n      var len = a.length &gt;&gt;&gt; 0;\n\n      // 3. Let separator be the String value for the \n      //    list-separator String appropriate for the \n      //    host environment's current locale (this is \n      //    derived in an implementation-defined way).\n      // NOTE: In this case, we will use a comma\n      var separator = ',';\n\n      // 4. If len is zero, return the empty String.\n      if (len === 0) {\n        return '';\n      }\n\n      // 5. Let firstElement be ? Get(A, \"0\").\n      var firstElement = a[0];\n      // 6. If firstElement is undefined or null, then\n      //  a.Let R be the empty String.\n      // 7. Else,\n      //  a. Let R be ? \n      //     ToString(? \n      //       Invoke(\n      //        firstElement, \n      //        \"toLocaleString\", \n      //        « locales, options »\n      //       )\n      //     )\n      var r = firstElement == null ? \n        '' : firstElement.toLocaleString(locales, options);\n\n      // 8. Let k be 1.\n      var k = 1;\n\n      // 9. Repeat, while k &lt; len\n      while (k &lt; len) {\n        // a. Let S be a String value produced by \n        //   concatenating R and separator.\n        var s = r + separator;\n\n        // b. Let nextElement be ? Get(A, ToString(k)).\n        var nextElement = a[k];\n\n        // c. If nextElement is undefined or null, then\n        //   i. Let R be the empty String.\n        // d. Else,\n        //   i. Let R be ? \n        //     ToString(? \n        //       Invoke(\n        //        nextElement, \n        //        \"toLocaleString\", \n        //        « locales, options »\n        //       )\n        //     )\n        r = nextElement == null ? \n          '' : nextElement.toLocaleString(locales, options);\n\n        // e. Let R be a String value produced by \n        //   concatenating S and R.\n        r = s + r;\n\n        // f. Increase k by 1.\n        k++;\n      }\n\n      // 10. Return R.\n      return r;\n    }\n  });\n}\n</pre> <p>If you need to support truly obsolete JavaScript engines that don't support <code><a href=\"../object/defineproperty\">Object.defineProperty</a></code>, it's best not to polyfill <code>Array.prototype</code> methods at all, as you can't make them non-enumerable.</p> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-array.prototype.tolocalestring\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Array.prototype.toLocaleString' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td>Initial definition was in ECMAScript 3.</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma402/#sup-array.prototype.tolocalestring\" hreflang=\"en\">ECMAScript Internationalization API 4.0 (ECMA-402)<br><small>The definition of 'Array.prototype.toLocaleString' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td>This definition supersedes the definition provided in ECMA-262.</td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>   <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">Optional <code>locales</code> parameter</th>\n<td> ? </td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 52</td>\n<td> ? </td>\n<td> ? </td>\n<td> ? </td>\n</tr>\n<tr>\n<th scope=\"row\">Optional <code>options</code> parameter</th>\n<td> ? </td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 52</td>\n<td> ? </td>\n<td> ? </td>\n<td> ? </td>\n</tr>\n</tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">Optional <code>locales</code> parameter</th>\n<td> ? </td>\n<td> ? </td>\n<td> ? </td>\n<td class=\"bc-supports-no\"> No</td>\n<td> ? </td>\n<td> ? </td>\n<td> ? </td>\n</tr>\n<tr>\n<th scope=\"row\">Optional <code>options</code> parameter</th>\n<td class=\"bc-supports-no\"> No</td>\n<td> ? </td>\n<td> ? </td>\n<td class=\"bc-supports-no\"> No</td>\n<td> ? </td>\n<td> ? </td>\n<td> ? </td>\n</tr>\n</tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">Optional <code>locales</code> parameter</th>\n<td> ? </td>\n</tr>\n<tr>\n<th scope=\"row\">Optional <code>options</code> parameter</th>\n<td> ? </td>\n</tr>\n</tbody>\n</table>\n</div>  <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"tostring\"><code>Array.prototype.toString()</code></a></li> <li><a href=\"../intl\"><code>Intl</code></a></li> <li><a href=\"../object/tolocalestring\"><code>Object.prototype.toLocaleString()</code></a></li> <li><a href=\"../number/tolocalestring\"><code>Number.prototype.toLocaleString()</code></a></li> <li><a href=\"../date/tolocalestring\"><code>Date.prototype.toLocaleString()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/toLocaleString$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/toLocaleString\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/toLocaleString</a>\n  </p>\n</div>\n","global_objects/number/positive_infinity":"<h1>Number.POSITIVE_INFINITY</h1> <p>The <code>Number.POSITIVE_INFINITY</code> property represents the positive Infinity value.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/number-positive-infinity.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <p>You do not have to create a <a href=\"../number\"><code>Number</code></a> object to access this static property (use <code>Number.POSITIVE_INFINITY</code>).</p> <div class=\"_table\"><table class=\"standard-table\"> <thead> <tr> <th colspan=\"2\" class=\"header\">Property attributes of <code>Number.POSITIVE_INFINITY</code>\n</th> </tr> </thead> <tbody> <tr> <td>Writable</td> <td>no</td> </tr> <tr> <td>Enumerable</td> <td>no</td> </tr> <tr> <td>Configurable</td> <td>no</td> </tr> </tbody> </table></div> <h2 id=\"Description\">Description</h2> <p>The value of <code>Number.POSITIVE_INFINITY</code> is the same as the value of the global object's <a href=\"../infinity\"><code>Infinity</code></a> property.</p> <p>This value behaves slightly differently than mathematical infinity:</p> <ul> <li>Any positive value, including <code>POSITIVE_INFINITY</code>, multiplied by <code>POSITIVE_INFINITY</code> is <code>POSITIVE_INFINITY</code>.</li> <li>Any negative value, including <a href=\"negative_infinity\"><code>NEGATIVE_INFINITY</code></a>, multiplied by <code>POSITIVE_INFINITY</code> is <a href=\"negative_infinity\"><code>NEGATIVE_INFINITY</code></a>.</li> <li>Any positive number divided by <code>POSITIVE_INFINITY</code> is positive Zero.</li> <li>Any negative number divided by <code>POSITIVE_INFINITY</code> is negative Zero.</li> <li>Zero multiplied by <code>POSITIVE_INFINITY</code> is <a href=\"../nan\"><code>NaN</code></a>.</li> <li>\n<a href=\"../nan\"><code>NaN</code></a> multiplied by <code>POSITIVE_INFINITY</code> is <a href=\"../nan\"><code>NaN</code></a>.</li> <li>\n<code>POSITIVE_INFINITY</code>, divided by any negative value except <a href=\"negative_infinity\"><code>NEGATIVE_INFINITY</code></a>, is <a href=\"negative_infinity\"><code>NEGATIVE_INFINITY</code></a>.</li> <li>\n<code>POSITIVE_INFINITY</code>, divided by any positive value except <code>POSITIVE_INFINITY</code>, is <code>POSITIVE_INFINITY</code>.</li> <li>\n<code>POSITIVE_INFINITY</code>, divided by either <a href=\"negative_infinity\"><code>NEGATIVE_INFINITY</code></a> or <code>POSITIVE_INFINITY</code>, is <a href=\"../nan\"><code>NaN</code></a>.</li> </ul> <p>You might use the <code>Number.POSITIVE_INFINITY</code> property to indicate an error condition that returns a finite number in case of success. Note, however, that <a href=\"../isfinite\"><code>isFinite</code></a> would be more appropriate in such a case.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Using_POSITIVE_INFINITY\">Using <code>POSITIVE_INFINITY</code>\n</h3> <p>In the following example, the variable <code>bigNumber</code> is assigned a value that is larger than the maximum value. When the <a href=\"../../statements/if...else\"><code>if</code></a> statement executes, <code>bigNumber</code> has the value <code>Infinity</code>, so <code>bigNumber</code> is set to a more manageable value before continuing.</p> <pre data-language=\"js\">var bigNumber = Number.MAX_VALUE * 2;\n\nif (bigNumber == Number.POSITIVE_INFINITY) {\n  bigNumber = returnFinite();\n}\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/publications/files/ECMA-ST-ARCH/ECMA-262,%201st%20edition,%20June%201997.pdf\" hreflang=\"en\">ECMAScript 1st Edition (ECMA-262)</a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition. Implemented in JavaScript 1.1.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/5.1/#sec-15.7.3.6\" hreflang=\"en\">ECMAScript 5.1 (ECMA-262)<br><small>The definition of 'Number.POSITIVE_INFINITY' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-number.positive_infinity\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Number.POSITIVE_INFINITY' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-number.positive_infinity\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Number.POSITIVE_INFINITY' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"negative_infinity\"><code>Number.NEGATIVE_INFINITY</code></a></li> <li><a href=\"isfinite\"><code>Number.isFinite()</code></a></li> <li><a href=\"../infinity\"><code>Infinity</code></a></li> <li><a href=\"../isfinite\"><code>isFinite()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/POSITIVE_INFINITY$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/POSITIVE_INFINITY\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/POSITIVE_INFINITY</a>\n  </p>\n</div>\n","global_objects/number/negative_infinity":"<h1>Number.NEGATIVE_INFINITY</h1> <p>The <code>Number.NEGATIVE_INFINITY</code> property represents the negative Infinity value.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/number-negative-infinity.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <p>You do not have to create a <a href=\"../number\"><code>Number</code></a> object to access this static property (use <code>Number.NEGATIVE_INFINITY</code>).</p> <div class=\"_table\"><table class=\"standard-table\"> <thead> <tr> <th colspan=\"2\" class=\"header\">Property attributes of <code>Number.NEGATIVE_INFINITY</code>\n</th> </tr> </thead> <tbody> <tr> <td>Writable</td> <td>no</td> </tr> <tr> <td>Enumerable</td> <td>no</td> </tr> <tr> <td>Configurable</td> <td>no</td> </tr> </tbody> </table></div> <h2 id=\"Description\">Description</h2> <p>The value of <code>Number.NEGATIVE_INFINITY</code> is the same as the negative value of the global object's <a href=\"../infinity\"><code>Infinity</code></a> property.</p> <p>This value behaves slightly differently than mathematical infinity:</p> <ul> <li>Any positive value, including <a href=\"positive_infinity\"><code>POSITIVE_INFINITY</code></a>, multiplied by <code>NEGATIVE_INFINITY</code> is <code>NEGATIVE_INFINITY</code>.</li> <li>Any negative value, including <code>NEGATIVE_INFINITY</code>, multiplied by <code>NEGATIVE_INFINITY</code> is <a href=\"positive_infinity\"><code>POSITIVE_INFINITY</code></a>.</li> <li>Any positive value divided by <code>NEGATIVE_INFINITY</code> is negativezero.</li> <li>Any negative value divided by <code>NEGATIVE_INFINITY</code> is positive zero.</li> <li>Zero multiplied by <code>NEGATIVE_INFINITY</code> is <a href=\"../nan\"><code>NaN</code></a>.</li> <li>\n<a href=\"../nan\"><code>NaN</code></a> multiplied by <code>NEGATIVE_INFINITY</code> is <a href=\"../nan\"><code>NaN</code></a>.</li> <li>\n<code>NEGATIVE_INFINITY</code>, divided by any negative value except <code>NEGATIVE_INFINITY</code>, is <a href=\"positive_infinity\"><code>POSITIVE_INFINITY</code></a>.</li> <li>\n<code>NEGATIVE_INFINITY</code>, divided by any positive value except <a href=\"positive_infinity\"><code>POSITIVE_INFINITY</code></a>, is <code>NEGATIVE_INFINITY</code>.</li> <li>\n<code>NEGATIVE_INFINITY</code>, divided by either <code>NEGATIVE_INFINITY</code> or <a href=\"positive_infinity\"><code>POSITIVE_INFINITY</code></a>, is <a href=\"../nan\"><code>NaN</code></a>.</li> </ul> <p>You might use the <code>Number.NEGATIVE_INFINITY</code> property to indicate an error condition that returns a finite number in case of success. Note, however, that <a href=\"../isfinite\"><code>isFinite</code></a> would be more appropriate in such a case.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Using_NEGATIVE_INFINITY\">Using <code>NEGATIVE_INFINITY</code>\n</h3> <p>In the following example, the variable <code>smallNumber</code> is assigned a value that is smaller than the minimum value. When the <a href=\"../../statements/if...else\"><code>if</code></a> statement executes, <code>smallNumber</code> has the value <code>-Infinity</code>, so <code>smallNumber</code> is set to a more manageable value before continuing.</p> <pre data-language=\"js\">var smallNumber = (-Number.MAX_VALUE) * 2;\n\nif (smallNumber === Number.NEGATIVE_INFINITY) {\n  smallNumber = returnFinite();\n}\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/publications/files/ECMA-ST-ARCH/ECMA-262,%201st%20edition,%20June%201997.pdf\" hreflang=\"en\">ECMAScript 1st Edition (ECMA-262)</a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition. Implemented in JavaScript 1.1.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/5.1/#sec-15.7.3.5\" hreflang=\"en\">ECMAScript 5.1 (ECMA-262)<br><small>The definition of 'Number.NEGATIVE_INFINITY' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-number.negative_infinity\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Number.NEGATIVE_INFINITY' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-number.negative_infinity\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Number.NEGATIVE_INFINITY' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"positive_infinity\"><code>Number.POSITIVE_INFINITY</code></a></li> <li><a href=\"isfinite\"><code>Number.isFinite()</code></a></li> <li><a href=\"../infinity\"><code>Infinity</code></a></li> <li><a href=\"../isfinite\"><code>isFinite()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/NEGATIVE_INFINITY$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/NEGATIVE_INFINITY\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/NEGATIVE_INFINITY</a>\n  </p>\n</div>\n","global_objects/collator/compare":"<h1>Intl.collator.compare</h1> <p>The <code>Intl.Collator.prototype.compare</code> property returns a function that compares two strings according to the sort order of this <a href=\"../collator\"><code>Collator</code></a> object.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/intl-collator-prototype-compare.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\"><var>collator</var>.compare(<var>string1</var>, <var>string2</var>)</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><code>string1</code></dt> <dt><code>string2</code></dt> <dd>The strings to compare against each other.</dd> </dl> <h2 id=\"Description\">Description</h2> <p>The function returned by the <code>compare</code> getter returns a number indicating how <code>string1</code> and <code>string2</code> compare to each other according to the sort order of this <a href=\"../collator\"><code>Collator</code></a> object: a negative value if <code>string1</code> comes before <code>string2</code>; a positive value if <code>string1</code> comes after <code>string2</code>; 0 if they are considered equal.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Using_compare_for_array_sort\">Using <code>compare</code> for array sort</h3> <p>Use the function returned by the <code>compare</code> getter for sorting arrays. Note that the function is bound to the collator from which it was obtained, so it can be passed directly to <a href=\"../array/sort\"><code>Array.prototype.sort()</code></a>.</p> <pre data-language=\"js\">var a = ['Offenbach', 'Österreich', 'Odenwald'];\nvar collator = new Intl.Collator('de-u-co-phonebk');\na.sort(collator.compare);\nconsole.log(a.join(', '));\n// → \"Odenwald, Österreich, Offenbach\"\n</pre> <h3 id=\"Using_compare_for_array_search\">Using <code>compare</code> for array search</h3> <p>Use the function returned by the <code>compare</code> getter for finding matching strings in arrays:</p> <pre data-language=\"js\">var a = ['Congrès', 'congres', 'Assemblée', 'poisson'];\nvar collator = new Intl.Collator('fr', { usage: 'search', sensitivity: 'base' });\nvar s = 'congres';\nvar matches = a.filter(v =&gt; collator.compare(v, s) === 0);\nconsole.log(matches.join(', '));\n// → \"Congrès, congres\"\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-402/1.0/#sec-10.3.2\" hreflang=\"en\">ECMAScript Internationalization API 1.0 (ECMA-402)<br><small>The definition of 'Intl.Collator.prototype.compare' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-402/2.0/#sec-10.3.2\" hreflang=\"en\">ECMAScript Internationalization API 2.0 (ECMA-402)<br><small>The definition of 'Intl.Collator.prototype.compare' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma402/#sec-Intl.Collator.prototype.compare\" hreflang=\"en\">ECMAScript Internationalization API 4.0 (ECMA-402)<br><small>The definition of 'Intl.Collator.prototype.compare' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>   <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 24</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 29</td>\n<td class=\"bc-supports-yes\"> 11</td>\n<td class=\"bc-supports-yes\"> 15</td>\n<td class=\"bc-supports-yes\"> 10</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 26</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 56</td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 10</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td> ? </td>\n</tr></tbody>\n</table>\n</div>  <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"../collator\"><code>Intl.Collator</code></a></li> <li><a href=\"../string/localecompare\"><code>String.prototype.localeCompare()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Collator/compare$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Collator/compare\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Collator/compare</a>\n  </p>\n</div>\n","global_objects/numberformat/prototype":"<h1>Intl.NumberFormat.prototype</h1> <p>The <code>Intl.NumberFormat.prototype</code> property represents the prototype object for the <a href=\"../numberformat\"><code>Intl.NumberFormat</code></a> constructor.</p> <div class=\"_table\"><table class=\"standard-table\"> <thead> <tr> <th colspan=\"2\" class=\"header\">Property attributes of <code>Intl.NumberFormat.prototype</code>\n</th> </tr> </thead> <tbody> <tr> <td>Writable</td> <td>no</td> </tr> <tr> <td>Enumerable</td> <td>no</td> </tr> <tr> <td>Configurable</td> <td>no</td> </tr> </tbody> </table></div> <h2 id=\"Description\">Description</h2> <p>See <a href=\"../numberformat\"><code>NumberFormat</code></a> for a description of <code>Intl.NumberFormat</code> instances.</p> <p><a href=\"../numberformat\"><code>Intl.NumberFormat</code></a> instances inherit from <code>Intl.NumberFormat.prototype</code>. Modifications to the prototype object are inherited by all <a href=\"../numberformat\"><code>Intl.NumberFormat</code></a> instances.</p> <h2 id=\"Properties\">Properties</h2> <dl> <dt><code>Intl.NumberFormat.prototype.constructor</code></dt> <dd>A reference to <code>Intl.NumberFormat</code>.</dd> <dt><a href=\"format\"><code>Intl.NumberFormat.prototype.format</code></a></dt> <dd>Getter; returns a function that formats a number according to the locale and formatting options of this <a href=\"../numberformat\"><code>NumberFormat</code></a> object.</dd> </dl> <h2 id=\"Methods\">Methods</h2> <dl> <dt><a href=\"formattoparts\"><code>Intl.NumberFormat.prototype.formatToParts()</code></a></dt> <dd>Returns an <a href=\"../array\"><code>Array</code></a> of objects representing the number string in parts that can be used for custom locale-aware formatting.</dd> <dt><a href=\"resolvedoptions\"><code>Intl.NumberFormat.prototype.resolvedOptions()</code></a></dt> <dd>Returns a new object with properties reflecting the locale and collation options computed during initialization of the object.</dd> </dl> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-402/1.0/#sec-11.2.1\" hreflang=\"en\">ECMAScript Internationalization API 1.0 (ECMA-402)<br><small>The definition of 'Intl.NumberFormat.prototype' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-402/2.0/#sec-11.2.1\" hreflang=\"en\">ECMAScript Internationalization API 2.0 (ECMA-402)<br><small>The definition of 'Intl.NumberFormat.prototype' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma402/#sec-Intl.NumberFormat.prototype\" hreflang=\"en\">ECMAScript Internationalization API 4.0 (ECMA-402)<br><small>The definition of 'Intl.NumberFormat.prototype' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>   <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 24</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 29</td>\n<td class=\"bc-supports-yes\"> 11</td>\n<td class=\"bc-supports-yes\"> 15</td>\n<td class=\"bc-supports-yes\"> 10</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 26</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 56</td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 10</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td> ? </td>\n</tr></tbody>\n</table>\n</div>  <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"../numberformat\"><code>Intl.NumberFormat</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/NumberFormat/prototype$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/NumberFormat/prototype\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/NumberFormat/prototype</a>\n  </p>\n</div>\n","global_objects/collator/supportedlocalesof":"<h1>Intl.Collator.supportedLocalesOf</h1> <p>The <code>Intl.Collator.supportedLocalesOf()</code> method returns an array containing those of the provided locales that are supported in collation without having to fall back to the runtime's default locale.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/intl-collator-prototype-supportedlocalesof.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\">Intl.Collator.supportedLocalesOf(<var>locales</var>[, <var>options</var>])</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><code>locales</code></dt> <dd>A string with a BCP 47 language tag, or an array of such strings. For the general form of the <code>locales</code> argument, see the <a href=\"../intl#Locale_identification_and_negotiation\">Intl page</a>.</dd> <dt><code>options</code></dt> <dd> <p>Optional. An object that may have the following property:</p> <dl> <dt><code>localeMatcher</code></dt> <dd>The locale matching algorithm to use. Possible values are <code>\"lookup\"</code> and <code>\"best fit\"</code>; the default is <code>\"best fit\"</code>. For information about this option, see the <a href=\"../intl#Locale_negotiation\">Intl page</a>.</dd> </dl> </dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p>An array of strings representing a subset of the given locale tags that are supported in collation without having to fall back to the runtime's default locale.</p> <h2 id=\"Description\">Description</h2> <p>Returns an array with a subset of the language tags provided in <code>locales</code>. The language tags returned are those for which the runtime supports a locale in collation that the locale matching algorithm used considers a match, so that it wouldn't have to fall back to the default locale.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Using_supportedLocalesOf\">Using <code>supportedLocalesOf</code>\n</h3> <p>Assuming a runtime that supports Indonesian and German but not Balinese in collation, <code>supportedLocalesOf</code> returns the Indonesian and German language tags unchanged, even though pinyin collation is not used with Indonesian and a specialized German for Indonesia is unlikely to be supported. Note the specification of the <code>\"lookup\"</code> algorithm here — a <code>\"best fit\"</code> matcher might decide that Indonesian is an adequate match for Balinese since most Balinese speakers also understand Indonesian, and therefore return the Balinese language tag as well.</p> <pre data-language=\"js\">var locales = ['ban', 'id-u-co-pinyin', 'de-ID'];\nvar options = { localeMatcher: 'lookup' };\nconsole.log(Intl.Collator.supportedLocalesOf(locales, options).join(', '));\n// → \"id-u-co-pinyin, de-ID\"\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-402/1.0/#sec-10.2.2\" hreflang=\"en\">ECMAScript Internationalization API 1.0 (ECMA-402)<br><small>The definition of 'Intl.Collator.supportedLocalesOf' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-402/2.0/#sec-10.2.2\" hreflang=\"en\">ECMAScript Internationalization API 2.0 (ECMA-402)<br><small>The definition of 'Intl.Collator.supportedLocalesOf' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma402/#sec-Intl.Collator.supportedLocalesOf\" hreflang=\"en\">ECMAScript Internationalization API 4.0 (ECMA-402)<br><small>The definition of 'Intl.Collator.supportedLocalesOf' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>   <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 24</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 29</td>\n<td class=\"bc-supports-yes\"> 11</td>\n<td class=\"bc-supports-yes\"> 15</td>\n<td class=\"bc-supports-yes\"> 10</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 26</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 56</td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 10</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td> ? </td>\n</tr></tbody>\n</table>\n</div>  <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"../collator\"><code>Intl.Collator</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Collator/supportedLocalesOf$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Collator/supportedLocalesOf\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Collator/supportedLocalesOf</a>\n  </p>\n</div>\n","global_objects/number/isfinite":"<h1>Number.isFinite</h1> <p>The <code>Number.isFinite()</code> method determines whether the passed value is a finite number.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/number-isfinite.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\">Number.isFinite(v<var>alue</var>)</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><code>value</code></dt> <dd>The value to be tested for finiteness.</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p>A <a href=\"../boolean\"><code>Boolean</code></a> indicating whether or not the given value is a finite number.</p> <h2 id=\"Description\">Description</h2> <p>In comparison to the global <a href=\"../isfinite\"><code>isFinite()</code></a> function, this method doesn't forcibly convert the parameter to a number. This means only values of the type number, that are also finite, return <code>true</code>.</p> <h2 id=\"Examples\">Examples</h2> <pre data-language=\"js\">Number.isFinite(Infinity);  // false\nNumber.isFinite(NaN);       // false\nNumber.isFinite(-Infinity); // false\n\nNumber.isFinite(0);         // true\nNumber.isFinite(2e64);      // true\n\nNumber.isFinite('0');       // false, would've been true with\n                            // global isFinite('0')\nNumber.isFinite(null);      // false, would've been true with\n                            // global isFinite(null)\n</pre> <h2 id=\"Polyfill\">Polyfill</h2> <pre data-language=\"js\">if (Number.isFinite === undefined) Number.isFinite = function(value) {\n    return typeof value === 'number' &amp;&amp; isFinite(value);\n}\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-number.isfinite\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Number.isInteger' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-number.isfinite\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Number.isInteger' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 19</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 16</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 15</td>\n<td class=\"bc-supports-yes\"> 9</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 16</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 0.10</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li>The <a href=\"../number\"><code>Number</code></a> object it belongs to.</li> <li>The global function <a href=\"../isfinite\"><code>isFinite</code></a>.</li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/isFinite$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/isFinite\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/isFinite</a>\n  </p>\n</div>\n","global_objects/numberformat/format":"<h1>Intl.numberFormat.format</h1> <p>The <code>Intl.NumberFormat.prototype.format</code> property returns a getter function that formats a number according to the locale and formatting options of this <a href=\"../numberformat\"><code>NumberFormat</code></a> object.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/intl-numberformat-prototype-format.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\"><var>numberFormat</var>.format(<var>number</var>)</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><code>number</code></dt> <dd>The number to format.</dd> </dl> <h2 id=\"Description\">Description</h2> <p>The function returned by the <code>format</code> getter formats a number into a string according to the locale and formatting options of this <a href=\"../numberformat\"><code>NumberFormat</code></a> object.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Using_format\">Using <code>format</code>\n</h3> <p>Use the function returned by the <code>format</code> getter for formatting a single currency value, here for Russia:</p> <pre data-language=\"js\">var options = { style: 'currency', currency: 'RUB' };\nvar numberFormat = new Intl.NumberFormat('ru-RU', options);\nconsole.log(numberFormat.format(654321.987));\n// → \"654 321,99 руб.\"\n</pre> <h3 id=\"Using_format_with_map\">Using <code>format</code> with <code>map</code>\n</h3> <p>Use the function returned by the <code>format</code> getter for formatting all numbers in an array. Note that the function is bound to the <a href=\"../numberformat\"><code>NumberFormat</code></a> from which it was obtained, so it can be passed directly to <a href=\"../array/map\"><code>Array.prototype.map</code></a>.</p> <pre data-language=\"js\">var a = [123456.789, 987654.321, 456789.123];\nvar numberFormat = new Intl.NumberFormat('es-ES');\nvar formatted = a.map(numberFormat.format);\nconsole.log(formatted.join('; '));\n// → \"123.456,789; 987.654,321; 456.789,123\"\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-402/1.0/#sec-11.3.2\" hreflang=\"en\">ECMAScript Internationalization API 1.0 (ECMA-402)<br><small>The definition of 'Intl.NumberFormat.prototype.format' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-402/2.0/#sec-11.3.2\" hreflang=\"en\">ECMAScript Internationalization API 2.0 (ECMA-402)<br><small>The definition of 'Intl.NumberFormat.prototype.format' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma402/#sec-Intl.NumberFormat.prototype.format\" hreflang=\"en\">ECMAScript Internationalization API 4.0 (ECMA-402)<br><small>The definition of 'Intl.NumberFormat.prototype.format' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>   <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 24</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 29</td>\n<td class=\"bc-supports-yes\"> 11</td>\n<td class=\"bc-supports-yes\"> 15</td>\n<td class=\"bc-supports-yes\"> 10</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 26</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 56</td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 10</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td> ? </td>\n</tr></tbody>\n</table>\n</div>  <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"../numberformat\"><code>Intl.NumberFormat</code></a></li> <li><a href=\"../number/tolocalestring\"><code>Number.prototype.toLocaleString()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/NumberFormat/format$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/NumberFormat/format\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/NumberFormat/format</a>\n  </p>\n</div>\n","global_objects/numberformat/resolvedoptions":"<h1>Intl.numberFormat.resolvedOptions</h1> <p>The <code>Intl.NumberFormat.prototype.resolvedOptions()</code> method returns a new object with properties reflecting the locale and number formatting options computed during initialization of this <a href=\"../numberformat\"><code>NumberFormat</code></a> object.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/intl-numberformat-prototype-resolvedoptions.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\"><var>numberFormat</var>.resolvedOptions()</pre> <h3 id=\"Return_value\">Return value</h3> <p>A new object with properties reflecting the locale and number formatting options computed during the initialization of the given <a href=\"../numberformat\"><code>NumberFormat</code></a> object.</p> <h2 id=\"Description\">Description</h2> <p>The resulting object has the following properties:</p> <dl> <dt><code>locale</code></dt> <dd>The BCP 47 language tag for the locale actually used. If any Unicode extension values were requested in the input BCP 47 language tag that led to this locale, the key-value pairs that were requested and are supported for this locale are included in <code>locale</code>.</dd> <dt><code>numberingSystem</code></dt> <dd>The value requested using the Unicode extension key <code>\"nu\"</code> or filled in as a default.</dd> <dt><code>style</code></dt> <dt><code>useGrouping</code></dt> <dd>The values provided for these properties in the <code>options</code> argument or filled in as defaults.</dd> <dt><code>currency</code></dt> <dt><code>currencyDisplay</code></dt> <dd>The values provided for these properties in the <code>options</code> argument or filled in as defaults. These properties are only present if <code>style</code> is <code>\"currency\"</code>.</dd> </dl> <p>Only one of the following two groups of properties is included:</p> <dl> <dt><code>minimumIntegerDigits</code></dt> <dt><code>minimumFractionDigits</code></dt> <dt><code>maximumFractionDigits</code></dt> <dd>The values provided for these properties in the <code>options</code> argument or filled in as defaults. These properties are present only if neither <code>minimumSignificantDigits</code> nor <code>maximumSignificantDigits</code> was provided in the <code>options</code> argument.</dd> <dt><code>minimumSignificantDigits</code></dt> <dt><code>maximumSignificantDigits</code></dt> <dd>The values provided for these properties in the <code>options</code> argument or filled in as defaults. These properties are present only if at least one of them was provided in the <code>options</code> argument.</dd> </dl> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Using_the_resolvedOptions_method\">Using the <code>resolvedOptions</code> method</h3> <pre data-language=\"js\">var de = new Intl.NumberFormat('de-DE');\nvar usedOptions = de.resolvedOptions();\n\nusedOptions.locale;                // \"de-DE\"\nusedOptions.numberingSystem;       // \"latn\"\nusedOption.style;                  // \"decimal\"\nusedOptions.minimumIntegerDigits;  // 1\nusedOptions.minimumFractionDigits; // 0\nusedOptions.maximumFractionDigits; // 3\nusedOptions.useGrouping;           // true\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-402/1.0/#sec-11.3.3\" hreflang=\"en\">ECMAScript Internationalization API 1.0 (ECMA-402)<br><small>The definition of 'Intl.NumberFormat.prototype.resolvedOptions' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-402/2.0/#sec-11.3.3\" hreflang=\"en\">ECMAScript Internationalization API 2.0 (ECMA-402)<br><small>The definition of 'Intl.NumberFormat.prototype.resolvedOptions' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma402/#sec-Intl.NumberFormat.prototype.resolvedOptions\" hreflang=\"en\">ECMAScript Internationalization API 4.0 (ECMA-402)<br><small>The definition of 'Intl.NumberFormat.prototype.resolvedOptions' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>   <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 24</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 29</td>\n<td class=\"bc-supports-yes\"> 11</td>\n<td class=\"bc-supports-yes\"> 15</td>\n<td class=\"bc-supports-yes\"> 10</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 26</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 56</td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 10</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td> ? </td>\n</tr></tbody>\n</table>\n</div>  <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"../numberformat\"><code>Intl.NumberFormat</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/NumberFormat/resolvedOptions$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/NumberFormat/resolvedOptions\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/NumberFormat/resolvedOptions</a>\n  </p>\n</div>\n","global_objects/numberformat/supportedlocalesof":"<h1>Intl.NumberFormat.supportedLocalesOf</h1> <p>The <code>Intl.NumberFormat.supportedLocalesOf()</code> method returns an array containing those of the provided locales that are supported in number formatting without having to fall back to the runtime's default locale.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/intl-numberformat-prototype-supportedlocalesof.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\">Intl.NumberFormat.supportedLocalesOf(<var>locales</var>[, <var>options</var>])</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><code>locales</code></dt> <dd>A string with a BCP 47 language tag, or an array of such strings. For the general form of the <code>locales</code> argument, see the <a href=\"../intl#Locale_identification_and_negotiation\">Intl page</a>.</dd> <dt><code>options</code></dt> <dd> <p>Optional. An object that may have the following property:</p> <dl> <dt><code>localeMatcher</code></dt> <dd>The locale matching algorithm to use. Possible values are <code>\"lookup\"</code> and <code>\"best fit\"</code>; the default is <code>\"best fit\"</code>. For information about this option, see the <a href=\"../intl#Locale_negotiation\">Intl page</a>.</dd> </dl> </dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p>An array of strings representing a subset of the given locale tags that are supported in number formatting without having to fall back to the runtime's default locale.</p> <h2 id=\"Description\">Description</h2> <p>Returns an array with a subset of the language tags provided in <code>locales</code>. The language tags returned are those for which the runtime supports a locale in number formatting that the locale matching algorithm used considers a match, so that it wouldn't have to fall back to the default locale.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Using_supportedLocalesOf\">Using <code>supportedLocalesOf</code>\n</h3> <p>Assuming a runtime that supports Indonesian and German but not Balinese in number formatting, <code>supportedLocalesOf</code> returns the Indonesian and German language tags unchanged, even though <code>pinyin</code> collation is neither relevant to number formatting nor used with Indonesian, and a specialized German for Indonesia is unlikely to be supported. Note the specification of the <code>\"lookup\"</code> algorithm here — a <code>\"best fit\"</code> matcher might decide that Indonesian is an adequate match for Balinese since most Balinese speakers also understand Indonesian, and therefore return the Balinese language tag as well.</p> <pre data-language=\"js\">var locales = ['ban', 'id-u-co-pinyin', 'de-ID'];\nvar options = { localeMatcher: 'lookup' };\nconsole.log(Intl.NumberFormat.supportedLocalesOf(locales, options).join(', '));\n// → \"id-u-co-pinyin, de-ID\"\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-402/1.0/#sec-11.2.2\" hreflang=\"en\">ECMAScript Internationalization API 1.0 (ECMA-402)<br><small>The definition of 'Intl.NumberFormat.supportedLocalesOf' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-402/2.0/#sec-11.2.2\" hreflang=\"en\">ECMAScript Internationalization API 2.0 (ECMA-402)<br><small>The definition of 'Intl.NumberFormat.supportedLocalesOf' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma402/#sec-Intl.NumberFormat.supportedLocalesOf\" hreflang=\"en\">ECMAScript Internationalization API 4.0 (ECMA-402)<br><small>The definition of 'Intl.NumberFormat.supportedLocalesOf' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>   <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 24</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 29</td>\n<td class=\"bc-supports-yes\"> 11</td>\n<td class=\"bc-supports-yes\"> 15</td>\n<td class=\"bc-supports-yes\"> 10</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 26</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 56</td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 10</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td> ? </td>\n</tr></tbody>\n</table>\n</div>  <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"../numberformat\"><code>Intl.NumberFormat</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/NumberFormat/supportedLocalesOf$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/NumberFormat/supportedLocalesOf\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/NumberFormat/supportedLocalesOf</a>\n  </p>\n</div>\n","global_objects/string/localecompare":"<h1>string.localeCompare</h1> <p>The <code>localeCompare()</code> method returns a number indicating whether a reference string comes before or after or is the same as the given string in sort order.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/string-localecompare.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <p>The new <code>locales</code> and <code>options</code> arguments let applications specify the language whose sort order should be used and customize the behavior of the function. In older implementations, which ignore the <code>locales</code> and <code>options</code> arguments, the locale and sort order used are entirely implementation dependent.</p> <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\"><var>referenceStr</var>.localeCompare(<var>compareString</var>[, <var>locales</var>[, <var>options</var>]])</pre> <h3 id=\"Parameters\">Parameters</h3> <p>Check the <a href=\"#Browser_compatibility\">Browser compatibility</a> section to see which browsers support the <code>locales</code> and <code>options</code> arguments, and <a href=\"#Check_browser_support_for_extended_arguments\">Check browser support for extended arguments</a> for feature detection.</p> <dl> <dt><code>compareString</code></dt> <dd>The string against which the referring string is compared</dd> </dl> <dl> <dt><code>locales</code></dt> <dd> <p>Optional. A string with a BCP 47 language tag, or an array of such strings. For the general form and interpretation of the <code>locales</code> argument, see the <a href=\"../intl#Locale_identification_and_negotiation\">Intl page</a>. The following Unicode extension keys are allowed:</p> <dl> <dt><code>co</code></dt> <dd>Variant collations for certain locales. Possible values include: <code>\"big5han\"</code>, <code>\"dict\"</code>, <code>\"direct\"</code>, <code>\"ducet\"</code>, <code>\"gb2312\"</code>, <code>\"phonebk\"</code>, <code>\"phonetic\"</code>, <code>\"pinyin\"</code>, <code>\"reformed\"</code>, <code>\"searchjl\"</code>, <code>\"stroke\"</code>, <code>\"trad\"</code>, <code>\"unihan\"</code>. The <code>\"standard\"</code> and <code>\"search\"</code> values are ignored; they are replaced by the <code>options</code> property <code>usage</code> (see below).</dd> <dt><code>kn</code></dt> <dd>Whether numeric collation should be used, such that \"1\" &lt; \"2\" &lt; \"10\". Possible values are <code>\"true\"</code> and <code>\"false\"</code>. This option can be set through an <code>options</code> property or through a Unicode extension key; if both are provided, the <code>options</code> property takes precedence.</dd> <dt><code>kf</code></dt> <dd>Whether upper case or lower case should sort first. Possible values are <code>\"upper\"</code>, <code>\"lower\"</code>, or <code>\"false\"</code> (use the locale's default). This option can be set through an <code>options</code> property or through a Unicode extension key; if both are provided, the <code>options</code> property takes precedence.</dd> </dl> </dd> <dt><code>options</code></dt> <dd> <p>Optional. An object with some or all of the following properties:</p> <dl> <dt><code>localeMatcher</code></dt> <dd>The locale matching algorithm to use. Possible values are <code>\"lookup\"</code> and <code>\"best fit\"</code>; the default is <code>\"best fit\"</code>. For information about this option, see the <a href=\"../intl#Locale_negotiation\">Intl page</a>.</dd> <dt><code>usage</code></dt> <dd>Whether the comparison is for sorting or for searching for matching strings. Possible values are <code>\"sort\"</code> and <code>\"search\"</code>; the default is <code>\"sort\"</code>.</dd> <dt><code>sensitivity</code></dt> <dd> <p>Which differences in the strings should lead to non-zero result values. Possible values are:</p> <ul> <li>\n<code>\"base\"</code>: Only strings that differ in base letters compare as unequal. Examples: <code>a ≠ b</code>, <code>a = á</code>, <code>a = A</code>.</li> <li>\n<code>\"accent\"</code>: Only strings that differ in base letters or accents and other diacritic marks compare as unequal. Examples: <code>a ≠ b</code>, <code>a ≠ á</code>, <code>a = A</code>.</li> <li>\n<code>\"case\"</code>: Only strings that differ in base letters or case compare as unequal. Examples: <code>a ≠ b</code>, <code>a = á</code>, <code>a ≠ A</code>.</li> <li>\n<code>\"variant\"</code>: Strings that differ in base letters, accents and other diacritic marks, or case compare as unequal. Other differences may also be taken into consideration. Examples: <code>a ≠ b</code>, <code>a ≠ á</code>, <code>a ≠ A</code>.</li> </ul> <p>The default is <code>\"variant\"</code> for usage <code>\"sort\"</code>; it's locale dependent for usage <code>\"search\"</code>.</p> </dd> <dt><code>ignorePunctuation</code></dt> <dd>Whether punctuation should be ignored. Possible values are <code>true</code> and <code>false</code>; the default is <code>false</code>.</dd> <dt><code>numeric</code></dt> <dd>Whether numeric collation should be used, such that \"1\" &lt; \"2\" &lt; \"10\". Possible values are <code>true</code> and <code>false</code>; the default is <code>false</code>. This option can be set through an <code>options</code> property or through a Unicode extension key; if both are provided, the <code>options</code> property takes precedence. Implementations are not required to support this property.</dd> <dt><code>caseFirst</code></dt> <dd>Whether upper case or lower case should sort first. Possible values are <code>\"upper\"</code>, <code>\"lower\"</code>, or <code>\"false\"</code> (use the locale's default); the default is <code>\"false\"</code>. This option can be set through an <code>options</code> property or through a Unicode extension key; if both are provided, the <code>options</code> property takes precedence. Implementations are not required to support this property.</dd> </dl> </dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p>A <strong>negative</strong> number if the reference string occurs before the compare string; <strong>positive</strong> if the reference string occurs after the compare string; <strong>0</strong> if they are equivalent.</p> <h2 id=\"Description\">Description</h2> <p>Returns an integer indicating whether the <strong>referenceStr</strong> comes before, after or is equivalent to the <strong>compareStr</strong>.</p> <ul> <li>Negative when the <strong>referenceStr</strong> occurs before <strong>compareStr</strong>\n</li> <li>Positive when the <strong>referenceStr</strong> occurs after <strong>compareStr</strong>\n</li> <li>Returns 0 if they are equivalent</li> </ul> <p><strong>DO NOT rely on exact return values of -1 or 1. </strong>Negative and positive integer results vary between browsers (as well as between browser versions) because the W3C specification only mandates negative and positive values. Some browsers may return -2 or 2 or even some other negative or positive value.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Using_localeCompare()\">Using <code>localeCompare()</code>\n</h3> <pre data-language=\"js\">// The letter \"a\" is before \"c\" yielding a negative value\n'a'.localeCompare('c'); // -2 or -1 (or some other negative value)\n\n// Alphabetically the word \"check\" comes after \"against\" yielding a positive value\n'check'.localeCompare('against'); // 2 or 1 (or some other positive value)\n\n// \"a\" and \"a\" are equivalent yielding a neutral value of zero\n'a'.localeCompare('a'); // 0\n</pre> <h3 id=\"Sort_an_array\">Sort an array</h3> <p><code>localeCompare</code> enables a case-insensitive sort of an array.</p> <pre data-language=\"js\">var items = ['réservé', 'Premier', 'Cliché', 'communiqué', 'café', 'Adieu'];\nitems.sort((a, b) =&gt; a.localeCompare(b, 'fr', {ignorePunctuation: true})); // ['Adieu', 'café', 'Cliché', 'communiqué', 'Premier', 'réservé']\n</pre> <h3 id=\"Check_browser_support_for_extended_arguments\">Check browser support for extended arguments</h3> <p>The <code>locales</code> and <code>options</code> arguments are not supported in all browsers yet. To check whether an implementation supports them, use the \"i\" argument (a requirement that illegal language tags are rejected) and look for a <a href=\"../rangeerror\"><code>RangeError</code></a> exception:</p> <pre data-language=\"js\">function localeCompareSupportsLocales() {\n  try {\n    'foo'.localeCompare('bar', 'i');\n  } catch (e) {\n    return e.name === 'RangeError';\n  }\n  return false;\n}\n</pre> <h3 id=\"Using_locales\">Using <code>locales</code>\n</h3> <p>The results provided by <code>localeCompare()</code> vary between languages. In order to get the sort order of the language used in the user interface of your application, make sure to specify that language (and possibly some fallback languages) using the <code>locales</code> argument:</p> <pre data-language=\"js\">console.log('ä'.localeCompare('z', 'de')); // a negative value: in German, ä sorts before z\nconsole.log('ä'.localeCompare('z', 'sv')); // a positive value: in Swedish, ä sorts after z\n</pre> <h3 id=\"Using_options\">Using <code>options</code>\n</h3> <p>The results provided by <code>localeCompare()</code> can be customized using the <code>options</code> argument:</p> <pre data-language=\"js\">// in German, ä has a as the base letter\nconsole.log('ä'.localeCompare('a', 'de', { sensitivity: 'base' })); // 0\n\n// in Swedish, ä and a are separate base letters\nconsole.log('ä'.localeCompare('a', 'sv', { sensitivity: 'base' })); // a positive value\n</pre> <h3 id=\"Numeric_sorting\">Numeric sorting</h3> <pre data-language=\"js\">// by default, \"2\" &gt; \"10\"\nconsole.log(<span class=\"message-body-wrapper\"><span class=\"message-flex-body\"><span class=\"devtools-monospace message-body\">\"2\".localeCompare(\"10\")</span></span></span>); // 1\n\n// numeric using options:\nconsole.log(<span class=\"message-body-wrapper\"><span class=\"message-flex-body\"><span class=\"devtools-monospace message-body\">\"2\".localeCompare(\"10\", undefined, {numeric: true})</span></span></span>); // -1\n\n// numeric using locales tag:\nconsole.log(<span class=\"message-body-wrapper\"><span class=\"message-flex-body\"><span class=\"devtools-monospace message-body\">\"2\".localeCompare(\"10\", \"en-u-kn-true\")</span></span></span>); // -1\n</pre> <h2 id=\"Performance\">Performance</h2> <p>When comparing large numbers of strings, such as in sorting large arrays, it is better to create an <a href=\"../collator\"><code>Intl.Collator</code></a> object and use the function provided by its <a href=\"../collator/compare\"><code>compare</code></a> property.</p> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/publications/files/ECMA-ST-ARCH/ECMA-262,%203rd%20edition,%20December%201999.pdf\" hreflang=\"en\">ECMAScript 3rd Edition (ECMA-262)</a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition. Implemented in JavaScript 1.2.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/5.1/#sec-15.5.4.9\" hreflang=\"en\">ECMAScript 5.1 (ECMA-262)<br><small>The definition of 'String.prototype.localeCompare' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-string.prototype.localecompare\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'String.prototype.localeCompare' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-string.prototype.localecompare\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'String.prototype.localeCompare' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-402/1.0/#sec-13.1.1\" hreflang=\"en\">ECMAScript Internationalization API 1.0 (ECMA-402)<br><small>The definition of 'String.prototype.localeCompare' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>\n<code>locale</code> and <code>option</code> parameter definitions.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-402/2.0/#sec-13.1.1\" hreflang=\"en\">ECMAScript Internationalization API 2.0 (ECMA-402)<br><small>The definition of 'String.prototype.localeCompare' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma402/#sec-String.prototype.localeCompare\" hreflang=\"en\">ECMAScript Internationalization API 4.0 (ECMA-402)<br><small>The definition of 'String.prototype.localeCompare' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><code>locales</code></th>\n<td class=\"bc-supports-yes\"> 24</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 29</td>\n<td class=\"bc-supports-yes\"> 11</td>\n<td class=\"bc-supports-yes\"> 15</td>\n<td class=\"bc-supports-yes\"> 10</td>\n</tr>\n<tr>\n<th scope=\"row\"><code>options</code></th>\n<td class=\"bc-supports-yes\"> 24</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 29</td>\n<td class=\"bc-supports-yes\"> 11</td>\n<td class=\"bc-supports-yes\"> 15</td>\n<td class=\"bc-supports-yes\"> 10</td>\n</tr>\n</tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><code>locales</code></th>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 26</td>\n<td> ? </td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 10</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><code>options</code></th>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 26</td>\n<td> ? </td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 10</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n</tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><code>locales</code></th>\n<td> ? </td>\n</tr>\n<tr>\n<th scope=\"row\"><code>options</code></th>\n<td> ? </td>\n</tr>\n</tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"../collator\"><code>Intl.Collator</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/localeCompare$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/localeCompare\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/localeCompare</a>\n  </p>\n</div>\n","global_objects/number/tolocalestring":"<h1>number.toLocaleString</h1> <p>The <code>toLocaleString()</code> method returns a string with a language-sensitive representation of this number.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/number-tolocalestring.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <p>The new <code>locales</code> and <code>options</code> arguments customize the behavior of the function and let applications specify the language whose formatting conventions should be used. In older implementations, which ignore the <code>locales</code> and <code>options</code> arguments, the locale used and the form of the string returned are entirely implementation dependent.</p> <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\"><em>numObj</em>.toLocaleString([locales [, options]])</pre> <h3 id=\"Parameters\">Parameters</h3> <p>Check the <a href=\"#Browser_compatibility\">Browser compatibility</a> section to see which browsers support the <code>locales</code> and <code>options</code> arguments, and the <a href=\"#Checking_for_support_for_locales_and_options_arguments\">Example: Checking for support for <code>locales</code> and <code>options</code> arguments</a> for feature detection.</p> <div class=\"note\"> <p><strong>Note:</strong> ECMAScript Internationalization API, implemented with Firefox 29, added the <code>locales</code> argument to the <code>Number.toLocaleString()</code> method. If the argument is <a href=\"../undefined\"><code>undefined</code></a>, this method returns localized digits specified by the OS, while the previous versions of Firefox returned<a href=\"https://en.wikipedia.org/wiki/Arabic_numerals\"> Western Arabic</a> digits. This change has been reported as a regression affecting backward compatibility which might be fixed soon. (<a href=\"https://bugzilla.mozilla.org/show_bug.cgi?id=999003\">bug 999003</a>)</p> </div> <dl> <dt><code>locales</code></dt> <dd> <p>Optional. A string with a BCP 47 language tag, or an array of such strings. For the general form and interpretation of the <code>locales</code> argument, see the <a href=\"../intl#Locale_identification_and_negotiation\">Intl page</a>. The following Unicode extension key is allowed:</p> <dl> <dt><code>nu</code></dt> <dd>The numbering system to be used. Possible values include: <code>\"arab\"</code>, <code>\"arabext\"</code>, <code>\"bali\"</code>, <code>\"beng\"</code>, <code>\"deva\"</code>, <code>\"fullwide\"</code>, <code>\"gujr\"</code>, <code>\"guru\"</code>, <code>\"hanidec\"</code>, <code>\"khmr\"</code>, <code>\"knda\"</code>, <code>\"laoo\"</code>, <code>\"latn\"</code>, <code>\"limb\"</code>, <code>\"mlym\"</code>, <code>\"mong\"</code>, <code>\"mymr\"</code>, <code>\"orya\"</code>, <code>\"tamldec\"</code>, <code>\"telu\"</code>, <code>\"thai\"</code>, <code>\"tibt\"</code>.</dd> </dl> </dd> <dt><code>options</code></dt> <dd> <p>Optional. An object with some or all of the following properties:</p> <dl> <dt><code>localeMatcher</code></dt> <dd>The locale matching algorithm to use. Possible values are <code>\"lookup\"</code> and <code>\"best fit\"</code>; the default is <code>\"best fit\"</code>. For information about this option, see the <a href=\"../intl#Locale_negotiation\">Intl page</a>.</dd> <dt><code>style</code></dt> <dd>The formatting style to use. Possible values are <code>\"decimal\"</code> for plain number formatting, <code>\"currency\"</code> for currency formatting, and <code>\"percent\"</code> for percent formatting; the default is <code>\"decimal\"</code>.</dd> <dt><code>currency</code></dt> <dd>The currency to use in currency formatting. Possible values are the ISO 4217 currency codes, such as <code>\"USD\"</code> for the US dollar, <code>\"EUR\"</code> for the euro, or <code>\"CNY\"</code> for the Chinese RMB — see the <a href=\"http://www.currency-iso.org/en/home/tables/table-a1.html\">Current currency &amp; funds code list</a>. There is no default value; if the <code>style</code> is <code>\"currency\"</code>, the <code>currency</code> property must be provided.</dd> <dt><code>currencyDisplay</code></dt> <dd>How to display the currency in currency formatting. Possible values are <code>\"symbol\"</code> to use a localized currency symbol such as €, <code>\"code\"</code> to use the ISO currency code, <code>\"name\"</code> to use a localized currency name such as <code>\"dollar\"</code>; the default is <code>\"symbol\"</code>.</dd> <dt><code>useGrouping</code></dt> <dd>Whether to use grouping separators, such as thousands separators or thousand/lakh/crore separators. Possible values are <code>true</code> and <code>false</code>; the default is <code>true</code>.</dd> </dl> <p>The following properties fall into two groups: <code>minimumIntegerDigits</code>, <code>minimumFractionDigits</code>, and <code>maximumFractionDigits</code> in one group, <code>minimumSignificantDigits</code> and <code>maximumSignificantDigits</code> in the other. If at least one property from the second group is defined, then the first group is ignored.</p> <dl> <dt><code>minimumIntegerDigits</code></dt> <dd>The minimum number of integer digits to use. Possible values are from 1 to 21; the default is 1.</dd> <dt><code>minimumFractionDigits</code></dt> <dd>The minimum number of fraction digits to use. Possible values are from 0 to 20; the default for plain number and percent formatting is 0; the default for currency formatting is the number of minor unit digits provided by the <a href=\"http://www.currency-iso.org/en/home/tables/table-a1.html\">ISO 4217 currency code list</a> (2 if the list doesn't provide that information).</dd> <dt><code>maximumFractionDigits</code></dt> <dd>The maximum number of fraction digits to use. Possible values are from 0 to 20; the default for plain number formatting is the larger of <code>minimumFractionDigits</code> and 3; the default for currency formatting is the larger of <code>minimumFractionDigits</code> and the number of minor unit digits provided by the <a href=\"http://www.currency-iso.org/en/home/tables/table-a1.html\">ISO 4217 currency code list</a> (2 if the list doesn't provide that information); the default for percent formatting is the larger of <code>minimumFractionDigits</code> and 0.</dd> <dt><code>minimumSignificantDigits</code></dt> <dd>The minimum number of significant digits to use. Possible values are from 1 to 21; the default is 1.</dd> <dt><code>maximumSignificantDigits</code></dt> <dd>The maximum number of significant digits to use. Possible values are from 1 to 21; the default is 21.</dd> </dl> </dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p>A string with a language-sensitive representation of the given number.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Using_toLocaleString\">Using <code>toLocaleString</code>\n</h3> <p>In basic use without specifying a locale, a formatted string in the default locale and with default options is returned.</p> <pre data-language=\"js\">var number = 3500;\n\nconsole.log(number.toLocaleString()); // Displays \"3,500\" if in U.S. English locale\n</pre> <h3 id=\"Checking_for_support_for_locales_and_options_arguments\">Checking for support for <code>locales</code> and <code>options</code> arguments</h3> <p>The <code>locales</code> and <code>options</code> arguments are not supported in all browsers yet. To check for support in ES5.1 and later implementations, the requirement that illegal language tags are rejected with a <a href=\"../rangeerror\"><code>RangeError</code></a> exception can be used:</p> <pre data-language=\"js\">function toLocaleStringSupportsLocales() {\n  var number = 0;\n  try {\n    number.toLocaleString('i');\n  } catch (e) {\n    return e.name === 'RangeError';\n  }\n  return false;\n}\n</pre> <p>Prior to ES5.1, implementations were not required to throw a range error exception if <code>toLocaleString</code> is called with arguments.</p> <p>A check that works in all hosts, including those supporting ECMA-262 prior to ed 5.1, is to test for the features specified in ECMA-402 that are required to support regional options for <code>Number.prototype.toLocaleString</code> directly:</p> <pre data-language=\"js\">function toLocaleStringSupportsOptions() {\n  return !!(typeof Intl == 'object' &amp;&amp; Intl &amp;&amp; typeof Intl.NumberFormat == 'function');\n}\n</pre> <p>This tests for a global <code>Intl</code> object, checks that it's not <code>null</code> and that it has a <code>NumberFormat</code> property that is a function.</p> <h3 id=\"Using_locales\">Using <code>locales</code>\n</h3> <p>This example shows some of the variations in localized number formats. In order to get the format of the language used in the user interface of your application, make sure to specify that language (and possibly some fallback languages) using the <code>locales</code> argument:</p> <pre data-language=\"js\">var number = 123456.789;\n\n// German uses comma as decimal separator and period for thousands\nconsole.log(number.toLocaleString('de-DE'));\n// → 123.456,789\n\n// Arabic in most Arabic speaking countries uses <a href=\"https://en.wikipedia.org/wiki/Eastern_Arabic_numerals\">Eastern Arabic</a> digits\nconsole.log(number.toLocaleString('ar-EG'));\n// → ١٢٣٤٥٦٫٧٨٩\n\n// India uses thousands/lakh/crore separators\nconsole.log(number.toLocaleString('en-IN'));\n// → 1,23,456.789\n\n// the nu extension key requests a numbering system, e.g. Chinese decimal\nconsole.log(number.toLocaleString('zh-Hans-CN-u-nu-hanidec'));\n// → 一二三,四五六.七八九\n\n// when requesting a language that may not be supported, such as\n// Balinese, include a fallback language, in this case Indonesian\nconsole.log(number.toLocaleString(['ban', 'id']));\n// → 123.456,789\n</pre> <h3 id=\"Using_options\">Using <code>options</code>\n</h3> <p>The results provided by <code>toLocaleString</code> can be customized using the <code>options</code> argument:</p> <pre data-language=\"js\">var number = 123456.789;\n\n// request a currency format\nconsole.log(number.toLocaleString('de-DE', { style: 'currency', currency: 'EUR' }));\n// → 123.456,79 €\n\n// the Japanese yen doesn't use a minor unit\nconsole.log(number.toLocaleString('ja-JP', { style: 'currency', currency: 'JPY' }))\n// → ￥123,457\n\n// limit to three significant digits\nconsole.log(number.toLocaleString('en-IN', { maximumSignificantDigits: 3 }));\n// → 1,23,000\n\n// Use the host default language with options for number formatting\nvar num = 30000.65;\nconsole.log(num.toLocaleString(undefined, {minimumFractionDigits: 2, maximumFractionDigits: 2}));\n// → \"30,000.65\" where English is the default language, or\n// → \"30.000,65\" where German is the default language, or\n// → \"30 000,65\" where French is the default language\n</pre> <h2 id=\"Performance\">Performance</h2> <p>When formatting large numbers of numbers, it is better to create a <a href=\"../numberformat\"><code>NumberFormat</code></a> object and use the function provided by its <a href=\"../numberformat/format\"><code>NumberFormat.format</code></a> property.</p> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/publications/files/ECMA-ST-ARCH/ECMA-262,%203rd%20edition,%20December%201999.pdf\" hreflang=\"en\">ECMAScript 3rd Edition (ECMA-262)</a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition. Implemented in JavaScript 1.5.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/5.1/#sec-15.7.4.3\" hreflang=\"en\">ECMAScript 5.1 (ECMA-262)<br><small>The definition of 'Number.prototype.toLocaleString' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-number.prototype.tolocalestring\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Number.prototype.toLocaleString' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-number.prototype.tolocalestring\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Number.prototype.toLocaleString' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-402/1.0/#sec-13.2.1\" hreflang=\"en\">ECMAScript Internationalization API 1.0 (ECMA-402)<br><small>The definition of 'Number.prototype.toLocaleString' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-402/2.0/#sec-13.2.1\" hreflang=\"en\">ECMAScript Internationalization API 2.0 (ECMA-402)<br><small>The definition of 'Number.prototype.toLocaleString' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma402/#sec-Number.prototype.toLocaleString\" hreflang=\"en\">ECMAScript Internationalization API 4.0 (ECMA-402)<br><small>The definition of 'Number.prototype.toLocaleString' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><code>locales</code></th>\n<td class=\"bc-supports-yes\"> 24</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 29</td>\n<td class=\"bc-supports-yes\"> 11</td>\n<td class=\"bc-supports-yes\"> 15</td>\n<td class=\"bc-supports-yes\"> 10</td>\n</tr>\n<tr>\n<th scope=\"row\"><code>options</code></th>\n<td class=\"bc-supports-yes\"> 24</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 29</td>\n<td class=\"bc-supports-yes\"> 11</td>\n<td class=\"bc-supports-yes\"> 15</td>\n<td class=\"bc-supports-yes\"> 10</td>\n</tr>\n</tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><code>locales</code></th>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 26</td>\n<td> ? </td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 10</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><code>options</code></th>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 26</td>\n<td> ? </td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 10</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n</tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><code>locales</code></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><code>options</code></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n</tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"tostring\"><code>Number.prototype.toString()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toLocaleString$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toLocaleString\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toLocaleString</a>\n  </p>\n</div>\n","global_objects/date/tolocalestring":"<h1>date.toLocaleString</h1> <p>The <code>toLocaleString()</code> method returns a string with a language sensitive representation of this date. The new <code>locales</code> and <code>options</code> arguments let applications specify the language whose formatting conventions should be used and customize the behavior of the function. In older implementations, which ignore the <code>locales</code> and <code>options</code> arguments, the locale used and the form of the string returned are entirely implementation dependent.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/date-tolocalestring.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\"><var>dateObj</var>.toLocaleString([<var>locales</var>[, <var>options</var>]])</pre> <h3 id=\"Parameters\">Parameters</h3> <p>Check the <a href=\"#Browser_Compatibility\">Browser compatibility</a> section to see which browsers support the <code>locales</code> and <code>options</code> arguments, and the <a href=\"#Example:_Checking_for_support_for_locales_and_options_arguments\">Example: Checking for support for <code>locales</code> and <code>options</code> arguments</a> for feature detection.</p> <dl> <dt><code>locales</code></dt> <dd> <p>Optional. A string with a BCP 47 language tag, or an array of such strings. For the general form and interpretation of the <code>locales</code> argument, see the <a href=\"../intl#Locale_identification_and_negotiation\">Intl page</a>. The following Unicode extension keys are allowed:</p> <dl> <dt><code>nu</code></dt> <dd>Numbering system. Possible values include: <code>\"arab\"</code>, <code>\"arabext\"</code>, <code>\"bali\"</code>, <code>\"beng\"</code>, <code>\"deva\"</code>, <code>\"fullwide\"</code>, <code>\"gujr\"</code>, <code>\"guru\"</code>, <code>\"hanidec\"</code>, <code>\"khmr\"</code>, <code>\"knda\"</code>, <code>\"laoo\"</code>, <code>\"latn\"</code>, <code>\"limb\"</code>, <code>\"mlym\"</code>, <code>\"mong\"</code>, <code>\"mymr\"</code>, <code>\"orya\"</code>, <code>\"tamldec\"</code>, <code>\"telu\"</code>, <code>\"thai\"</code>, <code>\"tibt\"</code>.</dd> <dt><code>ca</code></dt> <dd>Calendar. Possible values include: <code>\"buddhist\"</code>, <code>\"chinese\"</code>, <code>\"coptic\"</code>, <code>\"ethioaa\"</code>, <code>\"ethiopic\"</code>, <code>\"gregory\"</code>, <code>\"hebrew\"</code>, <code>\"indian\"</code>, <code>\"islamic\"</code>, <code>\"islamicc\"</code>, <code>\"iso8601\"</code>, <code>\"japanese\"</code>, <code>\"persian\"</code>, <code>\"roc\"</code>.</dd> <dt><code>hc</code></dt> <dd>Hour cycle. Possible values include: <code>\"h11\"</code>, <code>\"h12\"</code>, <code>\"h23\"</code>, <code>\"h24\"</code>.</dd> </dl> </dd> <dt><code>options</code></dt> <dd> <p>Optional. An object with some or all of the following properties:</p> <dl> <dt><code>localeMatcher</code></dt> <dd>The locale matching algorithm to use. Possible values are <code>\"lookup\"</code> and <code>\"best fit\"</code>; the default is <code>\"best fit\"</code>. For information about this option, see the <a href=\"../intl#Locale_negotiation\">Intl page</a>.</dd> <dt><code>timeZone</code></dt> <dd>The time zone to use. The only value implementations must recognize is <code>\"UTC\"</code>; the default is the runtime's default time zone. Implementations may also recognize the time zone names of the <a href=\"https://www.iana.org/time-zones\">IANA time zone database</a>, such as <code>\"Asia/Shanghai\"</code>, <code>\"Asia/Kolkata\"</code>, <code>\"America/New_York\"</code>.</dd> <dt><code>hour12</code></dt> <dd>Whether to use 12-hour time (as opposed to 24-hour time). Possible values are <code>true</code> and <code>false</code>; the default is locale dependent. This option overrides the <code>hc</code> language tag and/or the <code>hourCycle</code> option in case both are present.</dd> <dt><code>hourCycle</code></dt> <dd>The hour cycle to use. Possible values are <code>\"h11\"</code>, <code>\"h12\"</code>, <code>\"h23\"</code>, or <code>\"h24\"</code>. This option overrides the <code>hc</code> language tag, if both are present, and the <code>hour12</code> option takes precedence in case both options have been specified.</dd> <dt><code>formatMatcher</code></dt> <dd>The format matching algorithm to use. Possible values are <code>\"basic\"</code> and <code>\"best fit\"</code>; the default is <code>\"best fit\"</code>. See the following paragraphs for information about the use of this property.</dd> </dl> <p>The following properties describe the date-time components to use in formatted output, and their desired representations. Implementations are required to support at least the following subsets:</p> <ul> <li>\n<code>weekday</code>, <code>year</code>, <code>month</code>, <code>day</code>, <code>hour</code>, <code>minute</code>, <code>second</code>\n</li> <li>\n<code>weekday</code>, <code>year</code>, <code>month</code>, <code>day</code>\n</li> <li>\n<code>year</code>, <code>month</code>, <code>day</code>\n</li> <li>\n<code>year</code>, <code>month</code>\n</li> <li>\n<code>month</code>, <code>day</code>\n</li> <li>\n<code>hour</code>, <code>minute</code>, <code>second</code>\n</li> <li>\n<code>hour</code>, <code>minute</code>\n</li> </ul> <p>Implementations may support other subsets, and requests will be negotiated against all available subset-representation combinations to find the best match. Two algorithms are available for this negotiation and selected by the <code>formatMatcher</code> property: A <a href=\"http://www.ecma-international.org/ecma-402/1.0/#BasicFormatMatcher\">fully specified <code>\"basic\"</code> algorithm</a> and an implementation-dependent <code>\"best fit\"</code> algorithm.</p> <dl> <dt><code>weekday</code></dt> <dd>The representation of the weekday. Possible values are <code>\"narrow\"</code>, <code>\"short\"</code>, <code>\"long\"</code>.</dd> <dt><code>era</code></dt> <dd>The representation of the era. Possible values are <code>\"narrow\"</code>, <code>\"short\"</code>, <code>\"long\"</code>.</dd> <dt><code>year</code></dt> <dd>The representation of the year. Possible values are <code>\"numeric\"</code>, <code>\"2-digit\"</code>.</dd> <dt><code>month</code></dt> <dd>The representation of the month. Possible values are <code>\"numeric\"</code>, <code>\"2-digit\"</code>, <code>\"narrow\"</code>, <code>\"short\"</code>, <code>\"long\"</code>.</dd> <dt><code>day</code></dt> <dd>The representation of the day. Possible values are <code>\"numeric\"</code>, <code>\"2-digit\"</code>.</dd> <dt><code>hour</code></dt> <dd>The representation of the hour. Possible values are <code>\"numeric\"</code>, <code>\"2-digit\"</code>.</dd> <dt><code>minute</code></dt> <dd>The representation of the minute. Possible values are <code>\"numeric\"</code>, <code>\"2-digit\"</code>.</dd> <dt><code>second</code></dt> <dd>The representation of the second. Possible values are <code>\"numeric\"</code>, <code>\"2-digit\"</code>.</dd> <dt><code>timeZoneName</code></dt> <dd>The representation of the time zone name. Possible values are <code>\"short\"</code>, <code>\"long\"</code>.</dd> </dl> </dd> </dl> <p>The default value for each date-time component property is <a href=\"../undefined\"><code>undefined</code></a>, but if the <code>weekday</code>, <code>year</code>, <code>month</code>, <code>day</code>, <code>hour</code>, <code>minute</code>, <code>second</code> properties are all <a href=\"../undefined\"><code>undefined</code></a>, then <code>year</code>, <code>month</code>, <code>day</code>, <code>hour</code>, <code>minute</code>, and <code>second</code> are assumed to be <code>\"numeric\"</code>.</p> <h3 id=\"Return_value\">Return value</h3> <p>A string representing the given date according to language-specific conventions.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Using_toLocaleString()\">Using <code>toLocaleString()</code>\n</h3> <p>In basic use without specifying a locale, a formatted string in the default locale and with default options is returned.</p> <pre data-language=\"js\">var date = new Date(Date.UTC(2012, 11, 12, 3, 0, 0));\n\n// toLocaleString() without arguments depends on the implementation,\n// the default locale, and the default time zone\nconsole.log(date.toLocaleString());\n// → \"12/11/2012, 7:00:00 PM\" if run in en-US locale with time zone America/Los_Angeles\n</pre> <h3 id=\"Checking_for_support_for_locales_and_options_arguments\">Checking for support for <code>locales</code> and <code>options</code> arguments</h3> <p>The <code>locales</code> and <code>options</code> arguments are not supported in all browsers yet. To check whether an implementation supports them already, you can use the requirement that illegal language tags are rejected with a <a href=\"../rangeerror\"><code>RangeError</code></a> exception:</p> <pre data-language=\"js\">function toLocaleStringSupportsLocales() {\n  try {\n    new Date().toLocaleString('i');\n  } catch (e) {\n    return e instanceof RangeError;\n  }\n  return false;\n}\n</pre> <h3 id=\"Using_locales\">Using <code>locales</code>\n</h3> <p>This example shows some of the variations in localized date and time formats. In order to get the format of the language used in the user interface of your application, make sure to specify that language (and possibly some fallback languages) using the <code>locales</code> argument:</p> <pre data-language=\"js\">var date = new Date(Date.UTC(2012, 11, 20, 3, 0, 0));\n\n// formats below assume the local time zone of the locale;\n// America/Los_Angeles for the US\n\n// US English uses month-day-year order and 12-hour time with AM/PM\nconsole.log(date.toLocaleString('en-US'));\n// → \"12/19/2012, 7:00:00 PM\"\n\n// British English uses day-month-year order and 24-hour time without AM/PM\nconsole.log(date.toLocaleString('en-GB'));\n// → \"20/12/2012 03:00:00\"\n\n// Korean uses year-month-day order and 12-hour time with AM/PM\nconsole.log(date.toLocaleString('ko-KR'));\n// → \"2012. 12. 20. 오후 12:00:00\"\n\n// Arabic in most Arabic speaking countries uses real Arabic digits\nconsole.log(date.toLocaleString('ar-EG'));\n// → \"<span dir=\"rtl\">٢٠‏/١٢‏/٢٠١٢ ٥:٠٠:٠٠ ص</span>\"\n\n// for Japanese, applications may want to use the Japanese calendar,\n// where 2012 was the year 24 of the Heisei era\nconsole.log(date.toLocaleString('ja-JP-u-ca-japanese'));\n// → \"24/12/20 12:00:00\"\n\n// when requesting a language that may not be supported, such as\n// Balinese, include a fallback language, in this case Indonesian\nconsole.log(date.toLocaleString(['ban', 'id']));\n// → \"20/12/2012 11.00.00\"\n</pre> <h3 id=\"Using_options\">Using <code>options</code>\n</h3> <p>The results provided by <code>toLocaleString()</code> can be customized using the <code>options</code> argument:</p> <pre data-language=\"js\">var date = new Date(Date.UTC(2012, 11, 20, 3, 0, 0));\n\n// request a weekday along with a long date\nvar options = { weekday: 'long', year: 'numeric', month: 'long', day: 'numeric' };\nconsole.log(date.toLocaleString('de-DE', options));\n// → \"Donnerstag, 20. Dezember 2012\"\n\n// an application may want to use UTC and make that visible\noptions.timeZone = 'UTC';\noptions.timeZoneName = 'short';\nconsole.log(date.toLocaleString('en-US', options));\n// → \"Thursday, December 20, 2012, GMT\"\n\n// sometimes even the US needs 24-hour time\nconsole.log(date.toLocaleString('en-US', { hour12: false }));\n// → \"12/19/2012, 19:00:00\"\n</pre> <h2 id=\"Performance\">Performance</h2> <p>When formatting large numbers of dates, it is better to create an <a href=\"../datetimeformat\"><code>Intl.DateTimeFormat</code></a> object and use the function provided by its <a href=\"../datetimeformat/format\"><code>format</code></a> property.</p> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/publications/files/ECMA-ST-ARCH/ECMA-262,%201st%20edition,%20June%201997.pdf\" hreflang=\"en\">ECMAScript 1st Edition (ECMA-262)</a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition. Implemented in JavaScript 1.0.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/5.1/#sec-15.9.5.5\" hreflang=\"en\">ECMAScript 5.1 (ECMA-262)<br><small>The definition of 'Date.prototype.toLocaleString' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-date.prototype.tolocalestring\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Date.prototype.toLocaleString' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-date.prototype.tolocalestring\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Date.prototype.toLocaleString' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-402/1.0/#sec-13.3.1\" hreflang=\"en\">ECMAScript Internationalization API 1.0 (ECMA-402)<br><small>The definition of 'Date.prototype.toLocaleString' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Defines <code>locales</code> and <code>options</code> arguments.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-402/2.0/#sec-13.3.1\" hreflang=\"en\">ECMAScript Internationalization API 2.0 (ECMA-402)<br><small>The definition of 'Date.prototype.toLocaleString' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma402/#sec-Date.prototype.toLocaleString\" hreflang=\"en\">ECMAScript Internationalization API 4.0 (ECMA-402)<br><small>The definition of 'Date.prototype.toLocaleString' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><code>locales</code></th>\n<td class=\"bc-supports-yes\"> 24</td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 29</td>\n<td class=\"bc-supports-yes\"> 11</td>\n<td class=\"bc-supports-yes\"> 15</td>\n<td class=\"bc-supports-yes\"> 10</td>\n</tr>\n<tr>\n<th scope=\"row\"><code>options</code></th>\n<td class=\"bc-supports-yes\"> 24</td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 29</td>\n<td class=\"bc-supports-yes\"> 11</td>\n<td class=\"bc-supports-yes\"> 15</td>\n<td class=\"bc-supports-yes\"> 10</td>\n</tr>\n<tr>\n<th scope=\"row\">IANA time zone names in <code>timeZone</code> option</th>\n<td class=\"bc-supports-yes\"> 24</td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 52</td>\n<td> ? </td>\n<td> ? </td>\n<td> ? </td>\n</tr>\n</tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><code>locales</code></th>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 26</td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 56</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 10</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><code>options</code></th>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 26</td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 56</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 10</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">IANA time zone names in <code>timeZone</code> option</th>\n<td> ? </td>\n<td> ? </td>\n<td> ? </td>\n<td class=\"bc-supports-no\"> No</td>\n<td> ? </td>\n<td> ? </td>\n<td> ? </td>\n</tr>\n</tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td> ? </td>\n</tr>\n<tr>\n<th scope=\"row\"><code>locales</code></th>\n<td> ? </td>\n</tr>\n<tr>\n<th scope=\"row\"><code>options</code></th>\n<td> ? </td>\n</tr>\n<tr>\n<th scope=\"row\">IANA time zone names in <code>timeZone</code> option</th>\n<td> ? </td>\n</tr>\n</tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"../datetimeformat\"><code>Intl.DateTimeFormat</code></a></li> <li><a href=\"tolocaledatestring\"><code>Date.prototype.toLocaleDateString()</code></a></li> <li><a href=\"tolocaletimestring\"><code>Date.prototype.toLocaleTimeString()</code></a></li> <li><a href=\"tostring\"><code>Date.prototype.toString()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toLocaleString$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toLocaleString\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toLocaleString</a>\n  </p>\n</div>\n","global_objects/numberformat/formattoparts":"<h1>Intl.numberFormat.formatToParts</h1> <div class=\"blockIndicator experimental indicator-warning\"> <p> <strong>This is an <a href=\"https://developer.mozilla.org/en-US/docs/MDN/Contribute/Guidelines/Conventions_definitions#Experimental\">experimental technology</a></strong><br>Check the <a href=\"#Browser_compatibility\">Browser compatibility table</a> carefully before using this in production.</p> </div> <p>The <code>Intl.Numberformat.prototype.formatToParts()</code> method allows locale-aware formatting of strings produced by <code>NumberTimeFormat</code> formatters.</p> <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\">Intl.NumberFormat.prototype.formatToParts(number)</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt>\n<code>number</code> <span class=\"inlineIndicator optional optionalInline\">Optional</span>\n</dt> <dd>The number to format.</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p>An <a href=\"../array\"><code>Array</code></a> of objects containing the formatted number in parts.</p> <h2 id=\"Description\">Description</h2> <p>The <code>formatToParts()</code> method is useful for custom formatting of number strings. It returns an <a href=\"../array\"><code>Array</code></a> of objects containing the locale-specific tokens from which it possible to build custom strings while preserving the locale-specific parts. The structure the <code>formatToParts()</code> method returns, looks like this:</p> <pre data-language=\"js\">[\n  { type: \"integer\", value: \"3\" }\n  { type: \"group\", value: \".\" }\n  { type: \"integer\", value: \"500\" }\n]</pre> <p>Possible types are the following:</p> <dl> <dt>currency</dt> <dd>The currency string, such as the symbols \"$\" and \"€\" or the name \"Dollar\", \"Euro\" depending on how <code>currencyDisplay</code> is specified.</dd> <dt>decimal</dt> <dd>The decimal separator string (\".\").</dd> <dt>fraction</dt> <dd>The fraction number.</dd> <dt>group</dt> <dd>The group separator string (\",\").</dd> <dt>infinity</dt> <dd>The <a href=\"../infinity\"><code>Infinity</code></a> string (\"∞\").</dd> <dt>integer</dt> <dd>The integer number.</dd> <dt>literal</dt> <dd>Any literal strings or whitespace in the formatted number.</dd> <dt>minusSign</dt> <dd>The minus sign string (\"-\").</dd> <dt>nan</dt> <dd>The <a href=\"../nan\"><code>NaN</code></a> string (\"NaN\").</dd> <dt>plusSign</dt> <dd>The plus sign string (\"+\").</dd> </dl> <dl> <dt>percentSign</dt> <dd>The percent sign string (\"%\").</dd> </dl> <h2 id=\"Examples\">Examples</h2> <p><code>NumberFormat</code> outputs localized, opaque strings that cannot be manipulated directly:</p> <pre data-language=\"js\">var number = 3500;\n\nvar formatter = new Intl.NumberFormat('de-DE', { \n  style: 'currency', \n  currency: 'EUR' \n});\n\nformatter.format(number);\n// \"3.500,00 €\"\n</pre> <p>However, in many User Interfaces there is a desire to customize the formatting of this string. The <code>formatToParts</code> method enables locale-aware formatting of strings produced by <code>NumberFormat</code> formatters by providing you the string in parts:</p> <pre data-language=\"js\">formatter.formatToParts(number);\n\n// return value: \n[ \n  { type: \"integer\",  value: \"3\"   }\n  { type: \"group\",    value: \".\"   }\n  { type: \"integer\",  value: \"500\" }\n  { type: \"decimal\",  value: \",\"   }\n  { type: \"fraction\", value: \"00\"  }\n  { type: \"literal\",  value: \" \"   }\n  { type: \"currency\", value: \"€\"   }\n]\n</pre> <p>Now the information is available separately and it can be formatted and concatenated again in a customized way. For example by using <a href=\"../array/map\"><code>Array.prototype.map()</code></a>, <a href=\"../../functions/arrow_functions\">arrow functions</a>, a <a href=\"../../statements/switch\">switch statement</a>, <a href=\"../../template_literals\">template literals</a>, and <a href=\"../array/reduce\"><code>Array.prototype.reduce()</code></a>.</p> <pre data-language=\"js\">var numberString = formatter.formatToParts(number).map(({type, value}) =&gt; { \n  switch (type) {\n    case 'currency': return `&lt;strong&gt;${value}&lt;/strong&gt;`; \n    default : return value; \n  } \n}).reduce((string, part) =&gt; string + part);\n</pre> <p>This will make the currency bold, when using the <code>formatToParts()</code> method.</p> <pre data-language=\"js\">console.log(numberString);\n// \"3.500,00 &lt;strong&gt;€&lt;/strong&gt;\"</pre> <h2 id=\"Polyfill\">Polyfill</h2> <p>A polyfill for this feature is available in the <a href=\"https://github.com/zbraniecki/proposal-intl-formatToParts\">proposal repository</a>.</p> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma402/#sec-Intl.NumberFormat.prototype.formatToParts\" hreflang=\"en\">ECMAScript Internationalization API 4.0 (ECMA-402)<br><small>The definition of 'Intl.NumberFormat.prototype.formatToParts' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td>Initial definition</td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>   <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support \n</th>\n<td class=\"bc-supports-yes bc-has-history\"> 63<div class=\"bc-icons\"> Disabled </div>\n<section class=\"bc-history\" id=\"sect1\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 63<div class=\"bc-icons\"> Disabled </div>\n</dt>\n<dd> Need to set the flag on the commandline via --js-flags</dd>\n<dd>Disabled From version 63: this feature is behind the <code>harmony-number-format-to-parts</code> runtime flag.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 58</td>\n<td> ? </td>\n<td> ? </td>\n<td> ? </td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support \n</th>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes bc-has-history\"> 63<div class=\"bc-icons\"> Disabled </div>\n<section class=\"bc-history\" id=\"sect2\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 63<div class=\"bc-icons\"> Disabled </div>\n</dt>\n<dd> Need to set the flag on the commandline via --js-flags</dd>\n<dd>Disabled From version 63: this feature is behind the <code>harmony-number-format-to-parts</code> runtime flag.</dd>\n</dl></section>\n</td>\n<td> ? </td>\n<td> ? </td>\n<td> ? </td>\n<td> ? </td>\n<td class=\"bc-supports-no\"> No</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support \n</th>\n<td> ? </td>\n</tr></tbody>\n</table>\n</div>  <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"../numberformat\"><code>Intl.NumberFormat</code></a></li> <li><a href=\"format\"><code>Intl.NumberFormat.prototype.format</code></a></li> <li>Formatting dates: <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DateFormat/formatToParts\"><code>Intl.DateTimeFormat.prototype.formatToParts()</code></a>\n</li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/NumberFormat/formatToParts$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/NumberFormat/formatToParts\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/NumberFormat/formatToParts</a>\n  </p>\n</div>\n","global_objects/pluralrules/prototype":"<h1>PluralRules.prototype</h1> <p>The <code>Intl.PluralRules.prototype</code> property represents the prototype object for the <a href=\"../pluralrules\"><code>Intl.PluralRules</code></a> constructor.</p> <div class=\"_table\"><table class=\"standard-table\"> <thead> <tr> <th colspan=\"2\" class=\"header\">Property attributes of <code>Intl.PluralRules.prototype</code>\n</th> </tr> </thead> <tbody> <tr> <td>Writable</td> <td>no</td> </tr> <tr> <td>Enumerable</td> <td>no</td> </tr> <tr> <td>Configurable</td> <td>no</td> </tr> </tbody> </table></div> <h2 id=\"Description\">Description</h2> <p>See <a href=\"../pluralrules\"><code>PluralRules</code></a> for a description of <code>Intl.PluralRules</code> instances.</p> <p><a href=\"../pluralrules\"><code>Intl.PluralRules</code></a> instances inherit from <code>Intl.PluralRules.prototype</code>. Modifications to the prototype object are inherited by all <a href=\"../pluralrules\"><code>Intl.PluralRules</code></a> instances.</p> <h2 id=\"Properties\">Properties</h2> <dl> <dt><code>Intl.PluralRules.prototype.constructor</code></dt> <dd>A reference to <code>Intl.PluralRules</code>.</dd> </dl> <h2 id=\"Methods\">Methods</h2> <dl> <dt><a href=\"resolvedoptions\"><code>Intl.PluralRules.prototype.resolvedOptions()</code></a></dt> <dd>Returns a new object with properties reflecting the locale and collation options computed during initialization of the object.</dd> <dt><a href=\"select\"><code>Intl.PluralRules.prototype.select()</code></a></dt> <dd>Returns a <a href=\"../string\"><code>String</code></a> indicating which plurar rule to use for locale-aware formatting.</dd> </dl> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://rawgit.com/caridy/intl-plural-rules-spec/master/index.html\">Intl Plural Rules Draft</a></td> <td>Draft</td> <td>Initial definition.</td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>   <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 63</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 58</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 50</td>\n<td class=\"bc-supports-no\"> No</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 63</td>\n<td class=\"bc-supports-yes\"> 63</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 58</td>\n<td class=\"bc-supports-yes\"> 50</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-no\"> No</td>\n</tr></tbody>\n</table>\n</div>  <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"../pluralrules\"><code>Intl.PluralRules</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/PluralRules/prototype$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/PluralRules/prototype\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/PluralRules/prototype</a>\n  </p>\n</div>\n","global_objects/datetimeformat/format":"<h1>Intl.dateTimeFormat.format</h1> <p>The <code>Intl.DateTimeFormat.prototype.format</code> property returns a getter function that formats a date according to the locale and formatting options of this <a href=\"../datetimeformat\"><code>Intl.DateTimeFormat</code></a> object.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/intl-datetimeformat-prototype-format.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\"><var>dateTimeFormat</var>.format(<var>date</var>)</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><code>date</code></dt> <dd>The date to format.</dd> </dl> <h2 id=\"Description\">Description</h2> <p>The function returned by the <code>format</code> getter formats a date into a string according to the locale and formatting options of this <a href=\"../datetimeformat\"><code>Intl.DateTimeFormat</code></a> object.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Using_format\">Using <code>format</code>\n</h3> <p>Use the function returned by the <code>format</code> getter for formatting a single date, here for Serbia:</p> <pre data-language=\"js\">var options = { weekday: 'long', year: 'numeric', month: 'long', day: 'numeric' };\nvar dateTimeFormat = new Intl.DateTimeFormat('sr-RS', options);\nconsole.log(dateTimeFormat.format(new Date()));\n// → \"недеља, 7. април 2013.\"\n</pre> <h3 id=\"Using_format_with_map\">Using <code>format</code> with <code>map</code>\n</h3> <p>Use the function returned by the <code>format</code> getter for formatting all dates in an array. Note that the function is bound to the <a href=\"../datetimeformat\"><code>Intl.DateTimeFormat</code></a> from which it was obtained, so it can be passed directly to <a href=\"../array/map\"><code>Array.prototype.map()</code></a>.</p> <pre data-language=\"js\">var a = [new Date(2012, 08), new Date(2012, 11), new Date(2012, 03)];\nvar options = { year: 'numeric', month: 'long' };\nvar dateTimeFormat = new Intl.DateTimeFormat('pt-BR', options);\nvar formatted = a.map(dateTimeFormat.format);\nconsole.log(formatted.join('; '));\n// → \"setembro de 2012; dezembro de 2012; abril de 2012\"\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-402/1.0/#sec-12.3.2\" hreflang=\"en\">ECMAScript Internationalization API 1.0 (ECMA-402)<br><small>The definition of 'Intl.DateTimeFormat.format' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-402/2.0/#sec-12.3.2\" hreflang=\"en\">ECMAScript Internationalization API 2.0 (ECMA-402)<br><small>The definition of 'Intl.DateTimeFormat.format' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma402/#sec-Intl.DateTimeFormat.prototype.format\" hreflang=\"en\">ECMAScript Internationalization API 4.0 (ECMA-402)<br><small>The definition of 'Intl.DateTimeFormat.format' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>   <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 24</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 29</td>\n<td class=\"bc-supports-yes\"> 11</td>\n<td class=\"bc-supports-yes\"> 15</td>\n<td class=\"bc-supports-yes\"> 10</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 26</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 56</td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 10</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td> ? </td>\n</tr></tbody>\n</table>\n</div>  <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"../datetimeformat\"><code>Intl.DateTimeFormat</code></a></li> <li><a href=\"../date/tolocalestring\"><code>Date.prototype.toLocaleString()</code></a></li> <li><a href=\"../date/tolocaledatestring\"><code>Date.prototype.toLocaleDateString()</code></a></li> <li><a href=\"../date/tolocaletimestring\"><code>Date.prototype.toLocaleTimeString()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DateTimeFormat/format$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DateTimeFormat/format\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DateTimeFormat/format</a>\n  </p>\n</div>\n","global_objects/json/parse":"<h1>JSON.parse</h1> <p>The <code>JSON.parse()</code> method parses a JSON string, constructing the JavaScript value or object described by the string. An optional <strong>reviver</strong> function can be provided to perform a transformation on the resulting object before it is returned.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/json-parse.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\">JSON.parse(<var>text</var>[, <var>reviver</var>])</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><code>text</code></dt> <dd>The string to parse as JSON. See the <a href=\"../json\"><code>JSON</code></a> object for a description of JSON syntax.</dd> <dt>\n<code>reviver</code> <span class=\"inlineIndicator optional optionalInline\">Optional</span>\n</dt> <dd>If a function, this prescribes how the value originally produced by parsing is transformed, before being returned.</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p>The <a href=\"../object\"><code>Object</code></a> corresponding to the given JSON <code>text</code>.</p> <h3 id=\"Exceptions\">Exceptions</h3> <p>Throws a <a href=\"../syntaxerror\"><code>SyntaxError</code></a> exception if the string to parse is not valid JSON.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Using_JSON.parse()\">Using <code>JSON.parse()</code>\n</h3> <pre data-language=\"js\">JSON.parse('{}');              // {}\nJSON.parse('true');            // true\nJSON.parse('\"foo\"');           // \"foo\"\nJSON.parse('[1, 5, \"false\"]'); // [1, 5, \"false\"]\nJSON.parse('null');            // null\n</pre> <h3 id=\"Using_the_reviver_parameter\">Using the <code>reviver</code> parameter</h3> <p>If a <code>reviver</code> is specified, the value computed by parsing is <em>transformed</em> before being returned. Specifically, the computed value and all its properties (beginning with the most nested properties and proceeding to the original value itself) are individually run through the <code>reviver</code>. Then it is called, with the object containing the property being processed as <code>this</code>, and with the property name as a string, and the property value as arguments. If the <code>reviver</code> function returns <a href=\"../undefined\"><code>undefined</code></a> (or returns no value, for example, if execution falls off the end of the function), the property is deleted from the object. Otherwise, the property is redefined to be the return value.</p> <p>If the <code>reviver</code> only transforms some values and not others, be certain to return all untransformed values as-is, otherwise they will be deleted from the resulting object.</p> <pre data-language=\"js\">JSON.parse('{\"p\": 5}', (key, value) =&gt;\n  typeof value === 'number'\n    ? value * 2 // return value * 2 for numbers\n    : value     // return everything else unchanged\n);\n\n// { p: 10 }\n\nJSON.parse('{\"1\": 1, \"2\": 2, \"3\": {\"4\": 4, \"5\": {\"6\": 6}}}', (key, value) =&gt; {\n  console.log(key); // log the current property name, the last is \"\".\n  return value;     // return the unchanged property value.\n});\n\n// 1\n// 2\n// 4\n// 6\n// 5\n// 3 \n// \"\"\n</pre> <h3 id=\"JSON.parse()_does_not_allow_trailing_commas\">\n<code>JSON.parse()</code> does not allow trailing commas</h3> <pre class=\"example-bad brush: js example-bad\">// both will throw a SyntaxError\nJSON.parse('[1, 2, 3, 4, ]');\nJSON.parse('{\"foo\" : 1, }');\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/5.1/#sec-15.12.2\" hreflang=\"en\">ECMAScript 5.1 (ECMA-262)<br><small>The definition of 'JSON.parse' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition. Implemented in JavaScript 1.7.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-json.parse\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'JSON.parse' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-json.parse\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'JSON.parse' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>   <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 3.5</td>\n<td class=\"bc-supports-yes\"> 8</td>\n<td class=\"bc-supports-yes\"> 10.5</td>\n<td class=\"bc-supports-yes\"> 4</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div>  <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"stringify\"><code>JSON.stringify()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse</a>\n  </p>\n</div>\n","global_objects/datetimeformat/supportedlocalesof":"<h1>Intl.DateTimeFormat.supportedLocalesOf</h1> <p>The <code>Intl.DateTimeFormat.supportedLocalesOf()</code> method returns an array containing those of the provided locales that are supported in date and time formatting without having to fall back to the runtime's default locale.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/intl-datetimeformat-prototype-supportedlocalesof.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\">Intl.DateTimeFormat.supportedLocalesOf(<var>locales</var>[, <var>options</var>])</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><code>locales</code></dt> <dd>A string with a BCP 47 language tag, or an array of such strings. For the general form of the <code>locales</code> argument, see the <a href=\"../intl#Locale_identification_and_negotiation\">Intl page</a>.</dd> <dt><code>options</code></dt> <dd> <p>Optional. An object that may have the following property:</p> <dl> <dt><code>localeMatcher</code></dt> <dd>The locale matching algorithm to use. Possible values are <code>\"lookup\"</code> and <code>\"best fit\"</code>; the default is <code>\"best fit\"</code>. For information about this option, see the <a href=\"../intl#Locale_negotiation\">Intl page</a>.</dd> </dl> </dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p>An array of strings representing a subset of the given locale tags that are supported in date and time formatting without having to fall back to the runtime's default locale.</p> <h2 id=\"Description\">Description</h2> <p>Returns an array with a subset of the language tags provided in <code>locales</code>. The language tags returned are those for which the runtime supports a locale in date and time formatting that the locale matching algorithm used considers a match, so that it wouldn't have to fall back to the default locale.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Using_supportedLocalesOf\">Using <code>supportedLocalesOf</code>\n</h3> <p>Assuming a runtime that supports Indonesian and German but not Balinese in date and time formatting, <code>supportedLocalesOf</code> returns the Indonesian and German language tags unchanged, even though pinyin collation is neither relevant to date and time formatting nor used with Indonesian, and a specialized German for Indonesia is unlikely to be supported. Note the specification of the <code>\"lookup\"</code> algorithm here — a <code>\"best fit\"</code> matcher might decide that Indonesian is an adequate match for Balinese since most Balinese speakers also understand Indonesian, and therefore return the Balinese language tag as well.</p> <pre data-language=\"js\">var locales = ['ban', 'id-u-co-pinyin', 'de-ID'];\nvar options = { localeMatcher: 'lookup' };\nconsole.log(Intl.DateTimeFormat.supportedLocalesOf(locales, options).join(', '));\n// → \"id-u-co-pinyin, de-ID\"\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-402/1.0/#sec-12.2.2\" hreflang=\"en\">ECMAScript Internationalization API 1.0 (ECMA-402)<br><small>The definition of 'Intl.DateTimeFormat.supportedLocalesOf' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-402/2.0/#sec-12.2.2\" hreflang=\"en\">ECMAScript Internationalization API 2.0 (ECMA-402)<br><small>The definition of 'Intl.DateTimeFormat.supportedLocalesOf' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma402/#sec-Intl.DateTimeFormat.supportedLocalesOf\" hreflang=\"en\">ECMAScript Internationalization API 4.0 (ECMA-402)<br><small>The definition of 'Intl.DateTimeFormat.supportedLocalesOf' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>   <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Collator/supportedLocalesOf\">Basic support</a></th>\n<td class=\"bc-supports-yes\"> 24</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 29</td>\n<td class=\"bc-supports-yes\"> 11</td>\n<td class=\"bc-supports-yes\"> 15</td>\n<td class=\"bc-supports-yes\"> 10</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Collator/supportedLocalesOf\">Basic support</a></th>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 26</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 56</td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 10</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Collator/supportedLocalesOf\">Basic support</a></th>\n<td> ? </td>\n</tr></tbody>\n</table>\n</div>  <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"../datetimeformat\"><code>Intl.DateTimeFormat</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DateTimeFormat/supportedLocalesOf$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DateTimeFormat/supportedLocalesOf\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DateTimeFormat/supportedLocalesOf</a>\n  </p>\n</div>\n","global_objects/json/stringify":"<h1>JSON.stringify</h1> <p>The <code>JSON.stringify()</code> method converts a JavaScript object or value to a JSON string, optionally replacing values if a replacer function is specified or optionally including only the specified properties if a replacer array is specified.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/json-stringify.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\">JSON.stringify(<var>value</var>[, <var>replacer</var>[, <var>space</var>]])</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><code>value</code></dt> <dd>The value to convert to a JSON string.</dd> <dt>\n<code>replacer</code><span class=\"inlineIndicator optional optionalInline\">Optional</span>\n</dt> <dd>A function that alters the behavior of the stringification process, or an array of <a href=\"../string\"><code>String</code></a> and <a href=\"../number\"><code>Number</code></a> objects that serve as a whitelist for selecting/filtering the properties of the value object to be included in the JSON string. If this value is <a href=\"../null\"><code>null</code></a> or not provided, all properties of the object are included in the resulting JSON string.</dd> <dt>\n<code>space</code><span class=\"inlineIndicator optional optionalInline\">Optional</span>\n</dt> <dd>A <a href=\"../string\"><code>String</code></a> or <a href=\"../number\"><code>Number</code></a> object that's used to insert white space into the output JSON string for readability purposes. <p>If this is a <code>Number</code>, it indicates the number of space characters to use as white space; this number is capped at 10 (if it is greater, the value is just <code>10</code>). Values less than 1 indicate that no space should be used.</p> <p>If this is a <code>String</code>, the string (or the first 10 characters of the string, if it's longer than that) is used as white space. If this parameter is not provided (or is <a href=\"../null\"><code>null</code></a>), no white space is used.</p> </dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p>A JSON string representing the given value.</p> <h3 id=\"Exceptions\">Exceptions</h3> <p>Throws a <a href=\"../typeerror\"><code>TypeError</code></a> (\"cyclic object value\") exception when a circular reference is found.</p> <h2 id=\"Description\">Description</h2> <p><code>JSON.stringify()</code> converts a value to JSON notation representing it:</p> <ul> <li>If the value has a <a href=\"#toJSON()_behavior\">toJSON()</a> method, it's responsible to define what data will be serialized.</li> <li>\n<a href=\"../boolean\"><code>Boolean</code></a>, <a href=\"../number\"><code>Number</code></a>, and <a href=\"../string\"><code>String</code></a> objects are converted to the corresponding primitive values during stringification, in accord with the traditional conversion semantics.</li> <li>If <a href=\"../undefined\"><code>undefined</code></a>, a <a href=\"../function\"><code>Function</code></a>, or a <a href=\"../symbol\"><code>Symbol</code></a> is encountered during conversion it is either omitted (when it is found in an object) or censored to <a href=\"../null\"><code>null</code></a> (when it is found in an array). <code>JSON.stringify()</code> can also just return <code>undefined</code> when passing in \"pure\" values like <code>JSON.stringify(function(){})</code> or <code>JSON.stringify(undefined)</code>.</li> <li>All <a href=\"../symbol\"><code>Symbol</code></a>-keyed properties will be completely ignored, even when using the <code>replacer</code> function.</li> <li>The instances of <a href=\"../date\"><code>Date</code></a> implement the <code>toJSON()</code> function by returning a string (the same as <code>date.toISOString()</code>). Thus, they are treated as strings.</li> <li>The numbers <a href=\"../infinity\"><code>Infinity</code></a> and <a href=\"../nan\"><code>NaN</code></a>, as well as the value <a href=\"../null\"><code>null</code></a>, are all considered <code>null</code>.</li> <li>All the other <a href=\"../object\"><code>Object</code></a> instances (including <a href=\"../map\"><code>Map</code></a>, <a href=\"../set\"><code>Set</code></a>, <a href=\"../weakmap\"><code>WeakMap</code></a>, and <a href=\"../weakset\"><code>WeakSet</code></a>) will have only their enumerable properties serialized.</li> </ul> <pre data-language=\"js\">JSON.stringify({});                    // '{}'\nJSON.stringify(true);                  // 'true'\nJSON.stringify('foo');                 // '\"foo\"'\nJSON.stringify([1, 'false', false]);   // '[1,\"false\",false]'\nJSON.stringify([NaN, null, Infinity]); // '[null,null,null]'\nJSON.stringify({ x: 5 });              // '{\"x\":5}'\n\nJSON.stringify(new Date(2006, 0, 2, 15, 4, 5)) \n// '\"2006-01-02T15:04:05.000Z\"'\n\nJSON.stringify({ x: 5, y: 6 });\n// '{\"x\":5,\"y\":6}'\nJSON.stringify([new Number(3), new String('false'), new Boolean(false)]);\n// '[3,\"false\",false]'\n\n// String-keyed array elements are not enumerable and make no sense in JSON\nlet a = ['foo', 'bar'];\na['baz'] = 'quux';      // a: [ 0: 'foo', 1: 'bar', baz: 'quux' ]\nJSON.stringify(a); \n// '[\"foo\",\"bar\"]'\n\nJSON.stringify({ x: [10, undefined, function(){}, Symbol('')] }); \n// '{\"x\":[10,null,null,null]}' \n\n// Standard data structures\nJSON.stringify([new Set([1]), new Map([[1, 2]]), new WeakSet([{a: 1}]), new WeakMap([[{a: 1}, 2]])]);\n// '[{},{},{},{}]'\n\n// TypedArray\nJSON.stringify([new Int8Array([1]), new Int16Array([1]), new Int32Array([1])]);\n// '[{\"0\":1},{\"0\":1},{\"0\":1}]'\nJSON.stringify([new Uint8Array([1]), new Uint8ClampedArray([1]), new Uint16Array([1]), new Uint32Array([1])]);\n// '[{\"0\":1},{\"0\":1},{\"0\":1},{\"0\":1}]'\nJSON.stringify([new Float32Array([1]), new Float64Array([1])]);\n// '[{\"0\":1},{\"0\":1}]'\n \n// toJSON()\nJSON.stringify({ x: 5, y: 6, toJSON(){ return this.x + this.y; } });\n// '11'\n\n// Symbols:\nJSON.stringify({ x: undefined, y: Object, z: Symbol('') });\n// '{}'\nJSON.stringify({ [Symbol('foo')]: 'foo' });\n// '{}'\nJSON.stringify({ [Symbol.for('foo')]: 'foo' }, [Symbol.for('foo')]);\n// '{}'\nJSON.stringify({ [Symbol.for('foo')]: 'foo' }, function(k, v) {\n  if (typeof k === 'symbol') {\n    return 'a symbol';\n  }\n});\n// undefined\n\n// Non-enumerable properties:\nJSON.stringify( Object.create(null, { x: { value: 'x', enumerable: false }, y: { value: 'y', enumerable: true } }) );\n// '{\"y\":\"y\"}'\n</pre> <h3 id=\"The replacer parameter\">The <code>replacer</code> parameter</h3> <p>The <code>replacer</code> parameter can be either a function or an array.</p> <p><strong>As a function</strong>, it takes two parameters: the <var>key</var> and the <var>value</var> being stringified. The object in which the key was found is provided as the replacer's <code>this</code> parameter.</p> <p>Initially, the <code>replacer</code> function is called with an empty string as key representing the object being stringified. It is then called for each property on the object or array being stringified.</p> <p>It should return the value that should be added to the JSON string, as follows:</p> <ul> <li>If you return a <a href=\"../number\"><code>Number</code></a>, the string corresponding to that number is used as the value for the property when added to the JSON string.</li> <li>If you return a <a href=\"../string\"><code>String</code></a>, that string is used as the property's value when adding it to the JSON string.</li> <li>If you return a <a href=\"../boolean\"><code>Boolean</code></a>, \"true\" or \"false\" is used as the property's value, as appropriate, when adding it to the JSON string.</li> <li>If you return <code>null</code>, <code>null</code> will be added to the JSON string.</li> <li>If you return any other object, the object is recursively stringified into the JSON string, calling the <code>replacer</code> function on each property, unless the object is a function, in which case nothing is added to the JSON string.</li> <li>If you return <code>undefined</code>, the property is not included (i.e., filtered out) in the output JSON string.</li> </ul> <div class=\"blockIndicator note\"> <p><strong>Note:</strong> You cannot use the <code>replacer</code> function to remove values from an array. If you return <code>undefined</code> or a function then <code>null</code> is used instead.</p> </div> <div class=\"blockIndicator note\"> <p><strong>Note:</strong> If you wish the replacer to distinguish an initial object from a key with an empty string property (since both would give the empty string as key and potentially an object as value), you will have to keep track of the iteration count (if it is beyond the first iteration, it is a genuine empty string key).</p> </div> <h4 id=\"Example_replacer_as_a_function\">Example <var>replacer</var>, as a function</h4> <pre data-language=\"js\">function replacer(key, value) {\n  // Filtering out properties\n  if (typeof value === 'string') {\n    return undefined;\n  }\n  return value;\n}\n\nvar foo = {foundation: 'Mozilla', model: 'box', week: 45, transport: 'car', month: 7};\nJSON.stringify(foo, replacer);\n// '{\"week\":45,\"month\":7}'\n</pre> <h4 id=\"Example_replacer_as_an_array\">Example <var>replacer</var>, as an array</h4> <p>If <code>replacer</code> is an array, the array's values indicate the names of the properties in the object that should be included in the resulting JSON string.</p> <pre data-language=\"js\">JSON.stringify(foo, ['week', 'month']);  \n// '{\"week\":45,\"month\":7}', only keep \"week\" and \"month\" properties\n</pre> <h3 id=\"The space argument\">The <code>space</code> argument</h3> <p>The <code>space</code> argument may be used to control spacing in the final string.</p> <ul> <li>\n<strong>If it is a number</strong>, successive levels in the stringification will each be indented by this many space characters (up to 10).</li> <li>\n<strong>If it is a string</strong>, successive levels will be indented by this string (or the first ten characters of it).</li> </ul> <pre data-language=\"js\">JSON.stringify({ a: 2 }, null, ' ');\n// '{\n//  \"a\": 2\n// }'\n</pre> <p>Using a tab character mimics standard pretty-print appearance:</p> <pre data-language=\"js\">JSON.stringify({ uno: 1, dos: 2 }, null, '\\t');\n// returns the string:\n// '{\n//     \"uno\": 1,\n//     \"dos\": 2\n// }'\n</pre> <h3 id=\"toJSON()_behavior\">\n<code>toJSON()</code> behavior</h3> <p>If an object being stringified has a property named <code>toJSON</code> whose value is a function, then the <code>toJSON()</code> method customizes JSON stringification behavior: instead of the object being serialized, the value returned by the <code>toJSON()</code> method when called will be serialized. <code>JSON.stringify()</code> calls <code>toJSON</code> with one parameter:</p> <ul> <li>if this object is a property value, the property name</li> <li>if it is in an array, the index in the array, as a string</li> <li>an empty string if <code>JSON.stringify()</code> was directly called on this object</li> </ul> <p>For example:</p> <pre data-language=\"js\">var obj = {\n    data: 'data',\n    \n    toJSON(key){\n        if(key)\n            return `Now I am a nested object under key '${key}'`;\n        \n        else\n            return this;\n    }\n};\n\nJSON.stringify(obj);\n// '{\"data\":\"data\"}'\n\nJSON.stringify({ obj })\n// '{\"obj\":\"Now I am a nested object under key 'obj'\"}'\n\nJSON.stringify([ obj ])\n// '[\"Now I am a nested object under key '0'\"]'\n</pre> <h3 id=\"Issue_with_JSON.stringify()_when_serializing_circular_references\">Issue with <code>JSON.stringify()</code> when serializing circular references</h3> <p>Note that since the <a href=\"https://www.json.org/\">JSON format</a> doesn't support object references (although an <a href=\"http://tools.ietf.org/html/draft-pbryan-zyp-json-ref-03\">IETF draft exists</a>), a <a href=\"../typeerror\"><code>TypeError</code></a> will be thrown if one attempts to encode an object with circular references.</p> <pre data-language=\"js\">const circularReference = {};\ncircularReference.myself = circularReference;\n\n// Serializing circular references throws \"TypeError: cyclic object value\"\nJSON.stringify(circularReference);\n</pre> <p>To serialize circular references you can use a library that supports them (e.g. <a href=\"https://github.com/douglascrockford/JSON-js/blob/master/cycle.js\">cycle.js</a> by Douglas Crockford) or implement a solution by yourself, which will require finding and replacing (or removing) the cyclic references by serializable values.</p> <h3 id=\"Issue_with_plain_JSON.stringify_for_use_as_JavaScript\">Issue with plain <code>JSON.stringify</code> for use as JavaScript</h3> <p>Note that JSON is <a href=\"http://timelessrepo.com/json-isnt-a-javascript-subset\">not a completely strict subset of JavaScript</a>, with two line terminators (Line separator and Paragraph separator) which do not require escaping in JSON, but do require escaping in JavaScript.</p> <p>Therefore, if the JSON is meant to be evaluated or directly utilized within <a href=\"https://en.wikipedia.org/wiki/JSONP\">JSONP</a>, the following utility can be used:</p> <pre data-language=\"js\">function jsFriendlyJSONStringify (s) {\n    return JSON.stringify(s).\n        replace(/\\u2028/g, '\\\\u2028').\n        replace(/\\u2029/g, '\\\\u2029');\n}\n\nvar s = {\n    a: String.fromCharCode(0x2028),\n    b: String.fromCharCode(0x2029)\n};\ntry {\n    eval('(' + JSON.stringify(s) + ')');\n} catch (e) {\n    console.log(e); // \"SyntaxError: unterminated string literal\"\n}\n\n// No need for a catch\neval('(' + jsFriendlyJSONStringify(s) + ')');\n\n// console.log in Firefox unescapes the Unicode if\n//   logged to console, so we use alert\nalert(jsFriendlyJSONStringify(s)); // {\"a\":\"\\u2028\",\"b\":\"\\u2029\"}\n</pre> <div class=\"blockIndicator note\"> <p><strong>Note</strong>: Properties of non-array objects are not guaranteed to be stringified in any particular order. Do not rely on ordering of properties within the same object within the stringification.</p> </div> <pre data-language=\"js\">var a = JSON.stringify({ foo: \"bar\", baz: \"quux\" })\n//'{\"foo\":\"bar\",\"baz\":\"quux\"}'\nvar b = JSON.stringify({ baz: \"quux\", foo: \"bar\" })\n//'{\"baz\":\"quux\",\"foo\":\"bar\"}'\nconsole.log(a !== b) // true\n\n// some memoization function use the JSON.stringify to serialize arguments,\n// which may missing the cache when encountering the same object like above\n</pre> <h3 id=\"Example_of_using_JSON.stringify()_with_localStorage\">Example of using <code>JSON.stringify()</code> with <code>localStorage</code>\n</h3> <p>In a case where you want to store an object created by your user and allowing it to be restored even after the browser has been closed, the following example is a model for the applicability of <code>JSON.stringify()</code>:</p> <pre data-language=\"js\">// Creating an example of JSON\nvar session = {\n  'screens': [],\n  'state': true\n};\nsession.screens.push({ 'name': 'screenA', 'width': 450, 'height': 250 });\nsession.screens.push({ 'name': 'screenB', 'width': 650, 'height': 350 });\nsession.screens.push({ 'name': 'screenC', 'width': 750, 'height': 120 });\nsession.screens.push({ 'name': 'screenD', 'width': 250, 'height': 60 });\nsession.screens.push({ 'name': 'screenE', 'width': 390, 'height': 120 });\nsession.screens.push({ 'name': 'screenF', 'width': 1240, 'height': 650 });\n\n// Converting the JSON string with JSON.stringify()\n// then saving with localStorage in the name of session\nlocalStorage.setItem('session', JSON.stringify(session));\n\n// Example of how to transform the String generated through \n// JSON.stringify() and saved in localStorage in JSON object again\nvar restoredSession = JSON.parse(localStorage.getItem('session'));\n\n// Now restoredSession variable contains the object that was saved\n// in localStorage\nconsole.log(restoredSession);\n</pre> <h3 id=\"Well-formed_JSON.stringify()\">Well-formed <code>JSON.stringify()</code>\n</h3> <p>Engines implementing the <a href=\"https://github.com/tc39/proposal-well-formed-stringify\">well-formed JSON.stringify specfication</a>, prevent returning ill-formed Unicode strings. Previously, <code>JSON.stringify</code> would output lone surrogates if the input contained any lone surrogates, which is invalid UTF-8:</p> <pre data-language=\"js\">JSON.stringify(\"\\uD800\"); // '\"�\"'</pre> <p>With this change, rather than return unpaired surrogate code points as single UTF-16 code units, <code>JSON.stringify</code> represents them with JSON escape sequences:</p> <pre data-language=\"js\">JSON.stringify(\"\\uD800\"); // \"\\ud800\"'</pre> <p>Unicode escape sequences are valid JSON and are well-formed in both UTF-16 and UTF-8.</p> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/5.1/#sec-15.12.3\" hreflang=\"en\">ECMAScript 5.1 (ECMA-262)<br><small>The definition of 'JSON.stringify' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition. Implemented in JavaScript 1.7.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-json.stringify\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'JSON.stringify' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-json.stringify\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'JSON.stringify' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>   <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 3.5</td>\n<td class=\"bc-supports-yes\"> 8</td>\n<td class=\"bc-supports-yes\"> 10.5</td>\n<td class=\"bc-supports-yes\"> 4</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div>  <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"parse\"><code>JSON.parse()</code></a></li> <li>\n<a href=\"https://github.com/douglascrockford/JSON-js/blob/master/cycle.js\">cycle.js</a> – Introduces two functions: <code>JSON.decycle</code> and <code>JSON.retrocycle</code>. These allow encoding and decoding of cyclical structures and DAGs into an extended and retrocompatible JSON format.</li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify</a>\n  </p>\n</div>\n","global_objects/datetimeformat/prototype":"<h1>Intl.DateTimeFormat.prototype</h1> <p>The <code>Intl.DateTimeFormat.prototype</code> property represents the prototype object for the <a href=\"../datetimeformat\"><code>Intl.DateTimeFormat</code></a> constructor.</p> <div class=\"_table\"><table class=\"standard-table\"> <thead> <tr> <th colspan=\"2\" class=\"header\">Property attributes of <code>Intl.DateTimeFormat.prototype</code>\n</th> </tr> </thead> <tbody> <tr> <td>Writable</td> <td>no</td> </tr> <tr> <td>Enumerable</td> <td>no</td> </tr> <tr> <td>Configurable</td> <td>no</td> </tr> </tbody> </table></div> <h2 id=\"Description\">Description</h2> <p>See <a href=\"../datetimeformat\"><code>DateTimeFormat</code></a> for a description of <code>Intl.DateTimeFormat</code> instances.</p> <p><a href=\"../datetimeformat\"><code>Intl.DateTimeFormat</code></a> instances inherit from <code>Intl.DateTimeFormat.prototype</code>. Modifications to the prototype object are inherited by all <a href=\"../datetimeformat\"><code>Intl.DateTimeFormat</code></a> instances.</p> <h2 id=\"Properties\">Properties</h2> <dl> <dt><code>Intl.DateTimeFormat.prototype.constructor</code></dt> <dd>A reference to <a href=\"../datetimeformat\"><code>Intl.DateTimeFormat</code></a>.</dd> <dt><a href=\"format\"><code>Intl.DateTimeFormat.prototype.format</code></a></dt> <dd>Getter; returns a function that formats a date according to the locale and formatting options of this <a href=\"../datetimeformat\"><code>DateTimeFormat</code></a> object.</dd> </dl> <h2 id=\"Methods\">Methods</h2> <dl> <dt><a href=\"formattoparts\"><code>Intl.DateTimeFormat.prototype.formatToParts()</code></a></dt> <dd>Returns an <a href=\"../array\"><code>Array</code></a> of objects representing the date string in parts that can be used for custom locale-aware formatting.</dd> <dt><a href=\"resolvedoptions\"><code>Intl.DateTimeFormat.prototype.resolvedOptions()</code></a></dt> <dd>Returns a new object with properties reflecting the locale and formatting options computed during initialization of the object.</dd> </dl> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-402/1.0/#sec-12.2.1\" hreflang=\"en\">ECMAScript Internationalization API 1.0 (ECMA-402)<br><small>The definition of 'Intl.DateTimeFormat.prototype' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-402/2.0/#sec-12.2.1\" hreflang=\"en\">ECMAScript Internationalization API 2.0 (ECMA-402)<br><small>The definition of 'Intl.DateTimeFormat.prototype' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma402/#sec-Intl.DateTimeFormat.prototype\" hreflang=\"en\">ECMAScript Internationalization API 4.0 (ECMA-402)<br><small>The definition of 'Intl.DateTimeFormat.prototype' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>   <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 24</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 29</td>\n<td class=\"bc-supports-yes\"> 11</td>\n<td class=\"bc-supports-yes\"> 15</td>\n<td class=\"bc-supports-yes\"> 10</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 26</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 56</td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 10</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td> ? </td>\n</tr></tbody>\n</table>\n</div>  <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"../datetimeformat\"><code>Intl.DateTimeFormat</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DateTimeFormat/prototype$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DateTimeFormat/prototype\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DateTimeFormat/prototype</a>\n  </p>\n</div>\n","global_objects/datetimeformat/resolvedoptions":"<h1>Intl.dateTimeFormat.resolvedOptions</h1> <p>The <code>Intl.DateTimeFormat.prototype.resolvedOptions()</code> method returns a new object with properties reflecting the locale and date and time formatting options computed during initialization of this <a href=\"../datetimeformat\"><code>DateTimeFormat</code></a> object.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/intl-datetimeformat-prototype-resolvedoptions.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\"><var>dateTimeFormat</var>.resolvedOptions()</pre> <h3 id=\"Return_value\">Return value</h3> <p>A new object with properties reflecting the locale and date and time formatting options computed during the initialization of the given <a href=\"../datetimeformat\"><code>DateTimeFormat</code></a> object.</p> <h2 id=\"Description\">Description</h2> <p>The resulting object has the following properties:</p> <dl> <dt><code>locale</code></dt> <dd>The BCP 47 language tag for the locale actually used. If any Unicode extension values were requested in the input BCP 47 language tag that led to this locale, the key-value pairs that were requested and are supported for this locale are included in <code>locale</code>.</dd> <dt><code>calendar</code></dt> <dt><code>numberingSystem</code></dt> <dd>The values requested using the Unicode extension keys <code>\"ca\"</code> and <code>\"nu\"</code> or filled in as default values.</dd> <dt><code>timeZone</code></dt> <dd>The value provided for this property in the <code>options</code> argument; <a href=\"../undefined\"><code>undefined</code></a> (representing the runtime's default time zone) if none was provided. Warning: Applications should not rely on <a href=\"../undefined\"><code>undefined</code></a> being returned, as future versions may return a <a href=\"../string\"><code>String</code></a> value identifying the runtime’s default time zone instead.</dd> <dt><code>hour12</code></dt> <dd>The value provided for this property in the <code>options</code> argument or filled in as a default.</dd> <dt><code>weekday</code></dt> <dt><code>era</code></dt> <dt><code>year</code></dt> <dt><code>month</code></dt> <dt><code>day</code></dt> <dt><code>hour</code></dt> <dt><code>minute</code></dt> <dt><code>second</code></dt> <dt><code>timeZoneName</code></dt> <dd>The values resulting from format matching between the corresponding properties in the <code>options</code> argument and the available combinations and representations for date-time formatting in the selected locale. Some of these properties may not be present, indicating that the corresponding components will not be represented in formatted output.</dd> </dl> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Using_the_resolvedOptions_method\">Using the <code>resolvedOptions</code> method</h3> <pre data-language=\"js\">var germanFakeRegion = new Intl.DateTimeFormat('de-XX', { timeZone: 'UTC' });\nvar usedOptions = germanFakeRegion.resolvedOptions();\n\nusedOptions.locale;          // \"de\"\nusedOptions.calendar;        // \"gregory\"\nusedOptions.numberingSystem; // \"latn\"\nusedOptions.timeZone;        // \"UTC\"\nusedOptions.month;           // \"numeric\"\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-402/1.0/#sec-12.3.3\" hreflang=\"en\">ECMAScript Internationalization API 1.0 (ECMA-402)<br><small>The definition of 'Intl.DateTimeFormat.prototype.resolvedOptions' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-402/2.0/#sec-Intl.DateTimeFormat.prototype.resolvedOptions\" hreflang=\"en\">ECMAScript Internationalization API 2.0 (ECMA-402)<br><small>The definition of 'Intl.DateTimeFormat.prototype.resolvedOptions' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma402/#sec-Intl.DateTimeFormat.prototype.resolvedOptions\" hreflang=\"en\">ECMAScript Internationalization API 4.0 (ECMA-402)<br><small>The definition of 'Intl.DateTimeFormat.prototype.resolvedOptions' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>   <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 24</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 29</td>\n<td class=\"bc-supports-yes\"> 11</td>\n<td class=\"bc-supports-yes\"> 15</td>\n<td class=\"bc-supports-yes\"> 10</td>\n</tr>\n<tr>\n<th scope=\"row\">computed <code>timeZone</code>\n</th>\n<td class=\"bc-supports-yes\"> 35</td>\n<td class=\"bc-supports-yes\"> 14</td>\n<td class=\"bc-supports-yes\"> 53</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 30</td>\n<td class=\"bc-supports-yes\"> 10</td>\n</tr>\n</tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 26</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 56</td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 10</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">computed <code>timeZone</code>\n</th>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 56</td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 10</td>\n<td> ? </td>\n</tr>\n</tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td> ? </td>\n</tr>\n<tr>\n<th scope=\"row\">computed <code>timeZone</code>\n</th>\n<td> ? </td>\n</tr>\n</tbody>\n</table>\n</div>  <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"../datetimeformat\"><code>Intl.DateTimeFormat</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DateTimeFormat/resolvedOptions$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DateTimeFormat/resolvedOptions\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DateTimeFormat/resolvedOptions</a>\n  </p>\n</div>\n","global_objects/date/tolocaletimestring":"<h1>date.toLocaleTimeString</h1> <p>The <code>toLocaleTimeString()</code> method returns a string with a language sensitive representation of the time portion of this date. The new <code>locales</code> and <code>options</code> arguments let applications specify the language whose formatting conventions should be used and customize the behavior of the function. In older implementations, which ignore the <code>locales</code> and <code>options</code> arguments, the locale used and the form of the string returned are entirely implementation dependent.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/date-tolocaletimestring.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\"><var>dateObj</var>.toLocaleTimeString([<var>locales</var>[, <var>options</var>]])</pre> <h3 id=\"Parameters\">Parameters</h3> <p>Check the <a href=\"#Browser_Compatibility\">Browser compatibility</a> section to see which browsers support the <code>locales</code> and <code>options</code> arguments, and <a href=\"#Checking_for_support_for_locales_and_options_arguments\">Checking for support for <code>locales</code> and <code>options</code> arguments</a> for feature detection.</p> <dl> <dt><code>locales</code></dt> <dd> <p>Optional. A string with a BCP 47 language tag, or an array of such strings. For the general form and interpretation of the <code>locales</code> argument, see the <a href=\"../intl#Locale_identification_and_negotiation\">Intl page</a>. The following Unicode extension keys are allowed:</p> <dl> <dt><code>nu</code></dt> <dd>Numbering system. Possible values include: <code>\"arab\"</code>, <code>\"arabext\"</code>, <code>\"bali\"</code>, <code>\"beng\"</code>, <code>\"deva\"</code>, <code>\"fullwide\"</code>, <code>\"gujr\"</code>, <code>\"guru\"</code>, <code>\"hanidec\"</code>, <code>\"khmr\"</code>, <code>\"knda\"</code>, <code>\"laoo\"</code>, <code>\"latn\"</code>, <code>\"limb\"</code>, <code>\"mlym\"</code>, <code>\"mong\"</code>, <code>\"mymr\"</code>, <code>\"orya\"</code>, <code>\"tamldec\"</code>, <code>\"telu\"</code>, <code>\"thai\"</code>, <code>\"tibt\"</code>.</dd> <dt><code>ca</code></dt> <dd>Calendar. Possible values include: <code>\"buddhist\"</code>, <code>\"chinese\"</code>, <code>\"coptic\"</code>, <code>\"ethioaa\"</code>, <code>\"ethiopic\"</code>, <code>\"gregory\"</code>, <code>\"hebrew\"</code>, <code>\"indian\"</code>, <code>\"islamic\"</code>, <code>\"islamicc\"</code>, <code>\"iso8601\"</code>, <code>\"japanese\"</code>, <code>\"persian\"</code>, <code>\"roc\"</code>.</dd> <dt><code>hc</code></dt> <dd>Hour cycle. Possible values include: <code>\"h11\"</code>, <code>\"h12\"</code>, <code>\"h23\"</code>, <code>\"h24\"</code>.</dd> </dl> </dd> <dt><code>options</code></dt> <dd> <p>Optional. An object with some or all of the following properties:</p> <dl> <dt><code>localeMatcher</code></dt> <dd>The locale matching algorithm to use. Possible values are <code>\"lookup\"</code> and <code>\"best fit\"</code>; the default is <code>\"best fit\"</code>. For information about this option, see the <a href=\"../intl#Locale_negotiation\">Intl page</a>.</dd> <dt><code>timeZone</code></dt> <dd>The time zone to use. The only value implementations must recognize is <code>\"UTC\"</code>; the default is the runtime's default time zone. Implementations may also recognize the time zone names of the <a href=\"https://www.iana.org/time-zones\">IANA time zone database</a>, such as <code>\"Asia/Shanghai\"</code>, <code>\"Asia/Kolkata\"</code>, <code>\"America/New_York\"</code>.</dd> <dt><code>hour12</code></dt> <dd>Whether to use 12-hour time (as opposed to 24-hour time). Possible values are <code>true</code> and <code>false</code>; the default is locale dependent. This option overrides the <code>hc</code> language tag and/or the <code>hourCycle</code> option in case both are present.</dd> <dt><code>hourCycle</code></dt> <dd>The hour cycle to use. Possible values are <code>\"h11\"</code>, <code>\"h12\"</code>, <code>\"h23\"</code>, or <code>\"h24\"</code>. This option overrides the <code>hc</code> language tag, if both are present, and the <code>hour12</code> option takes precedence in case both options have been specified.</dd> <dt><code>formatMatcher</code></dt> <dd>The format matching algorithm to use. Possible values are <code>\"basic\"</code> and <code>\"best fit\"</code>; the default is <code>\"best fit\"</code>. See the following paragraphs for information about the use of this property.</dd> </dl> <p>The following properties describe the date-time components to use in formatted output, and their desired representations. Implementations are required to support at least the following subsets:</p> <ul> <li>\n<code>weekday</code>, <code>year</code>, <code>month</code>, <code>day</code>, <code>hour</code>, <code>minute</code>, <code>second</code>\n</li> <li>\n<code>weekday</code>, <code>year</code>, <code>month</code>, <code>day</code>\n</li> <li>\n<code>year</code>, <code>month</code>, <code>day</code>\n</li> <li>\n<code>year</code>, <code>month</code>\n</li> <li>\n<code>month</code>, <code>day</code>\n</li> <li>\n<code>hour</code>, <code>minute</code>, <code>second</code>\n</li> <li>\n<code>hour</code>, <code>minute</code>\n</li> </ul> <p>Implementations may support other subsets, and requests will be negotiated against all available subset-representation combinations to find the best match. Two algorithms are available for this negotiation and selected by the <code>formatMatcher</code> property: A <a href=\"http://www.ecma-international.org/ecma-402/1.0/#BasicFormatMatcher\">fully specified <code>\"basic\"</code> algorithm</a> and an implementation-dependent <code>\"best fit\"</code> algorithm.</p> <dl> <dt><code>weekday</code></dt> <dd>The representation of the weekday. Possible values are <code>\"narrow\"</code>, <code>\"short\"</code>, <code>\"long\"</code>.</dd> <dt><code>era</code></dt> <dd>The representation of the era. Possible values are <code>\"narrow\"</code>, <code>\"short\"</code>, <code>\"long\"</code>.</dd> <dt><code>year</code></dt> <dd>The representation of the year. Possible values are <code>\"numeric\"</code>, <code>\"2-digit\"</code>.</dd> <dt><code>month</code></dt> <dd>The representation of the month. Possible values are <code>\"numeric\"</code>, <code>\"2-digit\"</code>, <code>\"narrow\"</code>, <code>\"short\"</code>, <code>\"long\"</code>.</dd> <dt><code>day</code></dt> <dd>The representation of the day. Possible values are <code>\"numeric\"</code>, <code>\"2-digit\"</code>.</dd> <dt><code>hour</code></dt> <dd>The representation of the hour. Possible values are <code>\"numeric\"</code>, <code>\"2-digit\"</code>.</dd> <dt><code>minute</code></dt> <dd>The representation of the minute. Possible values are <code>\"numeric\"</code>, <code>\"2-digit\"</code>.</dd> <dt><code>second</code></dt> <dd>The representation of the second. Possible values are <code>\"numeric\"</code>, <code>\"2-digit\"</code>.</dd> <dt><code>timeZoneName</code></dt> <dd>The representation of the time zone name. Possible values are <code>\"short\"</code>, <code>\"long\"</code>.</dd> </dl> </dd> </dl> <p>The default value for each date-time component property is <a href=\"../undefined\"><code>undefined</code></a>, but if the <code>hour</code>, <code>minute</code>, <code>second</code> properties are all <a href=\"../undefined\"><code>undefined</code></a>, then <code>hour</code>, <code>minute</code>, and <code>second</code> are assumed to be <code>\"numeric\"</code>.</p> <h3 id=\"Return_value\">Return value</h3> <p>A string representing the time portion of the given <a href=\"../date\"><code>Date</code></a> instance according to language-specific conventions.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Using_toLocaleTimeString()\">Using <code>toLocaleTimeString()</code>\n</h3> <p>In basic use without specifying a locale, a formatted string in the default locale and with default options is returned.</p> <pre data-language=\"js\">var date = new Date(Date.UTC(2012, 11, 12, 3, 0, 0));\n\n// toLocaleTimeString() without arguments depends on the implementation,\n// the default locale, and the default time zone\nconsole.log(date.toLocaleTimeString());\n// → \"7:00:00 PM\" if run in en-US locale with time zone America/Los_Angeles\n</pre> <h3 id=\"Checking_for_support_for_locales_and_options_arguments\">Checking for support for <code>locales</code> and <code>options</code> arguments</h3> <p>The <code>locales</code> and <code>options</code> arguments are not supported in all browsers yet. To check whether an implementation supports them already, you can use the requirement that illegal language tags are rejected with a <a href=\"../rangeerror\"><code>RangeError</code></a> exception:</p> <pre data-language=\"js\">function toLocaleTimeStringSupportsLocales() {\n  try {\n    new Date().toLocaleTimeString('i');\n  } catch (e) {\n    return e​.name === 'RangeError';\n  }\n  return false;\n}\n</pre> <h3 id=\"Using_locales\">Using <code>locales</code>\n</h3> <p>This example shows some of the variations in localized time formats. In order to get the format of the language used in the user interface of your application, make sure to specify that language (and possibly some fallback languages) using the <code>locales</code> argument:</p> <pre data-language=\"js\">var date = new Date(Date.UTC(2012, 11, 20, 3, 0, 0));\n\n// formats below assume the local time zone of the locale;\n// America/Los_Angeles for the US\n\n// US English uses 12-hour time with AM/PM\nconsole.log(date.toLocaleTimeString('en-US'));\n// → \"7:00:00 PM\"\n\n// British English uses 24-hour time without AM/PM\nconsole.log(date.toLocaleTimeString('en-GB'));\n// → \"03:00:00\"\n\n// Korean uses 12-hour time with AM/PM\nconsole.log(date.toLocaleTimeString('ko-KR'));\n// → \"오후 12:00:00\"\n\n// Arabic in most Arabic speaking countries uses real Arabic digits\nconsole.log(date.toLocaleTimeString('ar-EG'));\n// → \"<span dir=\"rtl\">٧:٠٠:٠٠ م</span>\"\n\n// when requesting a language that may not be supported, such as\n// Balinese, include a fallback language, in this case Indonesian\nconsole.log(date.toLocaleTimeString(['ban', 'id']));\n// → \"11.00.00\"\n</pre> <h3 id=\"Using_options\">Using <code>options</code>\n</h3> <p>The results provided by <code>toLocaleTimeString()</code> can be customized using the <code>options</code> argument:</p> <pre data-language=\"js\">var date = new Date(Date.UTC(2012, 11, 20, 3, 0, 0));\n\n// an application may want to use UTC and make that visible\nvar options = { timeZone: 'UTC', timeZoneName: 'short' };\nconsole.log(date.toLocaleTimeString('en-US', options));\n// → \"3:00:00 AM GMT\"\n\n// sometimes even the US needs 24-hour time\nconsole.log(date.toLocaleTimeString('en-US', { hour12: false }));\n// → \"19:00:00\"\n</pre> <h2 id=\"Performance\">Performance</h2> <p>When formatting large numbers of dates, it is better to create an <a href=\"../datetimeformat\"><code>Intl.DateTimeFormat</code></a> object and use the function provided by its <a href=\"../datetimeformat/format\"><code>format</code></a> property.</p> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/publications/files/ECMA-ST-ARCH/ECMA-262,%203rd%20edition,%20December%201999.pdf\" hreflang=\"en\">ECMAScript 3rd Edition (ECMA-262)</a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition. Implemented in JavaScript 1.0.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/5.1/#sec-15.9.5.7\" hreflang=\"en\">ECMAScript 5.1 (ECMA-262)<br><small>The definition of 'Date.prototype.toLocaleTimeString' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-date.prototype.tolocalestring\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Date.prototype.toLocaleTimeString' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-date.prototype.tolocalestring\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Date.prototype.toLocaleTimeString' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-402/1.0/#sec-13.3.3\" hreflang=\"en\">ECMAScript Internationalization API 1.0 (ECMA-402)<br><small>The definition of 'Date.prototype.toLocaleTimeString' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Defines <code>locales</code> and <code>options</code> arguments.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-402/2.0/#sec-13.3.3\" hreflang=\"en\">ECMAScript Internationalization API 2.0 (ECMA-402)<br><small>The definition of 'Date.prototype.toLocaleTimeString' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma402/#sec-Date.prototype.toLocaleTimeString\" hreflang=\"en\">ECMAScript Internationalization API 4.0 (ECMA-402)<br><small>The definition of 'Date.prototype.toLocaleTimeString' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><code>locales</code></th>\n<td class=\"bc-supports-yes\"> 24</td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 29</td>\n<td class=\"bc-supports-yes\"> 11</td>\n<td class=\"bc-supports-yes\"> 15</td>\n<td class=\"bc-supports-yes\"> 10</td>\n</tr>\n<tr>\n<th scope=\"row\"><code>options</code></th>\n<td class=\"bc-supports-yes\"> 24</td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 29</td>\n<td class=\"bc-supports-yes\"> 11</td>\n<td class=\"bc-supports-yes\"> 15</td>\n<td class=\"bc-supports-yes\"> 10</td>\n</tr>\n<tr>\n<th scope=\"row\">IANA time zone names in <code>timeZone</code> option</th>\n<td class=\"bc-supports-yes\"> 24</td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 52</td>\n<td> ? </td>\n<td> ? </td>\n<td> ? </td>\n</tr>\n</tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><code>locales</code></th>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 26</td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 56</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 10</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><code>options</code></th>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 26</td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 56</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 10</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">IANA time zone names in <code>timeZone</code> option</th>\n<td> ? </td>\n<td> ? </td>\n<td> ? </td>\n<td class=\"bc-supports-no\"> No</td>\n<td> ? </td>\n<td> ? </td>\n<td> ? </td>\n</tr>\n</tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td> ? </td>\n</tr>\n<tr>\n<th scope=\"row\"><code>locales</code></th>\n<td> ? </td>\n</tr>\n<tr>\n<th scope=\"row\"><code>options</code></th>\n<td> ? </td>\n</tr>\n<tr>\n<th scope=\"row\">IANA time zone names in <code>timeZone</code> option</th>\n<td> ? </td>\n</tr>\n</tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"../datetimeformat\"><code>Intl.DateTimeFormat</code></a></li> <li><a href=\"tolocaledatestring\"><code>Date.prototype.toLocaleDateString()</code></a></li> <li><a href=\"tolocalestring\"><code>Date.prototype.toLocaleString()</code></a></li> <li><a href=\"totimestring\"><code>Date.prototype.toTimeString()</code></a></li> <li><a href=\"tostring\"><code>Date.prototype.toString()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toLocaleTimeString$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toLocaleTimeString\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toLocaleTimeString</a>\n  </p>\n</div>\n","global_objects/pluralrules/select":"<h1>pluralRules.select</h1> <p>The <code>Intl.PluralRules.prototype.select</code> method returns a String indicating which plural rule to use for locale-aware formatting.</p> <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\"><var>pluralRule</var>.select(<var>number</var>)</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><code>number</code></dt> <dd>The number to get a plural rule for.</dd> </dl> <h2 id=\"Description\">Description</h2> <p>This function selects a plural rule according to the locale and formatting options of a <a href=\"../pluralrules\"><code>PluralRules</code></a> object.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Using_select\">Using <code>select</code>\n</h3> <pre data-language=\"js\"> new Intl.PluralRules('ar-EG').select(0); \n// → 'zero' \n\nnew Intl.PluralRules('ar-EG').select(1); \n// → 'one'\n\nnew Intl.PluralRules('ar-EG').select(2); \n// → 'two'\n\nnew Intl.PluralRules('ar-EG').select(6); \n// → 'few'\n\nnew Intl.PluralRules('ar-EG').select(18); \n// → 'many'\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://rawgit.com/caridy/intl-plural-rules-spec/master/index.html\">Intl Plural Rules Draft</a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td>Initial definition</td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>   <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 63</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 58</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 50</td>\n<td class=\"bc-supports-no\"> No</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 63</td>\n<td class=\"bc-supports-yes\"> 63</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 58</td>\n<td class=\"bc-supports-yes\"> 50</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-no\"> No</td>\n</tr></tbody>\n</table>\n</div>  <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"../pluralrules\"><code>Intl.PluralRules</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/PluralRules/select$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/PluralRules/select\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/PluralRules/select</a>\n  </p>\n</div>\n","global_objects/object/defineproperty":"<h1>Object.defineProperty</h1> <p>The static method <code><strong>Object.defineProperty()</strong></code> defines a new property directly on an object, or modifies an existing property on an object, and returns the object.</p> <div class=\"note\"> <p><strong>Note:</strong> You call this method directly on the <a href=\"../object\"><code>Object</code></a> constructor rather than on an instance of type <code>Object</code>.</p> </div> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/object-defineproperty.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\">Object.defineProperty(<var>obj</var>, <var>prop</var>, <var>descriptor</var>)</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><code>obj</code></dt> <dd>The object on which to define the property.</dd> <dt><code>prop</code></dt> <dd>The name or <a href=\"../symbol\"><code>Symbol</code></a> of the property to be defined or modified.</dd> <dt><code>descriptor</code></dt> <dd>The descriptor for the property being defined or modified.</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p>The object that was passed to the function.</p> <h2 id=\"Description\">Description</h2> <p>This method allows a precise addition to or modification of a property on an object. Normal property addition through assignment creates properties which show up during property enumeration (<a href=\"../../statements/for...in\"><code>for...in</code></a> loop or <a href=\"keys\"><code>Object.keys</code></a> method), whose values may be changed, and which may be <a href=\"../../operators/delete\">deleted</a>. This method allows these extra details to be changed from their defaults. By default, values added using <code>Object.defineProperty()</code> are immutable.</p> <p>Property descriptors present in objects come in two main flavors: data descriptors and accessor descriptors. A <em><dfn>data descriptor</dfn></em> is a property that has a value, which may or may not be writable. An <em><dfn>accessor descriptor</dfn></em> is a property described by a getter-setter pair of functions. A descriptor must be one of these two flavors; it cannot be both.</p> <p>Both data and accessor descriptors are objects. They share the following optional keys:</p> <dl> <dt><code>configurable</code></dt> <dd>\n<code>true</code> if and only if the type of this property descriptor may be changed and if the property may be deleted from the corresponding object.<br> <code>false</code>\n</dd> <dt><code>enumerable</code></dt> <dd>\n<code>true</code> if and only if this property shows up during enumeration of the properties on the corresponding object.<br> <code>false</code>\n</dd> </dl> <p>A data descriptor also has the following optional keys:</p> <dl> <dt><code>value</code></dt> <dd>The value associated with the property. Can be any valid JavaScript value (number, object, function, etc).<br> <strong>Defaults to <a href=\"../undefined\"><code>undefined</code></a>.</strong>\n</dd> <dt><code>writable</code></dt> <dd>\n<code>true</code> if and only if the value associated with the property may be changed with an <a href=\"../../operators/assignment_operators\">assignment operator</a>.<br> <code>false</code>\n</dd> </dl> <p>An accessor descriptor also has the following optional keys:</p> <dl> <dt><code>get</code></dt> <dd>A function which serves as a getter for the property, or <a href=\"../undefined\"><code>undefined</code></a> if there is no getter. When the property is accessed, this function is called without arguments and with <code>this</code> set to the object through which the property is accessed (this may not be the object on which the property is defined due to inheritance). The return value will be used as the value of the property.<br> <strong>Defaults to <a href=\"../undefined\"><code>undefined</code></a>.</strong>\n</dd> <dt><code>set</code></dt> <dd>A function which serves as a setter for the property, or <a href=\"../undefined\"><code>undefined</code></a> if there is no setter. When the property is assigned to, this function is called with one argument (the value being assigned to the property) and with <code>this</code> set to the object through which the property is assigned.<br> <strong>Defaults to <a href=\"../undefined\"><code>undefined</code></a>.</strong>\n</dd> </dl> <p>If a descriptor has neither of <code>value</code>, <code>writable</code>, <code>get</code> and <code>set</code> keys, it is treated as a data descriptor. If a descriptor has both <code>value</code> or <code>writable</code> and <code>get</code> or <code>set</code> keys, an exception is thrown.</p> <p>Bear in mind that these attributes are not necessarily the descriptor's own properties. Inherited properties will be considered as well. In order to ensure these defaults are preserved, you might freeze the <a href=\"prototype\"><code>Object.prototype</code></a> upfront, specify all options explicitly, or point to <a href=\"../null\"><code>null</code></a> with <a href=\"create\"><code>Object.create(null)</code></a>.</p> <pre data-language=\"js\">// using __proto__\nvar obj = {};\nvar descriptor = Object.create(null); // no inherited properties\n// not enumerable, not configurable, not writable as defaults\ndescriptor.value = 'static';\nObject.defineProperty(obj, 'key', descriptor);\n\n// being explicit\nObject.defineProperty(obj, 'key', {\n  enumerable: false,\n  configurable: false,\n  writable: false,\n  value: 'static'\n});\n\n// recycling same object\nfunction withValue(value) {\n  var d = withValue.d || (\n    withValue.d = {\n      enumerable: false,\n      writable: false,\n      configurable: false,\n      value: null\n    }\n  );\n  d.value = value;\n  return d;\n}\n// ... and ...\nObject.defineProperty(obj, 'key', withValue('static'));\n\n// if freeze is available, prevents adding or\n// removing the object prototype properties\n// (value, get, set, enumerable, writable, configurable)  \n(Object.freeze || Object)(Object.prototype);\n</pre> <h2 id=\"Examples\">Examples</h2> <p>If you want to see how to use the <code>Object.defineProperty</code> method with a <em>binary-flags-like</em> syntax, see <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/defineProperty/Additional_examples\">additional examples</a>.</p> <h3 id=\"Creating_a_property\">Creating a property</h3> <p>When the property specified doesn't exist in the object, <code>Object.defineProperty()</code> creates a new property as described. Fields may be omitted from the descriptor, and default values for those fields are inputted.</p> <pre data-language=\"js\">var o = {}; // Creates a new object\n\n// Example of an object property added\n// with defineProperty with a data property descriptor\nObject.defineProperty(o, 'a', {\n  value: 37,\n  writable: true,\n  enumerable: true,\n  configurable: true\n});\n// 'a' property exists in the o object and its value is 37\n\n// Example of an object property added\n// with defineProperty with an accessor property descriptor\nvar bValue = 38;\nObject.defineProperty(o, 'b', {\n  // Using shorthand method names (ES2015 feature).\n  // This is equivalent to:\n  // get: function() { return bValue; },\n  // set: function(newValue) { bValue = newValue; },\n  get() { return bValue; },\n  set(newValue) { bValue = newValue; },\n  enumerable: true,\n  configurable: true\n});\no.b; // 38\n// 'b' property exists in the o object and its value is 38\n// The value of o.b is now always identical to bValue,\n// unless o.b is redefined\n\n// You cannot try to mix both:\nObject.defineProperty(o, 'conflict', {\n  value: 0x9f91102,\n  get() { return 0xdeadbeef; }\n});\n// throws a TypeError: value appears\n// only in data descriptors,\n// get appears only in accessor descriptors\n</pre> <h3 id=\"Modifying_a_property\">Modifying a property</h3> <p>When the property already exists, <code>Object.defineProperty()</code> attempts to modify the property according to the values in the descriptor and the object's current configuration. If the old descriptor had its <code>configurable</code> attribute set to <code>false</code> the property is said to be “non-configurable”. It is not possible to change any attribute of a non-configurable accessor property. For data properties, it is possible to modify the value if the property is writable, and it is possible to change <code>writable</code> attribute from <code>true</code> to <code>false</code>. It is not possible to switch between data and accessor property types when the property is non-configurable.</p> <p>A <a href=\"../typeerror\"><code>TypeError</code></a> is thrown when attempts are made to change non-configurable property attributes (except <code>value</code> and <code>writable</code>, if permitted) unless the current and new values are the same.</p> <h4 id=\"Writable_attribute\">Writable attribute</h4> <p>When the <code>writable</code> property attribute is set to <code>false</code>, the property is said to be “non-writable”. It cannot be reassigned.</p> <pre data-language=\"js\">var o = {}; // Creates a new object\n\nObject.defineProperty(o, 'a', {\n  value: 37,\n  writable: false\n});\n\nconsole.log(o.a); // logs 37\no.a = 25; // No error thrown\n// (it would throw in strict mode,\n// even if the value had been the same)\nconsole.log(o.a); // logs 37. The assignment didn't work.\n\n// strict mode\n(function() {\n  'use strict';\n  var o = {};\n  Object.defineProperty(o, 'b', {\n    value: 2,\n    writable: false\n  });\n  o.b = 3; // throws TypeError: \"b\" is read-only\n  return o.b; // returns 2 without the line above\n}());\n</pre> <p>As seen in the example, trying to write into the non-writable property doesn't change it but doesn't throw an error either.</p> <h4 id=\"Enumerable_attribute\">Enumerable attribute</h4> <p>The <code>enumerable</code> property attribute defines whether the property is picked by <a href=\"assign\"><code>Object.assign()</code></a> or <a href=\"../../operators/spread_syntax\">spread </a>operator. For non-<a href=\"../symbol\"><code>Symbols</code></a> properties it also defines whether it shows up in a <a href=\"../../statements/for...in\"><code>for...in</code></a> loop and <a href=\"keys\"><code>Object.keys()</code></a> or not.</p> <pre data-language=\"js\">var o = {};\nObject.defineProperty(o, 'a', {\n  value: 1,\n  enumerable: true\n});\nObject.defineProperty(o, 'b', {\n  value: 2,\n  enumerable: false\n});\nObject.defineProperty(o, 'c', {\n  value: 3\n}); // enumerable defaults to false\no.d = 4; // enumerable defaults to true\n         // when creating a property by setting it\nObject.defineProperty(o, Symbol.for('e'), {\n  value: 5,\n  enumerable: true\n});\nObject.defineProperty(o, Symbol.for('f'), {\n  value: 6,\n  enumerable: false\n});\n\nfor (var i in o) {\n  console.log(i);\n}\n// logs 'a' and 'd' (in undefined order)\n\nObject.keys(o); // ['a', 'd']\n\no.propertyIsEnumerable('a'); // true\no.propertyIsEnumerable('b'); // false\no.propertyIsEnumerable('c'); // false\no.propertyIsEnumerable('d'); // true\no.propertyIsEnumerable(Symbol.for('e')); // true\no.propertyIsEnumerable(Symbol.for('f')); // false\n\nvar p = { ...o }\np.a // 1\np.b // undefined\np.c // undefined\np.d // 4\np[Symbol.for('e')] // 5\np[Symbol.for('f')] // undefined\n</pre> <h4 id=\"Configurable_attribute\">Configurable attribute</h4> <p>The <code>configurable</code> attribute controls at the same time whether the property can be deleted from the object and whether its attributes (other than <code>value</code> and <code>writable</code>) can be changed.</p> <pre data-language=\"js\">var o = {};\nObject.defineProperty(o, 'a', {\n  get() { return 1; },\n  configurable: false\n});\n\nObject.defineProperty(o, 'a', {\n  configurable: true\n}); // throws a TypeError\nObject.defineProperty(o, 'a', {\n  enumerable: true\n}); // throws a TypeError\nObject.defineProperty(o, 'a', {\n  set() {}\n}); // throws a TypeError (set was undefined previously)\nObject.defineProperty(o, 'a', {\n  get() { return 1; }\n}); // throws a TypeError\n// (even though the new get does exactly the same thing)\nObject.defineProperty(o, 'a', {\n  value: 12\n}); // throws a TypeError\n\nconsole.log(o.a); // logs 1\ndelete o.a; // Nothing happens\nconsole.log(o.a); // logs 1\n</pre> <p>If the <code>configurable</code> attribute of <code>o.a</code> had been <code>true</code>, none of the errors would be thrown and the property would be deleted at the end.</p> <h3 id=\"Adding_properties_and_default_values\">Adding properties and default values</h3> <p>It is important to consider the way default values of attributes are applied. There is often a difference between simply using dot notation to assign a value and using <code>Object.defineProperty()</code>, as shown in the example below.</p> <pre data-language=\"js\">var o = {};\n\no.a = 1;\n// is equivalent to:\nObject.defineProperty(o, 'a', {\n  value: 1,\n  writable: true,\n  configurable: true,\n  enumerable: true\n});\n\n// On the other hand,\nObject.defineProperty(o, 'a', { value: 1 });\n// is equivalent to:\nObject.defineProperty(o, 'a', {\n  value: 1,\n  writable: false,\n  configurable: false,\n  enumerable: false\n});\n</pre> <h3 id=\"Custom_Setters_and_Getters\">Custom Setters and Getters</h3> <p>The example below shows how to implement a self-archiving object. When <code>temperature</code> property is set, the <code>archive</code> array gets a log entry.</p> <pre data-language=\"js\">function Archiver() {\n  var temperature = null;\n  var archive = [];\n\n  Object.defineProperty(this, 'temperature', {\n    get() {\n      console.log('get!');\n      return temperature;\n    },\n    set(value) {\n      temperature = value;\n      archive.push({ val: temperature });\n    }\n  });\n\n  this.getArchive = function() { return archive; };\n}\n\nvar arc = new Archiver();\narc.temperature; // 'get!'\narc.temperature = 11;\narc.temperature = 13;\narc.getArchive(); // [{ val: 11 }, { val: 13 }]\n</pre> <p>In this example, a getter always returns the same value.</p> <pre data-language=\"js\">var pattern = {\n    get() {\n        return 'I always return this string, ' +\n               'whatever you have assigned';\n    },\n    set() {\n        this.myname = 'this is my name string';\n    }\n};\n\nfunction TestDefineSetAndGet() {\n    Object.defineProperty(this, 'myproperty', pattern);\n}\n\nvar instance = new TestDefineSetAndGet();\ninstance.myproperty = 'test';\nconsole.log(instance.myproperty);\n// I always return this string, whatever you have assigned\n\nconsole.log(instance.myname); // this is my name string\n</pre> <h3 id=\"Inheritance_of_properties\">Inheritance of properties</h3> <p>If an accessor property is inherited, its <code>get</code> and <code>set</code> methods will be called when the property is accessed and modified on descendant objects. If these methods use a variable to store the value, this value will be shared by all objects.</p> <pre data-language=\"js\">function myclass() {\n}\n\nvar value;\nObject.defineProperty(myclass.prototype, \"x\", {\n  get() {\n    return value;\n  },\n  set(x) {\n    value = x;\n  }\n});\n\nvar a = new myclass();\nvar b = new myclass();\na.x = 1;\nconsole.log(b.x); // 1\n</pre> <p>This can be fixed by storing the value in another property. In <code>get</code> and <code>set</code> methods, <code>this</code> points to the object which is used to access or modify the property.</p> <pre data-language=\"js\">function myclass() {\n}\n\nObject.defineProperty(myclass.prototype, \"x\", {\n  get() {\n    return this.stored_x;\n  },\n  set(x) {\n    this.stored_x = x;\n  }\n});\n\nvar a = new myclass();\nvar b = new myclass();\na.x = 1;\nconsole.log(b.x); // undefined\n</pre> <p>Unlike accessor properties, value properties are always set on the object itself, not on a prototype. However, if a non-writable value property is inherited, it still prevents from modifying the property on the object.</p> <pre data-language=\"js\">function myclass() {\n}\n\nmyclass.prototype.x = 1;\nObject.defineProperty(myclass.prototype, \"y\", {\n  writable: false,\n  value: 1\n});\n\nvar a = new myclass();\na.x = 2;\nconsole.log(a.x); // 2\nconsole.log(myclass.prototype.x); // 1\na.y = 2; // Ignored, throws in strict mode\nconsole.log(a.y); // 1\nconsole.log(myclass.prototype.y); // 1\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <thead> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> </thead> <tbody> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/5.1/#sec-15.2.3.6\" hreflang=\"en\">ECMAScript 5.1 (ECMA-262)<br><small>The definition of 'Object.defineProperty' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition. Implemented in JavaScript 1.8.5.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-object.defineproperty\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Object.defineProperty' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-object.defineproperty\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Object.defineProperty' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 5</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes bc-has-history\"> 9\n<section class=\"bc-history\" id=\"sect1\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 9\n</dt>\n<dd> Also supported in Internet Explorer 8, but only on DOM objects and with some non-standard behaviors.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-yes\"> 11.6</td>\n<td class=\"bc-supports-yes bc-has-history\"> 5.1\n<section class=\"bc-history\" id=\"sect2\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 5.1\n</dt>\n<dd> Also supported in Safari 5, but not on DOM objects.</dd>\n</dl></section>\n</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> 11.5</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"Compatibility_notes\">Compatibility notes</h2> <h3 id=\"Redefining_the_length_property_of_an_Array_object\">Redefining the <code>length</code> property of an <code>Array</code> object</h3> <p>It is possible to redefine the <a href=\"../array/length\"><code>length</code></a> property of arrays, subject to the usual redefinition restrictions. (The <a href=\"../array/length\"><code>length</code></a> property is initially non-configurable, non-enumerable, and writable. Thus on an unaltered array, it's possible to change the <a href=\"../array/length\"><code>length</code></a> property's value or to make it non-writable. It is not allowed to change its enumerability or configurability, or if it is non-writable to change its value or writability.) However, not all browsers permit this redefinition.</p> <p>Firefox 4 through 22 will throw a <a href=\"../typeerror\"><code>TypeError</code></a> on any attempt whatsoever (whether permitted or not) to redefine the <a href=\"../array/length\"><code>length</code></a> property of an array.</p> <p>Versions of Chrome which implement <code>Object.defineProperty()</code> in some circumstances ignore a length value different from the array's current <a href=\"../array/length\"><code>length</code></a> property. In some circumstances changing writability seems to silently not work (and not throw an exception). Also, relatedly, some array-mutating methods like <a href=\"../array/push\"><code>Array.prototype.push</code></a> don't respect a non-writable length.</p> <p>Versions of Safari which implement <code>Object.defineProperty()</code> ignore a <code>length</code> value different from the array's current <a href=\"../array/length\"><code>length</code></a> property, and attempts to change writability execute without error but do not actually change the property's writability.</p> <p>Only Internet Explorer 9 and later, and Firefox 23 and later, appear to fully and correctly implement redefinition of the <a href=\"../array/length\"><code>length</code></a> property of arrays. For now, don't rely on redefining the <a href=\"../array/length\"><code>length</code></a> property of an array to either work, or to work in a particular manner. And even when you <em>can</em> rely on it, <a href=\"http://whereswalden.com/2013/08/05/new-in-firefox-23-the-length-property-of-an-array-can-be-made-non-writable-but-you-shouldnt-do-it/\">there's really no good reason to do so</a>.</p> <h3 id=\"Internet_Explorer_8_specific_notes\">Internet Explorer 8 specific notes</h3> <p>Internet Explorer 8 implemented a <code>Object.defineProperty()</code> method that could <a href=\"https://msdn.microsoft.com/en-us/library/dd229916%28VS.85%29.aspx\">only be used on DOM objects</a>. A few things need to be noted:</p> <ul> <li>Trying to use <code>Object.defineProperty()</code> on native objects throws an error.</li> <li>Property attributes must be set to some values. The <code>configurable</code>, <code>enumerable</code> and <code>writable</code> attributes should all be set to <code>true</code> for data descriptor and <code>true</code> for <code>configurable</code>, <code>false</code> for <code>enumerable</code> for accessor descriptor.(?) Any attempt to provide other value(?) will result in an error being thrown.</li> <li>Reconfiguring a property requires first deleting the property. If the property isn't deleted, it stays as it was before the reconfiguration attempt.</li> </ul> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"https://developer.mozilla.org/en-US/docs/Enumerability_and_ownership_of_properties\">Enumerability and ownership of properties</a></li> <li><a href=\"defineproperties\"><code>Object.defineProperties()</code></a></li> <li><a href=\"propertyisenumerable\"><code>Object.propertyIsEnumerable()</code></a></li> <li><a href=\"getownpropertydescriptor\"><code>Object.getOwnPropertyDescriptor()</code></a></li> <li><a href=\"watch\"><code>Object.prototype.watch()</code></a></li> <li><a href=\"unwatch\"><code>Object.prototype.unwatch()</code></a></li> <li><a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/get\"><code>get</code></a></li> <li><a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/set\"><code>set</code></a></li> <li><a href=\"create\"><code>Object.create()</code></a></li> <li><a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/defineProperty/Additional_examples\">Additional <code>Object.defineProperty</code> examples</a></li> <li><a href=\"../reflect/defineproperty\"><code>Reflect.defineProperty()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/defineProperty$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/defineProperty\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/defineProperty</a>\n  </p>\n</div>\n","global_objects/date/tojson":"<h1>date.toJSON</h1> <p>The <code>toJSON()</code> method returns a string representation of the <a href=\"../date\"><code>Date</code></a> object.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/date-tojson.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\"><var>dateObj</var>.toJSON()</pre> <h3 id=\"Return_value\">Return value</h3> <p>A string representation of the given date.</p> <h2 id=\"Description\">Description</h2> <p><a href=\"../date\"><code>Date</code></a> instances refer to a specific point in time. Calling <code>toJSON()</code> returns a string (using <a href=\"toisostring\"><code>toISOString()</code></a>) representing the <a href=\"../date\"><code>Date</code></a> object's value. This method is generally intended to, by default, usefully serialize <a href=\"../date\"><code>Date</code></a> objects during <a href=\"https://developer.mozilla.org/en-US/docs/Glossary/JSON\">JSON</a> serialization.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Using_toJSON()\">Using <code>toJSON()</code>\n</h3> <pre data-language=\"js\">var jsonDate = (new Date()).toJSON();\nvar backToDate = new Date(jsonDate);\n\nconsole.log(jsonDate); //2015-10-26T07:46:36.611Z\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/5.1/#sec-15.9.5.44\" hreflang=\"en\">ECMAScript 5.1 (ECMA-262)<br><small>The definition of 'Date.prototype.toJSON' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition. Implemented in JavaScript 1.8.5.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-date.prototype.tojson\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Date.prototype.toJSON' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-date.prototype.tojson\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Date.prototype.toJSON' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> 8</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"tolocaledatestring\"><code>Date.prototype.toLocaleDateString()</code></a></li> <li><a href=\"totimestring\"><code>Date.prototype.toTimeString()</code></a></li> <li><a href=\"toutcstring\"><code>Date.prototype.toUTCString()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toJSON$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toJSON\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toJSON</a>\n  </p>\n</div>\n","global_objects/datetimeformat/formattoparts":"<h1>Intl.dateTimeFormat.formatToParts</h1> <div class=\"blockIndicator experimental indicator-warning\"> <p> <strong>This is an <a href=\"https://developer.mozilla.org/en-US/docs/MDN/Contribute/Guidelines/Conventions_definitions#Experimental\">experimental technology</a></strong><br>Check the <a href=\"#Browser_compatibility\">Browser compatibility table</a> carefully before using this in production.</p> </div> <p>The <code>Intl.DateTimeFormat.prototype.formatToParts()</code> method allows locale-aware formatting of strings produced by <code>DateTimeFormat</code> formatters.</p> <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\">Intl.DateTimeFormat.prototype.formatToParts(date)</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt>\n<code>date</code> <span class=\"inlineIndicator optional optionalInline\">Optional</span>\n</dt> <dd>The date to format.</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p>An <a href=\"../array\"><code>Array</code></a> of objects containing the formatted date in parts.</p> <h2 id=\"Description\">Description</h2> <p>The <code>formatToParts()</code> method is useful for custom formatting of date strings. It returns an <a href=\"../array\"><code>Array</code></a> of objects containing the locale-specific tokens from which it possible to build custom strings while preserving the locale-specific parts. The structure the <code>formatToParts()</code> method returns, looks like this:</p> <pre data-language=\"js\">[\n  { type: 'day', value: '17' },\n  { type: 'weekday', value: 'Monday' }\n]</pre> <p>Possible types are the following:</p> <dl> <dt>day</dt> <dd>The string used for the day, for example <code>\"17\"</code>.</dd> <dt>dayPeriod</dt> <dd>The string used for the day period, for example, <code>\"AM\"</code> or <code>\"PM\"</code>.</dd> <dt>era</dt> <dd>The string used for the era, for example <code>\"BC\"</code> or <code>\"AD\"</code>.</dd> <dt>hour</dt> <dd>The string used for the hour, for example <code>\"3\"</code> or <code>\"03\"</code>.</dd> <dt>literal</dt> <dd>The string used for separating date and time values, for example <code>\"/\"</code>, <code>\",\"</code>, <code>\"o'clock\"</code>, <code>\"de\"</code>, etc.</dd> <dt>minute</dt> <dd>The string used for the minute, for example <code>\"00\"</code>.</dd> <dt>month</dt> <dd>The string used for the month, for example <code>\"12\"</code>.</dd> <dt>second</dt> <dd>The string used for the second, for example <code>\"07\"</code> or <code>\"42\"</code>.</dd> <dt>timeZoneName</dt> <dd>The string used for the name of the time zone, for example <code>\"UTC\"</code>.</dd> <dt>weekday</dt> <dd>The string used for the weekday, for example <code>\"M\"</code>, <code>\"Monday\"</code>, or <code>\"Montag\"</code>.</dd> <dt>year</dt> <dd>The string used for the year, for example <code>\"2012\"</code> or <code>\"96\"</code>.</dd> </dl> <h2 id=\"Examples\">Examples</h2> <p><code>DateTimeFormat</code> outputs localized, opaque strings that cannot be manipulated directly:</p> <pre data-language=\"js\">var date = Date.UTC(2012, 11, 17, 3, 0, 42);\n\nvar formatter = new Intl.DateTimeFormat('en-us', {\n  weekday: 'long',\n  year: 'numeric',\n  month: 'numeric',\n  day: 'numeric',\n  hour: 'numeric',\n  minute: 'numeric',\n  second: 'numeric',\n  hour12: true,\n  timeZone: 'UTC'\n});\n\nformatter.format(date);\n// \"Monday, 12/17/2012, 3:00:42 AM\"\n</pre> <p>However, in many User Interfaces there is a desire to customize the formatting of this string. The <code>formatToParts</code> method enables locale-aware formatting of strings produced by <code>DateTimeFormat</code> formatters by providing you the string in parts:</p> <pre data-language=\"js\">formatter.formatToParts(date);\n\n// return value: \n[ \n  { type: 'weekday',   value: 'Monday' }, \n  { type: 'literal',   value: ', '     }, \n  { type: 'month',     value: '12'     }, \n  { type: 'literal',   value: '/'      }, \n  { type: 'day',       value: '17'     }, \n  { type: 'literal',   value: '/'      }, \n  { type: 'year',      value: '2012'   }, \n  { type: 'literal',   value: ', '     }, \n  { type: 'hour',      value: '3'      }, \n  { type: 'literal',   value: ':'      }, \n  { type: 'minute',    value: '00'     }, \n  { type: 'literal',   value: ':'      }, \n  { type: 'second',    value: '42'     }, \n  { type: 'literal',   value: ' '      }, \n  { type: 'dayPeriod', value: 'AM'     } \n]\n</pre> <p>Now the information is available separately and it can be formatted and concatenated again in a customized way. For example by using <a href=\"../array/map\"><code>Array.prototype.map()</code></a>, <a href=\"../../functions/arrow_functions\">arrow functions</a>, a <a href=\"../../statements/switch\">switch statement</a>, <a href=\"../../template_literals\">template literals</a>, and <a href=\"../array/reduce\"><code>Array.prototype.reduce()</code></a>.</p> <pre data-language=\"js\">var dateString = formatter.formatToParts(date).map(({type, value}) =&gt; { \n  switch (type) {\n    case 'dayPeriod': return `&lt;b&gt;${value}&lt;/b&gt;`; \n    default : return value; \n  } \n}).reduce((string, part) =&gt; string + part);\n</pre> <p>This will make the day period bold, when using the <code>formatToParts()</code> method.</p> <pre data-language=\"js\">console.log(formatter.format(date));\n// \"Monday, 12/17/2012, 3:00:42 AM\"\n\nconsole.log(dateString);\n// \"Monday, 12/17/2012, 3:00:42 &lt;b&gt;AM&lt;/b&gt;\"</pre> <h2 id=\"Polyfill\">Polyfill</h2> <p>A polyfill for this feature is available in the <a href=\"https://github.com/zbraniecki/proposal-intl-formatToParts\">proposal repository</a>.</p> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma402/#sec-Intl.DateTimeFormat.prototype.formatToParts\" hreflang=\"en\">ECMAScript Internationalization API 4.0 (ECMA-402)<br><small>The definition of 'Intl.DateTimeFormat.prototype.formatToParts' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td>Initial definition</td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>   <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes bc-has-history\"> 57\n<section class=\"bc-history\" id=\"sect1\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 57\n</dt>\n\n<dt class=\"bc-supports-no bc-supports\">55 — 60<div class=\"bc-icons\">Disabled </div>\n</dt>\n<dd>Disabled From version 55 until version 60 (exclusive): this feature is behind the <code>--datetime-format-to-parts</code> runtime flag.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 51</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 11</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 57</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 56</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 11</td>\n<td class=\"bc-supports-yes\"> 7.0</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div>  <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"../datetimeformat\"><code>Intl.DateTimeFormat</code></a></li> <li><a href=\"format\"><code>Intl.DateTimeFormat.prototype.format</code></a></li> <li><a href=\"../date/tolocalestring\"><code>Date.prototype.toLocaleString()</code></a></li> <li><a href=\"../date/tolocaledatestring\"><code>Date.prototype.toLocaleDateString()</code></a></li> <li><a href=\"../date/tolocaletimestring\"><code>Date.prototype.toLocaleTimeString()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DateTimeFormat/formatToParts$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DateTimeFormat/formatToParts\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DateTimeFormat/formatToParts</a>\n  </p>\n</div>\n","global_objects/pluralrules/supportedlocalesof":"<h1>PluralRules.supportedLocalesOf</h1> <p>The <code>Intl.PluralRules.supportedLocalesOf()</code> method returns an array containing those of the provided locales that are supported in plural formatting without having to fall back to the runtime's default locale.</p> <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\">Intl.PluralRules.supportedLocalesOf(<var>locales</var>[, <var>options</var>])</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><code>locales</code></dt> <dd>A string with a BCP 47 language tag, or an array of such strings. For the general form of the <code>locales</code> argument, see the <a href=\"../intl#Locale_identification_and_negotiation\">Intl page</a>.</dd> <dt><code>options</code></dt> <dd> <p>Optional. An object that may have the following property:</p> <dl> <dt><code>localeMatcher</code></dt> <dd>The locale matching algorithm to use. Possible values are <code>\"lookup\"</code> and <code>\"best fit\"</code>; the default is <code>\"best fit\"</code>. For information about this option, see the <a href=\"../intl#Locale_negotiation\">Intl page</a>.</dd> </dl> </dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p>An array of strings representing a subset of the given locale tags that are supported in plural formatting without having to fall back to the runtime's default locale.</p> <h2 id=\"Description\">Description</h2> <p>Returns an array with a subset of the language tags provided in <code>locales</code>. The language tags returned are those for which the runtime supports a locale in plural formatting that the locale matching algorithm used considers a match, so that it wouldn't have to fall back to the default locale.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Using_supportedLocalesOf\">Using <code>supportedLocalesOf</code>\n</h3> <p>Assuming a runtime that supports Indonesian and German but not Balinese in plural formatting, <code>supportedLocalesOf</code> returns the Indonesian and German language tags unchanged, even though <code>pinyin</code> collation is neither relevant to plural formatting nor used with Indonesian, and a specialized German for Indonesia is unlikely to be supported. Note the specification of the <code>\"lookup\"</code> algorithm here — a <code>\"best fit\"</code> matcher might decide that Indonesian is an adequate match for Balinese since most Balinese speakers also understand Indonesian, and therefore return the Balinese language tag as well.</p> <pre data-language=\"js\">var locales = ['ban', 'id-u-co-pinyin', 'de-ID'];\nvar options = { localeMatcher: 'lookup' };\nconsole.log(Intl.PluralRules.supportedLocalesOf(locales, options).join(', '));\n// → \"id-u-co-pinyin, de-ID\"\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://rawgit.com/caridy/intl-plural-rules-spec/master/index.html\">Intl Plural Rules Draft</a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td>Initial definition</td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>   <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 63</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 58</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 50</td>\n<td class=\"bc-supports-no\"> No</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 63</td>\n<td class=\"bc-supports-yes\"> 63</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 58</td>\n<td class=\"bc-supports-yes\"> 50</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-no\"> No</td>\n</tr></tbody>\n</table>\n</div>  <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"../pluralrules\"><code>Intl.PluralRules</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/PluralRules/supportedLocalesOf$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/PluralRules/supportedLocalesOf\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/PluralRules/supportedLocalesOf</a>\n  </p>\n</div>\n","global_objects/number/toexponential":"<h1>number.toExponential</h1> <p>The <code>toExponential()</code> method returns a string representing the Number object in exponential notation.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/number-toexponential.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\"><var>numObj</var>.toExponential([<var>fractionDigits</var>])</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><code>fractionDigits</code></dt> <dd>Optional. An integer specifying the number of digits after the decimal point. Defaults to as many digits as necessary to specify the number.</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p>A string representing the given <a href=\"../number\"><code>Number</code></a> object in exponential notation with one digit before the decimal point, rounded to <code>fractionDigits</code> digits after the decimal point.</p> <h3 id=\"Exceptions\">Exceptions</h3> <dl> <dt><a href=\"../rangeerror\"><code>RangeError</code></a></dt> <dd>If <code>fractionDigits</code> is too small or too large. Values between 0 and 20, inclusive, will not cause a <a href=\"../rangeerror\"><code>RangeError</code></a>. Implementations are allowed to support larger and smaller values as well.</dd> <dt><a href=\"../typeerror\"><code>TypeError</code></a></dt> <dd>If this method is invoked on an object that is not a <a href=\"../number\"><code>Number</code></a>.</dd> </dl> <h2 id=\"Description\">Description</h2> <p>If the <code>fractionDigits</code> argument is omitted, the number of digits after the decimal point defaults to the number of digits necessary to represent the value uniquely.</p> <p>If you use the <code>toExponential()</code> method for a numeric literal and the numeric literal has no exponent and no decimal point, leave whitespace(s) before the dot that precedes the method call to prevent the dot from being interpreted as a decimal point.</p> <p>If a number has more digits than requested by the <code>fractionDigits</code> parameter, the number is rounded to the nearest number represented by <code>fractionDigits</code> digits. See the discussion of rounding in the description of the <a href=\"tofixed\"><code>toFixed()</code></a> method, which also applies to <code>toExponential()</code>.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Using_toExponential\">Using <code>toExponential</code>\n</h3> <pre data-language=\"js\">var numObj = 77.1234;\n\nconsole.log(numObj.toExponential());  // logs 7.71234e+1\nconsole.log(numObj.toExponential(4)); // logs 7.7123e+1\nconsole.log(numObj.toExponential(2)); // logs 7.71e+1\nconsole.log(77.1234.toExponential()); // logs 7.71234e+1\nconsole.log(77 .toExponential());     // logs 7.7e+1\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/publications/files/ECMA-ST-ARCH/ECMA-262,%203rd%20edition,%20December%201999.pdf\" hreflang=\"en\">ECMAScript 3rd Edition (ECMA-262)</a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition. Implemented in JavaScript 1.5.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/5.1/#sec-15.7.4.6\" hreflang=\"en\">ECMAScript 5.1 (ECMA-262)<br><small>The definition of 'Number.prototype.toExponential' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-number.prototype.toexponential\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Number.prototype.toExponential' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-number.prototype.toexponential\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Number.prototype.toExponential' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"tofixed\"><code>Number.prototype.toFixed()</code></a></li> <li><a href=\"toprecision\"><code>Number.prototype.toPrecision()</code></a></li> <li><a href=\"tostring\"><code>Number.prototype.toString()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toExponential$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toExponential\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toExponential</a>\n  </p>\n</div>\n","global_objects/number/tofixed":"<h1>number.toFixed</h1> <p>The <code>toFixed()</code> method formats a number using fixed-point notation.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/number-tofixed.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\"><var>numObj</var>.toFixed([<var>digits</var>])</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><code>digits</code></dt> <dd>Optional. The number of digits to appear after the decimal point; this may be a value between 0 and 20, inclusive, and implementations may optionally support a larger range of values. If this argument is omitted, it is treated as 0.</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p>A string representing the given number using fixed-point notation.</p> <h3 id=\"Exceptions\">Exceptions</h3> <dl> <dt><a href=\"../rangeerror\"><code>RangeError</code></a></dt> <dd>If <code>digits</code> is too small or too large. Values between 0 and 100, inclusive, will not cause a <a href=\"../rangeerror\"><code>RangeError</code></a>. Implementations are allowed to support larger and smaller values as chosen.</dd> <dt><a href=\"../typeerror\"><code>TypeError</code></a></dt> <dd>If this method is invoked on an object that is not a <a href=\"../number\"><code>Number</code></a>.</dd> </dl> <h2 id=\"Description\">Description</h2> <p><code>toFixed()</code> returns a string representation of <code>numObj</code> that does not use exponential notation and has exactly <code>digits</code> digits after the decimal place. The number is rounded if necessary, and the fractional part is padded with zeros if necessary so that it has the specified length. If <code>numObj</code> is greater than <code>1e+21</code>, this method simply calls <a href=\"tostring\"><code>Number.prototype.toString()</code></a> and returns a string in exponential notation.</p> <div class=\"warning\"> <p>Floating point numbers cannot represent all decimals precisely in binary which can lead to unexpected results such as <code>0.1 + 0.2 === 0.3</code> returning <code>false</code> .</p> </div> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Using_toFixed\">Using <code>toFixed</code>\n</h3> <pre data-language=\"js\">var numObj = 12345.6789;\n\nnumObj.toFixed();       // Returns '12346': note rounding, no fractional part\nnumObj.toFixed(1);      // Returns '12345.7': note rounding\nnumObj.toFixed(6);      // Returns '12345.678900': note added zeros\n(1.23e+20).toFixed(2);  // Returns '123000000000000000000.00'\n(1.23e-10).toFixed(2);  // Returns '0.00'\n2.34.toFixed(1);        // Returns '2.3'\n2.35.toFixed(1);        // Returns '2.4'. Note it rounds up\n2.55.toFixed(1);        // Returns '2.5'. Note it rounds down - see warning above\n-2.34.toFixed(1);       // Returns -2.3 (due to operator precedence, negative number literals don't return a string...)\n(-2.34).toFixed(1);     // Returns '-2.3' (...unless you use parentheses)\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/publications/files/ECMA-ST-ARCH/ECMA-262,%203rd%20edition,%20December%201999.pdf\" hreflang=\"en\">ECMAScript 3rd Edition (ECMA-262)</a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition. Implemented in JavaScript 1.5.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/5.1/#sec-15.7.4.5\" hreflang=\"en\">ECMAScript 5.1 (ECMA-262)<br><small>The definition of 'Number.prototype.toFixed' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-number.prototype.tofixed\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Number.prototype.toFixed' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-number.prototype.tofixed\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Number.prototype.toFixed' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"toexponential\"><code>Number.prototype.toExponential()</code></a></li> <li><a href=\"toprecision\"><code>Number.prototype.toPrecision()</code></a></li> <li><a href=\"tostring\"><code>Number.prototype.toString()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toFixed$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toFixed\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toFixed</a>\n  </p>\n</div>\n","global_objects/rangeerror/prototype":"<h1>RangeError.prototype</h1> <p>The <code><strong>RangeError.prototype</strong></code> property represents the prototype the <a href=\"../rangeerror\"><code>RangeError</code></a> constructor.</p> <div class=\"_table\"><table class=\"standard-table\"> <thead> <tr> <th colspan=\"2\" class=\"header\">Property attributes of <code>RangeError.prototype</code>\n</th> </tr> </thead> <tbody> <tr> <td>Writable</td> <td>no</td> </tr> <tr> <td>Enumerable</td> <td>no</td> </tr> <tr> <td>Configurable</td> <td>no</td> </tr> </tbody> </table></div> <h2 id=\"Description\">Description</h2> <p>All <a href=\"../rangeerror\"><code>RangeError</code></a> instances inherit from <code>RangeError.prototype</code>. You can use the prototype to add properties or methods to all instances.</p> <h2 id=\"Properties\">Properties</h2> <dl> <dt><code>RangeError.prototype.constructor</code></dt> <dd>Specifies the function that created an instance's prototype.</dd> <dt><a href=\"../error/message\"><code>RangeError.prototype.message</code></a></dt> <dd>Error message. Although ECMA-262 specifies that <a href=\"../rangeerror\"><code>RangeError</code></a> should provide its own <code>message</code> property, in <a href=\"https://developer.mozilla.org/en-US/docs/Mozilla/Projects/SpiderMonkey\">SpiderMonkey</a>, it inherits <a href=\"../error/message\"><code>Error.prototype.message</code></a>.</dd> <dt><a href=\"../error/name\"><code>RangeError.prototype.name</code></a></dt> <dd>Error name. Inherited from <a href=\"../error\"><code>Error</code></a>.</dd> <dt><a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/fileName\"><code>RangeError.prototype.fileName</code></a></dt> <dd>Path to file that raised this error. Inherited from <a href=\"../error\"><code>Error</code></a>.</dd> <dt><a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/lineNumber\"><code>RangeError.prototype.lineNumber</code></a></dt> <dd>Line number in file that raised this error. Inherited from <a href=\"../error\"><code>Error</code></a>.</dd> <dt><a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/columnNumber\"><code>RangeError.prototype.columnNumber</code></a></dt> <dd>Column number in line that raised this error. Inherited from <a href=\"../error\"><code>Error</code></a>.</dd> <dt><a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/stack\"><code>RangeError.prototype.stack</code></a></dt> <dd>Stack trace. Inherited from <a href=\"../error\"><code>Error</code></a>.</dd> </dl> <h2 id=\"Methods\">Methods</h2> <p>Although the <a href=\"../rangeerror\"><code>RangeError</code></a> prototype object does not contain any methods of its own, <a href=\"../rangeerror\"><code>RangeError</code></a> instances do inherit some methods through the prototype chain.</p> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/publications/files/ECMA-ST-ARCH/ECMA-262,%203rd%20edition,%20December%201999.pdf\" hreflang=\"en\">ECMAScript 3rd Edition (ECMA-262)</a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/5.1/#sec-15.11.7.6\" hreflang=\"en\">ECMAScript 5.1 (ECMA-262)<br><small>The definition of 'NativeError.prototype' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Defined as <code><em>NativeError</em>.prototype</code>.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-nativeerror.prototype\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'NativeError.prototype' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Defined as <code><em>NativeError</em>.prototype</code>.</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-nativeerror.prototype\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'NativeError.prototype' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td>Defined as <code><em>NativeError</em>.prototype</code>.</td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>   <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/RangeError\">Basic support</a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/RangeError\">Basic support</a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/RangeError\">Basic support</a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div>  <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"../error/prototype\"><code>Error.prototype</code></a></li> <li><a href=\"../function/prototype\"><code>Function.prototype</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RangeError/prototype$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RangeError/prototype\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RangeError/prototype</a>\n  </p>\n</div>\n","global_objects/date/tolocaledatestring":"<h1>date.toLocaleDateString</h1> <p>The <code>toLocaleDateString()</code> method returns a string with a language sensitive representation of the date portion of this date. The new <code>locales</code> and <code>options</code> arguments let applications specify the language whose formatting conventions should be used and allow to customize the behavior of the function. In older implementations, which ignore the <code>locales</code> and <code>options</code> arguments, the locale used and the form of the string returned are entirely implementation dependent.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/date-tolocaledatestring.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\"><var>dateObj</var>.toLocaleDateString([<var>locales</var> [, <var>options</var>]])</pre> <h3 id=\"Parameters\">Parameters</h3> <p>Check the <a href=\"#Browser_compatibility\">Browser compatibility</a> section to see which browsers support the <code>locales</code> and <code>options</code> arguments, and the Example: <a href=\"#Checking_for_support_for_locales_and_options_arguments\">Checking for support for locales and options arguments</a> for feature detection.</p> <dl> <dt><code>locales</code></dt> <dd> <p>Optional. A string with a BCP 47 language tag, or an array of such strings. For the general form and interpretation of the <code>locales</code> argument, see the <a href=\"../intl#Locale_identification_and_negotiation\">Intl page</a>. The following Unicode extension keys are allowed:</p> <dl> <dt><code>nu</code></dt> <dd>Numbering system. Possible values include: <code>\"arab\"</code>, <code>\"arabext\"</code>, <code>\"bali\"</code>, <code>\"beng\"</code>, <code>\"deva\"</code>, <code>\"fullwide\"</code>, <code>\"gujr\"</code>, <code>\"guru\"</code>, <code>\"hanidec\"</code>, <code>\"khmr\"</code>, <code>\"knda\"</code>, <code>\"laoo\"</code>, <code>\"latn\"</code>, <code>\"limb\"</code>, <code>\"mlym\"</code>, <code>\"mong\"</code>, <code>\"mymr\"</code>, <code>\"orya\"</code>, <code>\"tamldec\"</code>, <code>\"telu\"</code>, <code>\"thai\"</code>, <code>\"tibt\"</code>.</dd> <dt><code>ca</code></dt> <dd>Calendar. Possible values include: <code>\"buddhist\"</code>, <code>\"chinese\"</code>, <code>\"coptic\"</code>, <code>\"ethioaa\"</code>, <code>\"ethiopic\"</code>, <code>\"gregory\"</code>, <code>\"hebrew\"</code>, <code>\"indian\"</code>, <code>\"islamic\"</code>, <code>\"islamicc\"</code>, <code>\"iso8601\"</code>, <code>\"japanese\"</code>, <code>\"persian\"</code>, <code>\"roc\"</code>.</dd> <dt><code>hc</code></dt> <dd>Hour cycle. Possible values include: <code>\"h11\"</code>, <code>\"h12\"</code>, <code>\"h23\"</code>, <code>\"h24\"</code>.</dd> </dl> </dd> <dt><code>options</code></dt> <dd> <p>Optional. An object with some or all of the following properties:</p> <dl> <dt><code>localeMatcher</code></dt> <dd>The locale matching algorithm to use. Possible values are <code>\"lookup\"</code> and <code>\"best fit\"</code>; the default is <code>\"best fit\"</code>. For information about this option, see the <a href=\"../intl#Locale_negotiation\">Intl page</a>.</dd> <dt><code>timeZone</code></dt> <dd>The time zone to use. The only value implementations must recognize is <code>\"UTC\"</code>; the default is the runtime's default time zone. Implementations may also recognize the time zone names of the <a href=\"https://www.iana.org/time-zones\">IANA time zone database</a>, such as <code>\"Asia/Shanghai\"</code>, <code>\"Asia/Kolkata\"</code>, <code>\"America/New_York\"</code>.</dd> <dt><code>hour12</code></dt> <dd>Whether to use 12-hour time (as opposed to 24-hour time). Possible values are <code>true</code> and <code>false</code>; the default is locale dependent. This option overrides the <code>hc</code> language tag and/or the <code>hourCycle</code> option in case both are present.</dd> <dt><code>hourCycle</code></dt> <dd>The hour cycle to use. Possible values are <code>\"h11\"</code>, <code>\"h12\"</code>, <code>\"h23\"</code>, or <code>\"h24\"</code>. This option overrides the <code>hc</code> language tag, if both are present, and the <code>hour12</code> option takes precedence in case both options have been specified.</dd> <dt><code>formatMatcher</code></dt> <dd>The format matching algorithm to use. Possible values are <code>\"basic\"</code> and <code>\"best fit\"</code>; the default is <code>\"best fit\"</code>. See the following paragraphs for information about the use of this property.</dd> </dl> <p>The following properties describe the date-time components to use in formatted output, and their desired representations. Implementations are required to support at least the following subsets:</p> <ul> <li>\n<code>weekday</code>, <code>year</code>, <code>month</code>, <code>day</code>, <code>hour</code>, <code>minute</code>, <code>second</code>\n</li> <li>\n<code>weekday</code>, <code>year</code>, <code>month</code>, <code>day</code>\n</li> <li>\n<code>year</code>, <code>month</code>, <code>day</code>\n</li> <li>\n<code>year</code>, <code>month</code>\n</li> <li>\n<code>month</code>, <code>day</code>\n</li> <li>\n<code>hour</code>, <code>minute</code>, <code>second</code>\n</li> <li>\n<code>hour</code>, <code>minute</code>\n</li> </ul> <p>Implementations may support other subsets, and requests will be negotiated against all available subset-representation combinations to find the best match. Two algorithms are available for this negotiation and selected by the <code>formatMatcher</code> property: A <a href=\"http://www.ecma-international.org/ecma-402/1.0/#BasicFormatMatcher\">fully specified <code>\"basic\"</code> algorithm</a> and an implementation-dependent <code>\"best fit\"</code> algorithm.</p> <dl> <dt><code>weekday</code></dt> <dd>The representation of the weekday. Possible values are <code>\"narrow\"</code>, <code>\"short\"</code>, <code>\"long\"</code>.</dd> <dt><code>era</code></dt> <dd>The representation of the era. Possible values are <code>\"narrow\"</code>, <code>\"short\"</code>, <code>\"long\"</code>.</dd> <dt><code>year</code></dt> <dd>The representation of the year. Possible values are <code>\"numeric\"</code>, <code>\"2-digit\"</code>.</dd> <dt><code>month</code></dt> <dd>The representation of the month. Possible values are <code>\"numeric\"</code>, <code>\"2-digit\"</code>, <code>\"narrow\"</code>, <code>\"short\"</code>, <code>\"long\"</code>.</dd> <dt><code>day</code></dt> <dd>The representation of the day. Possible values are <code>\"numeric\"</code>, <code>\"2-digit\"</code>.</dd> <dt><code>hour</code></dt> <dd>The representation of the hour. Possible values are <code>\"numeric\"</code>, <code>\"2-digit\"</code>.</dd> <dt><code>minute</code></dt> <dd>The representation of the minute. Possible values are <code>\"numeric\"</code>, <code>\"2-digit\"</code>.</dd> <dt><code>second</code></dt> <dd>The representation of the second. Possible values are <code>\"numeric\"</code>, <code>\"2-digit\"</code>.</dd> <dt><code>timeZoneName</code></dt> <dd>The representation of the time zone name. Possible values are <code>\"short\"</code>, <code>\"long\"</code>.</dd> </dl> </dd> </dl> <p>The default value for each date-time component property is <a href=\"../undefined\"><code>undefined</code></a>, but if the <code>weekday</code>, <code>year</code>, <code>month</code>, <code>day</code> properties are all <a href=\"../undefined\"><code>undefined</code></a>, then <code>year</code>, <code>month</code>, and <code>day</code> are assumed to be <code>\"numeric\"</code>.</p> <h3 id=\"Return_value\">Return value</h3> <p>A string representing the date portion of the given <a href=\"../date\"><code>Date</code></a> instance according to language-specific conventions.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Using_toLocaleDateString()\">Using <code>toLocaleDateString()</code>\n</h3> <p>In basic use without specifying a locale, a formatted string in the default locale and with default options is returned.</p> <pre data-language=\"js\">var date = new Date(Date.UTC(2012, 11, 12, 3, 0, 0));\n\n// toLocaleDateString() without arguments depends on the implementation,\n// the default locale, and the default time zone\nconsole.log(date.toLocaleDateString());\n// → \"12/11/2012\" if run in en-US locale with time zone America/Los_Angeles\n</pre> <h3 id=\"Checking_for_support_for_locales_and_options_arguments\">Checking for support for <code>locales</code> and <code>options</code> arguments</h3> <p>The <code>locales</code> and <code>options</code> arguments are not supported in all browsers yet. To check whether an implementation supports them already, you can use the requirement that illegal language tags are rejected with a <a href=\"../rangeerror\"><code>RangeError</code></a> exception:</p> <pre data-language=\"js\">function toLocaleDateStringSupportsLocales() {\n  try {\n    new Date().toLocaleDateString('i');\n  } catch (e) {\n    return e.name === 'RangeError';\n  }\n  return false;\n}\n</pre> <h3 id=\"Using_locales\">Using <code>locales</code>\n</h3> <p>This example shows some of the variations in localized date formats. In order to get the format of the language used in the user interface of your application, make sure to specify that language (and possibly some fallback languages) using the <code>locales</code> argument:</p> <pre data-language=\"js\">var date = new Date(Date.UTC(2012, 11, 20, 3, 0, 0));\n\n// formats below assume the local time zone of the locale;\n// America/Los_Angeles for the US\n\n// US English uses month-day-year order\nconsole.log(date.toLocaleDateString('en-US'));\n// → \"12/19/2012\"\n\n// British English uses day-month-year order\nconsole.log(date.toLocaleDateString('en-GB'));\n// → \"20/12/2012\"\n\n// Korean uses year-month-day order\nconsole.log(date.toLocaleDateString('ko-KR'));\n// → \"2012. 12. 20.\"\n\n// Event for Persian, It's hard to manually convert date to Solar Hijri\nconsole.log(date.toLocaleDateString('fa-IR'));\n// → \"۱۳۹۱/۹/۳۰\"\n\n// Arabic in most Arabic speaking countries uses real Arabic digits\nconsole.log(date.toLocaleDateString('ar-EG'));\n// → \"<span dir=\"rtl\">٢٠‏/١٢‏/٢٠١٢</span>\"\n\n// for Japanese, applications may want to use the Japanese calendar,\n// where 2012 was the year 24 of the Heisei era\nconsole.log(date.toLocaleDateString('ja-JP-u-ca-japanese'));\n// → \"24/12/20\"\n\n// when requesting a language that may not be supported, such as\n// Balinese, include a fallback language, in this case Indonesian\nconsole.log(date.toLocaleDateString(['ban', 'id']));\n// → \"20/12/2012\"\n</pre> <h3 id=\"Using_options\">Using <code>options</code>\n</h3> <p>The results provided by <code>toLocaleDateString()</code> can be customized using the <code>options</code> argument:</p> <pre data-language=\"js\">var date = new Date(Date.UTC(2012, 11, 20, 3, 0, 0));\n\n// request a weekday along with a long date\nvar options = { weekday: 'long', year: 'numeric', month: 'long', day: 'numeric' };\nconsole.log(date.toLocaleDateString('de-DE', options));\n// → \"Donnerstag, 20. Dezember 2012\"\n\n// an application may want to use UTC and make that visible\noptions.timeZone = 'UTC';\noptions.timeZoneName = 'short';\nconsole.log(date.toLocaleDateString('en-US', options));\n// → \"Thursday, December 20, 2012, GMT\"\n</pre> <h2 id=\"Performance\">Performance</h2> <p>When formatting large numbers of dates, it is better to create an <a href=\"../datetimeformat\"><code>Intl.DateTimeFormat</code></a> object and use the function provided by its <a href=\"../datetimeformat/format\"><code>format</code></a> property.</p> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/publications/files/ECMA-ST-ARCH/ECMA-262,%203rd%20edition,%20December%201999.pdf\" hreflang=\"en\">ECMAScript 3rd Edition (ECMA-262)</a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition. Implemented in JavaScript 1.0.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/5.1/sec-15.9.5.6\" hreflang=\"en\">ECMAScript 5.1 (ECMA-262)<br><small>The definition of 'Date.prototype.toLocaleDateString' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-date.prototype.tolocaledatestring\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Date.prototype.toLocaleDateString' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-date.prototype.tolocaledatestring\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Date.prototype.toLocaleDateString' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-402/1.0/#sec-13.3.2\" hreflang=\"en\">ECMAScript Internationalization API 1.0 (ECMA-402)<br><small>The definition of 'Date.prototype.toLocaleDateString' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Defines <code>locales</code> and <code>options</code> arguments.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-402/2.0/#sec-13.3.2\" hreflang=\"en\">ECMAScript Internationalization API 2.0 (ECMA-402)<br><small>The definition of 'Date.prototype.toLocaleDateString' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma402/#sec-Date.prototype.toLocaleDateString\" hreflang=\"en\">ECMAScript Internationalization API 4.0 (ECMA-402)<br><small>The definition of 'Date.prototype.toLocaleDateString' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><code>locales</code></th>\n<td class=\"bc-supports-yes\"> 24</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 29</td>\n<td class=\"bc-supports-yes\"> 11</td>\n<td class=\"bc-supports-yes\"> 15</td>\n<td class=\"bc-supports-yes\"> 10</td>\n</tr>\n<tr>\n<th scope=\"row\"><code>options</code></th>\n<td class=\"bc-supports-yes\"> 24</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 29</td>\n<td class=\"bc-supports-yes\"> 11</td>\n<td class=\"bc-supports-yes\"> 15</td>\n<td class=\"bc-supports-yes\"> 10</td>\n</tr>\n<tr>\n<th scope=\"row\">IANA time zone names in <code>timeZone</code> option</th>\n<td class=\"bc-supports-yes\"> 24</td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 52</td>\n<td> ? </td>\n<td> ? </td>\n<td> ? </td>\n</tr>\n</tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><code>locales</code></th>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 26</td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 56</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 10</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><code>options</code></th>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 26</td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 56</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 10</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">IANA time zone names in <code>timeZone</code> option</th>\n<td> ? </td>\n<td> ? </td>\n<td> ? </td>\n<td class=\"bc-supports-no\"> No</td>\n<td> ? </td>\n<td> ? </td>\n<td> ? </td>\n</tr>\n</tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td> ? </td>\n</tr>\n<tr>\n<th scope=\"row\"><code>locales</code></th>\n<td> ? </td>\n</tr>\n<tr>\n<th scope=\"row\"><code>options</code></th>\n<td> ? </td>\n</tr>\n<tr>\n<th scope=\"row\">IANA time zone names in <code>timeZone</code> option</th>\n<td> ? </td>\n</tr>\n</tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"../datetimeformat\"><code>Intl.DateTimeFormat</code></a></li> <li><a href=\"tolocalestring\"><code>Date.prototype.toLocaleString()</code></a></li> <li><a href=\"tolocaletimestring\"><code>Date.prototype.toLocaleTimeString()</code></a></li> <li><a href=\"tostring\"><code>Date.prototype.toString()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toLocaleDateString$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toLocaleDateString\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toLocaleDateString</a>\n  </p>\n</div>\n","global_objects/pluralrules/resolvedoptions":"<h1>pluralRules.resolvedOptions</h1> <p>The <code>Intl.PluralRules.prototype.resolvedOptions()</code> method returns a new object with properties reflecting the locale and plural formatting options computed during initialization of this <a href=\"../pluralrules\"><code>PluralRules</code></a> object.</p> <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\"><var>pluralRule</var>.resolvedOptions()</pre> <h3 id=\"Return_value\">Return value</h3> <p>A new object with properties reflecting the locale and plural formatting options computed during the initialization of the given <a href=\"../pluralrules\"><code>PluralRules</code></a> object.</p> <h2 id=\"Description\">Description</h2> <p>The resulting object has the following properties:</p> <dl> <dt><code>locale</code></dt> <dd>The BCP 47 language tag for the locale actually used. If any Unicode extension values were requested in the input BCP 47 language tag that led to this locale, the key-value pairs that were requested and are supported for this locale are included in <code>locale</code>.</dd> <dt><code>pluralCategories</code></dt> <dd>An <a href=\"../array\"><code>Array</code></a> of plural rules used by the given language.</dd> <dt><code>type</code></dt> <dd>The type used (<code>cardinal</code> or <code>ordinal</code>).</dd> </dl> <p>Only one of the following two groups of properties is included:</p> <dl> <dt><code>minimumIntegerDigits</code></dt> <dt><code>minimumFractionDigits</code></dt> <dt><code>maximumFractionDigits</code></dt> <dd>The values provided for these properties in the <code>options</code> argument or filled in as defaults. These properties are present only if neither <code>minimumSignificantDigits</code> nor <code>maximumSignificantDigits</code> was provided in the <code>options</code> argument.</dd> <dt><code>minimumSignificantDigits</code></dt> <dt><code>maximumSignificantDigits</code></dt> <dd>The values provided for these properties in the <code>options</code> argument or filled in as defaults. These properties are present only if at least one of them was provided in the <code>options</code> argument.</dd> </dl> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Using_the_resolvedOptions_method\">Using the <code>resolvedOptions</code> method</h3> <pre data-language=\"js\">var de = new Intl.PluralRules('de-DE');\nvar usedOptions = de.resolvedOptions();\n\nusedOptions.locale;                // \"de-DE\"\nusedOptions.maximumFractionDigits; // 3\nusedOptions.minimumFractionDigits; // 0\nusedOptions.minimumIntegerDigits;  // 1\nusedOptions.pluralCategories;      // Array [ \"one\", \"other\" ]\nusedOptions.type;                  // \"cardinal\"\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://rawgit.com/caridy/intl-plural-rules-spec/master/index.html\">Intl Plural Rules Draft</a></td> <td>Draft</td> <td>Initial definition</td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>   <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 63</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 58</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 50</td>\n<td class=\"bc-supports-no\"> No</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 63</td>\n<td class=\"bc-supports-yes\"> 63</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 58</td>\n<td class=\"bc-supports-yes\"> 50</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-no\"> No</td>\n</tr></tbody>\n</table>\n</div>  <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"../pluralrules\"><code>Intl.PluralRules</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/PluralRules/resolvedOptions$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/PluralRules/resolvedOptions\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/PluralRules/resolvedOptions</a>\n  </p>\n</div>\n","global_objects/number/toprecision":"<h1>number.toPrecision</h1> <p>The <code>toPrecision()</code> method returns a string representing the <a href=\"../number\"><code>Number</code></a> object to the specified precision.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/number-toprecision.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe> <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\"><var>numObj</var>.toPrecision([<var>precision</var>])</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><code>precision</code></dt> <dd>Optional. An integer specifying the number of significant digits.</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p>A string representing a <a href=\"../number\"><code>Number</code></a> object in fixed-point or exponential notation rounded to <code>precision</code> significant digits. See the discussion of rounding in the description of the <a href=\"tofixed\"><code>Number.prototype.toFixed()</code></a> method, which also applies to <code>toPrecision()</code>.</p> <p>If the <code>precision</code> argument is omitted, behaves as <a href=\"tostring\"><code>Number.prototype.toString()</code></a>. If the <code>precision</code> argument is a non-integer value, it is rounded to the nearest integer.</p> <h3 id=\"Exceptions\">Exceptions</h3> <dl> <dt><a href=\"../rangeerror\"><code>RangeError</code></a></dt> <dd>If <code>precision</code> is not between 1 and 100 (inclusive), a <a href=\"../rangeerror\"><code>RangeError</code></a> is thrown. Implementations are allowed to support larger and smaller values as well. ECMA-262 only requires a precision of up to 21 significant digits.</dd> </dl> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Using_toPrecision\">Using <code>toPrecision</code>\n</h3> <pre data-language=\"js\">var numObj = 5.123456;\n\nconsole.log(numObj.toPrecision());    // logs '5.123456'\nconsole.log(numObj.toPrecision(5));   // logs '5.1235'\nconsole.log(numObj.toPrecision(2));   // logs '5.1'\nconsole.log(numObj.toPrecision(1));   // logs '5'\n\nnumObj = 0.000123\n\nconsole.log(numObj.toPrecision());    // logs '0.000123'\nconsole.log(numObj.toPrecision(5));   // logs '0.00012300'\nconsole.log(numObj.toPrecision(2));   // logs '0.00012'\nconsole.log(numObj.toPrecision(1));   // logs '0.0001' \n\n// note that exponential notation might be returned in some circumstances\nconsole.log((1234.5).toPrecision(2)); // logs '1.2e+3'\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/publications/files/ECMA-ST-ARCH/ECMA-262,%203rd%20edition,%20December%201999.pdf\" hreflang=\"en\">ECMAScript 3rd Edition (ECMA-262)</a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition. Implemented in JavaScript 1.5.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/5.1/#sec-15.7.4.7\" hreflang=\"en\">ECMAScript 5.1 (ECMA-262)<br><small>The definition of 'Number.prototype.toPrecision' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-number.prototype.toprecision\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Number.prototype.toPrecision' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-number.prototype.toprecision\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Number.prototype.toPrecision' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"tofixed\"><code>Number.prototype.toFixed()</code></a></li> <li><a href=\"toexponential\"><code>Number.prototype.toExponential()</code></a></li> <li><a href=\"tostring\"><code>Number.prototype.toString()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toPrecision$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toPrecision\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toPrecision</a>\n  </p>\n</div>\n","global_objects/dataview/prototype":"<h1>DataView.prototype</h1> <p>The <code><strong>DataView</strong></code><code>.prototype</code> property represents the prototype for the <a href=\"../dataview\"><code>DataView</code></a> object.</p> <div class=\"_table\"><table class=\"standard-table\"> <thead> <tr> <th colspan=\"2\" class=\"header\">Property attributes of <code>DataView.prototype</code>\n</th> </tr> </thead> <tbody> <tr> <td>Writable</td> <td>no</td> </tr> <tr> <td>Enumerable</td> <td>no</td> </tr> <tr> <td>Configurable</td> <td>no</td> </tr> </tbody> </table></div> <h2 id=\"Description\">Description</h2> <p><code>DataView</code> instances inherit from <code>DataView.prototype</code>. As with all constructors, you can change the constructor's prototype object to make changes to all <code>DataView</code> instances.</p> <h2 id=\"Properties\">Properties</h2> <dl> <dt><code>DataView.prototype.constructor</code></dt> <dd>Specifies the function that creates an object's prototype. The initial value is the standard built-in <code>DataView</code> constructor.</dd> <dt>\n<a href=\"buffer\"><code>DataView.prototype.buffer</code></a> <span class=\"inlineIndicator readOnly readOnlyInline\">Read only </span>\n</dt> <dd>The <a href=\"../arraybuffer\"><code>ArrayBuffer</code></a> referenced by this view. Fixed at construction time and thus <strong>read only.</strong>\n</dd> <dt>\n<a href=\"bytelength\"><code>DataView.prototype.byteLength</code></a> <span class=\"inlineIndicator readOnly readOnlyInline\">Read only </span>\n</dt> <dd>The length (in bytes) of this view from the start of its <a href=\"../arraybuffer\"><code>ArrayBuffer</code></a>. Fixed at construction time and thus <strong>read only.</strong>\n</dd> <dt>\n<a href=\"byteoffset\"><code>DataView.prototype.byteOffset</code></a> <span class=\"inlineIndicator readOnly readOnlyInline\">Read only </span>\n</dt> <dd>The offset (in bytes) of this view from the start of its <a href=\"../arraybuffer\"><code>ArrayBuffer</code></a>. Fixed at construction time and thus <strong>read only.</strong>\n</dd> </dl> <h2 id=\"Methods\">Methods</h2> <h3 id=\"Read\">Read</h3> <dl> <dt><a href=\"getint8\"><code>DataView.prototype.getInt8()</code></a></dt> <dd>Gets a signed 8-bit integer (byte) at the specified byte offset from the start of the view.</dd> <dt><a href=\"getuint8\"><code>DataView.prototype.getUint8()</code></a></dt> <dd>Gets an unsigned 8-bit integer (unsigned byte) at the specified byte offset from the start of the view.</dd> <dt><a href=\"getint16\"><code>DataView.prototype.getInt16()</code></a></dt> <dd>Gets a signed 16-bit integer (short) at the specified byte offset from the start of the view.</dd> <dt><a href=\"getuint16\"><code>DataView.prototype.getUint16()</code></a></dt> <dd>Gets an unsigned 16-bit integer (unsigned short) at the specified byte offset from the start of the view.</dd> <dt><a href=\"getint32\"><code>DataView.prototype.getInt32()</code></a></dt> <dd>Gets a signed 32-bit integer (long) at the specified byte offset from the start of the view.</dd> <dt><a href=\"getuint32\"><code>DataView.prototype.getUint32()</code></a></dt> <dd>Gets an unsigned 32-bit integer (unsigned long) at the specified byte offset from the start of the view.</dd> <dt><a href=\"getfloat32\"><code>DataView.prototype.getFloat32()</code></a></dt> <dd>Gets a signed 32-bit float (float) at the specified byte offset from the start of the view.</dd> <dt><a href=\"getfloat64\"><code>DataView.prototype.getFloat64()</code></a></dt> <dd>Gets a signed 64-bit float (double) at the specified byte offset from the start of the view.</dd> </dl> <h3 id=\"Write\">Write</h3> <dl> <dt><a href=\"setint8\"><code>DataView.prototype.setInt8()</code></a></dt> <dd>Stores a signed 8-bit integer (byte) value at the specified byte offset from the start of the view.</dd> <dt><a href=\"setuint8\"><code>DataView.prototype.setUint8()</code></a></dt> <dd>Stores an unsigned 8-bit integer (unsigned byte) value at the specified byte offset from the start of the view.</dd> <dt><a href=\"setint16\"><code>DataView.prototype.setInt16()</code></a></dt> <dd>Stores a signed 16-bit integer (short) value at the specified byte offset from the start of the view.</dd> <dt><a href=\"setuint16\"><code>DataView.prototype.setUint16()</code></a></dt> <dd>Stores an unsigned 16-bit integer (unsigned short) value at the specified byte offset from the start of the view.</dd> <dt><a href=\"setint32\"><code>DataView.prototype.setInt32()</code></a></dt> <dd>Stores a signed 32-bit integer (long) value at the specified byte offset from the start of the view.</dd> <dt><a href=\"setuint32\"><code>DataView.prototype.setUint32()</code></a></dt> <dd>Stores an unsigned 32-bit integer (unsigned long) value at the specified byte offset from the start of the view.</dd> <dt><a href=\"setfloat32\"><code>DataView.prototype.setFloat32()</code></a></dt> <dd>Stores a signed 32-bit float (float) value at the specified byte offset from the start of the view.</dd> <dt><a href=\"setfloat64\"><code>DataView.prototype.setFloat64()</code></a></dt> <dd>Stores a signed 64-bit float (double) value at the specified byte offset from the start of the view.</dd> </dl> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-dataview.prototype\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'DataView.prototype' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-dataview.prototype\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'DataView.prototype' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 9</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 15</td>\n<td class=\"bc-supports-yes\"> 10</td>\n<td class=\"bc-supports-yes\"> 12.1</td>\n<td class=\"bc-supports-yes\"> 5.1</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 15</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 4.2</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"../dataview\"><code>DataView</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/prototype$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/prototype\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/prototype</a>\n  </p>\n</div>\n","global_objects/dataview/buffer":"<h1>dataView.buffer</h1> <p>The <code>buffer</code> accessor property represents the <a href=\"../arraybuffer\"><code>ArrayBuffer</code></a> or <a href=\"../sharedarraybuffer\"><code>SharedArrayBuffer</code></a> referenced by the <code>DataView</code> at construction time.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/dataview-buffer.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\"><var>dataview</var>.buffer</pre> <h2 id=\"Description\">Description</h2> <p>The <code>buffer</code> property is an accessor property whose set accessor function is <code>undefined</code>, meaning that you can only read this property. The value is established when the <code>DataView</code> is constructed and cannot be changed.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Using_the_buffer_property\">Using the <code>buffer</code> property</h3> <pre data-language=\"js\">var buffer = new ArrayBuffer(8);\nvar dataview = new DataView(buffer);\ndataview.buffer; // ArrayBuffer { byteLength: 8 }\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-get-dataview.prototype.buffer\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'DataView.prototype.buffer' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-get-dataview.prototype.buffer\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'DataView.prototype.buffer' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 9</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 15</td>\n<td class=\"bc-supports-yes\"> 10</td>\n<td class=\"bc-supports-yes\"> 12.1</td>\n<td class=\"bc-supports-yes\"> 5.1</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<code>SharedArrayBuffer</code> accepted as buffer</th>\n<td class=\"bc-supports-yes\"> 60</td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 55</td>\n<td> ? </td>\n<td> ? </td>\n<td> ? </td>\n</tr>\n</tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 15</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 4.2</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<code>SharedArrayBuffer</code> accepted as buffer</th>\n<td> ? </td>\n<td> ? </td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 55</td>\n<td> ? </td>\n<td> ? </td>\n<td> ? </td>\n</tr>\n</tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<code>SharedArrayBuffer</code> accepted as buffer</th>\n<td> ? </td>\n</tr>\n</tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"../dataview\"><code>DataView</code></a></li> <li><a href=\"../arraybuffer\"><code>ArrayBuffer</code></a></li> <li><a href=\"../sharedarraybuffer\"><code>SharedArrayBuffer</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/buffer$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/buffer\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/buffer</a>\n  </p>\n</div>\n","global_objects/dataview/getfloat32":"<h1>dataView.getFloat32</h1> <p>The <code>getFloat32()</code> method gets a signed 32-bit float (float) at the specified byte offset from the start of the <a href=\"../dataview\"><code>DataView</code></a>.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/dataview-getfloat32.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\"><var>dataview</var>.getFloat32(byteOffset [, littleEndian])</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt>byteOffset</dt> <dd>The offset, in byte, from the start of the view where to read the data.</dd> <dt>littleEndian</dt> <dd>\n<span class=\"inlineIndicator optional optionalInline\">Optional</span> Indicates whether the 32-bit float is stored in <a href=\"https://developer.mozilla.org/en-US/docs/Glossary/Endianness\">little- or big-endian</a> format. If false or undefined, a big-endian value is read.</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p>A signed 32-bit float number.</p> <h3 id=\"Errors_thrown\">Errors thrown</h3> <dl> <dt><a href=\"../rangeerror\"><code>RangeError</code></a></dt> <dd>Thrown if the <code>byteOffset</code> is set such as it would read beyond the end of the view.</dd> </dl> <h2 id=\"Description\">Description</h2> <p>There is no alignment constraint; multi-byte values may be fetched from any offset.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Using_the_getFloat32_method\">Using the <code>getFloat32</code> method</h3> <pre data-language=\"js\">var buffer = new ArrayBuffer(8);\nvar dataview = new DataView(buffer);\ndataview.getFloat32(1); // 0\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.khronos.org/registry/typedarray/specs/latest/\" hreflang=\"en\">Typed Array Specification</a></td> <td><span class=\"spec-Obsolete\">Obsolete</span></td> <td>Superseded by ECMAScript 2015.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-dataview.prototype.getfloat32\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'DataView.prototype.getFloat32' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition in an ECMA standard.</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-dataview.prototype.getfloat32\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'DataView.prototype.getFloat32' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 9</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 15</td>\n<td class=\"bc-supports-yes\"> 10</td>\n<td class=\"bc-supports-yes\"> 12.1</td>\n<td class=\"bc-supports-yes\"> 5.1</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 15</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 4.2</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"../dataview\"><code>DataView</code></a></li> <li><a href=\"../arraybuffer\"><code>ArrayBuffer</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/getFloat32$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/getFloat32\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/getFloat32</a>\n  </p>\n</div>\n","global_objects/dataview/getint8":"<h1>dataView.getInt8</h1> <p>The <code>getInt8()</code> method gets a signed 8-bit integer (byte) at the specified byte offset from the start of the <a href=\"../dataview\"><code>DataView</code></a>.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/dataview-getint8.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\"><var>dataview</var>.getInt8(byteOffset)</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt>byteOffset</dt> <dd>The offset, in byte, from the start of the view where to read the data.</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p>A signed 8-bit integer number.</p> <h3 id=\"Errors_thrown\">Errors thrown</h3> <dl> <dt><a href=\"../rangeerror\"><code>RangeError</code></a></dt> <dd>Thrown if the <code>byteOffset</code> is set such as it would read beyond the end of the view.</dd> </dl> <h2 id=\"Description\">Description</h2> <p>There is no alignment constraint; multi-byte values may be fetched from any offset.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Using_the_getInt8_method\">Using the <code>getInt8</code> method</h3> <pre data-language=\"js\">var buffer = new ArrayBuffer(8);\nvar dataview = new DataView(buffer);\ndataview.getInt8(1); // 0\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.khronos.org/registry/typedarray/specs/latest/\" hreflang=\"en\">Typed Array Specification</a></td> <td><span class=\"spec-Obsolete\">Obsolete</span></td> <td>Superseded by ECMAScript 2015.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-dataview.prototype.getint8\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'DataView.prototype.getInt8' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition in an ECMA standard.</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-dataview.prototype.getint8\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'DataView.prototype.getInt8' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 9</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 15</td>\n<td class=\"bc-supports-yes\"> 10</td>\n<td class=\"bc-supports-yes\"> 12.1</td>\n<td class=\"bc-supports-yes\"> 5.1</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 15</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 4.2</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"../dataview\"><code>DataView</code></a></li> <li><a href=\"../arraybuffer\"><code>ArrayBuffer</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/getInt8$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/getInt8\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/getInt8</a>\n  </p>\n</div>\n","global_objects/string/normalize":"<h1>string.normalize</h1> <p>The <code>normalize()</code> method returns the Unicode Normalization Form of a given string (if the value isn't a string, it will be converted to one first).</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/string-normalize.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\"><var>str</var>.normalize([<var>form</var>])</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><code>form</code></dt> <dd>One of <code>\"NFC\"</code>, <code>\"NFD\"</code>, <code>\"NFKC\"</code>, or <code>\"NFKD\"</code>, specifying the Unicode Normalization Form. If omitted or <a href=\"../undefined\"><code>undefined</code></a>, <code>\"NFC\"</code> is used. <ul> <li>\n<code>NFC</code> — Normalization Form Canonical Composition.</li> <li>\n<code>NFD</code> — Normalization Form Canonical Decomposition.</li> <li>\n<code>NFKC</code> — Normalization Form Compatibility Composition.</li> <li>\n<code>NFKD</code> — Normalization Form Compatibility Decomposition.</li> </ul> </dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p>A string containing the Unicode Normalization Form of the given string.</p> <h3 id=\"Errors_thrown\">Errors thrown</h3> <dl> <dt><a href=\"../rangeerror\"><code>RangeError</code></a></dt> <dd>A <a href=\"../rangeerror\"><code>RangeError</code></a> is thrown if <code>form</code> isn't one of the values specified above.</dd> </dl> <h2 id=\"Description\">Description</h2> <p>The <code>normalize()</code> method returns the specified Unicode Normalization Form of the string. It does not affect the value of the string itself.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Using_normalize()\">Using <code>normalize()</code>\n</h3> <pre data-language=\"js\">// Initial string\n\n// U+1E9B: LATIN SMALL LETTER LONG S WITH DOT ABOVE\n// U+0323: COMBINING DOT BELOW\nvar str = '\\u1E9B\\u0323';\n\n\n// Canonically-composed form (NFC)\n\n// U+1E9B: LATIN SMALL LETTER LONG S WITH DOT ABOVE\n// U+0323: COMBINING DOT BELOW\nstr.normalize('NFC'); // '\\u1E9B\\u0323'\nstr.normalize();      // same as above\n\n\n// Canonically-decomposed form (NFD)\n\n// U+017F: LATIN SMALL LETTER LONG S\n// U+0323: COMBINING DOT BELOW\n// U+0307: COMBINING DOT ABOVE\nstr.normalize('NFD'); // '\\u017F\\u0323\\u0307'\n\n\n// Compatibly-composed (NFKC)\n\n// U+1E69: LATIN SMALL LETTER S WITH DOT BELOW AND DOT ABOVE\nstr.normalize('NFKC'); // '\\u1E69'\n\n\n// Compatibly-decomposed (NFKD)\n\n// U+0073: LATIN SMALL LETTER S\n// U+0323: COMBINING DOT BELOW\n// U+0307: COMBINING DOT ABOVE\nstr.normalize('NFKD'); // '\\u0073\\u0323\\u0307'\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-string.prototype.normalize\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'String.prototype.normalize' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-string.prototype.normalize\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'String.prototype.normalize' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 34</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 31</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 10</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 34</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 31</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 10</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 0.12</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"http://www.unicode.org/reports/tr15/\">Unicode Standard Annex #15, Unicode Normalization Forms</a></li> <li><a href=\"http://en.wikipedia.org/wiki/Unicode_equivalence\">Unicode equivalence</a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/normalize$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/normalize\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/normalize</a>\n  </p>\n</div>\n","global_objects/dataview/bytelength":"<h1>dataView.byteLength</h1> <p>The <code>byteLength</code> accessor property represents the length (in bytes) of this view from the start of its <a href=\"../arraybuffer\"><code>ArrayBuffer</code></a> or <a href=\"../sharedarraybuffer\"><code>SharedArrayBuffer</code></a>.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/dataview-bytelength.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\"><var>dataview</var>.byteLength</pre> <h2 id=\"Description\">Description</h2> <p>The <code>byteLength</code> property is an accessor property whose set accessor function is <code>undefined</code>, meaning that you can only read this property. The value is established when an <code>DataView</code> is constructed and cannot be changed. If the <code>DataView</code> is not specifying an offset or a <code>byteLength</code>, the <code>byteLength</code> of the referenced <code>ArrayBuffer</code> or <code>SharedArrayBuffer</code> will be returned.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Using_the_byteLength_property\">Using the <code>byteLength</code> property</h3> <pre data-language=\"js\">var buffer = new ArrayBuffer(8);\nvar dataview = new DataView(buffer);\ndataview.byteLength; // 8 (matches the byteLength of the buffer)\n\nvar dataview2 = new DataView(buffer, 1, 5);\ndataview2.byteLength; // 5 (as specified when constructing the DataView)\n\nvar dataview3 = new DataView(buffer, 2);\ndataview3.byteLength; // 6 (due to the offset of the constructed DataView)\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-get-dataview.prototype.bytelength\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'DataView.prototype.byteLength' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-get-dataview.prototype.bytelength\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'DataView.prototype.byteLength' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 9</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 15</td>\n<td class=\"bc-supports-yes\"> 10</td>\n<td class=\"bc-supports-yes\"> 12.1</td>\n<td class=\"bc-supports-yes\"> 5.1</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 15</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 4.2</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"../dataview\"><code>DataView</code></a></li> <li><a href=\"../arraybuffer\"><code>ArrayBuffer</code></a></li> <li><a href=\"../sharedarraybuffer\"><code>SharedArrayBuffer</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/byteLength$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/byteLength\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/byteLength</a>\n  </p>\n</div>\n","global_objects/dataview/byteoffset":"<h1>dataView.byteOffset</h1> <p>The <code>byteOffset</code> accessor property represents the offset (in bytes) of this view from the start of its <a href=\"../arraybuffer\"><code>ArrayBuffer</code></a> or <a href=\"../sharedarraybuffer\"><code>SharedArrayBuffer</code></a>.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/dataview-byteoffset.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\"><var>dataview</var>.byteOffset</pre> <h2 id=\"Description\">Description</h2> <p>The <code>byteOffset</code> property is an accessor property whose set accessor function is <code>undefined</code>, meaning that you can only read this property. The value is established when an <code>DataView</code> is constructed and cannot be changed.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Using_the_byteOffset_property\">Using the <code>byteOffset</code> property</h3> <pre data-language=\"js\">var buffer = new ArrayBuffer(8);\nvar dataview = new DataView(buffer);\ndataview.byteOffset; // 0 (no offset specified)\n\nvar dataview2 = new DataView(buffer, 3);\ndataview2.byteOffset; // 3 (as specified when constructing the DataView)\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-get-dataview.prototype.byteoffset\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'DataView.prototype.byteOffset' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-get-dataview.prototype.byteoffset\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'DataView.prototype.byteOffset' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 9</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 15</td>\n<td class=\"bc-supports-yes\"> 10</td>\n<td class=\"bc-supports-yes\"> 12.1</td>\n<td class=\"bc-supports-yes\"> 5.1</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 15</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 4.2</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"../dataview\"><code>DataView</code></a></li> <li><a href=\"../arraybuffer\"><code>ArrayBuffer</code></a></li> <li><a href=\"../sharedarraybuffer\"><code>SharedArrayBuffer</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/byteOffset$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/byteOffset\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/byteOffset</a>\n  </p>\n</div>\n","global_objects/dataview/getfloat64":"<h1>dataView.getFloat64</h1> <p>The <code>getFloat64()</code> method gets a signed 64-bit float (double) at the specified byte offset from the start of the <a href=\"../dataview\"><code>DataView</code></a>.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/dataview-getfloat64.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\"><var>dataview</var>.getFloat64(byteOffset [, littleEndian])</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt>byteOffset</dt> <dd>The offset, in byte, from the start of the view where to read the data.</dd> <dt>littleEndian</dt> <dd>\n<span class=\"inlineIndicator optional optionalInline\">Optional</span> Indicates whether the 64-bit float is stored in <a href=\"https://developer.mozilla.org/en-US/docs/Glossary/Endianness\">little- or big-endian</a> format. If false or undefined, a big-endian value is read.</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p>A signed 64-bit float number.</p> <h3 id=\"Errors_thrown\">Errors thrown</h3> <dl> <dt><a href=\"../rangeerror\"><code>RangeError</code></a></dt> <dd>Thrown if the <code>byteOffset</code> is set such as it would read beyond the end of the view.</dd> </dl> <h2 id=\"Description\">Description</h2> <p>There is no alignment constraint; multi-byte values may be fetched from any offset.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Using_the_getFloat64_method\">Using the <code>getFloat64</code> method</h3> <pre data-language=\"js\">var buffer = new ArrayBuffer(8);\nvar dataview = new DataView(buffer);\ndataview.getFloat64(0); // 0\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.khronos.org/registry/typedarray/specs/latest/\" hreflang=\"en\">Typed Array Specification</a></td> <td><span class=\"spec-Obsolete\">Obsolete</span></td> <td>Superseded by ECMAScript 2015.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-dataview.prototype.getfloat64\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'DataView.prototype.getFloat64' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition in ECMA standard.</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-dataview.prototype.getfloat64\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'DataView.prototype.getFloat64' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 9</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 15</td>\n<td class=\"bc-supports-yes\"> 10</td>\n<td class=\"bc-supports-yes\"> 12.1</td>\n<td class=\"bc-supports-yes\"> 5.1</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 15</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 4.2</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"../dataview\"><code>DataView</code></a></li> <li><a href=\"../arraybuffer\"><code>ArrayBuffer</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/getFloat64$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/getFloat64\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/getFloat64</a>\n  </p>\n</div>\n","global_objects/dataview/getuint8":"<h1>dataView.getUint8</h1> <p>The <code>getUint8()</code> method gets an unsigned 8-bit integer (unsigned byte) at the specified byte offset from the start of the <a href=\"../dataview\"><code>DataView</code></a>.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/dataview-getuint8.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\"><var>dataview</var>.getUint8(byteOffset)</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt>byteOffset</dt> <dd>The offset, in byte, from the start of the view where to read the data.</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p>An unsigned 8-bit integer number.</p> <h3 id=\"Errors_thrown\">Errors thrown</h3> <dl> <dt><a href=\"../rangeerror\"><code>RangeError</code></a></dt> <dd>Thrown if the <code>byteOffset</code> is set such as it would read beyond the end of the view.</dd> </dl> <h2 id=\"Description\">Description</h2> <p>There is no alignment constraint; multi-byte values may be fetched from any offset.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Using_the_getUint8_method\">Using the <code>getUint8</code> method</h3> <pre data-language=\"js\">var buffer = new ArrayBuffer(8);\nvar dataview = new DataView(buffer);\ndataview.getUint8(1); // 0\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.khronos.org/registry/typedarray/specs/latest/\" hreflang=\"en\">Typed Array Specification</a></td> <td><span class=\"spec-Obsolete\">Obsolete</span></td> <td>Superseded by ECMAScript 2015.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-dataview.prototype.getuint8\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'DataView.prototype.getUint8' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition in an ECMA standard.</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-dataview.prototype.getuint8\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'DataView.prototype.getUint8' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 9</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 15</td>\n<td class=\"bc-supports-yes\"> 10</td>\n<td class=\"bc-supports-yes\"> 12.1</td>\n<td class=\"bc-supports-yes\"> 5.1</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 15</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 4.2</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"../dataview\"><code>DataView</code></a></li> <li><a href=\"../arraybuffer\"><code>ArrayBuffer</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/getUint8$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/getUint8\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/getUint8</a>\n  </p>\n</div>\n","global_objects/dataview/getint16":"<h1>dataView.getInt16</h1> <p>The <code>getInt16()</code> method gets a signed 16-bit integer (short) at the specified byte offset from the start of the <a href=\"../dataview\"><code>DataView</code></a>.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/dataview-getint16.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\"><var>dataview</var>.getInt16(byteOffset [, littleEndian])</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt>byteOffset</dt> <dd>The offset, in byte, from the start of the view where to read the data.</dd> <dt>littleEndian</dt> <dd>\n<span class=\"inlineIndicator optional optionalInline\">Optional</span> Indicates whether the 16-bit int is stored in <a href=\"https://developer.mozilla.org/en-US/docs/Glossary/Endianness\">little- or big-endian</a> format. If false or undefined, a big-endian value is read.</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p>A signed 16-bit integer number.</p> <h3 id=\"Errors_thrown\">Errors thrown</h3> <dl> <dt><a href=\"../rangeerror\"><code>RangeError</code></a></dt> <dd>Thrown if the <code>byteOffset</code> is set such as it would read beyond the end of the view.</dd> </dl> <h2 id=\"Description\">Description</h2> <p>There is no alignment constraint; multi-byte values may be fetched from any offset.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Using_the_getInt16_method\">Using the <code>getInt16</code> method</h3> <pre data-language=\"js\">var buffer = new ArrayBuffer(8);\nvar dataview = new DataView(buffer);\ndataview.getInt16(1); // 0\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.khronos.org/registry/typedarray/specs/latest/\" hreflang=\"en\">Typed Array Specification</a></td> <td><span class=\"spec-Obsolete\">Obsolete</span></td> <td>Superseded by ECMAScript 2015.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-dataview.prototype.getint16\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'DataView.prototype.getInt16' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition in an ECMA standard.</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-dataview.prototype.getint16\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'DataView.prototype.getInt16' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 9</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 15</td>\n<td class=\"bc-supports-yes\"> 10</td>\n<td class=\"bc-supports-yes\"> 12.1</td>\n<td class=\"bc-supports-yes\"> 5.1</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 15</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 4.2</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"../dataview\"><code>DataView</code></a></li> <li><a href=\"../arraybuffer\"><code>ArrayBuffer</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/getInt16$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/getInt16\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/getInt16</a>\n  </p>\n</div>\n","global_objects/dataview/setfloat32":"<h1>dataView.setFloat32</h1> <p>The <code>setFloat32()</code> method stores a signed 32-bit float (float) value at the specified byte offset from the start of the <a href=\"../dataview\"><code>DataView</code></a>.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/dataview-setfloat32.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\"><var>dataview</var>.setFloat32(byteOffset, value [, littleEndian])</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt>byteOffset</dt> <dd>The offset, in byte, from the start of the view where to store the data.</dd> <dt>value</dt> <dd>The value to set.</dd> <dt>littleEndian</dt> <dd>\n<span class=\"inlineIndicator optional optionalInline\">Optional</span> Indicates whether the 32-bit float is stored in <a href=\"https://developer.mozilla.org/en-US/docs/Glossary/Endianness\">little- or big-endian</a> format. If false or undefined, a big-endian value is written.</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p><a href=\"../undefined\"><code>undefined</code></a>.</p> <h3 id=\"Errors_thrown\">Errors thrown</h3> <dl> <dt><a href=\"../rangeerror\"><code>RangeError</code></a></dt> <dd>Thrown if the <code>byteOffset</code> is set such as it would store beyond the end of the view.</dd> </dl> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Using_the_setFloat32_method\">Using the <code>setFloat32</code> method</h3> <pre data-language=\"js\">var buffer = new ArrayBuffer(8);\nvar dataview = new DataView(buffer);\ndataview.setFloat32(1, 3);\ndataview.getFloat32(1); // 3\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.khronos.org/registry/typedarray/specs/latest/\" hreflang=\"en\">Typed Array Specification</a></td> <td><span class=\"spec-Obsolete\">Obsolete</span></td> <td>Superseded by ECMAScript 2015.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-dataview.prototype.setfloat32\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'DataView.prototype.setFloat32' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition in an ECMA standard.</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-dataview.prototype.setfloat32\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'DataView.prototype.setFloat32' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 9</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 15</td>\n<td class=\"bc-supports-yes\"> 10</td>\n<td class=\"bc-supports-yes\"> 12.1</td>\n<td class=\"bc-supports-yes\"> 5.1</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 15</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 4.2</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"../dataview\"><code>DataView</code></a></li> <li><a href=\"../arraybuffer\"><code>ArrayBuffer</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/setFloat32$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/setFloat32\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/setFloat32</a>\n  </p>\n</div>\n","global_objects/dataview/setfloat64":"<h1>dataView.setFloat64</h1> <p>The <code>setFloat64()</code> method stores a signed 64-bit float (double) value at the specified byte offset from the start of the <a href=\"../dataview\"><code>DataView</code></a>.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/dataview-setfloat64.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\"><var>dataview</var>.setFloat64(byteOffset, value [, littleEndian])</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt>byteOffset</dt> <dd>The offset, in byte, from the start of the view where to store the data.</dd> <dt>value</dt> <dd>The value to set.</dd> <dt>littleEndian</dt> <dd>\n<span class=\"inlineIndicator optional optionalInline\">Optional</span> Indicates whether the 64-bit float is stored in <a href=\"https://developer.mozilla.org/en-US/docs/Glossary/Endianness\">little- or big-endian</a> format. If false or undefined, a big-endian value is written.</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p><a href=\"../undefined\"><code>undefined</code></a>.</p> <h3 id=\"Errors_thrown\">Errors thrown</h3> <dl> <dt><a href=\"../rangeerror\"><code>RangeError</code></a></dt> <dd>Thrown if the <code>byteOffset</code> is set such as it would store beyond the end of the view.</dd> </dl> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Using_the_setFloat64_method\">Using the <code>setFloat64</code> method</h3> <pre data-language=\"js\">var buffer = new ArrayBuffer(8);\nvar dataview = new DataView(buffer);\ndataview.setFloat64(0, 3);\ndataview.getFloat64(0); // 3\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.khronos.org/registry/typedarray/specs/latest/\" hreflang=\"en\">Typed Array Specification</a></td> <td><span class=\"spec-Obsolete\">Obsolete</span></td> <td>Superseded by ECMAScript 2015.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-dataview.prototype.setfloat64\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'DataView.prototype.setFloat64' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition in an ECMA standard.</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-dataview.prototype.setfloat64\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'DataView.prototype.setFloat64' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 9</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 15</td>\n<td class=\"bc-supports-yes\"> 10</td>\n<td class=\"bc-supports-yes\"> 12.1</td>\n<td class=\"bc-supports-yes\"> 5.1</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 15</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 4.2</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"../dataview\"><code>DataView</code></a></li> <li><a href=\"../arraybuffer\"><code>ArrayBuffer</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/setFloat64$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/setFloat64\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/setFloat64</a>\n  </p>\n</div>\n","global_objects/dataview/setint16":"<h1>dataView.setInt16</h1> <p>The <code>setInt16()</code> method stores a signed 16-bit integer (short) value at the specified byte offset from the start of the <a href=\"../dataview\"><code>DataView</code></a>.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/dataview-setint16.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\"><var>dataview</var>.setInt16(byteOffset, value [, littleEndian])</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt>byteOffset</dt> <dd>The offset, in byte, from the start of the view where to store the data.</dd> <dt>value</dt> <dd>The value to set.</dd> <dt>littleEndian</dt> <dd>\n<span class=\"inlineIndicator optional optionalInline\">Optional</span> Indicates whether the 16-bit int is stored in <a href=\"https://developer.mozilla.org/en-US/docs/Glossary/Endianness\">little- or big-endian</a> format. If false or undefined, a big-endian value is written.</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p><a href=\"../undefined\"><code>undefined</code></a>.</p> <h3 id=\"Errors_thrown\">Errors thrown</h3> <dl> <dt><a href=\"../rangeerror\"><code>RangeError</code></a></dt> <dd>Thrown if the <code>byteOffset</code> is set such as it would store beyond the end of the view.</dd> </dl> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Using_the_setInt16_method\">Using the <code>setInt16</code> method</h3> <pre data-language=\"js\">var buffer = new ArrayBuffer(8);\nvar dataview = new DataView(buffer);\ndataview.setInt16(1, 3);\ndataview.getInt16(1); // 3\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.khronos.org/registry/typedarray/specs/latest/\" hreflang=\"en\">Typed Array Specification</a></td> <td><span class=\"spec-Obsolete\">Obsolete</span></td> <td>Superseded by ECMAScript 2015.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-dataview.prototype.setint16\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'DataView.prototype.setInt16' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition in an ECMA standard.</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-dataview.prototype.setint16\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'DataView.prototype.setInt16' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 9</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 15</td>\n<td class=\"bc-supports-yes\"> 10</td>\n<td class=\"bc-supports-yes\"> 12.1</td>\n<td class=\"bc-supports-yes\"> 5.1</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 15</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 4.2</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"../dataview\"><code>DataView</code></a></li> <li><a href=\"../arraybuffer\"><code>ArrayBuffer</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/setInt16$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/setInt16\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/setInt16</a>\n  </p>\n</div>\n","global_objects/dataview/getuint16":"<h1>dataView.getUint16</h1> <p>The <code>getUint16()</code> method gets an unsigned 16-bit integer (unsigned short) at the specified byte offset from the start of the <a href=\"../dataview\"><code>DataView</code></a>.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/dataview-getuint16.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\"><var>dataview</var>.getUint16(byteOffset [, littleEndian])</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt>byteOffset</dt> <dd>The offset, in byte, from the start of the view where to read the data.</dd> <dt>littleEndian</dt> <dd>\n<span class=\"inlineIndicator optional optionalInline\">Optional</span> Indicates whether the 16-bit int is stored in <a href=\"https://developer.mozilla.org/en-US/docs/Glossary/Endianness\">little- or big-endian</a> format. If false or undefined, a big-endian value is read.</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p>An unsigned 16-bit integer number.</p> <h3 id=\"Errors_thrown\">Errors thrown</h3> <dl> <dt><a href=\"../rangeerror\"><code>RangeError</code></a></dt> <dd>Thrown if the <code>byteOffset</code> is set such as it would read beyond the end of the view.</dd> </dl> <h2 id=\"Description\">Description</h2> <p>There is no alignment constraint; multi-byte values may be fetched from any offset.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Using_the_getUint16_method\">Using the <code>getUint16</code> method</h3> <pre data-language=\"js\">var buffer = new ArrayBuffer(8);\nvar dataview = new DataView(buffer);\ndataview.getUint16(1); // 0\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.khronos.org/registry/typedarray/specs/latest/\" hreflang=\"en\">Typed Array Specification</a></td> <td><span class=\"spec-Obsolete\">Obsolete</span></td> <td>Superseded by ECMAScript 2015.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-dataview.prototype.getuint16\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'DataView.prototype.getUint16' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition in an ECMA standard.</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-dataview.prototype.getuint16\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'DataView.prototype.getUint16' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 9</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 15</td>\n<td class=\"bc-supports-yes\"> 10</td>\n<td class=\"bc-supports-yes\"> 12.1</td>\n<td class=\"bc-supports-yes\"> 5.1</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 15</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 4.2</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"../dataview\"><code>DataView</code></a></li> <li><a href=\"../arraybuffer\"><code>ArrayBuffer</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/getUint16$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/getUint16\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/getUint16</a>\n  </p>\n</div>\n","global_objects/dataview/getuint32":"<h1>dataView.getUint32</h1> <p>The <code>getUint32()</code> method gets an unsigned 32-bit integer (unsigned long) at the specified byte offset from the start of the <a href=\"../dataview\"><code>DataView</code></a>.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/dataview-getuint32.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\"><var>dataview</var>.getUint32(byteOffset [, littleEndian])</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt>byteOffset</dt> <dd>The offset, in byte, from the start of the view where to read the data.</dd> <dt>littleEndian</dt> <dd>\n<span class=\"inlineIndicator optional optionalInline\">Optional</span> Indicates whether the 32-bit int is stored in <a href=\"https://developer.mozilla.org/en-US/docs/Glossary/Endianness\">little- or big-endian</a> format. If false or undefined, a big-endian value is read.</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p>An unsigned 32-bit integer number.</p> <h3 id=\"Errors_thrown\">Errors thrown</h3> <dl> <dt><a href=\"../rangeerror\"><code>RangeError</code></a></dt> <dd>Thrown if the <code>byteOffset</code> is set such as it would read beyond the end of the view.</dd> </dl> <h2 id=\"Description\">Description</h2> <p>There is no alignment constraint; multi-byte values may be fetched from any offset.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Using_the_getUint32_method\">Using the <code>getUint32</code> method</h3> <pre data-language=\"js\">var buffer = new ArrayBuffer(8);\nvar dataview = new DataView(buffer);\ndataview.getUint32(1); // 0\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.khronos.org/registry/typedarray/specs/latest/\" hreflang=\"en\">Typed Array Specification</a></td> <td><span class=\"spec-Obsolete\">Obsolete</span></td> <td>Superseded by ECMAScript 2015.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-dataview.prototype.getuint32\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'DataView.prototype.getUint32' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition in an ECMA standard.</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-dataview.prototype.getuint32\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'DataView.prototype.getUint32' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 9</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 15</td>\n<td class=\"bc-supports-yes\"> 10</td>\n<td class=\"bc-supports-yes\"> 12.1</td>\n<td class=\"bc-supports-yes\"> 5.1</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 15</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 4.2</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"../dataview\"><code>DataView</code></a></li> <li><a href=\"../arraybuffer\"><code>ArrayBuffer</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/getUint32$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/getUint32\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/getUint32</a>\n  </p>\n</div>\n","global_objects/dataview/setint32":"<h1>dataView.setInt32</h1> <p>The <code>setInt32()</code> method stores a signed 32-bit integer (long) value at the specified byte offset from the start of the <a href=\"../dataview\"><code>DataView</code></a>.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/dataview-setint32.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\"><var>dataview</var>.setInt32(byteOffset, value [, littleEndian])</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt>byteOffset</dt> <dd>The offset, in byte, from the start of the view where to store the data.</dd> <dt>value</dt> <dd>The value to set.</dd> <dt>littleEndian</dt> <dd>\n<span class=\"inlineIndicator optional optionalInline\">Optional</span> Indicates whether the 32-bit int is stored in <a href=\"https://developer.mozilla.org/en-US/docs/Glossary/Endianness\">little- or big-endian</a> format. If false or undefined, a big-endian value is written.</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p><a href=\"../undefined\"><code>undefined</code></a>.</p> <h3 id=\"Errors_thrown\">Errors thrown</h3> <dl> <dt><a href=\"../rangeerror\"><code>RangeError</code></a></dt> <dd>Thrown if the <code>byteOffset</code> is set such as it would store beyond the end of the view.</dd> </dl> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Using_the_setInt32_method\">Using the <code>setInt32</code> method</h3> <pre data-language=\"js\">var buffer = new ArrayBuffer(8);\nvar dataview = new DataView(buffer);\ndataview.setInt32(1, 3);\ndataview.getInt32(1); // 3\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.khronos.org/registry/typedarray/specs/latest/\" hreflang=\"en\">Typed Array Specification</a></td> <td><span class=\"spec-Obsolete\">Obsolete</span></td> <td>Superseded by ECMAScript 2015.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-dataview.prototype.setint32\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'DataView.prototype.setInt32' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition in an ECMA standard.</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-dataview.prototype.setint32\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'DataView.prototype.setInt32' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 9</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 15</td>\n<td class=\"bc-supports-yes\"> 10</td>\n<td class=\"bc-supports-yes\"> 12.1</td>\n<td class=\"bc-supports-yes\"> 5.1</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 15</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 4.2</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"../dataview\"><code>DataView</code></a></li> <li><a href=\"../arraybuffer\"><code>ArrayBuffer</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/setInt32$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/setInt32\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/setInt32</a>\n  </p>\n</div>\n","global_objects/atomics/islockfree":"<h1>Atomics.isLockFree</h1> <p>The static <code><strong>Atomics</strong></code><code>.isLockFree()</code> method is used to determine whether to use locks or atomic operations. It returns <code>true</code>, if the given size is one of the <a href=\"../typedarray/bytes_per_element\">BYTES_PER_ELEMENT</a> property of integer TypedArray types.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/atomics-islockfree.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\">Atomics.isLockFree(size)\n</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><code>size</code></dt> <dd>The size in bytes to check.</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p>A <a href=\"../boolean\"><code>Boolean</code></a> indicating whether the operation is lock free.</p> <h2 id=\"Examples\">Examples</h2> <pre data-language=\"js\">Atomics.isLockFree(1); // true\nAtomics.isLockFree(2); // true\nAtomics.isLockFree(3); // false\nAtomics.isLockFree(4); // true\nAtomics.isLockFree(5); // false\nAtomics.isLockFree(6); // false\nAtomics.isLockFree(7); // false\nAtomics.isLockFree(8); // false</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-atomics.islockfree\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Atomics.isLockFree' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td>Initial definition in ES2017.</td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes bc-has-history\"> 68\n<section class=\"bc-history\" id=\"sect1\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 68\n</dt>\n\n<dt class=\"bc-supports-no bc-supports\">60 — 63\n</dt>\n<dd> Chrome disabled <code>SharedArrayBuffer</code> on January 5, 2018 to help reduce the efficacy of <a href=\"https://www.chromium.org/Home/chromium-security/ssca\">speculative side-channel attacks</a>. This was a temporary removal while mitigations were put in place.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-yes bc-has-history\"> 16\n<section class=\"bc-history\" id=\"sect2\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 16\n</dt>\n<dd> Support was removed to mitigate <a href=\"https://blogs.windows.com/msedgedev/2018/01/03/speculative-execution-mitigations-microsoft-edge-internet-explorer\">speculative execution side-channel attacks (Windows blog)</a>.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-yes bc-has-history\"> 57<div class=\"bc-icons\"> Disabled </div>\n<section class=\"bc-history\" id=\"sect3\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 57<div class=\"bc-icons\"> Disabled </div>\n</dt>\n<dd> Support was disabled by default to mitigate <a href=\"https://blog.mozilla.org/security/2018/01/03/mitigations-landing-new-class-timing-attack/\">speculative execution side-channel attacks (Mozilla Security Blog)</a>.</dd>\n<dd>Disabled From version 57: this feature is behind the <code>javascript.options.shared_memory</code> preference (needs to be set to <code>true</code>). To change preferences in Firefox, visit about:config.</dd>\n<dt class=\"bc-supports-no bc-supports\">55 — 57\n</dt>\n\n<dt class=\"bc-supports-no bc-supports\">46 — 55<div class=\"bc-icons\">Disabled </div>\n</dt>\n<dd>Disabled From version 46 until version 55 (exclusive): this feature is behind the <code>javascript.options.shared_memory</code> preference (needs to be set to <code>true</code>). To change preferences in Firefox, visit about:config.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\">10.1 — ?</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-no bc-has-history\">60 — 63\n<section class=\"bc-history\" id=\"sect4\"><dl>\n<dt class=\"bc-supports-no bc-supports\">60 — 63\n</dt>\n<dd> Chrome disabled <code>SharedArrayBuffer</code> on January 5, 2018 to help reduce the efficacy of <a href=\"https://www.chromium.org/Home/chromium-security/ssca\">speculative side-channel attacks</a>. This is intended as a temporary measure until other mitigations are in place.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-no bc-has-history\">60 — 63\n<section class=\"bc-history\" id=\"sect5\"><dl>\n<dt class=\"bc-supports-no bc-supports\">60 — 63\n</dt>\n<dd> Chrome disabled <code>SharedArrayBuffer</code> on January 5, 2018 to help reduce the efficacy of <a href=\"https://www.chromium.org/Home/chromium-security/ssca\">speculative side-channel attacks</a>. This is intended as a temporary measure until other mitigations are in place.</dd>\n</dl></section>\n</td>\n<td> ? </td>\n<td class=\"bc-supports-yes bc-has-history\"> 57<div class=\"bc-icons\"> Disabled </div>\n<section class=\"bc-history\" id=\"sect6\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 57<div class=\"bc-icons\"> Disabled </div>\n</dt>\n<dd> Support was disabled by default to mitigate <a href=\"https://blog.mozilla.org/security/2018/01/03/mitigations-landing-new-class-timing-attack/\">speculative execution side-channel attacks (Mozilla Security Blog)</a>.</dd>\n<dd>Disabled From version 57: this feature is behind the <code>javascript.options.shared_memory</code> preference (needs to be set to <code>true</code>). To change preferences in Firefox, visit about:config.</dd>\n<dt class=\"bc-supports-no bc-supports\">55 — 57\n</dt>\n\n<dt class=\"bc-supports-no bc-supports\">46 — 55<div class=\"bc-icons\">Disabled </div>\n</dt>\n<dd>Disabled From version 46 until version 55 (exclusive): this feature is behind the <code>javascript.options.shared_memory</code> preference (needs to be set to <code>true</code>). To change preferences in Firefox, visit about:config.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 8.10.0</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"../atomics\"><code>Atomics</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics/isLockFree$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics/isLockFree\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics/isLockFree</a>\n  </p>\n</div>\n","global_objects/dataview/setuint8":"<h1>dataView.setUint8</h1> <p>The <code>setUint8()</code> method stores an unsigned 8-bit integer (byte) value at the specified byte offset from the start of the <a href=\"../dataview\"><code>DataView</code></a>.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/dataview-setuint8.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\"><var>dataview</var>.setUint8(byteOffset, value)</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt>byteOffset</dt> <dd>The offset, in byte, from the start of the view where to store the data.</dd> <dt>value</dt> <dd>The value to set.</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p><a href=\"../undefined\"><code>undefined</code></a>.</p> <h3 id=\"Errors_thrown\">Errors thrown</h3> <dl> <dt><a href=\"../rangeerror\"><code>RangeError</code></a></dt> <dd>Thrown if the <code>byteOffset</code> is set such as it would store beyond the end of the view.</dd> </dl> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Using_the_setUint8_method\">Using the <code>setUint8</code> method</h3> <pre data-language=\"js\">var buffer = new ArrayBuffer(8);\nvar dataview = new DataView(buffer);\ndataview.setUint8(1, 3);\ndataview.getUint8(1); // 3\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.khronos.org/registry/typedarray/specs/latest/\" hreflang=\"en\">Typed Array Specification</a></td> <td><span class=\"spec-Obsolete\">Obsolete</span></td> <td>Superseded by ECMAScript 2015.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-dataview.prototype.setuint8\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'DataView.prototype.setUint8' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition in an ECMA standard.</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-dataview.prototype.setuint8\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'DataView.prototype.setUint8' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 9</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 15</td>\n<td class=\"bc-supports-yes\"> 10</td>\n<td class=\"bc-supports-yes\"> 12.1</td>\n<td class=\"bc-supports-yes\"> 5.1</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 15</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 4.2</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"../dataview\"><code>DataView</code></a></li> <li><a href=\"../arraybuffer\"><code>ArrayBuffer</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/setUint8$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/setUint8\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/setUint8</a>\n  </p>\n</div>\n","global_objects/dataview/getint32":"<h1>dataView.getInt32</h1> <p>The <code>getInt32()</code> method gets a signed 32-bit integer (long) at the specified byte offset from the start of the <a href=\"../dataview\"><code>DataView</code></a>.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/dataview-getint32.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\"><var>dataview</var>.getInt32(byteOffset [, littleEndian])</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt>byteOffset</dt> <dd>The offset, in byte, from the start of the view where to read the data.</dd> <dt>littleEndian</dt> <dd>\n<span class=\"inlineIndicator optional optionalInline\">Optional</span> Indicates whether the 32-bit int is stored in <a href=\"https://developer.mozilla.org/en-US/docs/Glossary/Endianness\">little- or big-endian</a> format. If false or undefined, a big-endian value is read.</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p>A signed 32-bit integer number.</p> <h3 id=\"Errors_thrown\">Errors thrown</h3> <dl> <dt><a href=\"../rangeerror\"><code>RangeError</code></a></dt> <dd>Thrown if the <code>byteOffset</code> is set such as it would read beyond the end of the view.</dd> </dl> <h2 id=\"Description\">Description</h2> <p>There is no alignment constraint; multi-byte values may be fetched from any offset.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Using_the_getInt32_method\">Using the <code>getInt32</code> method</h3> <pre data-language=\"js\">var buffer = new ArrayBuffer(8);\nvar dataview = new DataView(buffer);\ndataview.getInt32(1); // 0\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.khronos.org/registry/typedarray/specs/latest/\" hreflang=\"en\">Typed Array Specification</a></td> <td><span class=\"spec-Obsolete\">Obsolete</span></td> <td>Superseded by ECMAScript 2015.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-dataview.prototype.getint32\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'DataView.prototype.getInt32' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition in an ECMA standard.</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-dataview.prototype.getint32\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'DataView.prototype.getInt32' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 9</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 15</td>\n<td class=\"bc-supports-yes\"> 10</td>\n<td class=\"bc-supports-yes\"> 12.1</td>\n<td class=\"bc-supports-yes\"> 5.1</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 15</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 4.2</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"../dataview\"><code>DataView</code></a></li> <li><a href=\"../arraybuffer\"><code>ArrayBuffer</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/getInt32$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/getInt32\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/getInt32</a>\n  </p>\n</div>\n","global_objects/dataview/setint8":"<h1>dataView.setInt8</h1> <p>The <code>setInt8()</code> method stores a signed 8-bit integer (byte) value at the specified byte offset from the start of the <a href=\"../dataview\"><code>DataView</code></a>.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/dataview-setint8.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\"><var>dataview</var>.setInt8(byteOffset, value)</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt>byteOffset</dt> <dd>The offset, in byte, from the start of the view where to store the data.</dd> <dt>value</dt> <dd>The value to set.</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p><a href=\"../undefined\"><code>undefined</code></a>.</p> <h3 id=\"Errors_thrown\">Errors thrown</h3> <dl> <dt><a href=\"../rangeerror\"><code>RangeError</code></a></dt> <dd>Thrown if the <code>byteOffset</code> is set such as it would store beyond the end of the view.</dd> </dl> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Using_the_setInt8_method\">Using the <code>setInt8</code> method</h3> <pre data-language=\"js\">var buffer = new ArrayBuffer(8);\nvar dataview = new DataView(buffer);\ndataview.setInt8(1, 3);\ndataview.getInt8(1); // 3\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.khronos.org/registry/typedarray/specs/latest/\" hreflang=\"en\">Typed Array Specification</a></td> <td><span class=\"spec-Obsolete\">Obsolete</span></td> <td>Superseded by ECMAScript 2015.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-dataview.prototype.setint8\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'DataView.prototype.setInt8' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition in an ECMA standard.</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-dataview.prototype.setint8\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'DataView.prototype.setInt8' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 9</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 15</td>\n<td class=\"bc-supports-yes\"> 10</td>\n<td class=\"bc-supports-yes\"> 12.1</td>\n<td class=\"bc-supports-yes\"> 5.1</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 15</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 4.2</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"../dataview\"><code>DataView</code></a></li> <li><a href=\"../arraybuffer\"><code>ArrayBuffer</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/setInt8$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/setInt8\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/setInt8</a>\n  </p>\n</div>\n","global_objects/dataview/setuint16":"<h1>dataView.setUint16</h1> <p>The <code>setUint16()</code> method stores an unsigned 16-bit integer (unsigned short) value at the specified byte offset from the start of the <a href=\"../dataview\"><code>DataView</code></a>.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/dataview-setuint16.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\"><var>dataview</var>.setUint16(byteOffset, value [, littleEndian])</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt>byteOffset</dt> <dd>The offset, in byte, from the start of the view where to store the data.</dd> <dt>value</dt> <dd>The value to set.</dd> <dt>littleEndian</dt> <dd>\n<span class=\"inlineIndicator optional optionalInline\">Optional</span> Indicates whether the 16-bit int is stored in <a href=\"https://developer.mozilla.org/en-US/docs/Glossary/Endianness\">little- or big-endian</a> format. If false or undefined, a big-endian value is written.</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p><a href=\"../undefined\"><code>undefined</code></a>.</p> <h3 id=\"Errors_thrown\">Errors thrown</h3> <dl> <dt><a href=\"../rangeerror\"><code>RangeError</code></a></dt> <dd>Thrown if the <code>byteOffset</code> is set such as it would store beyond the end of the view.</dd> </dl> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Using_the_setUint16_method\">Using the <code>setUint16</code> method</h3> <pre data-language=\"js\">var buffer = new ArrayBuffer(8);\nvar dataview = new DataView(buffer);\ndataview.setUint16(1, 3);\ndataview.getUint16(1); // 3\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.khronos.org/registry/typedarray/specs/latest/\" hreflang=\"en\">Typed Array Specification</a></td> <td><span class=\"spec-Obsolete\">Obsolete</span></td> <td>Superseded by ECMAScript 2015.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-dataview.prototype.setuint16\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'DataView.prototype.setUint16' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition in an ECMA standard.</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-dataview.prototype.setuint16\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'DataView.prototype.setUint16' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 9</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 15</td>\n<td class=\"bc-supports-yes\"> 10</td>\n<td class=\"bc-supports-yes\"> 12.1</td>\n<td class=\"bc-supports-yes\"> 5.1</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 15</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 4.2</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"../dataview\"><code>DataView</code></a></li> <li><a href=\"../arraybuffer\"><code>ArrayBuffer</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/setUint16$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/setUint16\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/setUint16</a>\n  </p>\n</div>\n","global_objects/dataview/setuint32":"<h1>dataView.setUint32</h1> <p>The <code>setUint32()</code> method stores an unsigned 32-bit integer (unsigned long) value at the specified byte offset from the start of the <a href=\"../dataview\"><code>DataView</code></a>.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/dataview-setuint32.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\"><var>dataview</var>.setUint32(byteOffset, value [, littleEndian])</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt>byteOffset</dt> <dd>The offset, in byte, from the start of the view where to store the data.</dd> <dt>value</dt> <dd>The value to set.</dd> <dt>littleEndian</dt> <dd>\n<span class=\"inlineIndicator optional optionalInline\">Optional</span> Indicates whether the 32-bit int is stored in <a href=\"https://developer.mozilla.org/en-US/docs/Glossary/Endianness\">little- or big-endian</a> format. If false or undefined, a big-endian value is written.</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p><a href=\"../undefined\"><code>undefined</code></a>.</p> <h3 id=\"Errors_thrown\">Errors thrown</h3> <dl> <dt><a href=\"../rangeerror\"><code>RangeError</code></a></dt> <dd>Thrown if the <code>byteOffset</code> is set such as it would store beyond the end of the view.</dd> </dl> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Using_the_setUint32_method\">Using the <code>setUint32</code> method</h3> <pre data-language=\"js\">var buffer = new ArrayBuffer(8);\nvar dataview = new DataView(buffer);\ndataview.setUint32(1, 3);\ndataview.getUint32(1); // 3\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.khronos.org/registry/typedarray/specs/latest/\" hreflang=\"en\">Typed Array Specification</a></td> <td><span class=\"spec-Obsolete\">Obsolete</span></td> <td>Superseded by ECMAScript 2015.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-dataview.prototype.setuint32\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'DataView.prototype.setUint32' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition in an ECMA standard.</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-dataview.prototype.setuint32\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'DataView.prototype.setUint32' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 9</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 15</td>\n<td class=\"bc-supports-yes\"> 10</td>\n<td class=\"bc-supports-yes\"> 12.1</td>\n<td class=\"bc-supports-yes\"> 5.1</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 15</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 4.2</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"../dataview\"><code>DataView</code></a></li> <li><a href=\"../arraybuffer\"><code>ArrayBuffer</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/setUint32$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/setUint32\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView/setUint32</a>\n  </p>\n</div>\n","global_objects/referenceerror/prototype":"<h1>ReferenceError.prototype</h1> <p>The <code><strong>ReferenceError.prototype</strong></code> property represents the prototype for the <a href=\"../referenceerror\"><code>ReferenceError</code></a> constructor.</p> <div class=\"_table\"><table class=\"standard-table\"> <thead> <tr> <th colspan=\"2\" class=\"header\">Property attributes of <code>ReferenceError.prototype</code>\n</th> </tr> </thead> <tbody> <tr> <td>Writable</td> <td>no</td> </tr> <tr> <td>Enumerable</td> <td>no</td> </tr> <tr> <td>Configurable</td> <td>no</td> </tr> </tbody> </table></div> <h2 id=\"Description\">Description</h2> <p>All <a href=\"../referenceerror\"><code>ReferenceError</code></a> instances inherit from <code>ReferenceError.prototype</code>. You can use the prototype to add properties or methods to all instances.</p> <h2 id=\"Properties\">Properties</h2> <dl> <dt><code>ReferenceError.prototype.constructor</code></dt> <dd>Specifies the function that created an instance's prototype.</dd> <dt><a href=\"../error/message\"><code>ReferenceError.prototype.message</code></a></dt> <dd>Error message. Although ECMA-262 specifies that <a href=\"../referenceerror\"><code>ReferenceError</code></a> should provide its own <code>message</code> property, in <a href=\"https://developer.mozilla.org/en-US/docs/Mozilla/Projects/SpiderMonkey\">SpiderMonkey</a>, it inherits <a href=\"../error/message\"><code>Error.prototype.message</code></a>.</dd> <dt><a href=\"../error/name\"><code>ReferenceError.prototype.name</code></a></dt> <dd>Error name. Inherited from <a href=\"../error\"><code>Error</code></a>.</dd> <dt><a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/fileName\"><code>ReferenceError.prototype.fileName</code></a></dt> <dd>Path to file that raised this error. Inherited from <a href=\"../error\"><code>Error</code></a>.</dd> <dt><a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/lineNumber\"><code>ReferenceError.prototype.lineNumber</code></a></dt> <dd>Line number in file that raised this error. Inherited from <a href=\"../error\"><code>Error</code></a>.</dd> <dt><a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/columnNumber\"><code>ReferenceError.prototype.columnNumber</code></a></dt> <dd>Column number in line that raised this error. Inherited from <a href=\"../error\"><code>Error</code></a>.</dd> <dt><a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/stack\"><code>ReferenceError.prototype.stack</code></a></dt> <dd>Stack trace. Inherited from <a href=\"../error\"><code>Error</code></a>.</dd> </dl> <h2 id=\"Methods\">Methods</h2> <p>Although the <a href=\"../referenceerror\"><code>ReferenceError</code></a> prototype object does not contain any methods of its own, <a href=\"../referenceerror\"><code>ReferenceError</code></a> instances do inherit some methods through the prototype chain.</p> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/publications/files/ECMA-ST-ARCH/ECMA-262,%203rd%20edition,%20December%201999.pdf\" hreflang=\"en\">ECMAScript 3rd Edition (ECMA-262)</a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/5.1/#sec-15.11.7.6\" hreflang=\"en\">ECMAScript 5.1 (ECMA-262)<br><small>The definition of 'NativeError.prototype' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Defined as <code><em>NativeError</em>.prototype</code>.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-nativeerror.prototype\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'NativeError.prototype' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Defined as <code><em>NativeError</em>.prototype</code>.</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-nativeerror.prototype\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'NativeError.prototype' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td>Defined as <code><em>NativeError</em>.prototype</code>.</td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>   <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/ReferenceError\">Basic support</a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/ReferenceError\">Basic support</a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/ReferenceError\">Basic support</a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div>  <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"../error/prototype\"><code>Error.prototype</code></a></li> <li><a href=\"../function/prototype\"><code>Function.prototype</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ReferenceError/prototype$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ReferenceError/prototype\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ReferenceError/prototype</a>\n  </p>\n</div>\n","global_objects/atomics/add":"<h1>Atomics.add</h1> <p>The static <code><strong>Atomics</strong></code><code>.add()</code> method adds a given value at a given position in the array and returns the old value at that position. This atomic operation guarantees that no other write happens until the modified value is written back.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/atomics-add.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\">Atomics.add(typedArray, index, value)\n</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><code>typedArray</code></dt> <dd>A shared integer typed array. One of <a href=\"../int8array\"><code>Int8Array</code></a>, <a href=\"../uint8array\"><code>Uint8Array</code></a>, <a href=\"../int16array\"><code>Int16Array</code></a>, <a href=\"../uint16array\"><code>Uint16Array</code></a>, <a href=\"../int32array\"><code>Int32Array</code></a>, or <a href=\"../uint32array\"><code>Uint32Array</code></a>.</dd> <dt><code>index</code></dt> <dd>The position in the <code>typedArray</code> to add a <code>value</code> to.</dd> <dt><code>value</code></dt> <dd>The number to add.</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p>The old value at the given position (<code>typedArray[index]</code>).</p> <h3 id=\"Exceptions\">Exceptions</h3> <ul> <li>Throws a <a href=\"../typeerror\"><code>TypeError</code></a>, if <code>typedArray</code> is not one of the allowed integer types.</li> <li>Throws a <a href=\"../typeerror\"><code>TypeError</code></a>, if <code>typedArray</code> is not a shared typed array type.</li> <li>Throws a <a href=\"../rangeerror\"><code>RangeError</code></a>, if <code>index</code> is out of bounds in the <code>typedArray</code>.</li> </ul> <h2 id=\"Examples\">Examples</h2> <pre data-language=\"js\">var sab = new SharedArrayBuffer(1024);\nvar ta = new Uint8Array(sab);\n\nAtomics.add(ta, 0, 12); // returns 0, the old value\nAtomics.load(ta, 0); // 12</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-atomics.add\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Atomics.add' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td>Initial definition in ES2017.</td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes bc-has-history\"> 68\n<section class=\"bc-history\" id=\"sect1\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 68\n</dt>\n\n<dt class=\"bc-supports-no bc-supports\">60 — 63\n</dt>\n<dd> Chrome disabled <code>SharedArrayBuffer</code> on January 5, 2018 to help reduce the efficacy of <a href=\"https://www.chromium.org/Home/chromium-security/ssca\">speculative side-channel attacks</a>. This was a temporary removal while mitigations were put in place.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-yes bc-has-history\"> 16\n<section class=\"bc-history\" id=\"sect2\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 16\n</dt>\n<dd> Support was removed to mitigate <a href=\"https://blogs.windows.com/msedgedev/2018/01/03/speculative-execution-mitigations-microsoft-edge-internet-explorer\">speculative execution side-channel attacks (Windows blog)</a>.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-yes bc-has-history\"> 57<div class=\"bc-icons\"> Disabled </div>\n<section class=\"bc-history\" id=\"sect3\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 57<div class=\"bc-icons\"> Disabled </div>\n</dt>\n<dd> Support was disabled by default to mitigate <a href=\"https://blog.mozilla.org/security/2018/01/03/mitigations-landing-new-class-timing-attack/\">speculative execution side-channel attacks (Mozilla Security Blog)</a>.</dd>\n<dd>Disabled From version 57: this feature is behind the <code>javascript.options.shared_memory</code> preference (needs to be set to <code>true</code>). To change preferences in Firefox, visit about:config.</dd>\n<dt class=\"bc-supports-no bc-supports\">55 — 57\n</dt>\n\n<dt class=\"bc-supports-no bc-supports\">46 — 55<div class=\"bc-icons\">Disabled </div>\n</dt>\n<dd>Disabled From version 46 until version 55 (exclusive): this feature is behind the <code>javascript.options.shared_memory</code> preference (needs to be set to <code>true</code>). To change preferences in Firefox, visit about:config.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\">10.1 — ?</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-no bc-has-history\">60 — 63\n<section class=\"bc-history\" id=\"sect4\"><dl>\n<dt class=\"bc-supports-no bc-supports\">60 — 63\n</dt>\n<dd> Chrome disabled <code>SharedArrayBuffer</code> on January 5, 2018 to help reduce the efficacy of <a href=\"https://www.chromium.org/Home/chromium-security/ssca\">speculative side-channel attacks</a>. This is intended as a temporary measure until other mitigations are in place.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-no bc-has-history\">60 — 63\n<section class=\"bc-history\" id=\"sect5\"><dl>\n<dt class=\"bc-supports-no bc-supports\">60 — 63\n</dt>\n<dd> Chrome disabled <code>SharedArrayBuffer</code> on January 5, 2018 to help reduce the efficacy of <a href=\"https://www.chromium.org/Home/chromium-security/ssca\">speculative side-channel attacks</a>. This is intended as a temporary measure until other mitigations are in place.</dd>\n</dl></section>\n</td>\n<td> ? </td>\n<td class=\"bc-supports-yes bc-has-history\"> 57<div class=\"bc-icons\"> Disabled </div>\n<section class=\"bc-history\" id=\"sect6\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 57<div class=\"bc-icons\"> Disabled </div>\n</dt>\n<dd> Support was disabled by default to mitigate <a href=\"https://blog.mozilla.org/security/2018/01/03/mitigations-landing-new-class-timing-attack/\">speculative execution side-channel attacks (Mozilla Security Blog)</a>.</dd>\n<dd>Disabled From version 57: this feature is behind the <code>javascript.options.shared_memory</code> preference (needs to be set to <code>true</code>). To change preferences in Firefox, visit about:config.</dd>\n<dt class=\"bc-supports-no bc-supports\">55 — 57\n</dt>\n\n<dt class=\"bc-supports-no bc-supports\">46 — 55<div class=\"bc-icons\">Disabled </div>\n</dt>\n<dd>Disabled From version 46 until version 55 (exclusive): this feature is behind the <code>javascript.options.shared_memory</code> preference (needs to be set to <code>true</code>). To change preferences in Firefox, visit about:config.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 8.10.0</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"../atomics\"><code>Atomics</code></a></li> <li><a href=\"sub\"><code>Atomics.sub()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics/add$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics/add\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics/add</a>\n  </p>\n</div>\n","global_objects/atomics/load":"<h1>Atomics.load</h1> <p>The static <code><strong>Atomics</strong></code><code>.load()</code> method returns a value at a given position in the array.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/atomics-load.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\">Atomics.load(typedArray, index)\n</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><code>typedArray</code></dt> <dd>A shared integer typed array. One of <a href=\"../int8array\"><code>Int8Array</code></a>, <a href=\"../uint8array\"><code>Uint8Array</code></a>, <a href=\"../int16array\"><code>Int16Array</code></a>, <a href=\"../uint16array\"><code>Uint16Array</code></a>, <a href=\"../int32array\"><code>Int32Array</code></a>, or <a href=\"../uint32array\"><code>Uint32Array</code></a>.</dd> <dt><code>index</code></dt> <dd>The position in the <code>typedArray</code> to load from<code>.</code>\n</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p>The value at the given position (<code>typedArray[index]</code>).</p> <h3 id=\"Exceptions\">Exceptions</h3> <ul> <li>Throws a <a href=\"../typeerror\"><code>TypeError</code></a>, if <code>typedArray</code> is not one of the allowed integer types.</li> <li>Throws a <a href=\"../typeerror\"><code>TypeError</code></a>, if <code>typedArray</code> is not a shared typed array type.</li> <li>Throws a <a href=\"../rangeerror\"><code>RangeError</code></a>, if <code>index</code> is out of bounds in the <code>typedArray</code>.</li> </ul> <h2 id=\"Examples\">Examples</h2> <pre data-language=\"js\">var sab = new SharedArrayBuffer(1024);\nvar ta = new Uint8Array(sab);\n\nAtomics.add(ta, 0, 12);\nAtomics.load(ta, 0); // 12</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-atomics.load\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Atomics.load' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td>Initial definition in ES2017.</td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes bc-has-history\"> 68\n<section class=\"bc-history\" id=\"sect1\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 68\n</dt>\n\n<dt class=\"bc-supports-no bc-supports\">60 — 63\n</dt>\n<dd> Chrome disabled <code>SharedArrayBuffer</code> on January 5, 2018 to help reduce the efficacy of <a href=\"https://www.chromium.org/Home/chromium-security/ssca\">speculative side-channel attacks</a>. This was a temporary removal while mitigations were put in place.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-yes bc-has-history\"> 16\n<section class=\"bc-history\" id=\"sect2\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 16\n</dt>\n<dd> Support was removed to mitigate <a href=\"https://blogs.windows.com/msedgedev/2018/01/03/speculative-execution-mitigations-microsoft-edge-internet-explorer\">speculative execution side-channel attacks (Windows blog)</a>.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-yes bc-has-history\"> 57<div class=\"bc-icons\"> Disabled </div>\n<section class=\"bc-history\" id=\"sect3\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 57<div class=\"bc-icons\"> Disabled </div>\n</dt>\n<dd> Support was disabled by default to mitigate <a href=\"https://blog.mozilla.org/security/2018/01/03/mitigations-landing-new-class-timing-attack/\">speculative execution side-channel attacks (Mozilla Security Blog)</a>.</dd>\n<dd>Disabled From version 57: this feature is behind the <code>javascript.options.shared_memory</code> preference (needs to be set to <code>true</code>). To change preferences in Firefox, visit about:config.</dd>\n<dt class=\"bc-supports-no bc-supports\">55 — 57\n</dt>\n\n<dt class=\"bc-supports-no bc-supports\">46 — 55<div class=\"bc-icons\">Disabled </div>\n</dt>\n<dd>Disabled From version 46 until version 55 (exclusive): this feature is behind the <code>javascript.options.shared_memory</code> preference (needs to be set to <code>true</code>). To change preferences in Firefox, visit about:config.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\">10.1 — ?</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-no bc-has-history\">60 — 63\n<section class=\"bc-history\" id=\"sect4\"><dl>\n<dt class=\"bc-supports-no bc-supports\">60 — 63\n</dt>\n<dd> Chrome disabled <code>SharedArrayBuffer</code> on January 5, 2018 to help reduce the efficacy of <a href=\"https://www.chromium.org/Home/chromium-security/ssca\">speculative side-channel attacks</a>. This is intended as a temporary measure until other mitigations are in place.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-no bc-has-history\">60 — 63\n<section class=\"bc-history\" id=\"sect5\"><dl>\n<dt class=\"bc-supports-no bc-supports\">60 — 63\n</dt>\n<dd> Chrome disabled SharedArrayBuffer on January 5, 2018 to help reduce the efficacy of <a href=\"https://www.chromium.org/Home/chromium-security/ssca\">speculative side-channel attacks</a>. This is intended as a temporary measure until other mitigations are in place.</dd>\n</dl></section>\n</td>\n<td> ? </td>\n<td class=\"bc-supports-yes bc-has-history\"> 57<div class=\"bc-icons\"> Disabled </div>\n<section class=\"bc-history\" id=\"sect6\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 57<div class=\"bc-icons\"> Disabled </div>\n</dt>\n<dd> Support was disabled by default to mitigate <a href=\"https://blog.mozilla.org/security/2018/01/03/mitigations-landing-new-class-timing-attack/\">speculative execution side-channel attacks (Mozilla Security Blog)</a>.</dd>\n<dd>Disabled From version 57: this feature is behind the <code>javascript.options.shared_memory</code> preference (needs to be set to <code>true</code>). To change preferences in Firefox, visit about:config.</dd>\n<dt class=\"bc-supports-no bc-supports\">55 — 57\n</dt>\n\n<dt class=\"bc-supports-no bc-supports\">46 — 55<div class=\"bc-icons\">Disabled </div>\n</dt>\n<dd>Disabled From version 46 until version 55 (exclusive): this feature is behind the <code>javascript.options.shared_memory</code> preference (needs to be set to <code>true</code>). To change preferences in Firefox, visit about:config.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 8.10.0</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"../atomics\"><code>Atomics</code></a></li> <li><a href=\"store\"><code>Atomics.store()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics/load$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics/load\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics/load</a>\n  </p>\n</div>\n","global_objects/number/nan":"<h1>Number.NaN</h1> <p>The <code>Number.NaN</code> property represents Not-A-Number. Equivalent of <a href=\"../nan\"><code>NaN</code></a>.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/number-nan.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe> <p>You do not have to create a <a href=\"../number\"><code>Number</code></a> object to access this static property (use <code>Number.NaN</code>).</p> <div class=\"_table\"><table class=\"standard-table\"> <thead> <tr> <th colspan=\"2\" class=\"header\">Property attributes of <code>Number.NaN</code>\n</th> </tr> </thead> <tbody> <tr> <td>Writable</td> <td>no</td> </tr> <tr> <td>Enumerable</td> <td>no</td> </tr> <tr> <td>Configurable</td> <td>no</td> </tr> </tbody> </table></div> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/publications/files/ECMA-ST-ARCH/ECMA-262,%201st%20edition,%20June%201997.pdf\" hreflang=\"en\">ECMAScript 1st Edition (ECMA-262)</a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition. Implemented in JavaScript 1.1.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/5.1/#sec-15.7.3.4\" hreflang=\"en\">ECMAScript 5.1 (ECMA-262)<br><small>The definition of 'Number.NaN' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-number.nan\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Number.NaN' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-number.nan\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Number.NaN' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li>The global <a href=\"../nan\"><code>NaN</code></a> object.</li> <li>The <a href=\"../number\"><code>Number</code></a> object it belongs to.</li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/NaN$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/NaN\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/NaN</a>\n  </p>\n</div>\n","global_objects/atomics/and":"<h1>Atomics.and</h1> <p>The static <code><strong>Atomics</strong></code><code>.and()</code> method computes a bitwise AND with a given value at a given position in the array, and returns the old value at that position. This atomic operation guarantees that no other write happens until the modified value is written back.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/atomics-and.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\">Atomics.and(typedArray, index, value)\n</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><code>typedArray</code></dt> <dd>A shared integer typed array. One of <a href=\"../int8array\"><code>Int8Array</code></a>, <a href=\"../uint8array\"><code>Uint8Array</code></a>, <a href=\"../int16array\"><code>Int16Array</code></a>, <a href=\"../uint16array\"><code>Uint16Array</code></a>, <a href=\"../int32array\"><code>Int32Array</code></a>, or <a href=\"../uint32array\"><code>Uint32Array</code></a>.</dd> <dt><code>index</code></dt> <dd>The position in the <code>typedArray</code> to compute the bitwise AND.</dd> <dt><code>value</code></dt> <dd>The number to compute the bitwise AND with.</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p>The old value at the given position (<code>typedArray[index]</code>).</p> <h3 id=\"Exceptions\">Exceptions</h3> <ul> <li>Throws a <a href=\"../typeerror\"><code>TypeError</code></a>, if <code>typedArray</code> is not one of the allowed integer types.</li> <li>Throws a <a href=\"../typeerror\"><code>TypeError</code></a>, if <code>typedArray</code> is not a shared typed array type.</li> <li>Throws a <a href=\"../rangeerror\"><code>RangeError</code></a>, if <code>index</code> is out of bounds in the <code>typedArray</code>.</li> </ul> <h2 id=\"Description\">Description</h2> <p>The bitwise AND operation only yields 1, if both <code>a</code> and <code>b</code> are 1. The truth table for the AND operation is:</p> <div class=\"_table\"><table class=\"standard-table\"> <thead> <tr> <th><code>a</code></th> <th><code>b</code></th> <th><code>a &amp; b</code></th> </tr> </thead> <tbody> <tr> <td>0</td> <td>0</td> <td>0</td> </tr> <tr> <td>0</td> <td>1</td> <td>0</td> </tr> <tr> <td>1</td> <td>0</td> <td>0</td> </tr> <tr> <td>1</td> <td>1</td> <td>1</td> </tr> </tbody> </table></div> <p>For example, a bitwise AND of <code>5 &amp; 1</code> results in <code>0001</code> which is 1 in decimal.</p> <pre>5  0101\n1  0001\n   ----\n1  0001</pre> <h2 id=\"Examples\">Examples</h2> <pre data-language=\"js\">var sab = new SharedArrayBuffer(1024);\nvar ta = new Uint8Array(sab);\nta[0] = 5;\n\nAtomics.and(ta, 0, 1); // returns 0, the old value\nAtomics.load(ta, 0);  // 1\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-atomics.and\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Atomics.and' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td>Initial definition in ES2017.</td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes bc-has-history\"> 68\n<section class=\"bc-history\" id=\"sect1\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 68\n</dt>\n\n<dt class=\"bc-supports-no bc-supports\">60 — 63\n</dt>\n<dd> Chrome disabled <code>SharedArrayBuffer</code> on January 5, 2018 to help reduce the efficacy of <a href=\"https://www.chromium.org/Home/chromium-security/ssca\">speculative side-channel attacks</a>. This was a temporary removal while mitigations were put in place.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-yes bc-has-history\"> 16\n<section class=\"bc-history\" id=\"sect2\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 16\n</dt>\n<dd> Support was removed to mitigate <a href=\"https://blogs.windows.com/msedgedev/2018/01/03/speculative-execution-mitigations-microsoft-edge-internet-explorer\">speculative execution side-channel attacks (Windows blog)</a>.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-yes bc-has-history\"> 57<div class=\"bc-icons\"> Disabled </div>\n<section class=\"bc-history\" id=\"sect3\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 57<div class=\"bc-icons\"> Disabled </div>\n</dt>\n<dd> Support was disabled by default to mitigate <a href=\"https://blog.mozilla.org/security/2018/01/03/mitigations-landing-new-class-timing-attack/\">speculative execution side-channel attacks (Mozilla Security Blog)</a>.</dd>\n<dd>Disabled From version 57: this feature is behind the <code>javascript.options.shared_memory</code> preference (needs to be set to <code>true</code>). To change preferences in Firefox, visit about:config.</dd>\n<dt class=\"bc-supports-no bc-supports\">55 — 57\n</dt>\n\n<dt class=\"bc-supports-no bc-supports\">46 — 55<div class=\"bc-icons\">Disabled </div>\n</dt>\n<dd>Disabled From version 46 until version 55 (exclusive): this feature is behind the <code>javascript.options.shared_memory</code> preference (needs to be set to <code>true</code>). To change preferences in Firefox, visit about:config.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\">10.1 — ?</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-no bc-has-history\">60 — 63\n<section class=\"bc-history\" id=\"sect4\"><dl>\n<dt class=\"bc-supports-no bc-supports\">60 — 63\n</dt>\n<dd> Chrome disabled <code>SharedArrayBuffer</code> on January 5, 2018 to help reduce the efficacy of <a href=\"https://www.chromium.org/Home/chromium-security/ssca\">speculative side-channel attacks</a>. This is intended as a temporary measure until other mitigations are in place.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-no bc-has-history\">60 — 63\n<section class=\"bc-history\" id=\"sect5\"><dl>\n<dt class=\"bc-supports-no bc-supports\">60 — 63\n</dt>\n<dd> Chrome disabled <code>SharedArrayBuffer</code> on January 5, 2018 to help reduce the efficacy of <a href=\"https://www.chromium.org/Home/chromium-security/ssca\">speculative side-channel attacks</a>. This is intended as a temporary measure until other mitigations are in place.</dd>\n</dl></section>\n</td>\n<td> ? </td>\n<td class=\"bc-supports-yes bc-has-history\"> 57<div class=\"bc-icons\"> Disabled </div>\n<section class=\"bc-history\" id=\"sect6\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 57<div class=\"bc-icons\"> Disabled </div>\n</dt>\n<dd> Support was disabled by default to mitigate <a href=\"https://blog.mozilla.org/security/2018/01/03/mitigations-landing-new-class-timing-attack/\">speculative execution side-channel attacks (Mozilla Security Blog)</a>.</dd>\n<dd>Disabled From version 57: this feature is behind the <code>javascript.options.shared_memory</code> preference (needs to be set to <code>true</code>). To change preferences in Firefox, visit about:config.</dd>\n<dt class=\"bc-supports-no bc-supports\">55 — 57\n</dt>\n\n<dt class=\"bc-supports-no bc-supports\">46 — 55<div class=\"bc-icons\">Disabled </div>\n</dt>\n<dd>Disabled From version 46 until version 55 (exclusive): this feature is behind the <code>javascript.options.shared_memory</code> preference (needs to be set to <code>true</code>). To change preferences in Firefox, visit about:config.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 8.10.0</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"../atomics\"><code>Atomics</code></a></li> <li><a href=\"or\"><code>Atomics.or()</code></a></li> <li><a href=\"xor\"><code>Atomics.xor()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics/and$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics/and\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics/and</a>\n  </p>\n</div>\n","global_objects/atomics/compareexchange":"<h1>Atomics.compareExchange</h1> <p>The static <code><strong>Atomics</strong></code><code>.compareExchange()</code> method exchanges a given replacement value at a given position in the array, if a given expected value equals the old value. It returns the old value at that position whether it was equal to the expected value or not. This atomic operation guarantees that no other write happens until the modified value is written back.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/atomics-compareexchange.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\">Atomics.compareExchange(typedArray, index, expectedValue, replacementValue)\n</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><code>typedArray</code></dt> <dd>A shared integer typed array. One of <a href=\"../int8array\"><code>Int8Array</code></a>, <a href=\"../uint8array\"><code>Uint8Array</code></a>, <a href=\"../int16array\"><code>Int16Array</code></a>, <a href=\"../uint16array\"><code>Uint16Array</code></a>, <a href=\"../int32array\"><code>Int32Array</code></a>, or <a href=\"../uint32array\"><code>Uint32Array</code></a>.</dd> <dt><code>index</code></dt> <dd>The position in the <code>typedArray</code> to exchange a <code>value</code>.</dd> <dt><code>expectedValue</code></dt> <dd>The value to check for equality.</dd> <dt>replacementValue</dt> <dd>The number to exchange.</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p>The old value at the given position (<code>typedArray[index]</code>).</p> <h3 id=\"Exceptions\">Exceptions</h3> <ul> <li>Throws a <a href=\"../typeerror\"><code>TypeError</code></a>, if <code>typedArray</code> is not one of the allowed integer types.</li> <li>Throws a <a href=\"../typeerror\"><code>TypeError</code></a>, if <code>typedArray</code> is not a shared typed array type.</li> <li>Throws a <a href=\"../rangeerror\"><code>RangeError</code></a>, if <code>index</code> is out of bounds in the <code>typedArray</code>.</li> </ul> <h2 id=\"Examples\">Examples</h2> <pre data-language=\"js\">var sab = new SharedArrayBuffer(1024);\nvar ta = new Uint8Array(sab);\nta[0] = 7;\n\nAtomics.compareExchange(ta, 0, 7, 12); // returns 7, the old value\nAtomics.load(ta, 0); // 12</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-atomics.compareexchange\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Atomics.compareExchange' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td>Initial definition in ES2017.</td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes bc-has-history\"> 68\n<section class=\"bc-history\" id=\"sect1\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 68\n</dt>\n\n<dt class=\"bc-supports-no bc-supports\">60 — 63\n</dt>\n<dd> Chrome disabled <code>SharedArrayBuffer</code> on January 5, 2018 to help reduce the efficacy of <a href=\"https://www.chromium.org/Home/chromium-security/ssca\">speculative side-channel attacks</a>. This was a temporary removal while mitigations were put in place.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-yes bc-has-history\"> 16\n<section class=\"bc-history\" id=\"sect2\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 16\n</dt>\n<dd> Support was removed to mitigate <a href=\"https://blogs.windows.com/msedgedev/2018/01/03/speculative-execution-mitigations-microsoft-edge-internet-explorer\">speculative execution side-channel attacks (Windows blog)</a>.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-yes bc-has-history\"> 57<div class=\"bc-icons\"> Disabled </div>\n<section class=\"bc-history\" id=\"sect3\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 57<div class=\"bc-icons\"> Disabled </div>\n</dt>\n<dd> Support was disabled by default to mitigate <a href=\"https://blog.mozilla.org/security/2018/01/03/mitigations-landing-new-class-timing-attack/\">speculative execution side-channel attacks (Mozilla Security Blog)</a>.</dd>\n<dd>Disabled From version 57: this feature is behind the <code>javascript.options.shared_memory</code> preference (needs to be set to <code>true</code>). To change preferences in Firefox, visit about:config.</dd>\n<dt class=\"bc-supports-no bc-supports\">55 — 57\n</dt>\n\n<dt class=\"bc-supports-no bc-supports\">46 — 55<div class=\"bc-icons\">Disabled </div>\n</dt>\n<dd>Disabled From version 46 until version 55 (exclusive): this feature is behind the <code>javascript.options.shared_memory</code> preference (needs to be set to <code>true</code>). To change preferences in Firefox, visit about:config.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\">10.1 — ?</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-no bc-has-history\">60 — 63\n<section class=\"bc-history\" id=\"sect4\"><dl>\n<dt class=\"bc-supports-no bc-supports\">60 — 63\n</dt>\n<dd> Chrome disabled <code>SharedArrayBuffer</code> on January 5, 2018 to help reduce the efficacy of <a href=\"https://www.chromium.org/Home/chromium-security/ssca\">speculative side-channel attacks</a>. This is intended as a temporary measure until other mitigations are in place.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-no bc-has-history\">60 — 63\n<section class=\"bc-history\" id=\"sect5\"><dl>\n<dt class=\"bc-supports-no bc-supports\">60 — 63\n</dt>\n<dd> Chrome disabled <code>SharedArrayBuffer</code> on January 5, 2018 to help reduce the efficacy of <a href=\"https://www.chromium.org/Home/chromium-security/ssca\">speculative side-channel attacks</a>. This is intended as a temporary measure until other mitigations are in place.</dd>\n</dl></section>\n</td>\n<td> ? </td>\n<td class=\"bc-supports-yes bc-has-history\"> 57<div class=\"bc-icons\"> Disabled </div>\n<section class=\"bc-history\" id=\"sect6\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 57<div class=\"bc-icons\"> Disabled </div>\n</dt>\n<dd> Support was disabled by default to mitigate <a href=\"https://blog.mozilla.org/security/2018/01/03/mitigations-landing-new-class-timing-attack/\">speculative execution side-channel attacks (Mozilla Security Blog)</a>.</dd>\n<dd>Disabled From version 57: this feature is behind the <code>javascript.options.shared_memory</code> preference (needs to be set to <code>true</code>). To change preferences in Firefox, visit about:config.</dd>\n<dt class=\"bc-supports-no bc-supports\">55 — 57\n</dt>\n\n<dt class=\"bc-supports-no bc-supports\">46 — 55<div class=\"bc-icons\">Disabled </div>\n</dt>\n<dd>Disabled From version 46 until version 55 (exclusive): this feature is behind the <code>javascript.options.shared_memory</code> preference (needs to be set to <code>true</code>). To change preferences in Firefox, visit about:config.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 8.10.0</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"../atomics\"><code>Atomics</code></a></li> <li><a href=\"exchange\"><code>Atomics.exchange()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics/compareExchange$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics/compareExchange\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics/compareExchange</a>\n  </p>\n</div>\n","global_objects/atomics/sub":"<h1>Atomics.sub</h1> <p>The static <code><strong>Atomics</strong></code><code>.sub()</code> method substracts a given value at a given position in the array and returns the old value at that position. This atomic operation guarantees that no other write happens until the modified value is written back.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/atomics-sub.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\">Atomics.sub(typedArray, index, value)\n</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><code>typedArray</code></dt> <dd>A shared integer typed array. One of <a href=\"../int8array\"><code>Int8Array</code></a>, <a href=\"../uint8array\"><code>Uint8Array</code></a>, <a href=\"../int16array\"><code>Int16Array</code></a>, <a href=\"../uint16array\"><code>Uint16Array</code></a>, <a href=\"../int32array\"><code>Int32Array</code></a>, or <a href=\"../uint32array\"><code>Uint32Array</code></a>.</dd> <dt><code>index</code></dt> <dd>The position in the <code>typedArray</code> to subtract a <code>value</code> from.</dd> <dt><code>value</code></dt> <dd>The number to subtract.</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p>The old value at the given position (<code>typedArray[index]</code>).</p> <h3 id=\"Exceptions\">Exceptions</h3> <ul> <li>Throws a <a href=\"../typeerror\"><code>TypeError</code></a>, if <code>typedArray</code> is not one of the allowed integer types.</li> <li>Throws a <a href=\"../typeerror\"><code>TypeError</code></a>, if <code>typedArray</code> is not a shared typed array type.</li> <li>Throws a <a href=\"../rangeerror\"><code>RangeError</code></a>, if <code>index</code> is out of bounds in the <code>typedArray</code>.</li> </ul> <h2 id=\"Examples\">Examples</h2> <pre data-language=\"js\">var sab = new SharedArrayBuffer(1024);\nvar ta = new Uint8Array(sab);\nta[0] = 48;\n\nAtomics.sub(ta, 0, 12); // returns 48, the old value\nAtomics.load(ta, 0); // 36\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-atomics.sub\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Atomics.sub' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td>Initial definition in ES2017.</td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes bc-has-history\"> 68\n<section class=\"bc-history\" id=\"sect1\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 68\n</dt>\n\n<dt class=\"bc-supports-no bc-supports\">60 — 63\n</dt>\n<dd> Chrome disabled <code>SharedArrayBuffer</code> on January 5, 2018 to help reduce the efficacy of <a href=\"https://www.chromium.org/Home/chromium-security/ssca\">speculative side-channel attacks</a>. This was a temporary removal while mitigations were put in place.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-yes bc-has-history\"> 16\n<section class=\"bc-history\" id=\"sect2\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 16\n</dt>\n<dd> Support was removed to mitigate <a href=\"https://blogs.windows.com/msedgedev/2018/01/03/speculative-execution-mitigations-microsoft-edge-internet-explorer\">speculative execution side-channel attacks (Windows blog)</a>.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-yes bc-has-history\"> 57<div class=\"bc-icons\"> Disabled </div>\n<section class=\"bc-history\" id=\"sect3\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 57<div class=\"bc-icons\"> Disabled </div>\n</dt>\n<dd> Support was disabled by default to mitigate <a href=\"https://blog.mozilla.org/security/2018/01/03/mitigations-landing-new-class-timing-attack/\">speculative execution side-channel attacks (Mozilla Security Blog)</a>.</dd>\n<dd>Disabled From version 57: this feature is behind the <code>javascript.options.shared_memory</code> preference (needs to be set to <code>true</code>). To change preferences in Firefox, visit about:config.</dd>\n<dt class=\"bc-supports-no bc-supports\">55 — 57\n</dt>\n\n<dt class=\"bc-supports-no bc-supports\">46 — 55<div class=\"bc-icons\">Disabled </div>\n</dt>\n<dd>Disabled From version 46 until version 55 (exclusive): this feature is behind the <code>javascript.options.shared_memory</code> preference (needs to be set to <code>true</code>). To change preferences in Firefox, visit about:config.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\">10.1 — ?</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-no bc-has-history\">60 — 63\n<section class=\"bc-history\" id=\"sect4\"><dl>\n<dt class=\"bc-supports-no bc-supports\">60 — 63\n</dt>\n<dd> Chrome disabled <code>SharedArrayBuffer</code> on January 5, 2018 to help reduce the efficacy of <a href=\"https://www.chromium.org/Home/chromium-security/ssca\">speculative side-channel attacks</a>. This is intended as a temporary measure until other mitigations are in place.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-no bc-has-history\">60 — 63\n<section class=\"bc-history\" id=\"sect5\"><dl>\n<dt class=\"bc-supports-no bc-supports\">60 — 63\n</dt>\n<dd> Chrome disabled SharedArrayBuffer on January 5, 2018 to help reduce the efficacy of <a href=\"https://www.chromium.org/Home/chromium-security/ssca\">speculative side-channel attacks</a>. This is intended as a temporary measure until other mitigations are in place.</dd>\n</dl></section>\n</td>\n<td> ? </td>\n<td class=\"bc-supports-yes bc-has-history\"> 57<div class=\"bc-icons\"> Disabled </div>\n<section class=\"bc-history\" id=\"sect6\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 57<div class=\"bc-icons\"> Disabled </div>\n</dt>\n<dd> Support was disabled by default to mitigate <a href=\"https://blog.mozilla.org/security/2018/01/03/mitigations-landing-new-class-timing-attack/\">speculative execution side-channel attacks (Mozilla Security Blog)</a>.</dd>\n<dd>Disabled From version 57: this feature is behind the <code>javascript.options.shared_memory</code> preference (needs to be set to <code>true</code>). To change preferences in Firefox, visit about:config.</dd>\n<dt class=\"bc-supports-no bc-supports\">55 — 57\n</dt>\n\n<dt class=\"bc-supports-no bc-supports\">46 — 55<div class=\"bc-icons\">Disabled </div>\n</dt>\n<dd>Disabled From version 46 until version 55 (exclusive): this feature is behind the <code>javascript.options.shared_memory</code> preference (needs to be set to <code>true</code>). To change preferences in Firefox, visit about:config.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 8.10.0</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"../atomics\"><code>Atomics</code></a></li> <li><a href=\"add\"><code>Atomics.add()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics/sub$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics/sub\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics/sub</a>\n  </p>\n</div>\n","global_objects/map/@@tostringtag":"<h1>map.@@toStringTag</h1> <p>The <code>Map[@@toStringTag]</code> property has an initial value of \"Map\".</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/map-prototype-@@tostringtag.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <div class=\"_table\"><table class=\"standard-table\"> <thead> <tr> <th colspan=\"2\" class=\"header\">Property attributes of <code>Map.prototype[@@toStringTag]</code>\n</th> </tr> </thead> <tbody> <tr> <td>Writable</td> <td>no</td> </tr> <tr> <td>Enumerable</td> <td>no</td> </tr> <tr> <td>Configurable</td> <td>yes</td> </tr> </tbody> </table></div> <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\">Map[Symbol.toStringTag]</pre> <h2 id=\"Example\">Example</h2> <pre data-language=\"js\">Object.prototype.toString.call(new Map()) // \"[object Map]\"\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-map.prototype-@@tostringtag\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Map.prototype[@@toStringTag]' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-map.prototype-@@tostringtag\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Map.prototype[@@toStringTag]' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 44</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 44</td>\n<td class=\"bc-supports-yes\"> 44</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 4.0</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-no\"> No</td>\n</tr></tbody>\n</table>\n</div><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/@@toStringTag$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/@@toStringTag\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/@@toStringTag</a>\n  </p>\n</div>\n","global_objects/atomics/store":"<h1>Atomics.store</h1> <p>The static <code><strong>Atomics</strong></code><code>.store()</code> method stores a given value at the given position in the array and returns that value.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/atomics-store.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\">Atomics.store(typedArray, index, value)\n</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><code>typedArray</code></dt> <dd>A shared integer typed array. One of <a href=\"../int8array\"><code>Int8Array</code></a>, <a href=\"../uint8array\"><code>Uint8Array</code></a>, <a href=\"../int16array\"><code>Int16Array</code></a>, <a href=\"../uint16array\"><code>Uint16Array</code></a>, <a href=\"../int32array\"><code>Int32Array</code></a>, or <a href=\"../uint32array\"><code>Uint32Array</code></a>.</dd> <dt><code>index</code></dt> <dd>The position in the <code>typedArray</code> to store a <code>value</code> in.</dd> <dt><code>value</code></dt> <dd>The number to store.</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p>The value that has been stored.</p> <h3 id=\"Exceptions\">Exceptions</h3> <ul> <li>Throws a <a href=\"../typeerror\"><code>TypeError</code></a>, if <code>typedArray</code> is not one of the allowed integer types.</li> <li>Throws a <a href=\"../typeerror\"><code>TypeError</code></a>, if <code>typedArray</code> is not a shared typed array type.</li> <li>Throws a <a href=\"../rangeerror\"><code>RangeError</code></a>, if <code>index</code> is out of bounds in the <code>typedArray</code>.</li> </ul> <h2 id=\"Examples\">Examples</h2> <pre data-language=\"js\">var buffer = new ArrayBuffer(4);         // common buffer\nvar float32 = new Float32Array(buffer);  // floating point\nvar uint32 = new Uint32Array(buffer);    // IEEE754 representation\n\nfloat32[0] = 0.5;\nconsole.log(\"0x\" + uint32[0].toString(16));\n\nuint32[0] = 0x3f000000;   /// IEEE754 32-bit representation of 0.5\nconsole.log(float32[0]);\n\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-atomics.store\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Atomics.store' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td>Initial definition in ES2017.</td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes bc-has-history\"> 68\n<section class=\"bc-history\" id=\"sect1\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 68\n</dt>\n\n<dt class=\"bc-supports-no bc-supports\">60 — 63\n</dt>\n<dd> Chrome disabled <code>SharedArrayBuffer</code> on January 5, 2018 to help reduce the efficacy of <a href=\"https://www.chromium.org/Home/chromium-security/ssca\">speculative side-channel attacks</a>. This was a temporary removal while mitigations were put in place.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-yes bc-has-history\"> 16\n<section class=\"bc-history\" id=\"sect2\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 16\n</dt>\n<dd> Support was removed to mitigate <a href=\"https://blogs.windows.com/msedgedev/2018/01/03/speculative-execution-mitigations-microsoft-edge-internet-explorer\">speculative execution side-channel attacks (Windows blog)</a>.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-yes bc-has-history\"> 57<div class=\"bc-icons\"> Disabled </div>\n<section class=\"bc-history\" id=\"sect3\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 57<div class=\"bc-icons\"> Disabled </div>\n</dt>\n<dd> Support was disabled by default to mitigate <a href=\"https://blog.mozilla.org/security/2018/01/03/mitigations-landing-new-class-timing-attack/\">speculative execution side-channel attacks (Mozilla Security Blog)</a>.</dd>\n<dd>Disabled From version 57: this feature is behind the <code>javascript.options.shared_memory</code> preference (needs to be set to <code>true</code>). To change preferences in Firefox, visit about:config.</dd>\n<dt class=\"bc-supports-no bc-supports\">55 — 57\n</dt>\n\n<dt class=\"bc-supports-no bc-supports\">46 — 55<div class=\"bc-icons\">Disabled </div>\n</dt>\n<dd>Disabled From version 46 until version 55 (exclusive): this feature is behind the <code>javascript.options.shared_memory</code> preference (needs to be set to <code>true</code>). To change preferences in Firefox, visit about:config.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\">10.1 — ?</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-no bc-has-history\">60 — 63\n<section class=\"bc-history\" id=\"sect4\"><dl>\n<dt class=\"bc-supports-no bc-supports\">60 — 63\n</dt>\n<dd> Chrome disabled <code>SharedArrayBuffer</code> on January 5, 2018 to help reduce the efficacy of <a href=\"https://www.chromium.org/Home/chromium-security/ssca\">speculative side-channel attacks</a>. This is intended as a temporary measure until other mitigations are in place.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-no bc-has-history\">60 — 63\n<section class=\"bc-history\" id=\"sect5\"><dl>\n<dt class=\"bc-supports-no bc-supports\">60 — 63\n</dt>\n<dd> Chrome disabled <code>SharedArrayBuffer</code> on January 5, 2018 to help reduce the efficacy of <a href=\"https://www.chromium.org/Home/chromium-security/ssca\">speculative side-channel attacks</a>. This is intended as a temporary measure until other mitigations are in place.</dd>\n</dl></section>\n</td>\n<td> ? </td>\n<td class=\"bc-supports-yes bc-has-history\"> 57<div class=\"bc-icons\"> Disabled </div>\n<section class=\"bc-history\" id=\"sect6\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 57<div class=\"bc-icons\"> Disabled </div>\n</dt>\n<dd> Support was disabled by default to mitigate <a href=\"https://blog.mozilla.org/security/2018/01/03/mitigations-landing-new-class-timing-attack/\">speculative execution side-channel attacks (Mozilla Security Blog)</a>.</dd>\n<dd>Disabled From version 57: this feature is behind the <code>javascript.options.shared_memory</code> preference (needs to be set to <code>true</code>). To change preferences in Firefox, visit about:config.</dd>\n<dt class=\"bc-supports-no bc-supports\">55 — 57\n</dt>\n\n<dt class=\"bc-supports-no bc-supports\">46 — 55<div class=\"bc-icons\">Disabled </div>\n</dt>\n<dd>Disabled From version 46 until version 55 (exclusive): this feature is behind the <code>javascript.options.shared_memory</code> preference (needs to be set to <code>true</code>). To change preferences in Firefox, visit about:config.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 8.10.0</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"../atomics\"><code>Atomics</code></a></li> <li><a href=\"load\"><code>Atomics.load()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics/store$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics/store\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics/store</a>\n  </p>\n</div>\n","global_objects/atomics/wait":"<h1>Atomics.wait</h1> <p>The static <code><strong>Atomics</strong></code><code>.wait()</code> method verifies that a given position in an <a href=\"../int32array\"><code>Int32Array</code></a> still contains a given value and if so sleeps, awaiting a wakeup or a timeout. It returns a string which is either <code>\"ok\"</code>, <code>\"not-equal\"</code>, or <code>\"timed-out\"</code>.</p> <div class=\"note\"> <p><strong>Note:</strong> This operation only works with a shared <a href=\"../int32array\"><code>Int32Array</code></a> and may not be allowed on the main thread.</p> </div> <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\">Atomics.wait(typedArray, index, value[, timeout])\n</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><code>typedArray</code></dt> <dd>A shared <a href=\"../int32array\"><code>Int32Array</code></a>.</dd> <dt><code>index</code></dt> <dd>The position in the <code>typedArray</code> to wait on.</dd> <dt><code>value</code></dt> <dd>The expected value to test .</dd> <dt>\n<code>timeout</code> <span class=\"inlineIndicator optional optionalInline\">Optional</span>\n</dt> <dd>Time to wait in milliseconds. <a href=\"../infinity\"><code>Infinity</code></a>, if no time is provided.</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p>A <a href=\"../string\"><code>String</code></a> which is either \"<code>ok</code>\", \"<code>not-equal</code>\", or \"<code>timed-out</code>\".</p> <h3 id=\"Exceptions\">Exceptions</h3> <ul> <li>Throws a <a href=\"../typeerror\"><code>TypeError</code></a>, if <code>typedArray</code> is not a shared <a href=\"../int32array\"><code>Int32Array</code></a>.</li> <li>Throws a <a href=\"../rangeerror\"><code>RangeError</code></a>, if <code>index</code> is out of bounds in the <code>typedArray</code>.</li> </ul> <h2 id=\"Examples\">Examples</h2> <p>Given a shared <code>Int32Array</code>:</p> <pre data-language=\"js\">var sab = new SharedArrayBuffer(1024);\nvar int32 = new Int32Array(sab);\n</pre> <p>A reading thread is sleeping and waiting on location 0 which is expected to be 0. As long as that is true, it will not go on. However, once the writing thread has stored a new value, it will be woken up by the writing thread and return the new value (123).</p> <pre data-language=\"js\">Atomics.wait(int32, 0, 0);\nconsole.log(int32[0]); // 123</pre> <p>A writing thread stores a new value and wakes up the waiting thread once it has written:</p> <pre data-language=\"js\">console.log(int32[0]); // 0;\nAtomics.store(int32, 0, 123); \nAtomics.wake(int32, 0, 1);</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-atomics.wait\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Atomics.wait' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td>Initial definition in ES2017.</td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes bc-has-history\"> 68\n<section class=\"bc-history\" id=\"sect1\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 68\n</dt>\n\n<dt class=\"bc-supports-no bc-supports\">60 — 63\n</dt>\n<dd> Chrome disabled <code>SharedArrayBuffer</code> on January 5, 2018 to help reduce the efficacy of <a href=\"https://www.chromium.org/Home/chromium-security/ssca\">speculative side-channel attacks</a>. This was a temporary removal while mitigations were put in place.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-yes bc-has-history\"> 16\n<section class=\"bc-history\" id=\"sect2\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 16\n</dt>\n<dd> Support was removed to mitigate <a href=\"https://blogs.windows.com/msedgedev/2018/01/03/speculative-execution-mitigations-microsoft-edge-internet-explorer\">speculative execution side-channel attacks (Windows blog)</a>.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-yes bc-has-history\"> 57<div class=\"bc-icons\"> Disabled </div>\n<section class=\"bc-history\" id=\"sect3\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 57<div class=\"bc-icons\"> Disabled </div>\n</dt>\n<dd> Support was disabled by default to mitigate <a href=\"https://blog.mozilla.org/security/2018/01/03/mitigations-landing-new-class-timing-attack/\">speculative execution side-channel attacks (Mozilla Security Blog)</a>.</dd>\n<dd>Disabled From version 57: this feature is behind the <code>javascript.options.shared_memory</code> preference (needs to be set to <code>true</code>). To change preferences in Firefox, visit about:config.</dd>\n<dt class=\"bc-supports-no bc-supports\">55 — 57\n</dt>\n\n<dt class=\"bc-supports-no bc-supports\">48 — 55<div class=\"bc-icons\">Disabled </div>\n</dt>\n<dd>Disabled From version 48 until version 55 (exclusive): this feature is behind the <code>javascript.options.shared_memory</code> preference (needs to be set to <code>true</code>). To change preferences in Firefox, visit about:config.</dd>\n<dt class=\"bc-supports-no bc-supports\">46 — 48<div class=\"bc-icons\">  Disabled </div>\n</dt>\n<dd> The method returns values <code>Atomics.OK</code>, <code>Atomics.TIMEDOUT</code>, and <code>Atomics.NOTEQUAL</code>, instead of the later-specified strings.</dd>\n<dd> Uses the non-standard name: <code>futexWait</code>\n</dd>\n<dd>Disabled From version 46 until version 48 (exclusive): this feature is behind the <code>javascript.options.shared_memory</code> preference (needs to be set to <code>true</code>). To change preferences in Firefox, visit about:config.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\">10.1 — ?</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-no bc-has-history\">60 — 63\n<section class=\"bc-history\" id=\"sect4\"><dl>\n<dt class=\"bc-supports-no bc-supports\">60 — 63\n</dt>\n<dd> Chrome disabled <code>SharedArrayBuffer</code> on January 5, 2018 to help reduce the efficacy of <a href=\"https://www.chromium.org/Home/chromium-security/ssca\">speculative side-channel attacks</a>. This is intended as a temporary measure until other mitigations are in place.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-no bc-has-history\">60 — 63\n<section class=\"bc-history\" id=\"sect5\"><dl>\n<dt class=\"bc-supports-no bc-supports\">60 — 63\n</dt>\n<dd> Chrome disabled <code>SharedArrayBuffer</code> on January 5, 2018 to help reduce the efficacy of <a href=\"https://www.chromium.org/Home/chromium-security/ssca\">speculative side-channel attacks</a>. This is intended as a temporary measure until other mitigations are in place.</dd>\n</dl></section>\n</td>\n<td> ? </td>\n<td class=\"bc-supports-yes bc-has-history\"> 57<div class=\"bc-icons\"> Disabled </div>\n<section class=\"bc-history\" id=\"sect6\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 57<div class=\"bc-icons\"> Disabled </div>\n</dt>\n<dd> Support was disabled by default to mitigate <a href=\"https://blog.mozilla.org/security/2018/01/03/mitigations-landing-new-class-timing-attack/\">speculative execution side-channel attacks (Mozilla Security Blog)</a>.</dd>\n<dd>Disabled From version 57: this feature is behind the <code>javascript.options.shared_memory</code> preference (needs to be set to <code>true</code>). To change preferences in Firefox, visit about:config.</dd>\n<dt class=\"bc-supports-no bc-supports\">55 — 57\n</dt>\n\n<dt class=\"bc-supports-no bc-supports\">48 — 55<div class=\"bc-icons\">Disabled </div>\n</dt>\n<dd>Disabled From version 48 until version 55 (exclusive): this feature is behind the <code>javascript.options.shared_memory</code> preference (needs to be set to <code>true</code>). To change preferences in Firefox, visit about:config.</dd>\n<dt class=\"bc-supports-no bc-supports\">46 — 48<div class=\"bc-icons\">  Disabled </div>\n</dt>\n<dd> The method returns values <code>Atomics.OK</code>, <code>Atomics.TIMEDOUT</code>, and <code>Atomics.NOTEQUAL</code>, instead of the later-specified strings.</dd>\n<dd> Uses the non-standard name: <code>futexWait</code>\n</dd>\n<dd>Disabled From version 46 until version 48 (exclusive): this feature is behind the <code>javascript.options.shared_memory</code> preference (needs to be set to <code>true</code>). To change preferences in Firefox, visit about:config.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 8.10.0</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"../atomics\"><code>Atomics</code></a></li> <li><a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics/wake\"><code>Atomics.wake()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics/wait$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics/wait\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics/wait</a>\n  </p>\n</div>\n","global_objects/number/isnan":"<h1>Number.isNaN</h1> <p>The <code>Number.isNaN()</code> method determines whether the passed value is <a href=\"../nan\"><code>NaN</code></a> and its type is <a href=\"../number\"><code>Number</code></a>. It is a more robust version of the original, global <a href=\"../isnan\"><code>isNaN()</code></a>.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/number-isnan.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js taller\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\">Number.isNaN(<var>value</var>)</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><code>value</code></dt> <dd>The value to be tested for <a href=\"../nan\"><code>NaN</code></a>.</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p><strong>true</strong> if the given value is <a href=\"../nan\"><code>NaN</code></a> and its type is <a href=\"../number\"><code>Number</code></a>; otherwise, <strong>false</strong>.</p> <h2 id=\"Description\">Description</h2> <p>Due to both equality operators, <a href=\"../../operators/comparison_operators#Equality\"><code>==</code></a> and <a href=\"../../operators/comparison_operators#Identity\"><code>===</code></a>, evaluating to <code>false</code> when checking if <a href=\"../nan\"><code>NaN</code></a> <em>is</em> <a href=\"../nan\"><code>NaN</code></a>, the function <code>Number.isNaN()</code> has become necessary. This situation is unlike all other possible value comparisons in JavaScript.</p> <p>In comparison to the global <a href=\"../isnan\"><code>isNaN()</code></a> function, <code>Number.isNaN()</code> doesn't suffer the problem of forcefully converting the parameter to a number. This means it is now safe to pass values that would normally convert to <a href=\"../nan\"><code>NaN</code></a>, but aren't actually the same value as <a href=\"../nan\"><code>NaN</code></a>. This also means that only values of the type number, that are also <a href=\"../nan\"><code>NaN</code></a>, return <code>true</code>.</p> <h2 id=\"Examples\">Examples</h2> <pre data-language=\"js\">Number.isNaN(NaN);        // true\nNumber.isNaN(Number.NaN); // true\nNumber.isNaN(0 / 0);      // true\n\n// e.g. these would have been true with global isNaN()\nNumber.isNaN('NaN');      // false\nNumber.isNaN(undefined);  // false\nNumber.isNaN({});         // false\nNumber.isNaN('blabla');   // false\n\n// These all return false\nNumber.isNaN(true);\nNumber.isNaN(null);\nNumber.isNaN(37);\nNumber.isNaN('37');\nNumber.isNaN('37.37');\nNumber.isNaN('');\nNumber.isNaN(' ');\n</pre> <h2 id=\"Polyfill\">Polyfill</h2> <p>The following works because NaN is the only value in javascript which is not equal to itself.</p> <pre data-language=\"js\">Number.isNaN = Number.isNaN || function(value) {     \n    return value !== value;\n}\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-number.isnan\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Number.isnan' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-number.isnan\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Number.isnan' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 25</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 15</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 9</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 15</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 9</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 0.10</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"../number\"><code>Number</code></a></li> <li><a href=\"../isnan\"><code>isNaN()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/isNaN$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/isNaN\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/isNaN</a>\n  </p>\n</div>\n","global_objects/map/size":"<h1>map.size</h1> <p>The <code><strong>size</strong></code> accessor property returns the number of elements in a <a href=\"../map\"><code>Map</code></a> object.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/map-prototype-size.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Description\">Description</h2> <p>The value of <code>size</code> is an integer representing how many entries the <code>Map</code> object has. A set accessor function for <code>size</code> is <code>undefined</code>; you can not change this property.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Using_size\">Using <code>size</code>\n</h3> <pre data-language=\"js\">var myMap = new Map();\nmyMap.set('a', 'alpha');\nmyMap.set('b', 'beta');\nmyMap.set('g', 'gamma');\n\nmyMap.size // 3\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-get-map.prototype.size\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Map.prototype.size' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-get-map.prototype.size\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Map.prototype.size' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 38</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes bc-has-history\"> 19\n<section class=\"bc-history\" id=\"sect1\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 19\n</dt>\n<dd> From Firefox 13 to Firefox 18, the <code>size</code> property was implemented as a <code>Map.prototype.size()</code> method, this has been changed to a property in later versions conform to the ECMAScript 2015 specification.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-yes\"> 11</td>\n<td class=\"bc-supports-yes\"> 25</td>\n<td class=\"bc-supports-yes\"> 8</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 38</td>\n<td class=\"bc-supports-yes\"> 38</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes bc-has-history\"> 19\n<section class=\"bc-history\" id=\"sect2\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 19\n</dt>\n<dd> From Firefox 13 to Firefox 18, the <code>size</code> property was implemented as a <code>Map.prototype.size()</code> method, this has been changed to a property in later versions conform to the ECMAScript 2015 specification.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-yes\"> 25</td>\n<td class=\"bc-supports-yes\"> 8</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 0.12</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"../map\"><code>Map</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/size$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/size\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/size</a>\n  </p>\n</div>\n","global_objects/map/@@species":"<h1>Map.@@species</h1> <p>The <code><strong>Map[@@species]</strong></code> accessor property returns the <code>Map</code> constructor.</p> <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\">Map[Symbol.species]\n</pre> <h2 id=\"Description\">Description</h2> <p>The species accessor property returns the default constructor for <code>Map</code> objects. Subclass constructors may over-ride it to change the constructor assignment.</p> <h2 id=\"Examples\">Examples</h2> <p>The species property returns the default constructor function, which is the <code>Map</code> constructor for <code>Map</code> objects:</p> <pre data-language=\"js\">Map[Symbol.species]; // function Map()</pre> <p>In a derived collection object (e.g. your custom map <code>MyMap</code>), the <code>MyMap</code> species is the <code>MyMap</code> constructor. However, you might want to overwrite this, in order to return parent <code>Map</code> objects in your derived class methods:</p> <pre data-language=\"js\">class MyMap extends Map {\n  // Overwrite MyMap species to the parent Map constructor\n  static get [Symbol.species]() { return Map; }\n}</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-get-map-@@species\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'get Map [ @@species ]' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-get-map-@@species\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'get Map [ @@species ]' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>   <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 51</td>\n<td class=\"bc-supports-yes\"> 13</td>\n<td class=\"bc-supports-yes\"> 41</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 38</td>\n<td class=\"bc-supports-yes\"> 10</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 51</td>\n<td class=\"bc-supports-yes\"> 51</td>\n<td class=\"bc-supports-yes\"> 13</td>\n<td class=\"bc-supports-yes\"> 41</td>\n<td class=\"bc-supports-yes\"> 38</td>\n<td class=\"bc-supports-yes\"> 10</td>\n<td class=\"bc-supports-yes\"> 5.0</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes bc-has-history\"> 6.5.0\n<section class=\"bc-history\" id=\"sect1\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 6.5.0\n</dt>\n\n<dt class=\"bc-supports-yes bc-supports\"> 6.0.0<div class=\"bc-icons\">Disabled </div>\n</dt>\n<dd>Disabled From version 6.0.0: this feature is behind the <code>--harmony</code> runtime flag.</dd>\n</dl></section>\n</td>\n</tr></tbody>\n</table>\n</div>  <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"../map\"><code>Map</code></a></li> <li><a href=\"../symbol/species\"><code>Symbol.species</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/@@species$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/@@species\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/@@species</a>\n  </p>\n</div>\n","global_objects/map/get":"<h1>map.get</h1> <p>The <code><strong>get()</strong></code> method returns a specified element from a <code>Map</code> object.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/map-prototype-get.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\"><em>myMap</em>.get(key);</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt>key</dt> <dd>Required. The key of the element to return from the <code>Map</code> object.</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p>Returns the element associated with the specified key or <code>undefined</code> if the key can't be found in the <code>Map</code> object.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Using_the_get_method\">Using the <code>get</code> method</h3> <pre data-language=\"js\">var myMap = new Map();\nmyMap.set('bar', 'foo');\n\nmyMap.get('bar');  // Returns \"foo\".\nmyMap.get('baz');  // Returns undefined.\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-map.prototype.get\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Map.prototype.get' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-map.prototype.get\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Map.prototype.get' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 38</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 13</td>\n<td class=\"bc-supports-yes\"> 11</td>\n<td class=\"bc-supports-yes\"> 25</td>\n<td class=\"bc-supports-yes\"> 8</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 38</td>\n<td class=\"bc-supports-yes\"> 38</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 14</td>\n<td class=\"bc-supports-yes\"> 25</td>\n<td class=\"bc-supports-yes\"> 8</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"../map\"><code>Map</code></a></li> <li><a href=\"set\"><code>Map.prototype.set()</code></a></li> <li><a href=\"has\"><code>Map.prototype.has()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/get$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/get\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/get</a>\n  </p>\n</div>\n","global_objects/atomics/exchange":"<h1>Atomics.exchange</h1> <p>The static <code>Atomics.exchange()</code> method stores a given value at a given position in the array and returns the old value at that position. This atomic operation guarantees that no other write happens between the read of the old value and the write of the new value.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/atomics-exchange.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\">Atomics.exchange(typedArray, index, value)\n</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><code>typedArray</code></dt> <dd>A shared integer typed array. One of <a href=\"../int8array\"><code>Int8Array</code></a>, <a href=\"../uint8array\"><code>Uint8Array</code></a>, <a href=\"../int16array\"><code>Int16Array</code></a>, <a href=\"../uint16array\"><code>Uint16Array</code></a>, <a href=\"../int32array\"><code>Int32Array</code></a>, or <a href=\"../uint32array\"><code>Uint32Array</code></a>.</dd> <dt><code>index</code></dt> <dd>The position in the <code>typedArray</code> to exchange a <code>value</code>.</dd> <dt><code>value</code></dt> <dd>The number to exchange.</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p>The old value at the given position (<code>typedArray[index]</code>).</p> <h3 id=\"Exceptions\">Exceptions</h3> <ul> <li>Throws a <a href=\"../typeerror\"><code>TypeError</code></a>, if <code>typedArray</code> is not one of the allowed integer types.</li> <li>Throws a <a href=\"../typeerror\"><code>TypeError</code></a>, if <code>typedArray</code> is not a shared typed array type.</li> <li>Throws a <a href=\"../rangeerror\"><code>RangeError</code></a>, if <code>index</code> is out of bounds in the <code>typedArray</code>.</li> </ul> <h2 id=\"Examples\">Examples</h2> <pre data-language=\"js\">var sab = new SharedArrayBuffer(1024);\nvar ta = new Uint8Array(sab);\n\nAtomics.exchange(ta, 0, 12); // returns 0, the old value\nAtomics.load(ta, 0); // 12</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-atomics.exchange\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Atomics.exchange' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td>Initial definition in ES2017.</td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes bc-has-history\"> 68\n<section class=\"bc-history\" id=\"sect1\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 68\n</dt>\n\n<dt class=\"bc-supports-no bc-supports\">60 — 63\n</dt>\n<dd> Chrome disabled <code>SharedArrayBuffer</code> on January 5, 2018 to help reduce the efficacy of <a href=\"https://www.chromium.org/Home/chromium-security/ssca\">speculative side-channel attacks</a>. This was a temporary removal while mitigations were put in place.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-yes bc-has-history\"> 16\n<section class=\"bc-history\" id=\"sect2\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 16\n</dt>\n<dd> Support was removed to mitigate <a href=\"https://blogs.windows.com/msedgedev/2018/01/03/speculative-execution-mitigations-microsoft-edge-internet-explorer\">speculative execution side-channel attacks (Windows blog)</a>.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-yes bc-has-history\"> 57<div class=\"bc-icons\"> Disabled </div>\n<section class=\"bc-history\" id=\"sect3\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 57<div class=\"bc-icons\"> Disabled </div>\n</dt>\n<dd> Support was disabled by default to mitigate <a href=\"https://blog.mozilla.org/security/2018/01/03/mitigations-landing-new-class-timing-attack/\">speculative execution side-channel attacks (Mozilla Security Blog)</a>.</dd>\n<dd>Disabled From version 57: this feature is behind the <code>javascript.options.shared_memory</code> preference (needs to be set to <code>true</code>). To change preferences in Firefox, visit about:config.</dd>\n<dt class=\"bc-supports-no bc-supports\">55 — 57\n</dt>\n\n<dt class=\"bc-supports-no bc-supports\">46 — 55<div class=\"bc-icons\">Disabled </div>\n</dt>\n<dd>Disabled From version 46 until version 55 (exclusive): this feature is behind the <code>javascript.options.shared_memory</code> preference (needs to be set to <code>true</code>). To change preferences in Firefox, visit about:config.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\">10.1 — ?</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-no bc-has-history\">60 — 63\n<section class=\"bc-history\" id=\"sect4\"><dl>\n<dt class=\"bc-supports-no bc-supports\">60 — 63\n</dt>\n<dd> Chrome disabled <code>SharedArrayBuffer</code> on January 5, 2018 to help reduce the efficacy of <a href=\"https://www.chromium.org/Home/chromium-security/ssca\">speculative side-channel attacks</a>. This is intended as a temporary measure until other mitigations are in place.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-no bc-has-history\">60 — 63\n<section class=\"bc-history\" id=\"sect5\"><dl>\n<dt class=\"bc-supports-no bc-supports\">60 — 63\n</dt>\n<dd> Chrome disabled <code>SharedArrayBuffer</code> on January 5, 2018 to help reduce the efficacy of <a href=\"https://www.chromium.org/Home/chromium-security/ssca\">speculative side-channel attacks</a>. This is intended as a temporary measure until other mitigations are in place.</dd>\n</dl></section>\n</td>\n<td> ? </td>\n<td class=\"bc-supports-yes bc-has-history\"> 57<div class=\"bc-icons\"> Disabled </div>\n<section class=\"bc-history\" id=\"sect6\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 57<div class=\"bc-icons\"> Disabled </div>\n</dt>\n<dd> Support was disabled by default to mitigate <a href=\"https://blog.mozilla.org/security/2018/01/03/mitigations-landing-new-class-timing-attack/\">speculative execution side-channel attacks (Mozilla Security Blog)</a>.</dd>\n<dd>Disabled From version 57: this feature is behind the <code>javascript.options.shared_memory</code> preference (needs to be set to <code>true</code>). To change preferences in Firefox, visit about:config.</dd>\n<dt class=\"bc-supports-no bc-supports\">55 — 57\n</dt>\n\n<dt class=\"bc-supports-no bc-supports\">46 — 55<div class=\"bc-icons\">Disabled </div>\n</dt>\n<dd>Disabled From version 46 until version 55 (exclusive): this feature is behind the <code>javascript.options.shared_memory</code> preference (needs to be set to <code>true</code>). To change preferences in Firefox, visit about:config.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 8.10.0</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"../atomics\"><code>Atomics</code></a></li> <li><a href=\"compareexchange\"><code>Atomics.compareExchange()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics/exchange$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics/exchange\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics/exchange</a>\n  </p>\n</div>\n","global_objects/atomics/or":"<h1>Atomics.or</h1> <p>The static <code><strong>Atomics</strong></code><code>.or()</code> method computes a bitwise OR with a given value at a given position in the array, and returns the old value at that position. This atomic operation guarantees that no other write happens until the modified value is written back.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/atomics-or.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\">Atomics.or(typedArray, index, value)\n</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><code>typedArray</code></dt> <dd>A shared integer typed array. One of <a href=\"../int8array\"><code>Int8Array</code></a>, <a href=\"../uint8array\"><code>Uint8Array</code></a>, <a href=\"../int16array\"><code>Int16Array</code></a>, <a href=\"../uint16array\"><code>Uint16Array</code></a>, <a href=\"../int32array\"><code>Int32Array</code></a>, or <a href=\"../uint32array\"><code>Uint32Array</code></a>.</dd> <dt><code>index</code></dt> <dd>The position in the <code>typedArray</code> to compute the bitwise OR.</dd> <dt><code>value</code></dt> <dd>The number to compute the bitwise OR with.</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p>The old value at the given position (<code>typedArray[index]</code>).</p> <h3 id=\"Exceptions\">Exceptions</h3> <ul> <li>Throws a <a href=\"../typeerror\"><code>TypeError</code></a>, if <code>typedArray</code> is not one of the allowed integer types.</li> <li>Throws a <a href=\"../typeerror\"><code>TypeError</code></a>, if <code>typedArray</code> is not a shared typed array type.</li> <li>Throws a <a href=\"../rangeerror\"><code>RangeError</code></a>, if <code>index</code> is out of bounds in the <code>typedArray</code>.</li> </ul> <h2 id=\"Description\">Description</h2> <p>The bitwise OR operation yields 1, if either <code>a</code> or <code>b</code> are 1. The truth table for the OR operation is:</p> <div class=\"_table\"><table class=\"standard-table\"> <thead> <tr> <th><code>a</code></th> <th><code>b</code></th> <th><code>a | b</code></th> </tr> </thead> <tbody> <tr> <td>0</td> <td>0</td> <td>0</td> </tr> <tr> <td>0</td> <td>1</td> <td>1</td> </tr> <tr> <td>1</td> <td>0</td> <td>1</td> </tr> <tr> <td>1</td> <td>1</td> <td>1</td> </tr> </tbody> </table></div> <p>For example, a bitwise OR of <code>5 &amp; 1</code> results in <code>0101</code> which is 5 in decimal.</p> <pre>5  0101\n1  0001\n   ----\n5  0101\n</pre> <h2 id=\"Examples\">Examples</h2> <pre data-language=\"js\">var sab = new SharedArrayBuffer(1024);\nvar ta = new Uint8Array(sab);\nta[0] = 2;\n\nAtomics.or(ta, 0, 1); // returns 2, the old value\nAtomics.load(ta, 0);  // 3</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-atomics.or\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Atomics.or' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td>Initial definition in ES2017.</td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes bc-has-history\"> 68\n<section class=\"bc-history\" id=\"sect1\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 68\n</dt>\n\n<dt class=\"bc-supports-no bc-supports\">60 — 63\n</dt>\n<dd> Chrome disabled <code>SharedArrayBuffer</code> on January 5, 2018 to help reduce the efficacy of <a href=\"https://www.chromium.org/Home/chromium-security/ssca\">speculative side-channel attacks</a>. This was a temporary removal while mitigations were put in place.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-yes bc-has-history\"> 16\n<section class=\"bc-history\" id=\"sect2\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 16\n</dt>\n<dd> Support was removed to mitigate <a href=\"https://blogs.windows.com/msedgedev/2018/01/03/speculative-execution-mitigations-microsoft-edge-internet-explorer\">speculative execution side-channel attacks (Windows blog)</a>.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-yes bc-has-history\"> 57<div class=\"bc-icons\"> Disabled </div>\n<section class=\"bc-history\" id=\"sect3\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 57<div class=\"bc-icons\"> Disabled </div>\n</dt>\n<dd> Support was disabled by default to mitigate <a href=\"https://blog.mozilla.org/security/2018/01/03/mitigations-landing-new-class-timing-attack/\">speculative execution side-channel attacks (Mozilla Security Blog)</a>.</dd>\n<dd>Disabled From version 57: this feature is behind the <code>javascript.options.shared_memory</code> preference (needs to be set to <code>true</code>). To change preferences in Firefox, visit about:config.</dd>\n<dt class=\"bc-supports-no bc-supports\">55 — 57\n</dt>\n\n<dt class=\"bc-supports-no bc-supports\">46 — 55<div class=\"bc-icons\">Disabled </div>\n</dt>\n<dd>Disabled From version 46 until version 55 (exclusive): this feature is behind the <code>javascript.options.shared_memory</code> preference (needs to be set to <code>true</code>). To change preferences in Firefox, visit about:config.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\">10.1 — ?</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-no bc-has-history\">60 — 63\n<section class=\"bc-history\" id=\"sect4\"><dl>\n<dt class=\"bc-supports-no bc-supports\">60 — 63\n</dt>\n<dd> Chrome disabled <code>SharedArrayBuffer</code> on January 5, 2018 to help reduce the efficacy of <a href=\"https://www.chromium.org/Home/chromium-security/ssca\">speculative side-channel attacks</a>. This is intended as a temporary measure until other mitigations are in place.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-no bc-has-history\">60 — 63\n<section class=\"bc-history\" id=\"sect5\"><dl>\n<dt class=\"bc-supports-no bc-supports\">60 — 63\n</dt>\n<dd> Chrome disabled <code>SharedArrayBuffer</code> on January 5, 2018 to help reduce the efficacy of <a href=\"https://www.chromium.org/Home/chromium-security/ssca\">speculative side-channel attacks</a>. This is intended as a temporary measure until other mitigations are in place.</dd>\n</dl></section>\n</td>\n<td> ? </td>\n<td class=\"bc-supports-yes bc-has-history\"> 57<div class=\"bc-icons\"> Disabled </div>\n<section class=\"bc-history\" id=\"sect6\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 57<div class=\"bc-icons\"> Disabled </div>\n</dt>\n<dd> Support was disabled by default to mitigate <a href=\"https://blog.mozilla.org/security/2018/01/03/mitigations-landing-new-class-timing-attack/\">speculative execution side-channel attacks (Mozilla Security Blog)</a>.</dd>\n<dd>Disabled From version 57: this feature is behind the <code>javascript.options.shared_memory</code> preference (needs to be set to <code>true</code>). To change preferences in Firefox, visit about:config.</dd>\n<dt class=\"bc-supports-no bc-supports\">55 — 57\n</dt>\n\n<dt class=\"bc-supports-no bc-supports\">46 — 55<div class=\"bc-icons\">Disabled </div>\n</dt>\n<dd>Disabled From version 46 until version 55 (exclusive): this feature is behind the <code>javascript.options.shared_memory</code> preference (needs to be set to <code>true</code>). To change preferences in Firefox, visit about:config.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 8.10.0</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"../atomics\"><code>Atomics</code></a></li> <li><a href=\"and\"><code>Atomics.and()</code></a></li> <li><a href=\"xor\"><code>Atomics.xor()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics/or$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics/or\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics/or</a>\n  </p>\n</div>\n","global_objects/map/clear":"<h1>map.clear</h1> <p>The <code><strong>clear()</strong></code> method removes all elements from a <code>Map</code> object.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/map-prototype-clear.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\"><em>myMap</em>.clear();</pre> <h3 id=\"Return_value\">Return value</h3> <p><a href=\"../undefined\"><code>undefined</code></a>.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Using_the_clear_method\">Using the <code>clear</code> method</h3> <pre data-language=\"js\">var myMap = new Map();\nmyMap.set('bar', 'baz');\nmyMap.set(1, 'foo');\n\nmyMap.size;       // 2\nmyMap.has('bar'); // true\n\nmyMap.clear();\n\nmyMap.size;       // 0\nmyMap.has('bar')  // false\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-map.prototype.clear\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Map.prototype.clear' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-map.prototype.clear\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Map.prototype.clear' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 38</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 19</td>\n<td class=\"bc-supports-yes\"> 11</td>\n<td class=\"bc-supports-yes\"> 25</td>\n<td class=\"bc-supports-yes\"> 8</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 38</td>\n<td class=\"bc-supports-yes\"> 38</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 19</td>\n<td class=\"bc-supports-yes\"> 25</td>\n<td class=\"bc-supports-yes\"> 8</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 0.12</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"../map\"><code>Map</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/clear$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/clear\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/clear</a>\n  </p>\n</div>\n","global_objects/map/delete":"<h1>map.delete</h1> <p>The <code><strong>delete()</strong></code> method removes the specified element from a <code>Map</code> object.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/map-prototype-delete.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre data-language=\"js\">myMap.delete(key);</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><code>key</code></dt> <dd>The key of the element to remove from the <code>Map</code> object.</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p><code>true</code> if an element in the <code>Map</code> object existed and has been removed, or <code>false</code> if the element does not exist.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Using_the_delete_method\">Using the <code>delete</code> method</h3> <pre data-language=\"js\">var myMap = new Map();\nmyMap.set('bar', 'foo');\n\nmyMap.delete('bar'); // Returns true. Successfully removed.\nmyMap.has('bar');    // Returns false. The \"bar\" element is no longer present.\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-map.prototype.delete\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Map.prototype.delete' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-map.prototype.delete\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Map.prototype.delete' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 38</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 13</td>\n<td class=\"bc-supports-yes\"> 11</td>\n<td class=\"bc-supports-yes\"> 25</td>\n<td class=\"bc-supports-yes\"> 8</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 38</td>\n<td class=\"bc-supports-yes\"> 38</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 14</td>\n<td class=\"bc-supports-yes\"> 25</td>\n<td class=\"bc-supports-yes\"> 8</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes bc-has-history\"> 0.12\n<section class=\"bc-history\" id=\"sect1\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 0.12\n</dt>\n\n<dt class=\"bc-supports-yes bc-supports\"> 0.10<div class=\"bc-icons\">Disabled </div>\n</dt>\n<dd>Disabled From version 0.10: this feature is behind the <code>--harmony</code> runtime flag.</dd>\n</dl></section>\n</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"../map\"><code>Map</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/delete$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/delete\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/delete</a>\n  </p>\n</div>\n","global_objects/map/prototype":"<h1>Map.prototype</h1> <p>The <code><strong>Map</strong></code><code>.prototype</code> property represents the prototype for the <a href=\"../map\"><code>Map</code></a> constructor.</p> <div class=\"_table\"><table class=\"standard-table\"> <thead> <tr> <th colspan=\"2\" class=\"header\">Property attributes of <code>Map.prototype</code>\n</th> </tr> </thead> <tbody> <tr> <td>Writable</td> <td>no</td> </tr> <tr> <td>Enumerable</td> <td>no</td> </tr> <tr> <td>Configurable</td> <td>no</td> </tr> </tbody> </table></div> <h2 id=\"Description\">Description</h2> <p><a href=\"../map\"><code>Map</code></a> instances inherit from <a href=\"prototype\"><code>Map.prototype</code></a>. You can use the constructor's prototype object to add properties or methods to all <code>Map</code> instances.</p> <h2 id=\"Properties\">Properties</h2> <dl> <dt><code>Map.prototype.constructor</code></dt> <dd>Returns the function that created an instance's prototype. This is the <a href=\"../map\"><code>Map</code></a> function by default.</dd> <dt><a href=\"size\"><code>Map.prototype.size</code></a></dt> <dd>Returns the number of key/value pairs in the <code>Map</code> object.</dd> </dl> <h2 id=\"Methods\">Methods</h2> <dl> <dt><a href=\"clear\"><code>Map.prototype.clear()</code></a></dt> <dd>Removes all key/value pairs from the <code>Map</code> object.</dd> <dt><a href=\"delete\"><code>Map.prototype.delete(key)</code></a></dt> <dd>Returns <code>true</code> if an element in the <code>Map</code> object existed and has been removed, or <code>false</code> if the element does not exist. <code>Map.prototype.has(key)</code> will return <code>false</code> afterwards.</dd> <dt><a href=\"entries\"><code>Map.prototype.entries()</code></a></dt> <dd>Returns a new <code>Iterator</code> object that contains<code>[key, value]</code> for each element in the <code>Map</code> object in insertion order.</dd> <dt><a href=\"foreach\"><code>Map.prototype.forEach(callbackFn[, thisArg])</code></a></dt> <dd>Calls callbackFn once for each key-value pair present in the <code>Map</code> object, in insertion order. If a thisArg parameter is provided to forEach, it will be used as the this value for each callback.</dd> <dt><a href=\"get\"><code>Map.prototype.get(key)</code></a></dt> <dd>Returns the value associated to the <code>key</code>, or <code>undefined</code> if there is none.</dd> <dt><a href=\"has\"><code>Map.prototype.has(key)</code></a></dt> <dd>Returns a boolean asserting whether a value has been associated to the <code>key</code> in the <code>Map</code> object or not.</dd> <dt><a href=\"keys\"><code>Map.prototype.keys()</code></a></dt> <dd>Returns a new <code>Iterator</code> object that contains the <strong>keys</strong> for each element in the <code>Map</code> object in insertion order.</dd> <dt><a href=\"set\"><code>Map.prototype.set(key, value)</code></a></dt> <dd>Sets the value for the <code>key</code> in the <code>Map</code> object. Returns the <code>Map</code> object.</dd> <dt><a href=\"values\"><code>Map.prototype.values()</code></a></dt> <dd>Returns a new <code>Iterator</code> object that contains the <strong>values</strong> for each element in the <code>Map</code> object in insertion order.</dd> <dt><a href=\"@@iterator\"><code>Map.prototype[@@iterator]()</code></a></dt> <dd>Returns a new <code>Iterator</code> object that contains<code>[key, value]</code> for each element in the <code>Map</code> object in insertion order.</dd> </dl> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-map.prototype\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Map.prototype' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-map.prototype\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Map.prototype' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 38</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 13</td>\n<td class=\"bc-supports-yes\"> 11</td>\n<td class=\"bc-supports-yes\"> 25</td>\n<td class=\"bc-supports-yes\"> 8</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 38</td>\n<td class=\"bc-supports-yes\"> 38</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 14</td>\n<td class=\"bc-supports-yes\"> 25</td>\n<td class=\"bc-supports-yes\"> 8</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"../set/prototype\"><code>Set.prototype</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/prototype$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/prototype\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/prototype</a>\n  </p>\n</div>\n","global_objects/map/has":"<h1>map.has</h1> <p>The <code><strong>has()</strong></code> method returns a boolean indicating whether an element with the specified key exists or not.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/map-prototype-has.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\"><em>myMap</em>.has(key);</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt>key</dt> <dd>Required. The key of the element to test for presence in the <code>Map</code> object.</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <dl> <dt>Boolean</dt> <dd>Returns <code>true</code> if an element with the specified key exists in the <code>Map</code> object; otherwise <code>false</code>.</dd> </dl> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Using_the_has_method\">Using the <code>has</code> method</h3> <pre data-language=\"js\">var myMap = new Map();\nmyMap.set('bar', \"foo\");\n\nmyMap.has('bar');  // returns true\nmyMap.has('baz');  // returns false\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-map.prototype.has\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Map.prototype.has' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-map.prototype.has\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Map.prototype.has' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 38</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 13</td>\n<td class=\"bc-supports-yes\"> 11</td>\n<td class=\"bc-supports-yes\"> 25</td>\n<td class=\"bc-supports-yes\"> 8</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 38</td>\n<td class=\"bc-supports-yes\"> 38</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 14</td>\n<td class=\"bc-supports-yes\"> 25</td>\n<td class=\"bc-supports-yes\"> 8</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"../map\"><code>Map</code></a></li> <li><a href=\"set\"><code>Map.prototype.set()</code></a></li> <li><a href=\"get\"><code>Map.prototype.get()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/has$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/has\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/has</a>\n  </p>\n</div>\n","global_objects/atomics/notify":"<h1>Atomics.notify</h1> <p>The static <code><strong>Atomics</strong></code><code>.notify()</code> method notifies up some agents that are sleeping in the wait queue.</p> <div class=\"note\"> <p><strong>Note:</strong> This operation works with a shared <a href=\"../int32array\"><code>Int32Array</code></a> only.</p> </div> <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\">Atomics.notify(typedArray, index, count)\n</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><code>typedArray</code></dt> <dd>A shared <a href=\"../int32array\"><code>Int32Array</code></a>.</dd> <dt><code>index</code></dt> <dd>The position in the <code>typedArray</code> to wake up on.</dd> <dt><code>count</code></dt> <dd>The number of sleeping agents to notify. Defaults to <a href=\"../infinity\"><code>+Infinity</code></a>.</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p>A number of woken up agents.</p> <h3 id=\"Exceptions\">Exceptions</h3> <ul> <li>Throws a <a href=\"../typeerror\"><code>TypeError</code></a>, if <code>typedArray</code> is not a shared <a href=\"../int32array\"><code>Int32Array</code></a>.</li> <li>Throws a <a href=\"../rangeerror\"><code>RangeError</code></a>, if <code>index</code> is out of bounds in the <code>typedArray</code>.</li> </ul> <h2 id=\"Examples\">Examples</h2> <p>Given a shared <code>Int32Array</code>:</p> <pre data-language=\"js\">var sab = new SharedArrayBuffer(1024);\nvar int32 = new Int32Array(sab);\n</pre> <p>A reading thread is sleeping and waiting on location 0 which is expected to be 0. As long as that is true, it will not go on. However, once the writing thread has stored a new value, it will be notified by the writing thread and return the new value (123).</p> <pre data-language=\"js\">Atomics.wait(int32, 0, 0);\nconsole.log(int32[0]); // 123</pre> <p>A writing thread stores a new value and notifies the waiting thread once it has written:</p> <pre data-language=\"js\">console.log(int32[0]); // 0;\nAtomics.store(int32, 0, 123); \nAtomics.notify(int32, 0, 1);</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-atomics.notify\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Atomics.notify' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td>Initial definition in ES2017.</td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes bc-has-history\"> 68\n<section class=\"bc-history\" id=\"sect1\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 68\n</dt>\n\n<dt class=\"bc-supports-no bc-supports\">60 — 63\n</dt>\n<dd> Chrome disabled <code>SharedArrayBuffer</code> on January 5, 2018 to help reduce the efficacy of <a href=\"https://www.chromium.org/Home/chromium-security/ssca\">speculative side-channel attacks</a>. This was a temporary removal while mitigations were put in place.</dd>\n<dd> Uses the non-standard name: <code>wake</code>\n</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-yes bc-has-history\"> 16\n<section class=\"bc-history\" id=\"sect2\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 16\n</dt>\n<dd> Support was removed to mitigate <a href=\"https://blogs.windows.com/msedgedev/2018/01/03/speculative-execution-mitigations-microsoft-edge-internet-explorer\">speculative execution side-channel attacks (Windows blog)</a>.</dd>\n<dd> Uses the non-standard name: <code>wake</code>\n</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-yes bc-has-history\"> 63<div class=\"bc-icons\"> Disabled </div>\n<section class=\"bc-history\" id=\"sect3\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 63<div class=\"bc-icons\"> Disabled </div>\n</dt>\n<dd> Support was disabled by default to mitigate <a href=\"https://blog.mozilla.org/security/2018/01/03/mitigations-landing-new-class-timing-attack/\">speculative execution side-channel attacks (Mozilla Security Blog)</a>.</dd>\n<dd>Disabled From version 63: this feature is behind the <code>javascript.options.shared_memory</code> preference (needs to be set to <code>true</code>). To change preferences in Firefox, visit about:config.</dd>\n<dt class=\"bc-supports-yes bc-supports\"> 57<div class=\"bc-icons\">  Disabled </div>\n</dt>\n<dd> Support was disabled by default to mitigate <a href=\"https://blog.mozilla.org/security/2018/01/03/mitigations-landing-new-class-timing-attack/\">speculative execution side-channel attacks (Mozilla Security Blog)</a>.</dd>\n<dd> Uses the non-standard name: <code>wake</code>\n</dd>\n<dd>Disabled From version 57: this feature is behind the <code>javascript.options.shared_memory</code> preference (needs to be set to <code>true</code>). To change preferences in Firefox, visit about:config.</dd>\n<dt class=\"bc-supports-no bc-supports\">55 — 57\n</dt>\n\n<dt class=\"bc-supports-no bc-supports\">48 — 55<div class=\"bc-icons\">Disabled </div>\n</dt>\n<dd>Disabled From version 48 until version 55 (exclusive): this feature is behind the <code>javascript.options.shared_memory</code> preference (needs to be set to <code>true</code>). To change preferences in Firefox, visit about:config.</dd>\n<dt class=\"bc-supports-no bc-supports\">46 — 48<div class=\"bc-icons\">  Disabled </div>\n</dt>\n<dd> The <code>count</code> parameter defaults to <code>0</code> instead of the later-specified <code>+Infinity</code>.</dd>\n<dd> Uses the non-standard name: <code>futexWake</code>\n</dd>\n<dd>Disabled From version 46 until version 48 (exclusive): this feature is behind the <code>javascript.options.shared_memory</code> preference (needs to be set to <code>true</code>). To change preferences in Firefox, visit about:config.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no bc-has-history\">10.1 — ?\n<section class=\"bc-history\" id=\"sect4\"><dl>\n<dt class=\"bc-supports-no bc-supports\">10.1 — ?\n</dt>\n<dd> Uses the non-standard name: <code>wake</code>\n</dd>\n</dl></section>\n</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-no bc-has-history\">60 — 63\n<section class=\"bc-history\" id=\"sect5\"><dl>\n<dt class=\"bc-supports-no bc-supports\">60 — 63\n</dt>\n<dd> Chrome disabled <code>SharedArrayBuffer</code> on January 5, 2018 to help reduce the efficacy of <a href=\"https://www.chromium.org/Home/chromium-security/ssca\">speculative side-channel attacks</a>. This is intended as a temporary measure until other mitigations are in place.</dd>\n<dd> Uses the non-standard name: <code>wake</code>\n</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-no bc-has-history\">60 — 63\n<section class=\"bc-history\" id=\"sect6\"><dl>\n<dt class=\"bc-supports-no bc-supports\">60 — 63\n</dt>\n<dd> Chrome disabled <code>SharedArrayBuffer</code> on January 5, 2018 to help reduce the efficacy of <a href=\"https://www.chromium.org/Home/chromium-security/ssca\">speculative side-channel attacks</a>. This is intended as a temporary measure until other mitigations are in place.</dd>\n<dd> Uses the non-standard name: <code>wake</code>\n</dd>\n</dl></section>\n</td>\n<td> ? </td>\n<td class=\"bc-supports-yes bc-has-history\"> 63<div class=\"bc-icons\"> Disabled </div>\n<section class=\"bc-history\" id=\"sect7\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 63<div class=\"bc-icons\"> Disabled </div>\n</dt>\n<dd> Support was disabled by default to mitigate <a href=\"https://blog.mozilla.org/security/2018/01/03/mitigations-landing-new-class-timing-attack/\">speculative execution side-channel attacks (Mozilla Security Blog)</a>.</dd>\n<dd>Disabled From version 63: this feature is behind the <code>javascript.options.shared_memory</code> preference (needs to be set to <code>true</code>). To change preferences in Firefox, visit about:config.</dd>\n<dt class=\"bc-supports-yes bc-supports\"> 57<div class=\"bc-icons\">  Disabled </div>\n</dt>\n<dd> Support was disabled by default to mitigate <a href=\"https://blog.mozilla.org/security/2018/01/03/mitigations-landing-new-class-timing-attack/\">speculative execution side-channel attacks (Mozilla Security Blog)</a>.</dd>\n<dd> Uses the non-standard name: <code>wake</code>\n</dd>\n<dd>Disabled From version 57: this feature is behind the <code>javascript.options.shared_memory</code> preference (needs to be set to <code>true</code>). To change preferences in Firefox, visit about:config.</dd>\n<dt class=\"bc-supports-no bc-supports\">55 — 57\n</dt>\n\n<dt class=\"bc-supports-no bc-supports\">48 — 55<div class=\"bc-icons\">Disabled </div>\n</dt>\n<dd>Disabled From version 48 until version 55 (exclusive): this feature is behind the <code>javascript.options.shared_memory</code> preference (needs to be set to <code>true</code>). To change preferences in Firefox, visit about:config.</dd>\n<dt class=\"bc-supports-no bc-supports\">46 — 48<div class=\"bc-icons\">  Disabled </div>\n</dt>\n<dd> The <code>count</code> parameter defaults to <code>0</code> instead of the later-specified <code>+Infinity</code>.</dd>\n<dd> Uses the non-standard name: <code>futexWake</code>\n</dd>\n<dd>Disabled From version 46 until version 48 (exclusive): this feature is behind the <code>javascript.options.shared_memory</code> preference (needs to be set to <code>true</code>). To change preferences in Firefox, visit about:config.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes bc-has-history\"> 8.10.0\n<section class=\"bc-history\" id=\"sect8\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 8.10.0\n</dt>\n<dd> Uses the non-standard name: <code>wake</code>\n</dd>\n</dl></section>\n</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"../atomics\"><code>Atomics</code></a></li> <li><a href=\"wait\"><code>Atomics.wait()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics/notify$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics/notify\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics/notify</a>\n  </p>\n</div>\n","global_objects/map/foreach":"<h1>map.forEach</h1> <p>The <code><strong>forEach()</strong></code> method executes a provided function once per each key/value pair in the <code>Map</code> object, in insertion order.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/map-prototype-foreach.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\"><em>myMap</em>.forEach(<em>callback</em>[, <em>thisArg</em>])</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><code>callback</code></dt> <dd>Function to execute for each element.</dd> <dt><code>thisArg</code></dt> <dd>Value to use as <code>this</code> when executing <code>callback</code>.</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p><a href=\"../undefined\"><code>undefined</code></a>.</p> <h2 id=\"Description\">Description</h2> <p>The <code>forEach</code> method executes the provided <code>callback</code> once for each key of the map which actually exist. It is not invoked for keys which have been deleted. However, it is executed for values which are present but have the value <code>undefined</code>.</p> <p><code>callback</code> is invoked with <strong>three arguments</strong>:</p> <ul> <li>the <strong>element value</strong>\n</li> <li>the <strong>element key</strong>\n</li> <li>the <code>Map</code>\n</li> </ul> <p>If a <code>thisArg</code> parameter is provided to <code>forEach</code>, it will be passed to <code>callback</code> when invoked, for use as its <code>this</code> value. Otherwise, the value <code>undefined</code> will be passed for use as its <code>this</code> value. The <code>this</code> value ultimately observable by <code>callback</code> is determined according to <a href=\"../../operators/this\">the usual rules for determining the <code>this</code> seen by a function</a>.</p> <p>Each value is visited once, except in the case when it was deleted and re-added before <code>forEach</code> has finished. <code>callback</code> is not invoked for values deleted before being visited. New values added before <code>forEach</code> has finished will be visited.</p> <p><code>forEach</code> executes the <code>callback</code> function once for each element in the <code>Map</code> object; it does not return a value.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Printing_the_contents_of_a_Map_object\">Printing the contents of a <code>Map</code> object</h3> <p>The following code logs a line for each element in an <code>Map</code> object:</p> <pre data-language=\"js\">function logMapElements(value, key, map) {\n    console.log(`m[${key}] = ${value}`);\n}\nnew Map([['foo', 3], ['bar', {}], ['baz', undefined]]).forEach(logMapElements);\n// logs:\n// \"m[foo] = 3\"\n// \"m[bar] = [object Object]\"\n// \"m[baz] = undefined\"\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-map.prototype.foreach\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Map.prototype.forEach' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-map.prototype.foreach\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Map.prototype.forEach' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 38</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 25</td>\n<td class=\"bc-supports-yes\"> 11</td>\n<td class=\"bc-supports-yes\"> 25</td>\n<td class=\"bc-supports-yes\"> 8</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 38</td>\n<td class=\"bc-supports-yes\"> 38</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 25</td>\n<td class=\"bc-supports-yes\"> 25</td>\n<td class=\"bc-supports-yes\"> 8</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 0.12</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"../array/foreach\"><code>Array.prototype.forEach()</code></a></li> <li><a href=\"../set/foreach\"><code>Set.prototype.forEach()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/forEach$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/forEach\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/forEach</a>\n  </p>\n</div>\n","global_objects/map/@@iterator":"<h1>map.@@iterator</h1> <p class=\"seoSummary\">The initial value of the <code><strong>@@iterator</strong></code> property is the same function object as the initial value of the <a href=\"entries\"><code>entries</code></a> method.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/map-prototype-@@iterator.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\"><em>myMap</em>[Symbol.iterator]</pre> <h3 id=\"Return_value\">Return value</h3> <p>The map <strong>iterator</strong> function, which is the <a href=\"entries\"><code>entries()</code></a> function by default.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Using_iterator()\">Using <code>[@@iterator]()</code>\n</h3> <pre data-language=\"js\">const myMap = new Map();\nmyMap.set('0', 'foo');\nmyMap.set(1, 'bar');\nmyMap.set({}, 'baz');\n\nconst mapIter = myMap[Symbol.iterator]();\n\nconsole.log(mapIter.next().value); // [\"0\", \"foo\"]\nconsole.log(mapIter.next().value); // [1, \"bar\"]\nconsole.log(mapIter.next().value); // [Object, \"baz\"]\n</pre> <h3 id=\"Using_iterator()_with_for..of\">Using <code>[@@iterator]()</code> with <code>for..of</code>\n</h3> <pre data-language=\"js\">const myMap = new Map();\nmyMap.set('0', 'foo');\nmyMap.set(1, 'bar');\nmyMap.set({}, 'baz');\n\nfor (const entry of myMap) {\n  console.log(entry);\n}\n// [\"0\", \"foo\"]\n// [1, \"bar\"]\n// [{}, \"baz\"]\n\nfor (const [key, value] of myMap) {\n  console.log(`${key}: ${value}`);\n}\n// 0: foo\n// 1: bar\n// [Object]: baz\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-map.prototype-@@iterator\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Map.prototype[@@iterator]()' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-map.prototype-@@iterator\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Map.prototype[@@iterator]()' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes bc-has-history\"> 36\n<section class=\"bc-history\" id=\"sect1\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 36\n</dt>\n\n<dt class=\"bc-supports-no bc-supports\">27 — 36\n</dt>\n<dd> A placeholder property named <code>@@iterator</code> is used.</dd>\n<dd> Uses the non-standard name: <code>@@iterator</code>\n</dd>\n<dt class=\"bc-supports-no bc-supports\">17 — 27\n</dt>\n<dd> A placeholder property named <code>iterator</code> is used.</dd>\n<dd> Uses the non-standard name: <code>iterator</code>\n</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes bc-has-history\"> 36\n<section class=\"bc-history\" id=\"sect2\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 36\n</dt>\n\n<dt class=\"bc-supports-no bc-supports\">27 — 36\n</dt>\n<dd> A placeholder property named <code>@@iterator</code> is used.</dd>\n<dd> Uses the non-standard name: <code>@@iterator</code>\n</dd>\n<dt class=\"bc-supports-no bc-supports\">17 — 27\n</dt>\n<dd> A placeholder property named <code>iterator</code> is used.</dd>\n<dd> Uses the non-standard name: <code>iterator</code>\n</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 0.12</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"entries\"><code>Map.prototype.entries()</code></a></li> <li><a href=\"keys\"><code>Map.prototype.keys()</code></a></li> <li><a href=\"values\"><code>Map.prototype.values()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/@@iterator$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/@@iterator\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/@@iterator</a>\n  </p>\n</div>\n","global_objects/atomics/xor":"<h1>Atomics.xor</h1> <p>The static <code><strong>Atomics</strong></code><code>.xor()</code> method computes a bitwise XOR with a given value at a given position in the array, and returns the old value at that position. This atomic operation guarantees that no other write happens until the modified value is written back.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/atomics-xor.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\">Atomics.xor(typedArray, index, value)\n</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><code>typedArray</code></dt> <dd>A shared integer typed array. One of <a href=\"../int8array\"><code>Int8Array</code></a>, <a href=\"../uint8array\"><code>Uint8Array</code></a>, <a href=\"../int16array\"><code>Int16Array</code></a>, <a href=\"../uint16array\"><code>Uint16Array</code></a>, <a href=\"../int32array\"><code>Int32Array</code></a>, or <a href=\"../uint32array\"><code>Uint32Array</code></a>.</dd> <dt><code>index</code></dt> <dd>The position in the <code>typedArray</code> to compute the bitwise XOR.</dd> <dt><code>value</code></dt> <dd>The number to compute the bitwise XOR with.</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p>The old value at the given position (<code>typedArray[index]</code>).</p> <h3 id=\"Exceptions\">Exceptions</h3> <ul> <li>Throws a <a href=\"../typeerror\"><code>TypeError</code></a>, if <code>typedArray</code> is not one of the allowed integer types.</li> <li>Throws a <a href=\"../typeerror\"><code>TypeError</code></a>, if <code>typedArray</code> is not a shared typed array type.</li> <li>Throws a <a href=\"../rangeerror\"><code>RangeError</code></a>, if <code>index</code> is out of bounds in the <code>typedArray</code>.</li> </ul> <h2 id=\"Description\">Description</h2> <p>The bitwise XOR operation yields 1, if <code>a</code> and <code>b</code> are different. The truth table for the XOR operation is:</p> <div class=\"_table\"><table class=\"standard-table\"> <thead> <tr> <th><code>a</code></th> <th><code>b</code></th> <th><code>a ^ b</code></th> </tr> </thead> <tbody> <tr> <td>0</td> <td>0</td> <td>0</td> </tr> <tr> <td>0</td> <td>1</td> <td>1</td> </tr> <tr> <td>1</td> <td>0</td> <td>1</td> </tr> <tr> <td>1</td> <td>1</td> <td>0</td> </tr> </tbody> </table></div> <p>For example, a bitwise XOR of <code>5 &amp; 1</code> results in <code>0100</code> which is 4 in decimal.</p> <pre>5  0101\n1  0001\n   ----\n4  0100\n</pre> <h2 id=\"Examples\">Examples</h2> <pre data-language=\"js\">var sab = new SharedArrayBuffer(1024);\nvar ta = new Uint8Array(sab);\nta[0] = 5;\n\nAtomics.xor(ta, 0, 1); // returns 5, the old value\nAtomics.load(ta, 0);  // 4</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-atomics.xor\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Atomics.xor' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td>Initial definition in ES2017.</td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes bc-has-history\"> 68\n<section class=\"bc-history\" id=\"sect1\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 68\n</dt>\n\n<dt class=\"bc-supports-no bc-supports\">60 — 63\n</dt>\n<dd> Chrome disabled <code>SharedArrayBuffer</code> on January 5, 2018 to help reduce the efficacy of <a href=\"https://www.chromium.org/Home/chromium-security/ssca\">speculative side-channel attacks</a>. This was a temporary removal while mitigations were put in place.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-yes bc-has-history\"> 16\n<section class=\"bc-history\" id=\"sect2\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 16\n</dt>\n<dd> Support was removed to mitigate <a href=\"https://blogs.windows.com/msedgedev/2018/01/03/speculative-execution-mitigations-microsoft-edge-internet-explorer\">speculative execution side-channel attacks (Windows blog)</a>.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-yes bc-has-history\"> 57<div class=\"bc-icons\"> Disabled </div>\n<section class=\"bc-history\" id=\"sect3\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 57<div class=\"bc-icons\"> Disabled </div>\n</dt>\n<dd> Support was disabled by default to mitigate <a href=\"https://blog.mozilla.org/security/2018/01/03/mitigations-landing-new-class-timing-attack/\">speculative execution side-channel attacks (Mozilla Security Blog)</a>.</dd>\n<dd>Disabled From version 57: this feature is behind the <code>javascript.options.shared_memory</code> preference (needs to be set to <code>true</code>). To change preferences in Firefox, visit about:config.</dd>\n<dt class=\"bc-supports-no bc-supports\">55 — 57\n</dt>\n\n<dt class=\"bc-supports-no bc-supports\">46 — 55<div class=\"bc-icons\">Disabled </div>\n</dt>\n<dd>Disabled From version 46 until version 55 (exclusive): this feature is behind the <code>javascript.options.shared_memory</code> preference (needs to be set to <code>true</code>). To change preferences in Firefox, visit about:config.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\">10.1 — ?</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-no bc-has-history\">60 — 63\n<section class=\"bc-history\" id=\"sect4\"><dl>\n<dt class=\"bc-supports-no bc-supports\">60 — 63\n</dt>\n<dd> Chrome disabled <code>SharedArrayBuffer</code> on January 5, 2018 to help reduce the efficacy of <a href=\"https://www.chromium.org/Home/chromium-security/ssca\">speculative side-channel attacks</a>. This is intended as a temporary measure until other mitigations are in place.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-no bc-has-history\">60 — 63\n<section class=\"bc-history\" id=\"sect5\"><dl>\n<dt class=\"bc-supports-no bc-supports\">60 — 63\n</dt>\n<dd> Chrome disabled <code>SharedArrayBuffer</code> on January 5, 2018 to help reduce the efficacy of <a href=\"https://www.chromium.org/Home/chromium-security/ssca\">speculative side-channel attacks</a>. This is intended as a temporary measure until other mitigations are in place.</dd>\n</dl></section>\n</td>\n<td> ? </td>\n<td class=\"bc-supports-yes bc-has-history\"> 57<div class=\"bc-icons\"> Disabled </div>\n<section class=\"bc-history\" id=\"sect6\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 57<div class=\"bc-icons\"> Disabled </div>\n</dt>\n<dd> Support was disabled by default to mitigate <a href=\"https://blog.mozilla.org/security/2018/01/03/mitigations-landing-new-class-timing-attack/\">speculative execution side-channel attacks (Mozilla Security Blog)</a>.</dd>\n<dd>Disabled From version 57: this feature is behind the <code>javascript.options.shared_memory</code> preference (needs to be set to <code>true</code>). To change preferences in Firefox, visit about:config.</dd>\n<dt class=\"bc-supports-no bc-supports\">55 — 57\n</dt>\n\n<dt class=\"bc-supports-no bc-supports\">46 — 55<div class=\"bc-icons\">Disabled </div>\n</dt>\n<dd>Disabled From version 46 until version 55 (exclusive): this feature is behind the <code>javascript.options.shared_memory</code> preference (needs to be set to <code>true</code>). To change preferences in Firefox, visit about:config.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 8.10.0</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"../atomics\"><code>Atomics</code></a></li> <li><a href=\"and\"><code>Atomics.and()</code></a></li> <li><a href=\"or\"><code>Atomics.or()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics/xor$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics/xor\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics/xor</a>\n  </p>\n</div>\n","global_objects/map/entries":"<h1>map.entries</h1> <p>The <code><strong>entries()</strong></code> method returns a new <strong><a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Iterators_and_Generators\">Iterator</a></strong> object that contains the <code>[key, value]</code> pairs for each element in the <code>Map</code> object in insertion order.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/map-prototype-entries.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\"><em>myMap</em>.entries()</pre> <h3 id=\"Return_value\">Return value</h3> <p>A new <a href=\"../map\"><code>Map</code></a> iterator object.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Using_entries()\">Using <code>entries()</code>\n</h3> <pre data-language=\"js\">var myMap = new Map();\nmyMap.set('0', 'foo');\nmyMap.set(1, 'bar');\nmyMap.set({}, 'baz');\n\nvar mapIter = myMap.entries();\n\nconsole.log(mapIter.next().value); // [\"0\", \"foo\"]\nconsole.log(mapIter.next().value); // [1, \"bar\"]\nconsole.log(mapIter.next().value); // [Object, \"baz\"]\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-map.prototype.entries\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Map.prototype.entries' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-map.prototype.entries\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Map.prototype.entries' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 38</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 20</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 25</td>\n<td class=\"bc-supports-yes\"> 8</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 38</td>\n<td class=\"bc-supports-yes\"> 38</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 20</td>\n<td class=\"bc-supports-yes\"> 25</td>\n<td class=\"bc-supports-yes\"> 8</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 0.12</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"keys\"><code>Map.prototype.keys()</code></a></li> <li><a href=\"values\"><code>Map.prototype.values()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/entries$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/entries\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/entries</a>\n  </p>\n</div>\n","global_objects/map/set":"<h1>map.set</h1> <p>The <code><strong>set()</strong></code> method adds or updates an element with a specified <code>key</code> and <code>value</code> to a <code>Map</code> object.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/map-prototype-set.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\"><em>myMap</em>.set(key, value);</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt>key</dt> <dd>Required. The key of the element to add to the <code>Map</code> object.</dd> <dt>value</dt> <dd>Required. The value of the element to add to the <code>Map</code> object.</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p>The <code>Map</code> object.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Using_the_set_method\">Using the <code>set</code> method</h3> <pre data-language=\"js\">var myMap = new Map();\n\n// Add new elements to the map\nmyMap.set('bar', 'foo');\nmyMap.set(1, 'foobar');\n\n// Update an element in the map\nmyMap.set('bar', 'baz');\n</pre> <h3 id=\"Using_the_set_method_with_chaining\">Using the <code>set</code> method with chaining</h3> <p>Since the <code>set()</code> method returns back the same <code>Map</code> object, you can chain the method call like below:</p> <pre data-language=\"js\">// Add new elements to the map with chaining. \nmyMap.set('bar', 'foo')\n     .set(1, 'foobar')\n     .set(2, 'baz');\n\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-map.prototype.set\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Map.prototype.set' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-map.prototype.set\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Map.prototype.set' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 38</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 13</td>\n<td class=\"bc-supports-partial bc-has-history\">11\n<section class=\"bc-history\" id=\"sect1\"><dl>\n<dt class=\"bc-supports-partial bc-supports\">11\n</dt>\n<dd> Returns 'undefined' instead of the 'Map' object.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-yes\"> 25</td>\n<td class=\"bc-supports-yes\"> 8</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 38</td>\n<td class=\"bc-supports-yes\"> 38</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 14</td>\n<td class=\"bc-supports-yes\"> 25</td>\n<td class=\"bc-supports-yes\"> 8</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"../map\"><code>Map</code></a></li> <li><a href=\"get\"><code>Map.prototype.get()</code></a></li> <li><a href=\"has\"><code>Map.prototype.has()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/set$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/set\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/set</a>\n  </p>\n</div>\n","global_objects/map/values":"<h1>map.values</h1> <p>The <code><strong>values()</strong></code> method returns a new <strong><a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Iterators_and_Generators\">Iterator</a></strong> object that contains the values for each element in the <code>Map</code> object in insertion order.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/map-prototype-values.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\"><em>myMap</em>.values()</pre> <h3 id=\"Return_value\">Return value</h3> <p>A new <a href=\"../map\"><code>Map</code></a> iterator object.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Using_values()\">Using <code>values()</code>\n</h3> <pre data-language=\"js\">var myMap = new Map();\nmyMap.set('0', 'foo');\nmyMap.set(1, 'bar');\nmyMap.set({}, 'baz');\n\nvar mapIter = myMap.values();\n\nconsole.log(mapIter.next().value); // \"foo\"\nconsole.log(mapIter.next().value); // \"bar\"\nconsole.log(mapIter.next().value); // \"baz\"</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-map.prototype.values\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Map.prototype.values' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-map.prototype.values\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Map.prototype.values' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 38</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 20</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 25</td>\n<td class=\"bc-supports-yes\"> 8</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 38</td>\n<td class=\"bc-supports-yes\"> 38</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 20</td>\n<td class=\"bc-supports-yes\"> 25</td>\n<td class=\"bc-supports-yes\"> 8</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 0.12</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"entries\"><code>Map.prototype.entries()</code></a></li> <li><a href=\"keys\"><code>Map.prototype.keys()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/values$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/values\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/values</a>\n  </p>\n</div>\n","global_objects/promise/prototype":"<h1>Promise.prototype</h1> <p>The <code><strong>Promise</strong></code><code>.prototype</code> property represents the prototype for the <a href=\"../promise\"><code>Promise</code></a> constructor.</p> <div class=\"_table\"><table class=\"standard-table\"> <thead> <tr> <th colspan=\"2\" class=\"header\">Property attributes of <code>Promise.prototype</code>\n</th> </tr> </thead> <tbody> <tr> <td>Writable</td> <td>no</td> </tr> <tr> <td>Enumerable</td> <td>no</td> </tr> <tr> <td>Configurable</td> <td>no</td> </tr> </tbody> </table></div> <h2 id=\"Description\">Description</h2> <p><a href=\"../promise\"><code>Promise</code></a> instances inherit from <a href=\"prototype\"><code>Promise.prototype</code></a>. You can use the constructor's prototype object to add properties or methods to all <code>Promise</code> instances.</p> <h2 id=\"Properties\">Properties</h2> <dl> <dt><code>Promise.prototype.constructor</code></dt> <dd>Returns the function that created an instance's prototype. This is the <a href=\"../promise\"><code>Promise</code></a> function by default.</dd> </dl> <h2 id=\"Methods\">Methods</h2> <dl> <dt><a href=\"catch\"><code>Promise.prototype.catch(onRejected)</code></a></dt> <dd>Appends a rejection handler callback to the promise, and returns a new promise resolving to the return value of the callback if it is called, or to its original fulfillment value if the promise is instead fulfilled.</dd> <dt><a href=\"then\"><code>Promise.prototype.then(onFulfilled, onRejected)</code></a></dt> <dd>Appends fulfillment and rejection handlers to the promise, and returns a new promise resolving to the return value of the called handler, or to its original settled value if the promise was not handled (i.e. if the relevant handler <code>onFulfilled</code> or <code>onRejected</code> is not a function).</dd> <dt><a href=\"finally\"><code>Promise.prototype.finally(onFinally)</code></a></dt> <dd>Appends a handler to the promise, and returns a new promise which is resolved when the original promise is resolved. The handler is called when the promise is settled, whether fulfilled or rejected.</dd> </dl> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-promise.prototype\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Promise.prototype' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-promise.prototype\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Promise.prototype' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 32</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 29</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 19</td>\n<td class=\"bc-supports-yes\"> 8</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 4.4.3</td>\n<td class=\"bc-supports-yes\"> 32</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 29</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 8</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 0.12</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"../promise\"><code>Promise</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/prototype$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/prototype\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/prototype</a>\n  </p>\n</div>\n","global_objects/promise/race":"<h1>Promise.race</h1> <p>The <code><strong>Promise.race(iterable)</strong></code> method returns a promise that resolves or rejects as soon as one of the promises in the iterable resolves or rejects, with the value or reason from that promise.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/promise-race.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\"><var>Promise.race(iterable)</var>;</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt>iterable</dt> <dd>An iterable object, such as an <a href=\"../array\"><code>Array</code></a>. See <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/iterable\">iterable</a>.</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p>A <strong>pending</strong> <a href=\"../promise\"><code>Promise</code></a> that <strong>asynchronously </strong>yields the value of first promise in the given iterable to resolve or reject.</p> <h2 id=\"Description\">Description</h2> <p>The <code>race</code> function returns a <code>Promise</code> that is settled the same way (and takes the same value) as the first promise that settles amongst the promises of the iterable passed as argument.</p> <p>If the iterable passed is empty, the promise returned will be forever pending.</p> <p>If the iterable contains one or more non-promise value and/or an already resolved/rejected promise, then <code>Promise.race</code> will resolve to the first of these values found in the iterable.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Asynchronicity_of_Promise.race\"><font face=\"consolas, Liberation Mono, courier, monospace\">Asynchronicity of <code>Promise.race</code></font></h3> <p>This following example demonstrates the asynchronicity of <code>Promise.race:</code></p> <pre data-language=\"js\">// we are passing as argument an array of promises that are already resolved,\n// to trigger Promise.race as soon as possible\nvar resolvedPromisesArray = [Promise.resolve(33), Promise.resolve(44)];\n\nvar p = Promise.race(resolvedPromisesArray);\n// immediately logging the value of p\nconsole.log(p);\n\n// using setTimeout we can execute code after the stack is empty\nsetTimeout(function(){\n    console.log('the stack is now empty');\n    console.log(p);\n});\n\n// logs, in order:\n// Promise { &lt;state&gt;: \"pending\" }\n// the stack is now empty\n// Promise { &lt;state&gt;: \"fulfilled\", &lt;value&gt;: 33 }</pre> <p>An empty iterable causes the returned promise to be forever pending:</p> <pre data-language=\"js\">var foreverPendingPromise = Promise.race([]);\nconsole.log(foreverPendingPromise);\nsetTimeout(function(){\n    console.log('the stack is now empty');\n    console.log(foreverPendingPromise);\n});\n\n// logs, in order:\n// Promise { &lt;state&gt;: \"pending\" }\n// the stack is now empty\n// Promise { &lt;state&gt;: \"pending\" }\n</pre> <p>If the iterable contains one or more non-promise value and/or an already resolved/rejected promise, then <code>Promise.race</code> will resolve to the first of these values found in the array:</p> <pre data-language=\"js\">var foreverPendingPromise = Promise.race([]);\nvar alreadyResolvedProm = Promise.resolve(666);\n\nvar arr = [foreverPendingPromise, alreadyResolvedProm, \"non-Promise value\"];\nvar arr2 = [foreverPendingPromise, \"non-Promise value\", Promise.resolve(666)];\nvar p = Promise.race(arr);\nvar p2 = Promise.race(arr2);\n\nconsole.log(p);\nconsole.log(p2);\nsetTimeout(function(){\n    console.log('the stack is now empty');\n    console.log(p);\n    console.log(p2);\n});\n\n// logs, in order:\n// Promise { &lt;state&gt;: \"pending\" } \n// Promise { &lt;state&gt;: \"pending\" } \n// the stack is now empty\n// Promise { &lt;state&gt;: \"fulfilled\", &lt;value&gt;: 666 }\n// Promise { &lt;state&gt;: \"fulfilled\", &lt;value&gt;: \"non-Promise value\" }\n</pre> <h3 id=\"Using_Promise.race_–_examples_with_setTimeout\">Using <code>Promise.race</code> – examples with <a href=\"https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/setTimeout\"><code>setTimeout</code></a>\n</h3> <pre data-language=\"js\">var p1 = new Promise(function(resolve, reject) { \n    setTimeout(() =&gt; resolve('one'), 500); \n});\nvar p2 = new Promise(function(resolve, reject) { \n    setTimeout(() =&gt; resolve('two'), 100); \n});\n\nPromise.race([p1, p2])\n.then(function(value) {\n  console.log(value); // \"two\"\n  // Both resolve, but p2 is faster\n});\n\nvar p3 = new Promise(function(resolve, reject) { \n    setTimeout(() =&gt; resolve('three'), 100);\n});\nvar p4 = new Promise(function(resolve, reject) { \n    setTimeout(() =&gt; reject(new Error('four')), 500); \n});\n\nPromise.race([p3, p4])\n.then(function(value) {\n  console.log(value); // \"three\"\n  // p3 is faster, so it resolves\n}, function(reason) {\n  // Not called\n});\n\nvar p5 = new Promise(function(resolve, reject) { \n    setTimeout(() =&gt; resolve('five'), 500); \n});\nvar p6 = new Promise(function(resolve, reject) { \n    setTimeout(() =&gt; reject(new Error('six')), 100);\n});\n\nPromise.race([p5, p6])\n.then(function(value) {\n  // Not called\n}, function(error) {\n  console.log(error.message); // \"six\"\n  // p6 is faster, so it rejects\n});\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-promise.race\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Promise.race' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition in an ECMA standard.</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-promise.race\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Promise.race' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 32</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 29</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 19</td>\n<td class=\"bc-supports-yes\"> 8</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 4.4.3</td>\n<td class=\"bc-supports-yes\"> 32</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 29</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 8</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 0.12</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"../promise\"><code>Promise</code></a></li> <li><a href=\"all\"><code>Promise.all()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/race$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/race\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/race</a>\n  </p>\n</div>\n","global_objects/promise/resolve":"<h1>Promise.resolve</h1> <p>The <code><strong>Promise.resolve(value)</strong></code> method returns a <a href=\"../promise\"><code>Promise</code></a> object that is resolved with the given value. If the value is a promise, that promise is returned; if the value is a thenable (i.e. has a <a href=\"then\"><code>\"then\" method</code></a>), the returned promise will \"follow\" that thenable, adopting its eventual state; otherwise the returned promise will be fulfilled with the value. This function flattens nested layers of promise-like objects (e.g. a promise that resolves to a promise that resolves to something) into a single layer.</p> <div class=\"blockIndicator warning\"> <p><strong>Warning</strong>: Do not call <code>Promise.resolve</code> on a thenable that resolves to itself. This will cause infinite recursion as it tries to flatten what seems to be an infinitely nested promise. An <a href=\"https://stackblitz.com/edit/angular-promiseresovle-with-async-pipe?file=src/app/app.component.ts\">example</a> would be using it along with the <code>async</code> Pipe in Angular. Find more on that <a href=\"https://angular.io/guide/template-syntax#avoid-side-effects\">here</a>.</p> </div> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/promise-resolve.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre data-language=\"js\">Promise.resolve(value);\nPromise.resolve(promise);\nPromise.resolve(thenable); \n</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt>value</dt> <dd>Argument to be resolved by this <code>Promise</code>. Can also be a <code>Promise</code> or a thenable to resolve.</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p>A <a href=\"../promise\"><code>Promise</code></a> that is resolved with the given value, or the promise passed as value, if the value was a promise object.</p> <h2 id=\"Description\">Description</h2> <p>The static <code>Promise.resolve</code> function returns a <code>Promise</code> that is resolved.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Using_the_static_Promise.resolve_method\">Using the static <code>Promise.resolve</code> method</h3> <pre data-language=\"js\">Promise.resolve('Success').then(function(value) {\n  console.log(value); // \"Success\"\n}, function(value) {\n  // not called\n});\n</pre> <h3 id=\"Resolving_an_array\">Resolving an array</h3> <pre data-language=\"js\">var p = Promise.resolve([1,2,3]);\np.then(function(v) {\n  console.log(v[0]); // 1\n});\n</pre> <h3 id=\"Resolving_another_Promise\">Resolving another <code>Promise</code>\n</h3> <pre data-language=\"js\">var original = Promise.resolve(33);\nvar cast = Promise.resolve(original);\ncast.then(function(value) {\n  console.log('value: ' + value);\n});\nconsole.log('original === cast ? ' + (original === cast));\n\n// logs, in order:\n// original === cast ? true\n// value: 33\n</pre> <p>The inverted order of the logs is due to the fact that the <code>then</code> handlers are called asynchronously. See how <code>then</code> works <a href=\"then#Return_value\">here</a>.</p> <h3 id=\"Resolving_thenables_and_throwing_Errors\">Resolving thenables and throwing Errors</h3> <pre data-language=\"js\">// Resolving a thenable object\nvar p1 = Promise.resolve({ \n  then: function(onFulfill, onReject) { onFulfill('fulfilled!'); }\n});\nconsole.log(p1 instanceof Promise) // true, object casted to a Promise\n\np1.then(function(v) {\n    console.log(v); // \"fulfilled!\"\n  }, function(e) {\n    // not called\n});\n\n// Thenable throws before callback\n// Promise rejects\nvar thenable = { then: function(resolve) {\n  throw new TypeError('Throwing');\n  resolve('Resolving');\n}};\n\nvar p2 = Promise.resolve(thenable);\np2.then(function(v) {\n  // not called\n}, function(e) {\n  console.log(e); // TypeError: Throwing\n});\n\n// Thenable throws after callback\n// Promise resolves\nvar thenable = { then: function(resolve) {\n  resolve('Resolving');\n  throw new TypeError('Throwing');\n}};\n\nvar p3 = Promise.resolve(thenable);\np3.then(function(v) {\n  console.log(v); // \"Resolving\"\n}, function(e) {\n  // not called\n});\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-promise.resolve\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Promise.resolve' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition in an ECMA standard.</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-promise.resolve\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Promise.resolve' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 32</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 29</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 19</td>\n<td class=\"bc-supports-yes\"> 8</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 4.4.3</td>\n<td class=\"bc-supports-yes\"> 32</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 29</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 8</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 0.12</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"../promise\"><code>Promise</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/resolve$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/resolve\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/resolve</a>\n  </p>\n</div>\n","global_objects/map/keys":"<h1>map.keys</h1> <p>The <code><strong>keys()</strong></code> method returns a new <code><a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Iterators_and_Generators\">Iterator</a></code> object that contains the keys for each element in the <code>Map</code> object in insertion order.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/map-prototype-keys.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\"><em>myMap</em>.keys()</pre> <h3 id=\"Return_value\">Return value</h3> <p>A new <a href=\"../map\"><code>Map</code></a> iterator object.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Using_keys()\">Using <code>keys()</code>\n</h3> <pre data-language=\"js\">var myMap = new Map();\nmyMap.set('0', 'foo');\nmyMap.set(1, 'bar');\nmyMap.set({}, 'baz');\n\nvar mapIter = myMap.keys();\n\nconsole.log(mapIter.next().value); // \"0\"\nconsole.log(mapIter.next().value); // 1\nconsole.log(mapIter.next().value); // Object\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-map.prototype.keys\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Map.prototype.keys' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-map.prototype.keys\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Map.prototype.keys' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 38</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 20</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 25</td>\n<td class=\"bc-supports-yes\"> 8</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 38</td>\n<td class=\"bc-supports-yes\"> 38</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 20</td>\n<td class=\"bc-supports-yes\"> 25</td>\n<td class=\"bc-supports-yes\"> 8</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 0.12</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"entries\"><code>Map.prototype.entries()</code></a></li> <li><a href=\"values\"><code>Map.prototype.values()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/keys$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/keys\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/keys</a>\n  </p>\n</div>\n","global_objects/promise/catch":"<h1>promise.catch</h1> <p>The <strong>catch()</strong> method returns a <code>Promise</code> and deals with rejected cases only. It behaves the same as calling <a href=\"then\"><code>Promise.prototype.then(undefined, onRejected)</code></a> (in fact, calling <code>obj.catch(onRejected)</code> internally calls <code>obj.then(undefined, onRejected)</code>). This means, that you have to provide <code>onRejected</code> function even if you want to fallback to <code>undefined</code> result value - for example <code>obj.catch(() =&gt; {})</code>.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/promise-catch.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>    <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\"><var>p.catch(onRejected)</var>;\n\np.catch(function(reason) {\n   // rejection\n});\n</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt>onRejected</dt> <dd>A <a href=\"../function\"><code>Function</code></a> called when the <code>Promise</code> is rejected. This function has one argument: <dl> <dt><code>reason</code></dt> <dd>The rejection reason.</dd> </dl> The Promise returned by <code>catch()</code> is rejected if <code>onRejected</code> throws an error or returns a Promise which is itself rejected; otherwise, it is resolved.</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p>Internally calls <code>Promise.prototype.then</code> on the object upon which is called, passing the parameters <code>undefined</code> and the <code>onRejected</code> handler received; then returns the value of that call (which is a <a href=\"../promise\"><code>Promise</code></a>).</p> <div class=\"warning\"> <p>The examples below are throwing strings. This is considered bad practice. Always throw an instance of <a href=\"../error\">Error</a>. Otherwise the part doing the catching would have to make checks to see if the argument was a string or an error, and you might lose valuable information like stack traces</p> </div> <p><strong>Demonstration of the internal call:</strong></p> <pre data-language=\"js\">// overriding original Promise.prototype.then/catch just to add some logs\n(function(Promise){\n    var originalThen = Promise.prototype.then;\n    var originalCatch = Promise.prototype.catch;\n    \n    Promise.prototype.then = function(){\n        console.log('&gt; &gt; &gt; &gt; &gt; &gt; called .then on %o with arguments: %o', this, arguments);\n        return originalThen.apply(this, arguments);\n    };\n    Promise.prototype.catch = function(){\n        console.log('&gt; &gt; &gt; &gt; &gt; &gt; called .catch on %o with arguments: %o', this, arguments);\n        return originalCatch.apply(this, arguments);\n    };\n\n})(this.Promise);\n\n\n\n// calling catch on an already resolved promise\nPromise.resolve().catch(function XXX(){});\n\n// logs:\n// &gt; &gt; &gt; &gt; &gt; &gt; called .catch on Promise{} with arguments: Arguments{1} [0: function XXX()]\n// &gt; &gt; &gt; &gt; &gt; &gt; called .then on Promise{} with arguments: Arguments{2} [0: undefined, 1: function XXX()]\n</pre> <h2 id=\"Description\">Description</h2> <p>The <code>catch</code> method can be useful for error handling in your promise composition.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Using_and_chaining_the_catch_method\">Using and chaining the <code>catch</code> method</h3> <pre data-language=\"js\">var p1 = new Promise(function(resolve, reject) {\n  resolve('Success');\n});\n\np1.then(function(value) {\n  console.log(value); // \"Success!\"\n  throw 'oh, no!';\n}).catch(function(e) {\n  console.log(e); // \"oh, no!\"\n}).then(function(){\n  console.log('after a catch the chain is restored');\n}, function () {\n  console.log('Not fired due to the catch');\n});\n\n// The following behaves the same as above\np1.then(function(value) {\n  console.log(value); // \"Success!\"\n  return Promise.reject('oh, no!');\n}).catch(function(e) {\n  console.log(e); // \"oh, no!\"\n}).then(function(){\n  console.log('after a catch the chain is restored');\n}, function () {\n  console.log('Not fired due to the catch');\n});\n</pre> <h3 id=\"Gotchas_when_throwing_errors\">Gotchas when throwing errors</h3> <pre data-language=\"js\">// Throwing an error will call the catch method most of the time\nvar p1 = new Promise(function(resolve, reject) {\n  throw 'Uh-oh!';\n});\n\np1.catch(function(e) {\n  console.log(e); // \"Uh-oh!\"\n});\n\n// Errors thrown inside asynchronous functions will act like uncaught errors\nvar p2 = new Promise(function(resolve, reject) {\n  setTimeout(function() {\n    throw 'Uncaught Exception!';\n  }, 1000);\n});\n\np2.catch(function(e) {\n  console.log(e); // This is never called\n});\n\n// Errors thrown after resolve is called will be silenced\nvar p3 = new Promise(function(resolve, reject) {\n  resolve();\n  throw 'Silenced Exception!';\n});\n\np3.catch(function(e) {\n   console.log(e); // This is never called\n});</pre> <h3 id=\"If_it_is_resolved\">If it is resolved</h3> <pre data-language=\"js\">//Create a promise which would not call onReject\nvar p1 = Promise.resolve(\"calling next\");\n\nvar p2 = p1.catch(function (reason) {\n    //This is never called\n    console.log(\"catch p1!\");\n    console.log(reason);\n});\n\np2.then(function (value) {\n    console.log(\"next promise's onFulfilled\"); /* next promise's onFulfilled */\n    console.log(value); /* calling next */\n}, function (reason) {\n    console.log(\"next promise's onRejected\");\n    console.log(reason);\n});</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-promise.prototype.catch\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Promise.prototype.catch' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition in an ECMA standard.</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-promise.prototype.catch\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Promise.prototype.catch' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 32</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 29</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 19</td>\n<td class=\"bc-supports-yes\"> 8</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 4.4.3</td>\n<td class=\"bc-supports-yes\"> 32</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 29</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 8</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 0.12</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"../promise\"><code>Promise</code></a></li> <li><a href=\"then\"><code>Promise.prototype.then()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/catch$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/catch\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/catch</a>\n  </p>\n</div>\n","global_objects/proxy/handler/apply":"<h1>Proxy.handler.apply</h1> <p>The <code>handler.apply()</code> method is a trap for a function call.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/proxyhandler-apply.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js taller\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre data-language=\"js\">var p = new Proxy(target, {\n  apply: function(target, thisArg, argumentsList) {\n  }\n});\n</pre> <h3 id=\"Parameters\">Parameters</h3> <p>The following parameters are passed to the <code>apply</code> method. <code>this</code> is bound to the handler.</p> <dl> <dt><code>target</code></dt> <dd>The target object.</dd> <dt><code>thisArg</code></dt> <dd>The this argument for the call.</dd> <dt><code>argumentsList</code></dt> <dd>The list of arguments for the call.</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p>The <code>apply</code> method can return any value.</p> <h2 id=\"Description\">Description</h2> <p>The <code><strong>handler.apply</strong></code> method is a trap for a function call.</p> <h3 id=\"Interceptions\">Interceptions</h3> <p>This trap can intercept these operations:</p> <ul> <li><code>proxy(...args)</code></li> <li>\n<a href=\"../../function/apply\"><code>Function.prototype.apply()</code></a> and <a href=\"../../function/call\"><code>Function.prototype.call()</code></a>\n</li> <li><a href=\"../../reflect/apply\"><code>Reflect.apply()</code></a></li> </ul> <h3 id=\"Invariants\">Invariants</h3> <p>If the following invariants are violated, the proxy will throw a TypeError:</p> <p>The <code>target</code> must be a callable itself. That is, it must be a function object.</p> <h2 id=\"Examples\">Examples</h2> <p>The following code traps a function call.</p> <pre data-language=\"js\">var p = new Proxy(function() {}, {\n  apply: function(target, thisArg, argumentsList) {\n    console.log('called: ' + argumentsList.join(', '));\n    return argumentsList[0] + argumentsList[1] + argumentsList[2];\n  }\n});\n\nconsole.log(p(1, 2, 3)); // \"called: 1, 2, 3\"\n                         // 6\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-proxy-object-internal-methods-and-internal-slots-call-thisargument-argumentslist\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of '[[Call]]' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-proxy-object-internal-methods-and-internal-slots-call-thisargument-argumentslist\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of '[[Call]]' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>   <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 49</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 18</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 36</td>\n<td class=\"bc-supports-yes\"> 10</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 49</td>\n<td class=\"bc-supports-yes\"> 49</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 18</td>\n<td class=\"bc-supports-yes\"> 36</td>\n<td class=\"bc-supports-yes\"> 10</td>\n<td class=\"bc-supports-yes\"> 5.0</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 6.0.0</td>\n</tr></tbody>\n</table>\n</div>  <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"../../proxy\"><code>Proxy</code></a></li> <li><a href=\"../handler\"><code>handler</code></a></li> <li><a href=\"../../function/apply\"><code>Function.prototype.apply</code></a></li> <li><a href=\"../../function/call\"><code>Function.prototype.call</code></a></li> <li><a href=\"../../reflect/apply\"><code>Reflect.apply()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy/handler/apply$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy/handler/apply\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy/handler/apply</a>\n  </p>\n</div>\n","global_objects/proxy/handler/construct":"<h1>Proxy.handler.construct</h1> <p>The <code><strong>handler.construct()</strong></code> method is a trap for the <a href=\"../../../operators/new\"><code>new</code></a> operator. In order for the new operation to be valid on the resulting Proxy object, the target used to initialize the proxy must itself have a <code>[[Construct]]</code> internal method (i.e. <code>new target</code> must be valid).</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/proxyhandler-construct.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js taller\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre data-language=\"js\">var p = new Proxy(target, {\n  construct: function(target, argumentsList, newTarget) {\n  }\n});\n</pre> <h3 id=\"Parameters\">Parameters</h3> <p>The following parameters are passed to the <code>construct</code> method. <code>this</code> is bound to the handler.</p> <dl> <dt><code>target</code></dt> <dd>The target object.</dd> <dt><code>argumentsList</code></dt> <dd>The list of arguments for the constructor.</dd> <dt><code>newTarget</code></dt> <dd>The constructor that was originally called, <code>p</code> above.</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p>The <code>construct</code> method must return an object.</p> <h2 id=\"Description\">Description</h2> <p>The <code><strong>handler.construct()</strong></code> method is a trap for the <a href=\"../../../operators/new\"><code>new</code></a> operator.</p> <h3 id=\"Interceptions\">Interceptions</h3> <p>This trap can intercept these operations:</p> <ul> <li><code>new proxy(...args)</code></li> <li><a href=\"../../reflect/construct\"><code>Reflect.construct()</code></a></li> </ul> <h3 id=\"Invariants\">Invariants</h3> <p>If the following invariants are violated, the proxy will throw a <a href=\"../../typeerror\"><code>TypeError</code></a>:</p> <ul> <li>The result must be an <code>Object</code>.</li> </ul> <h2 id=\"Examples\">Examples</h2> <p>The following code traps the <a href=\"../../../operators/new\"><code>new</code></a> operator.</p> <pre data-language=\"js\">var p = new Proxy(function() {}, {\n  construct: function(target, argumentsList, newTarget) {\n    console.log('called: ' + argumentsList.join(', '));\n    return { value: argumentsList[0] * 10 };\n  }\n});\n\nconsole.log(new p(1).value); // \"called: 1\"\n                             // 10\n</pre> <p>The following code violates the invariant.</p> <pre data-language=\"js\">var p = new Proxy(function() {}, {\n  construct: function(target, argumentsList, newTarget) {\n    return 1;\n  }\n});\n\nnew p(); // TypeError is thrown\n</pre> <p>The following code improperly initializes the proxy. The <code>target</code> in Proxy initialization must itself be a valid constructor for the <code>new</code> operator.</p> <pre data-language=\"js\">var p = new Proxy({}, {\n  construct: function(target, argumentsList, newTarget) {\n    return {};\n  }\n});\n\nnew p(); // TypeError is thrown, \"p\" is not a constructor\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-proxy-object-internal-methods-and-internal-slots-construct-argumentslist-newtarget\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of '[[Construct]]' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-proxy-object-internal-methods-and-internal-slots-construct-argumentslist-newtarget\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of '[[Construct]]' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>   <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 49</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 18</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 36</td>\n<td class=\"bc-supports-yes\"> 10</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 49</td>\n<td class=\"bc-supports-yes\"> 49</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 18</td>\n<td class=\"bc-supports-yes\"> 36</td>\n<td class=\"bc-supports-yes\"> 10</td>\n<td class=\"bc-supports-yes\"> 5.0</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 6.0.0</td>\n</tr></tbody>\n</table>\n</div>  <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"../../proxy\"><code>Proxy</code></a></li> <li><a href=\"../handler\"><code>handler</code></a></li> <li>\n<a href=\"../../../operators/new\"><code>new</code></a> operator.</li> <li><a href=\"../../reflect/construct\"><code>Reflect.construct()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy/handler/construct$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy/handler/construct\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy/handler/construct</a>\n  </p>\n</div>\n","global_objects/proxy/handler/deleteproperty":"<h1>Proxy.handler.deleteProperty</h1> <p>The <code>handler.deleteProperty()</code> method is a trap for the <a href=\"../../../operators/delete\"><code>delete</code></a> operator.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/proxyhandler-deleteproperty.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js taller\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre data-language=\"js\">var p = new Proxy(target, {\n  deleteProperty: function(target, property) {\n  }\n});\n</pre> <h3 id=\"Parameters\">Parameters</h3> <p>The following parameters are passed to the <code>deleteProperty</code> method. <code>this</code> is bound to the handler.</p> <dl> <dt><code>target</code></dt> <dd>The target object.</dd> <dt><code>property</code></dt> <dd>The name or <a href=\"../../symbol\"><code>Symbol</code></a> of the property to delete.</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p>The <code>deleteProperty</code> method must return a <a href=\"../../boolean\"><code>Boolean</code></a> indicating whether or not the property has been successfully deleted.</p> <h2 id=\"Description\">Description</h2> <p>The <code><strong>handler.deleteProperty()</strong></code> method is a trap for the <a href=\"../../../operators/delete\"><code>delete</code></a> operator.</p> <h3 id=\"Interceptions\">Interceptions</h3> <p>This trap can intercept these operations:</p> <ul> <li>Property deletion: <code>delete proxy[foo]</code> and <code>delete proxy.foo</code>\n</li> <li><a href=\"../../reflect/deleteproperty\"><code>Reflect.deleteProperty()</code></a></li> </ul> <h3 id=\"Invariants\">Invariants</h3> <p>If the following invariants are violated, the proxy will throw a <a href=\"../../typeerror\"><code>TypeError</code></a>:</p> <ul> <li>A property cannot be deleted, if it exists as a non-configurable own property of the target object.</li> </ul> <h2 id=\"Examples\">Examples</h2> <p>The following code traps the <a href=\"../../../operators/delete\"><code>delete</code></a> operator.</p> <pre data-language=\"js\">var p = new Proxy({}, {\n  deleteProperty: function(target, prop) {\n    if (prop in target){\n      delete target[prop]\n      console.log('property removed: ' + prop)\n      return true\n    }\n    else {\n      console.log('property not found: ' + prop)\n      return false\n    }\n  }\n})\n\nvar result\n\np.a = 10\nconsole.log('a' in p)  // true\n\nresult = delete p.a    // \"property removed: a\"\nconsole.log(result)    // true\nconsole.log('a' in p)  // false\n\nresult = delete p.a    // \"property not found: a\"\nconsole.log(result)    // false\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-proxy-object-internal-methods-and-internal-slots-delete-p\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of '[[Delete]]' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-proxy-object-internal-methods-and-internal-slots-delete-p\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of '[[Delete]]' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>   <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 49</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 18</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 36</td>\n<td class=\"bc-supports-yes\"> 10</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 49</td>\n<td class=\"bc-supports-yes\"> 49</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 18</td>\n<td class=\"bc-supports-yes\"> 36</td>\n<td class=\"bc-supports-yes\"> 10</td>\n<td class=\"bc-supports-yes\"> 5.0</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 6.0.0</td>\n</tr></tbody>\n</table>\n</div>  <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"../../proxy\"><code>Proxy</code></a></li> <li><a href=\"../handler\"><code>handler</code></a></li> <li>\n<a href=\"../../../operators/delete\"><code>delete</code></a> operator</li> <li><a href=\"../../reflect/deleteproperty\"><code>Reflect.deleteProperty()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy/handler/deleteProperty$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy/handler/deleteProperty\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy/handler/deleteProperty</a>\n  </p>\n</div>\n","global_objects/promise/all":"<h1>Promise.all</h1> <p>The <code>Promise.all(<var>iterable</var>)</code> method returns a single <a href=\"../promise\"><code>Promise</code></a> that resolves when all of the promises in the <var>iterable</var> argument have resolved or when the <var>iterable</var> argument contains no promises. It rejects with the reason of the first promise that rejects.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/promise-all.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\">Promise.all(<var>iterable</var>);</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><var>iterable</var></dt> <dd>An <a href=\"../../iteration_protocols#The_iterable_protocol\">iterable</a> object such as an <a href=\"../array\"><code>Array</code></a> or <a href=\"../string\"><code>String</code></a>.</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <ul> <li>An <strong>already resolved</strong> <a href=\"../promise\"><code>Promise</code></a> if the <var>iterable</var> passed is empty.</li> <li>An <strong>asynchronously resolved</strong> <a href=\"../promise\"><code>Promise</code></a> if the <var>iterable</var> passed contains no promises. Note, Google Chrome 58 returns an <strong>already resolved</strong> promise in this case.</li> <li>A <strong>pending</strong> <a href=\"../promise\"><code>Promise</code></a> in all other cases. This returned promise is then resolved/rejected <strong>asynchronously</strong> (as soon as the stack is empty) when all the promises in the given <var>iterable</var> have resolved, or if any of the promises reject. See the example about \"Asynchronicity or synchronicity of Promise.all\" below. Returned values will be in order of the Promises passed, regardless of completion order.</li> </ul> <h2 id=\"Description\">Description</h2> <p>This method can be useful for aggregating the results of multiple promises.</p> <p>Fulfillment:<br> If an empty <var>iterable</var> is passed, then this method returns (synchronously) an already resolved promise.<br> If all of the passed-in promises fulfill, or are not promises, the promise returned by <code>Promise.all</code> is fulfilled asynchronously.<br> In all cases, the returned promise is fulfilled with an array containing <strong>all </strong>the values of the <var>iterable</var> passed as argument (also non-promise values).</p> <p>Rejection:<br> If any of the passed-in promises reject, <code>Promise.all</code> asynchronously rejects with the value of the promise that rejected, whether or not the other promises have resolved.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Using_Promise.all\">Using <code>Promise.all</code>\n</h3> <p><code>Promise.all</code> waits for all fulfillments (or the first rejection).</p> <pre data-language=\"js\">var p1 = Promise.resolve(3);\nvar p2 = 1337;\nvar p3 = new Promise((resolve, reject) =&gt; {\n  setTimeout(() =&gt; {\n    resolve(\"foo\");\n  }, 100);\n}); \n\nPromise.all([p1, p2, p3]).then(values =&gt; { \n  console.log(values); // [3, 1337, \"foo\"] \n});</pre> <p>If the <var>iterable</var> contains non-promise values, they will be ignored, but still counted in the returned promise array value (if the promise is fulfilled):</p> <pre data-language=\"js\">// this will be counted as if the iterable passed is empty, so it gets fulfilled\nvar p = Promise.all([1,2,3]);\n// this will be counted as if the iterable passed contains only the resolved promise with value \"444\", so it gets fulfilled\nvar p2 = Promise.all([1,2,3, Promise.resolve(444)]);\n// this will be counted as if the iterable passed contains only the rejected promise with value \"555\", so it gets rejected\nvar p3 = Promise.all([1,2,3, Promise.reject(555)]);\n\n// using setTimeout we can execute code after the stack is empty\nsetTimeout(function() {\n    console.log(p);\n    console.log(p2);\n    console.log(p3);\n});\n\n// logs\n// Promise { &lt;state&gt;: \"fulfilled\", &lt;value&gt;: Array[3] }\n// Promise { &lt;state&gt;: \"fulfilled\", &lt;value&gt;: Array[4] }\n// Promise { &lt;state&gt;: \"rejected\", &lt;reason&gt;: 555 }</pre> <h3 id=\"Asynchronicity_or_synchronicity_of_Promise.all\">Asynchronicity or synchronicity of <code>Promise.all</code>\n</h3> <p>This following example demonstrates the asynchronicity (or synchronicity, if the <var>iterable</var> passed is empty) of <code>Promise.all</code>:</p> <pre data-language=\"js\">// we are passing as argument an array of promises that are already resolved,\n// to trigger Promise.all as soon as possible\nvar resolvedPromisesArray = [Promise.resolve(33), Promise.resolve(44)];\n\nvar p = Promise.all(resolvedPromisesArray);\n// immediately logging the value of p\nconsole.log(p);\n\n// using setTimeout we can execute code after the stack is empty\nsetTimeout(function() {\n    console.log('the stack is now empty');\n    console.log(p);\n});\n\n// logs, in order:\n// Promise { &lt;state&gt;: \"pending\" } \n// the stack is now empty\n// Promise { &lt;state&gt;: \"fulfilled\", &lt;value&gt;: Array[2] }\n</pre> <p>The same thing happens if <code>Promise.all</code> rejects:</p> <pre data-language=\"js\">var mixedPromisesArray = [Promise.resolve(33), Promise.reject(44)];\nvar p = Promise.all(mixedPromisesArray);\nconsole.log(p);\nsetTimeout(function() {\n    console.log('the stack is now empty');\n    console.log(p);\n});\n\n// logs\n// Promise { &lt;state&gt;: \"pending\" } \n// the stack is now empty\n// Promise { &lt;state&gt;: \"rejected\", &lt;reason&gt;: 44 }\n</pre> <p>But, <code>Promise.all</code> resolves synchronously <strong>if and only if</strong> the <var>iterable</var> passed is empty:</p> <pre data-language=\"js\">var p = Promise.all([]); // will be immediately resolved\nvar p2 = Promise.all([1337, \"hi\"]); // non-promise values will be ignored, but the evaluation will be done asynchronously\nconsole.log(p);\nconsole.log(p2)\nsetTimeout(function() {\n    console.log('the stack is now empty');\n    console.log(p2);\n});\n\n// logs\n// Promise { &lt;state&gt;: \"fulfilled\", &lt;value&gt;: Array[0] }\n// Promise { &lt;state&gt;: \"pending\" }\n// the stack is now empty\n// Promise { &lt;state&gt;: \"fulfilled\", &lt;value&gt;: Array[2] }\n</pre> <h3 id=\"Promise.all_fail-fast_behaviour\">\n<code>Promise.all</code> fail-fast behaviour</h3> <p><code>Promise.all</code> is rejected if any of the elements are rejected. For example, if you pass in four promises that resolve after a timeout and one promise that rejects immediately, then <code>Promise.all</code> will reject immediately.</p> <pre data-language=\"js\">var p1 = new Promise((resolve, reject) =&gt; { \n  setTimeout(() =&gt; resolve('one'), 1000); \n}); \nvar p2 = new Promise((resolve, reject) =&gt; { \n  setTimeout(() =&gt; resolve('two'), 2000); \n});\nvar p3 = new Promise((resolve, reject) =&gt; {\n  setTimeout(() =&gt; resolve('three'), 3000);\n});\nvar p4 = new Promise((resolve, reject) =&gt; {\n  setTimeout(() =&gt; resolve('four'), 4000);\n});\nvar p5 = new Promise((resolve, reject) =&gt; {\n  reject(new Error('reject'));\n});\n\n\n// Using .catch:\nPromise.all([p1, p2, p3, p4, p5])\n.then(values =&gt; { \n  console.log(values);\n})\n.catch(error =&gt; { \n  console.log(error.message)\n});\n\n//From console: \n//\"reject\"\n\n</pre> <p>It is possible to change this behaviour by handling possible rejections:</p> <pre data-language=\"js\">var p1 = new Promise((resolve, reject) =&gt; { \n  setTimeout(() =&gt; resolve('p1_delayed_resolvement'), 1000); \n}); \n\nvar p2 = new Promise((resolve, reject) =&gt; {\n  reject(new Error('p2_immediate_rejection'));\n});\n\nPromise.all([\n  p1.catch(error =&gt; { return error }),\n  p2.catch(error =&gt; { return error }),\n]).then(values =&gt; { \n  console.log(values[0]) // \"p1_delayed_resolvement\"\n  console.log(values[1]) // \"Error: p2_immediate_rejection\"\n})\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-promise.all\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Promise.all' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition in an ECMA standard.</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-promise.all\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Promise.all' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 32</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 29</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 19</td>\n<td class=\"bc-supports-yes\"> 8</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 4.4.3</td>\n<td class=\"bc-supports-yes\"> 32</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 29</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 8</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 0.12</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"../promise\"><code>Promise</code></a></li> <li><a href=\"race\"><code>Promise.race()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/all$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/all\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/all</a>\n  </p>\n</div>\n","global_objects/promise/finally":"<h1>promise.finally</h1> <p>The <code><strong>finally()</strong></code> method returns a <a href=\"../promise\"><code>Promise</code></a>. When the promise is settled, whether fulfilled or rejected, the specified callback function is executed. This provides a way for code that must be executed once the <code>Promise</code> has been dealt with to be run whether the promise was fulfilled successfully or rejected.</p> <p>This lets you avoid duplicating code in both the promise's <a href=\"then\"><code>then()</code></a> and <a href=\"catch\"><code>catch()</code></a> handlers.</p> <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\"><var>p.finally(onFinally)</var>;\n\np.finally(function() {\n   // settled (fulfilled or rejected)\n});\n</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><code>onFinally</code></dt> <dd>A <a href=\"../function\"><code>Function</code></a> called when the <code>Promise</code> is settled.</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p>Returns a <a href=\"../promise\"><code>Promise</code></a> whose <code>finally</code> handler is set to the specified function, <code>onFinally</code>.</p> <h2 id=\"Description\">Description</h2> <p>The <code>finally()</code> method can be useful if you want to do some processing or cleanup once the promise is settled, regardless of its outcome.</p> <p>The <code>finally()</code> method is very similar to calling <code>.then(onFinally, onFinally)</code> however there are couple of differences:</p> <ul> <li>When creating a function inline, you can pass it once, instead of being forced to either declare it twice, or create a variable for it</li> <li>A <code>finally</code> callback will not receive any argument, since there's no reliable means of determining if the promise was fulfilled or rejected. This use case is for precisely when you <em>do not care</em> about the rejection reason, or the fulfillment value, and so there's no need to provide it.</li> <li>Unlike <code>Promise.resolve(2).then(() =&gt; {}, () =&gt; {})</code> (which will be resolved with <code>undefined</code>), <code>Promise.resolve(2).finally(() =&gt; {})</code> will be resolved with <code>2</code>.</li> <li>Similarly, unlike <code>Promise.reject(3).then(() =&gt; {}, () =&gt; {})</code> (which will be fulfilled with <code>undefined</code>), <code>Promise.reject(3).finally(() =&gt; {})</code> will be rejected with <code>3</code>.</li> </ul> <div class=\"note\"> <p><strong>Note:</strong> A <code>throw</code> (or returning a rejected promise) in the <code>finally</code> callback will reject the new promise with the rejection reason specified when calling <code>throw()</code>.</p> </div> <h2 id=\"Examples\">Examples</h2> <pre data-language=\"js\">let isLoading = true;\n\nfetch(myRequest).then(function(response) {\n    var contentType = response.headers.get(\"content-type\");\n    if(contentType &amp;&amp; contentType.includes(\"application/json\")) {\n      return response.json();\n    }\n    throw new TypeError(\"Oops, we haven't got JSON!\");\n  })\n  .then(function(json) { /* process your JSON further */ })\n  .catch(function(error) { console.log(error); /* this line can also throw, e.g. when console = {} */ })\n  .finally(function() { isLoading = false; });\n\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-promise.prototype.finally\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Promise.prototype.finally' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 63</td>\n<td class=\"bc-supports-yes\"> 18</td>\n<td class=\"bc-supports-yes\"> 58</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 50</td>\n<td class=\"bc-supports-yes\"> 11.1</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 63</td>\n<td class=\"bc-supports-yes\"> 63</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 58</td>\n<td class=\"bc-supports-yes\"> 50</td>\n<td class=\"bc-supports-yes\"> 11.1</td>\n<td class=\"bc-supports-no\"> No</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 10.0.0</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"../promise\"><code>Promise</code></a></li> <li><a href=\"then\"><code>Promise.prototype.then()</code></a></li> <li><a href=\"catch\"><code>Promise.prototype.catch()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/finally$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/finally\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/finally</a>\n  </p>\n</div>\n","global_objects/promise/then":"<h1>promise.then</h1> <p>The <code><strong>then()</strong></code> method returns a <a href=\"https://developer.mozilla.org/en-US/docs/Web/API/Promise\"><code>Promise</code></a>. It takes up to two arguments: callback functions for the success and failure cases of the <code>Promise</code>.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/promise-then.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <div class=\"note\"> <p>If one or both arguments are omitted or are provided non-functions, then <code>then</code> will be missing the handler(s), but will not generate any errors. If the <code>Promise</code> that <code>then</code> is called on adopts a state (<code>fulfillment</code> or <code>rejection</code>) for which <code>then</code> has no handler, a new <code>Promise</code> is created with no additional handlers, simply adopting the final state of the original <code>Promise</code> on which <code>then</code> was called.</p> </div> <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\"><var>p.then(onFulfilled[, onRejected])</var>;\n\np.then((value) =&gt; {\n  // fulfillment\n}, (reason) =&gt; {\n  // rejection\n});\n</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><code>onFulfilled</code></dt> <dd>A <a href=\"../function\"><code>Function</code></a> called if the <code>Promise</code> is fulfilled. This function has one argument, the <code>fulfillment value</code>. If it is not a function, it is internally replaced with an \"Identity\" function (it returns the received argument).</dd> <dt>\n<code>onRejected </code><span class=\"inlineIndicator optional optionalInline\">Optional</span>\n</dt> <dd>A <a href=\"../function\"><code>Function</code></a> called if the <code>Promise</code> is rejected. This function has one argument, the <code>rejection reason</code>. If it is not a function, it is internally replaced with a \"Thrower\" function (it throws an error it received as argument).</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p>Once a <a href=\"../promise\"><code>Promise</code></a> is fulfilled or rejected, the respective handler function (<code style=\"font-style: normal; font-weight: normal;\">onFulfilled</code> or <code style=\"font-style: normal; font-weight: normal;\">onRejected</code>) will be called <strong>asynchronously</strong> (scheduled in the current thread loop). The behavior of the handler function follows a specific set of rules. If a handler function:</p> <ul> <li>returns a value, the promise returned by <code>then</code> gets resolved with the returned value as its value;</li> <li>doesn't return anything, the promise returned by <code>then</code> gets resolved with an <code>undefined</code> value;</li> <li>throws an error, the promise returned by <code>then</code> gets rejected with the thrown error as its value;</li> <li>returns an already resolved promise, the promise returned by <code>then</code> gets resolved with that promise's value as its value;</li> <li>returns an already rejected promise, the promise returned by <code>then</code> gets rejected with that promise's value as its value;</li> <li>returns another <strong>pending</strong> promise object, the resolution/rejection of the promise returned by <code>then</code> will be subsequent to the resolution/rejection of the promise returned by the handler. Also, the value of the promise returned by <code>then</code> will be the same as the value of the promise returned by the handler.</li> </ul> <p>Following, an example to demonstrate the asynchronicity of the <code>then</code> method.</p> <pre data-language=\"js\">// using a resolved promise, the 'then' block will be triggered instantly, \n// but its handlers will be triggered asynchronously as demonstrated by the console.logs\nconst resolvedProm = Promise.resolve(33);\n\nlet thenProm = resolvedProm.then((value)=&gt;{\n    console.log(\"this gets called after the end of the main stack. the value received and returned is: \" + value);\n    return value;\n});\n// instantly logging the value of thenProm\nconsole.log(thenProm);\n\n// using setTimeout we can postpone the execution of a function to the moment the stack is empty\nsetTimeout(()=&gt;{\n    console.log(thenProm);\n});\n\n\n// logs, in order:\n// Promise {[[PromiseStatus]]: \"pending\", [[PromiseValue]]: undefined}\n// \"this gets called after the end of the main stack. the value received and returned is: 33\"\n// Promise {[[PromiseStatus]]: \"resolved\", [[PromiseValue]]: 33}</pre> <h2 id=\"Description\">Description</h2> <p>As the <code>then</code> and <a href=\"catch\"><code>Promise.prototype.catch()</code></a> methods return promises, they can be chained — an operation called <em>composition</em>.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Using_the_then_method\">Using the <code>then</code> method</h3> <pre data-language=\"js\">var p1 = new Promise( (resolve, reject) =&gt; {\n  resolve('Success!');\n  // or\n  // reject(new Error(\"Error!\"));\n} );\n\np1.then( value =&gt; {\n  console.log(value); // Success!\n}, reason =&gt; {\n  console.log(reason); // Error!\n} );\n</pre> <h3 id=\"Chaining\">Chaining</h3> <p>The <code>then</code> method returns a <code>Promise</code> which allows for method chaining.</p> <p>If the function passed as handler to <code>then</code> returns a <code>Promise</code>, an equivalent <code>Promise</code> will be exposed to the subsequent <code>then</code> in the method chain. The below snippet simulates asynchronous code with the <code>setTimeout</code> function. </p> <pre data-language=\"js\">Promise.resolve('foo')\n  // 1. Receive \"foo\", concatenate \"bar\" to it, and resolve that to the next then\n  .then(function(string) {\n    return new Promise(function(resolve, reject) {\n      setTimeout(function() {\n        string += 'bar';\n        resolve(string);\n      }, 1);\n    });\n  })\n  // 2. receive \"foobar\", register a callback function to work on that string\n  // and print it to the console, but not before returning the unworked on\n  // string to the next then\n  .then(function(string) {\n    setTimeout(function() {\n      string += 'baz';\n      console.log(string);\n    }, 1)\n    return string;\n  })\n  // 3. print helpful messages about how the code in this section will be run\n  // before the string is actually processed by the mocked asynchronous code in the\n  // previous then block.  \n  .then(function(string) {\n    console.log(\"Last Then:  oops... didn't bother to instantiate and return \" +\n                \"a promise in the prior then so the sequence may be a bit \" +\n                \"surprising\");\n\n    // Note that `string` will not have the 'baz' bit of it at this point. This \n    // is because we mocked that to happen asynchronously with a setTimeout function\n    console.log(string);\n  });\n\n// logs, in order:\n// Last Then: oops... didn't bother to instantiate and return a promise in the prior then so the sequence may be a bit surprising\n// foobar\n// foobarbaz</pre> <p>When a value is simply returned from within a <code>then</code> handler, it will effectively return <code>Promise.resolve(&lt;value returned by whichever handler was called&gt;)</code>.</p> <pre data-language=\"js\">var p2 = new Promise(function(resolve, reject) {\n  resolve(1);\n});\n\np2.then(function(value) {\n  console.log(value); // 1\n  return value + 1;\n}).then(function(value) {\n  console.log(value + ' - A synchronous value works');\n});\n\np2.then(function(value) {\n  console.log(value); // 1\n});\n</pre> <p>A <code>then</code> call will return a rejected promise if the function throws an error or returns a rejected Promise.</p> <pre data-language=\"js\">Promise.resolve()\n  .then( () =&gt; {\n    // Makes .then() return a rejected promise\n    throw new Error('Oh no!');\n  })\n  .then( () =&gt; { \n    console.log( 'Not called.' );\n  }, error =&gt; {\n    console.error( 'onRejected function called: ' + error.message );\n  });</pre> <p>In all other cases, a resolving Promise is returned. In the following example, the first <code>then()</code> will return <code>42</code> wrapped resolving Promise even though the previous Promise in the chain was rejected.</p> <pre data-language=\"js\">Promise.reject()\n  .then( () =&gt; 99, () =&gt; 42 ) // onRejected returns 42 which is wrapped in a resolving Promise\n  .then( solution =&gt; console.log( 'Resolved with ' + solution ) ); // Resolved with 42</pre> <p>In practice, it is often desirable to catch rejected promises rather than use <code>then</code>'s two case syntax, as demonstrated below.</p> <pre data-language=\"js\">Promise.resolve()\n  .then( () =&gt; {\n    // Makes .then() return a rejected promise\n    throw new Error('Oh no!');\n  })\n  .catch( error =&gt; {\n    console.error( 'onRejected function called: ' + error.message );\n  })\n  .then( () =&gt; {\n    console.log( \"I am always called even if the prior then's promise rejects\" );\n  });</pre> <p><br> You can also use chaining to implement one function with a Promise-based API on top of another such function.</p> <pre data-language=\"js\">function fetch_current_data() {\n  // The <a href=\"https://developer.mozilla.org/en-US/docs/Web/API/GlobalFetch/fetch\">fetch</a>() API returns a Promise.  This function\n  // exposes a similar API, except the fulfillment\n  // value of this function's Promise has had more\n  // work done on it.\n  return fetch('current-data.json').then((response) =&gt; {\n    if (response.headers.get('content-type') != 'application/json') {\n      throw new TypeError();\n    }\n    var j = response.json();\n    // maybe do something with j\n    return j; // fulfillment value given to user of\n              // fetch_current_data().then()\n  });\n}\n</pre> <p>If <code>onFulfilled</code> returns a promise, the return value of <code>then</code> will be resolved/rejected by the promise.</p> <pre data-language=\"js\">function resolveLater(resolve, reject) {\n  setTimeout(function () {\n    resolve(10);\n  }, 1000);\n}\nfunction rejectLater(resolve, reject) {\n  setTimeout(function () {\n    reject(new Error('Error'));\n  }, 1000);\n}\n\nvar p1 = Promise.resolve('foo');\nvar p2 = p1.then(function() {\n  // Return promise here, that will be resolved to 10 after 1 second\n  return new Promise(resolveLater);\n});\np2.then(function(v) {\n  console.log('resolved', v);  // \"resolved\", 10\n}, function(e) {\n  // not called\n  console.log('rejected', e);\n});\n\nvar p3 = p1.then(function() {\n  // Return promise here, that will be rejected with 'Error' after 1 second\n  return new Promise(rejectLater);\n});\np3.then(function(v) {\n  // not called\n  console.log('resolved', v);\n}, function(e) {\n  console.log('rejected', e); // \"rejected\", 'Error'\n});\n</pre> <h3 id=\"window.setImmediate_style_promise-based_polyfill\">\n<a href=\"https://developer.mozilla.org/en-US/docs/Web/API/Window/setImmediate\"><code>window.setImmediate</code></a> style promise-based polyfill</h3> <p>Using a <a href=\"../function/bind\"><code>Function.prototype.bind()</code></a> <code>Reflect.apply</code> (<a href=\"../reflect/apply\"><code>Reflect.apply()</code></a>) method to create a (non-cancellable) setImmediate-style function.</p> <pre data-language=\"js\">const nextTick = (()=&gt;{\n  const noop = () =&gt; {}; // literally\n  const nextTickPromise = () =&gt; Promise.resolve().then(noop);\n\n  const rfab = Reflect.apply.bind; // (thisArg, fn, thisArg, [...args])\n  const nextTick = (fn, ...args) =&gt; (\n    fn !== undefined\n    ? Promise.resolve(args).then(rfab(null, fn, null))\n    : nextTickPromise(),\n    undefined\n  );\n  nextTick.ntp = nextTickPromise;\n\n  return nextTick;\n})();\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-promise.prototype.then\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Promise.prototype.then' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition in an ECMA standard.</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-promise.prototype.then\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Promise.prototype.then' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 32</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 29</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 19</td>\n<td class=\"bc-supports-yes\"> 8</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 4.4.3</td>\n<td class=\"bc-supports-yes\"> 32</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 29</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 8</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 0.12</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"../promise\"><code>Promise</code></a></li> <li><a href=\"catch\"><code>Promise.prototype.catch()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/then$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/then\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/then</a>\n  </p>\n</div>\n","global_objects/proxy/handler/defineproperty":"<h1>Proxy.handler.defineProperty</h1> <p>The <code>handler.defineProperty()</code> method is a trap for <a href=\"../../object/defineproperty\"><code>Object.defineProperty()</code></a>.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/proxyhandler-defineproperty.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js taller\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre data-language=\"js\">var p = new Proxy(target, {\n  defineProperty: function(target, property, descriptor) {\n  }\n});\n</pre> <h3 id=\"Parameters\">Parameters</h3> <p>The following parameters are passed to the <code>defineProperty</code> method. <code>this</code> is bound to the handler.</p> <dl> <dt><code>target</code></dt> <dd>The target object.</dd> <dt><code>property</code></dt> <dd>The name or <a href=\"../../symbol\"><code>Symbol</code></a> of the property whose description is to be retrieved.</dd> <dt><code>descriptor</code></dt> <dd>The descriptor for the property being defined or modified.</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p>The <code>defineProperty</code> method must return a <a href=\"../../boolean\"><code>Boolean</code></a> indicating whether or not the property has been successfully defined.</p> <h2 id=\"Description\">Description</h2> <p>The <code><strong>handler.defineProperty()</strong></code> method is a trap for <a href=\"../../object/defineproperty\"><code>Object.defineProperty()</code></a>.</p> <h3 id=\"Interceptions\">Interceptions</h3> <p>This trap can intercept these operations:</p> <ul> <li><a href=\"../../object/defineproperty\"><code>Object.defineProperty()</code></a></li> <li><a href=\"../../reflect/defineproperty\"><code>Reflect.defineProperty()</code></a></li> </ul> <h3 id=\"Invariants\">Invariants</h3> <p>If the following invariants are violated, the proxy will throw a <a href=\"../../typeerror\"><code>TypeError</code></a>:</p> <ul> <li>A property cannot be added, if the target object is not extensible.</li> <li>A property cannot be added as or modified to be non-configurable, if it does not exists as a non-configurable own property of the target object.</li> <li>A property may not be non-configurable, if a corresponding configurable property of the target object exists.</li> <li>If a property has a corresponding target object property then <code>Object.defineProperty(target, prop, descriptor)</code> will not throw an exception.</li> <li>In strict mode, a <code>false</code> return value from the <code>defineProperty</code> handler will throw a <a href=\"../../typeerror\"><code>TypeError</code></a> exception.</li> </ul> <h2 id=\"Examples\">Examples</h2> <p>The following code traps <a href=\"../../object/defineproperty\"><code>Object.defineProperty()</code></a>.</p> <pre data-language=\"js\">var p = new Proxy({}, {\n  defineProperty: function(target, prop, descriptor) {\n    console.log('called: ' + prop);\n    return true;\n  }\n});\n\nvar desc = { configurable: true, enumerable: true, value: 10 };\nObject.defineProperty(p, 'a', desc); // \"called: a\"\n</pre> <p>When calling <a href=\"../../object/defineproperty\"><code>Object.defineProperty()</code></a> or <a href=\"../../reflect/defineproperty\"><code>Reflect.defineProperty()</code></a>, the <code>descriptor</code> passed to <code>defineProperty</code> trap has one restriction - only following properties are usable, nonstandard properties will be ignored:</p> <ul> <li><code>enumerable</code></li> <li><code>configurable</code></li> <li><code>writable</code></li> <li><code>value</code></li> <li><code>get</code></li> <li><code>set</code></li> </ul> <pre data-language=\"js\">var p = new Proxy({}, {\n  defineProperty(target, prop, descriptor) {\n    console.log(descriptor);\n    return Reflect.defineProperty(target, prop, descriptor);\n  }\n});\n\nObject.defineProperty(p, 'name', {\n  value: 'proxy',\n  type: 'custom'\n});  // { value: 'proxy' }\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-proxy-object-internal-methods-and-internal-slots-defineownproperty-p-desc\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of '[[DefineOwnProperty]]' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-proxy-object-internal-methods-and-internal-slots-defineownproperty-p-desc\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of '[[DefineOwnProperty]]' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>   <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 49</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 18</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 36</td>\n<td class=\"bc-supports-yes\"> 10</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 49</td>\n<td class=\"bc-supports-yes\"> 49</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 18</td>\n<td class=\"bc-supports-yes\"> 36</td>\n<td class=\"bc-supports-yes\"> 10</td>\n<td class=\"bc-supports-yes\"> 5.0</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 6.0.0</td>\n</tr></tbody>\n</table>\n</div>  <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"../../proxy\"><code>Proxy</code></a></li> <li><a href=\"../handler\"><code>handler</code></a></li> <li><a href=\"../../object/defineproperty\"><code>Object.defineProperty()</code></a></li> <li><a href=\"../../reflect/defineproperty\"><code>Reflect.defineProperty()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy/handler/defineProperty$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy/handler/defineProperty\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy/handler/defineProperty</a>\n  </p>\n</div>\n","global_objects/proxy/handler/get":"<h1>Proxy.handler.get</h1> <p>The <code>handler.get()</code> method is a trap for getting a property value.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/proxyhandler-get.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js taller\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre data-language=\"js\">var p = new Proxy(target, {\n  get: function(target, property, receiver) {\n  }\n});\n</pre> <h3 id=\"Parameters\">Parameters</h3> <p>The following parameters are passed to the <code>get</code> method. <code>this</code> is bound to the handler.</p> <dl> <dt><code>target</code></dt> <dd>The target object.</dd> <dt><code>property</code></dt> <dd>The name or <a href=\"../../symbol\"><code>Symbol</code></a> of the property to get. </dd> <dt><code>receiver</code></dt> <dd>Either the proxy or an object that inherits from the proxy.</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p>The <code>get</code> method can return any value.</p> <h2 id=\"Description\">Description</h2> <p>The <code><strong>handler.get</strong></code> method is a trap for getting a property value.</p> <h3 id=\"Interceptions\">Interceptions</h3> <p>This trap can intercept these operations:</p> <ul> <li>Property access: <code>proxy[foo]</code>and <code>proxy.bar</code>\n</li> <li>Inherited property access: <code>Object.create(proxy)[foo]</code>\n</li> <li><a href=\"../../reflect/get\"><code>Reflect.get()</code></a></li> </ul> <h3 id=\"Invariants\">Invariants</h3> <p>If the following invariants are violated, the proxy will throw a <a href=\"../../typeerror\"><code>TypeError</code></a>:</p> <ul> <li>The value reported for a property must be the same as the value of the corresponding target object property if the target object property is a non-writable, non-configurable data property.</li> <li>The value reported for a property must be undefined if the corresponding target object property is non-configurable accessor property that has undefined as its [[Get]] attribute.</li> </ul> <h2 id=\"Examples\">Examples</h2> <p>The following code traps getting a property value.</p> <pre data-language=\"js\">var p = new Proxy({}, {\n  get: function(target, property, receiver) {\n    console.log('called: ' + property);\n    return 10;\n  }\n});\n\nconsole.log(p.a); // \"called: a\"\n                  // 10\n</pre> <p>The following code violates an invariant.</p> <pre data-language=\"js\">var obj = {};\nObject.defineProperty(obj, 'a', { \n  configurable: false, \n  enumerable: false, \n  value: 10, \n  writable: false \n});\n\nvar p = new Proxy(obj, {\n  get: function(target, property) {\n    return 20;\n  }\n});\n\np.a; // TypeError is thrown\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-proxy-object-internal-methods-and-internal-slots-get-p-receiver\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of '[[Get]]' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-proxy-object-internal-methods-and-internal-slots-get-p-receiver\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of '[[Get]]' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>   <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 49</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 18</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 36</td>\n<td class=\"bc-supports-yes\"> 10</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 49</td>\n<td class=\"bc-supports-yes\"> 49</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 18</td>\n<td class=\"bc-supports-yes\"> 36</td>\n<td class=\"bc-supports-yes\"> 10</td>\n<td class=\"bc-supports-yes\"> 5.0</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 6.0.0</td>\n</tr></tbody>\n</table>\n</div>  <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"../../proxy\"><code>Proxy</code></a></li> <li><a href=\"../handler\"><code>handler</code></a></li> <li><a href=\"../../reflect/get\"><code>Reflect.get()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy/handler/get$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy/handler/get\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy/handler/get</a>\n  </p>\n</div>\n","global_objects/proxy/handler/getownpropertydescriptor":"<h1>Proxy.handler.getOwnPropertyDescriptor</h1> <p>The <code>handler.getOwnPropertyDescriptor()</code> method is a trap for <a href=\"../../object/getownpropertydescriptor\"><code>Object.getOwnPropertyDescriptor()</code></a>.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/proxyhandler-getownpropertydescriptor.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js taller\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre data-language=\"js\">var p = new Proxy(target, {\n  getOwnPropertyDescriptor: function(target, prop) {\n  }\n});\n</pre> <h3 id=\"Parameters\">Parameters</h3> <p>The following parameters are passed to the <code>getOwnPropertyDescriptor</code> method. <code>this</code> is bound to the handler.</p> <dl> <dt><code>target</code></dt> <dd>The target object.</dd> <dt><code>prop</code></dt> <dd>The name of the property whose description should be retrieved.</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p>The <code>getOwnPropertyDescriptor</code> method must return an object or <code>undefined</code>.</p> <h2 id=\"Description\">Description</h2> <p>The <code><strong>handler.getOwnPropertyDescriptor()</strong></code> method is a trap for <a href=\"../../object/getownpropertydescriptor\"><code>Object.getOwnPropertyDescriptor()</code></a>.</p> <h3 id=\"Interceptions\">Interceptions</h3> <p>This trap can intercept these operations:</p> <ul> <li><a href=\"../../object/getownpropertydescriptor\"><code>Object.getOwnPropertyDescriptor()</code></a></li> <li><a href=\"../../reflect/getownpropertydescriptor\"><code>Reflect.getOwnPropertyDescriptor()</code></a></li> </ul> <h3 id=\"Invariants\">Invariants</h3> <p>If the following invariants are violated, the proxy will throw a <a href=\"../../typeerror\"><code>TypeError</code></a>:</p> <ul> <li>\n<code>getOwnPropertyDescriptor</code> must return an object or <code>undefined</code>.</li> <li>A property cannot be reported as non-existent, if it exists as a non-configurable own property of the target object.</li> <li>A property cannot be reported as non-existent, if it exists as an own property of the target object and the target object is not extensible.</li> <li>A property cannot be reported as existent, if it does not exists as an own property of the target object and the target object is not extensible.</li> <li>A property cannot be reported as non-configurable, if it does not exists as an own property of the target object or if it exists as a configurable own property of the target object.</li> <li>The result of <code>Object.getOwnPropertyDescriptor(target)</code> can be applied to the target object using <code>Object.defineProperty</code> and will not throw an exception.</li> </ul> <h2 id=\"Examples\">Examples</h2> <p>The following code traps <a href=\"../../object/getownpropertydescriptor\"><code>Object.getOwnPropertyDescriptor()</code></a>.</p> <pre data-language=\"js\">var p = new Proxy({ a: 20}, {\n  getOwnPropertyDescriptor: function(target, prop) {\n    console.log('called: ' + prop);\n    return { configurable: true, enumerable: true, value: 10 };\n  }\n});\n\nconsole.log(Object.getOwnPropertyDescriptor(p, 'a').value); // \"called: a\"\n                                                            // 10\n</pre> <p>The following code violates an invariant.</p> <pre data-language=\"js\">var obj = { a: 10 };\nObject.preventExtensions(obj);\nvar p = new Proxy(obj, {\n  getOwnPropertyDescriptor: function(target, prop) {\n    return undefined;\n  }\n});\n\nObject.getOwnPropertyDescriptor(p, 'a'); // TypeError is thrown\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-proxy-object-internal-methods-and-internal-slots-getownproperty-p\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of '[[GetOwnProperty]]' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-proxy-object-internal-methods-and-internal-slots-getownproperty-p\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of '[[GetOwnProperty]]' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>   <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 49</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 18</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 36</td>\n<td class=\"bc-supports-yes\"> 10</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 49</td>\n<td class=\"bc-supports-yes\"> 49</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 18</td>\n<td class=\"bc-supports-yes\"> 36</td>\n<td class=\"bc-supports-yes\"> 10</td>\n<td class=\"bc-supports-yes\"> 5.0</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 6.0.0</td>\n</tr></tbody>\n</table>\n</div>  <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"../../proxy\"><code>Proxy</code></a></li> <li><a href=\"../handler\"><code>handler</code></a></li> <li><a href=\"../../object/getownpropertydescriptor\"><code>Object.getOwnPropertyDescriptor()</code></a></li> <li><a href=\"../../reflect/getownpropertydescriptor\"><code>Reflect.getOwnPropertyDescriptor()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy/handler/getOwnPropertyDescriptor$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy/handler/getOwnPropertyDescriptor\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy/handler/getOwnPropertyDescriptor</a>\n  </p>\n</div>\n","global_objects/proxy/revocable":"<h1>Proxy.revocable</h1> <p>The <code><strong>Proxy.revocable()</strong></code> method is used to create a revocable <a href=\"../proxy\"><code>Proxy</code></a> object.</p> <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\">Proxy.revocable(target, handler);\n</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><code>target</code></dt> <dd>A target object to wrap with <code>Proxy</code>. It can be any sort of object, including a native array, a function or even another proxy.</dd> <dt><code>handler</code></dt> <dd>An object whose properties are functions which define the behavior of the proxy when an operation is performed on it.</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p>A newly created revocable <code>Proxy</code> object is returned.</p> <h2 id=\"Description\">Description</h2> <p>A revocable <code>Proxy</code> is an object with following two properties <code>{proxy: proxy, revoke: revoke}</code>.</p> <dl> <dt><code>proxy</code></dt> <dd>A Proxy object created with <code>new Proxy(target, handler)</code> call.</dd> <dt><code>revoke</code></dt> <dd>A function with no argument to invalidate (switch off) the <code>proxy</code>.</dd> </dl> <p>If the <code>revoke()</code> function gets called, the proxy becomes unusable: Any trap to a handler will throw a <a href=\"../typeerror\"><code>TypeError</code></a>. Once a proxy is revoked, it will remain revoked and can be garbage collected. Calling <code>revoke()</code> again has no effect.</p> <h2 id=\"Examples\">Examples</h2> <pre data-language=\"js\">var revocable = Proxy.revocable({}, {\n  get: function(target, name) {\n    return \"[[\" + name + \"]]\";\n  }\n});\nvar proxy = revocable.proxy;\nconsole.log(proxy.foo); // \"[[foo]]\"\n\nrevocable.revoke();\n\nconsole.log(proxy.foo); // TypeError is thrown\nproxy.foo = 1           // TypeError again\ndelete proxy.foo;       // still TypeError\ntypeof proxy            // \"object\", typeof doesn't trigger any trap\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-proxy.revocable\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Proxy Revocation Functions' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-proxy.revocable\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Proxy Revocation Functions' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 34</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 10</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 34</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 10</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 6.0.0</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"../proxy\"><code>Proxy</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy/revocable$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy/revocable\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy/revocable</a>\n  </p>\n</div>\n","global_objects/promise/reject":"<h1>Promise.reject</h1> <p>The <code><strong>Promise.reject(reason)</strong></code> method returns a <code>Promise</code> object that is rejected with the given reason.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/promise-reject.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>    <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\"><var>Promise.reject(reason)</var>;</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt>reason</dt> <dd>Reason why this <code>Promise</code> rejected.</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p>A <a href=\"../promise\"><code>Promise</code></a> that is rejected with the given reason.</p> <h2 id=\"Description\">Description</h2> <p>The static <code>Promise.reject</code> function returns a <code>Promise</code> that is rejected. For debugging purposes and selective error catching, it is useful to make <code>reason</code> an <code>instanceof</code> <a href=\"../error\"><code>Error</code></a>.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Using_the_static_Promise.reject()_method\">Using the static Promise.reject() method</h3> <pre data-language=\"js\">Promise.reject(new Error('fail')).then(function() {\n  // not called\n}, function(error) {\n  console.log(error); // Stacktrace\n});</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-promise.reject\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Promise.reject' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition in an ECMA standard.</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-promise.reject\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Promise.reject' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 32</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 29</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 19</td>\n<td class=\"bc-supports-yes\"> 8</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 4.4.3</td>\n<td class=\"bc-supports-yes\"> 32</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 29</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 8</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 0.12</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"../promise\"><code>Promise</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/reject$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/reject\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/reject</a>\n  </p>\n</div>\n","global_objects/proxy/handler/getprototypeof":"<h1>Proxy.handler.getPrototypeOf</h1> <p>The <code>handler.getPrototypeOf()</code> method is a trap for the<code> [[GetPrototypeOf]]</code> internal method.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/proxyhandler-getprototypeof.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js taller\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre data-language=\"js\">var p = new Proxy(obj, {\n  getPrototypeOf(target) {\n  ...\n  }\n});\n</pre> <h3 id=\"Parameters\">Parameters</h3> <p>The following parameter is passed to the <code>getPrototypeOf</code> method. <code>this</code> is bound to the handler.</p> <dl> <dt><code>target</code></dt> <dd>The target object.</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p>The <code>getPrototypeOf</code> method must return an object or <code>null</code>.</p> <h2 id=\"Description\">Description</h2> <h3 id=\"Interceptions\">Interceptions</h3> <p>This trap can intercept these operations:</p> <ul> <li><a href=\"../../object/getprototypeof\"><code>Object.getPrototypeOf()</code></a></li> <li><a href=\"../../reflect/getprototypeof\"><code>Reflect.getPrototypeOf()</code></a></li> <li><a href=\"../../object/proto\"><code>__proto__</code></a></li> <li><a href=\"../../object/isprototypeof\"><code>Object.prototype.isPrototypeOf()</code></a></li> <li><a href=\"../../../operators/instanceof\"><code>instanceof</code></a></li> </ul> <h3 id=\"Invariants\">Invariants</h3> <p>If the following invariants are violated, the proxy will throw a <a href=\"../../typeerror\"><code>TypeError</code></a>:</p> <ul> <li>\n<code>getPrototypeOf</code> method must return an object or <code>null</code>.</li> <li>If <code>target</code> is not extensible, <code>Object.getPrototypeOf(proxy)</code> method must return the same value as <code>Object.getPrototypeOf(target)</code>.</li> </ul> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Basic_usage\">Basic usage</h3> <pre data-language=\"js\">var obj = {};\nvar proto = {};\nvar handler = {\n    getPrototypeOf(target) {\n        console.log(target === obj);   // true\n        console.log(this === handler); // true\n        return proto;\n    }\n};\n\nvar p = new Proxy(obj, handler);\nconsole.log(Object.getPrototypeOf(p) === proto);    // true\n</pre> <h3 id=\"Five_ways_to_trigger_the_getPrototypeOf_trap\">Five ways to trigger the getPrototypeOf trap</h3> <pre data-language=\"js\">var obj = {};\nvar p = new Proxy(obj, {\n    getPrototypeOf(target) {\n        return Array.prototype;\n    }\n});\nconsole.log(\n    Object.getPrototypeOf(p) === Array.prototype,  // true\n    Reflect.getPrototypeOf(p) === Array.prototype, // true\n    p.__proto__ === Array.prototype,               // true\n    Array.prototype.isPrototypeOf(p),              // true\n    p instanceof Array                             // true\n);\n</pre> <h3 id=\"Two_kinds_of_exceptions\">Two kinds of exceptions</h3> <pre data-language=\"js\">var obj = {};\nvar p = new Proxy(obj, {\n    getPrototypeOf(target) {\n        return 'foo';\n    }\n});\nObject.getPrototypeOf(p); // TypeError: \"foo\" is not an object or null\n\nvar obj = Object.preventExtensions({});\nvar p = new Proxy(obj, {\n    getPrototypeOf(target) {\n        return {};\n    }\n});\nObject.getPrototypeOf(p); // TypeError: expected same prototype value\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-proxy-object-internal-methods-and-internal-slots-getprototypeof\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of '[[GetPrototypeOf]]' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-proxy-object-internal-methods-and-internal-slots-getprototypeof\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of '[[GetPrototypeOf]]' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>   <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 49</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 49</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 6.0.0</td>\n</tr></tbody>\n</table>\n</div>  <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"../../proxy\"><code>Proxy</code></a></li> <li><a href=\"../handler\"><code>handler</code></a></li> <li><a href=\"../../object/getprototypeof\"><code>Object.getPrototypeOf()</code></a></li> <li><a href=\"../../reflect/getprototypeof\"><code>Reflect.getPrototypeOf()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy/handler/getPrototypeOf$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy/handler/getPrototypeOf\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy/handler/getPrototypeOf</a>\n  </p>\n</div>\n","global_objects/proxy/handler/isextensible":"<h1>Proxy.handler.isExtensible</h1> <p>The <code>handler.isExtensible()</code> method is a trap for <a href=\"../../object/isextensible\"><code>Object.isExtensible()</code></a>.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/proxyhandler-isextensible.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js taller\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre data-language=\"js\">var p = new Proxy(target, {\n  isExtensible: function(target) {\n  }\n});\n</pre> <h3 id=\"Parameters\">Parameters</h3> <p>The following parameter is passed to the <code>isExtensible</code> method. <code>this</code> is bound to the handler.</p> <dl> <dt><code>target</code></dt> <dd>The target object.</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p>The <code>isExtensible</code> method must return a boolean value.</p> <h2 id=\"Description\">Description</h2> <p>The <code><strong>handler.isExtensible()</strong></code> method is a trap for <a href=\"../../object/isextensible\"><code>Object.isExtensible()</code></a>.</p> <h3 id=\"Interceptions\">Interceptions</h3> <p>This trap can intercept these operations:</p> <ul> <li><a href=\"../../object/isextensible\"><code>Object.isExtensible()</code></a></li> <li><a href=\"../../reflect/isextensible\"><code>Reflect.isExtensible()</code></a></li> </ul> <h3 id=\"Invariants\">Invariants</h3> <p>If the following invariants are violated, the proxy will throw a <a href=\"../../typeerror\"><code>TypeError</code></a>:</p> <ul> <li>\n<code>Object.isExtensible(proxy)</code> must return the same value as <code>Object.isExtensible(target)</code>.</li> </ul> <h2 id=\"Examples\">Examples</h2> <p>The following code traps <a href=\"../../object/isextensible\"><code>Object.isExtensible()</code></a>.</p> <pre data-language=\"js\">var p = new Proxy({}, {\n  isExtensible: function(target) {\n    console.log('called');\n    return true;\n  }\n});\n\nconsole.log(Object.isExtensible(p)); // \"called\"\n                                     // true\n</pre> <p>The following code violates the invariant.</p> <pre data-language=\"js\">var p = new Proxy({}, {\n  isExtensible: function(target) {\n    return false;\n  }\n});\n\nObject.isExtensible(p); // TypeError is thrown\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-proxy-object-internal-methods-and-internal-slots-isextensible\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of '[[IsExtensible]]' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-proxy-object-internal-methods-and-internal-slots-isextensible\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of '[[IsExtensible]]' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>   <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td> ? </td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 31</td>\n<td class=\"bc-supports-no\"> No</td>\n<td> ? </td>\n<td> ? </td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td> ? </td>\n<td> ? </td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 31</td>\n<td> ? </td>\n<td> ? </td>\n<td> ? </td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 6.0.0</td>\n</tr></tbody>\n</table>\n</div>  <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"../../proxy\"><code>Proxy</code></a></li> <li><a href=\"../handler\"><code>handler</code></a></li> <li><a href=\"../../object/isextensible\"><code>Object.isExtensible()</code></a></li> <li><a href=\"../../reflect/isextensible\"><code>Reflect.isExtensible()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy/handler/isExtensible$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy/handler/isExtensible\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy/handler/isExtensible</a>\n  </p>\n</div>\n","global_objects/proxy/handler/ownkeys":"<h1>Proxy.handler.ownKeys</h1> <p>The <code>handler.ownKeys()</code> method is a trap for <a href=\"../../reflect/ownkeys\"><code>Reflect.ownKeys()</code></a>.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/proxyhandler-ownkeys.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js taller\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre data-language=\"js\">var p = new Proxy(target, {\n  ownKeys: function(target) {\n  }\n});\n</pre> <h3 id=\"Parameters\">Parameters</h3> <p>The following parameter is passed to the <code>ownKeys</code> method. <code>this</code> is bound to the handler.</p> <dl> <dt><code>target</code></dt> <dd>The target object.</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p>The <code>ownKeys</code> method must return an enumerable object.</p> <h2 id=\"Description\">Description</h2> <p>The <code><strong>handler.ownKeys()</strong></code> method is a trap for <a href=\"../../reflect/ownkeys\"><code>Reflect.ownKeys()</code></a>.</p> <h3 id=\"Interceptions\">Interceptions</h3> <p>This trap can intercept these operations:</p> <ul> <li><a href=\"../../object/getownpropertynames\"><code>Object.getOwnPropertyNames()</code></a></li> <li><a href=\"../../object/getownpropertysymbols\"><code>Object.getOwnPropertySymbols()</code></a></li> <li><a href=\"../../object/keys\"><code>Object.keys()</code></a></li> <li><a href=\"../../reflect/ownkeys\"><code>Reflect.ownKeys()</code></a></li> </ul> <h3 id=\"Invariants\">Invariants</h3> <p>If the following invariants are violated, the proxy will throw a <a href=\"../../typeerror\"><code>TypeError</code></a>:</p> <ul> <li>The result of <code>ownKeys</code> must be an array.</li> <li>The type of each array element is either a <a href=\"../../string\"><code>String</code></a> or a <a href=\"../../symbol\"><code>Symbol</code></a>.</li> <li>The result List must contain the keys of all non-configurable own properties of the target object.</li> <li>If the target object is not extensible, then the result List must contain all the keys of the own properties of the target object and no other values.</li> </ul> <h2 id=\"Examples\">Examples</h2> <p>The following code traps <a href=\"../../object/getownpropertynames\"><code>Object.getOwnPropertyNames()</code></a>.</p> <pre data-language=\"js\">var p = new Proxy({}, {\n  ownKeys: function(target) {\n    console.log('called');\n    return ['a', 'b', 'c'];\n  }\n});\n\nconsole.log(Object.getOwnPropertyNames(p)); // \"called\"\n                                            // [ 'a', 'b', 'c' ]</pre> <p>The following code violates an invariant.</p> <pre data-language=\"js\">var obj = {};\nObject.defineProperty(obj, 'a', { \n  configurable: false, \n  enumerable: true, \n  value: 10 }\n);\n\nvar p = new Proxy(obj, {\n  ownKeys: function(target) {\n    return [123, 12.5, true, false, undefined, null, {}, []];\n  }\n});\n\nconsole.log(Object.getOwnPropertyNames(p)); \n\n// TypeError: proxy [[OwnPropertyKeys]] must return an array \n// with only string and symbol elements\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-proxy-object-internal-methods-and-internal-slots-ownpropertykeys\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of '[[OwnPropertyKeys]]' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-proxy-object-internal-methods-and-internal-slots-ownpropertykeys\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of '[[OwnPropertyKeys]]' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>   <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 49</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes bc-has-history\"> 18\n<section class=\"bc-history\" id=\"sect1\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 18\n</dt>\n<dd> In Firefox 42, the implementation got updated to reflect the final ES2015 specification: The result is now checked if it is an array and if the array elements are either of type string or of type symbol. Enumerating duplicate own property names is not a failure anymore.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 36</td>\n<td class=\"bc-supports-yes\"> 10</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 49</td>\n<td class=\"bc-supports-yes\"> 49</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes bc-has-history\"> 18\n<section class=\"bc-history\" id=\"sect2\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 18\n</dt>\n<dd> In Firefox 42, the implementation got updated to reflect the final ES2015 specification: The result is now checked if it is an array and if the array elements are either of type string or of type symbol. Enumerating duplicate own property names is not a failure anymore.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-yes\"> 36</td>\n<td class=\"bc-supports-yes\"> 10</td>\n<td class=\"bc-supports-yes\"> 5.0</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 6.0.0</td>\n</tr></tbody>\n</table>\n</div>  <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"../../proxy\"><code>Proxy</code></a></li> <li><a href=\"../handler\"><code>handler</code></a></li> <li><a href=\"../../object/getownpropertynames\"><code>Object.getOwnPropertyNames()</code></a></li> <li><a href=\"../../reflect/ownkeys\"><code>Reflect.ownKeys()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy/handler/ownKeys$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy/handler/ownKeys\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy/handler/ownKeys</a>\n  </p>\n</div>\n","global_objects/proxy/handler/preventextensions":"<h1>Proxy.handler.preventExtensions</h1> <p>The <code>handler.preventExtensions()</code> method is a trap for <a href=\"../../object/preventextensions\"><code>Object.preventExtensions()</code></a>.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/proxyhandler-preventextensions.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js taller\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre data-language=\"js\">var p = new Proxy(target, {\n  preventExtensions: function(target) {\n  }\n});\n</pre> <h3 id=\"Parameters\">Parameters</h3> <p>The following parameter is passed to the <code>preventExtensions</code> method. <code>this</code> is bound to the handler.</p> <dl> <dt><code>target</code></dt> <dd>The target object.</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p>The <code>preventExtensions</code> method must return a boolean value.</p> <h2 id=\"Description\">Description</h2> <p>The <code><strong>handler.preventExtensions()</strong></code> method is a trap for <a href=\"../../object/preventextensions\"><code>Object.preventExtensions()</code></a>.</p> <h3 id=\"Interceptions\">Interceptions</h3> <p>This trap can intercept these operations:</p> <ul> <li><a href=\"../../object/preventextensions\"><code>Object.preventExtensions()</code></a></li> <li><a href=\"../../reflect/preventextensions\"><code>Reflect.preventExtensions()</code></a></li> </ul> <h3 id=\"Invariants\">Invariants</h3> <p>If the following invariants are violated, the proxy will throw a <a href=\"../../typeerror\"><code>TypeError</code></a>:</p> <ul> <li>\n<code>Object.preventExtensions(proxy)</code> only returns <code>true</code> if <code>Object.isExtensible(proxy)</code> is <code>false</code>.</li> </ul> <h2 id=\"Examples\">Examples</h2> <p>The following code traps <a href=\"../../object/preventextensions\"><code>Object.preventExtensions()</code></a>.</p> <pre data-language=\"js\">var p = new Proxy({}, {\n  preventExtensions: function(target) {\n    console.log('called');\n    Object.preventExtensions(target);\n    return true;\n  }\n});\n\nconsole.log(Object.preventExtensions(p)); // \"called\"\n                                          // false\n</pre> <p>The following code violates the invariant.</p> <pre data-language=\"js\">var p = new Proxy({}, {\n  preventExtensions: function(target) {\n    return true;\n  }\n});\n\nObject.preventExtensions(p); // TypeError is thrown\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-proxy-object-internal-methods-and-internal-slots-preventextensions\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of '[[PreventExtensions]]' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-proxy-object-internal-methods-and-internal-slots-preventextensions\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of '[[PreventExtensions]]' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>   <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 49</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 22</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 36</td>\n<td class=\"bc-supports-yes\"> 10</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 49</td>\n<td class=\"bc-supports-yes\"> 49</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 22</td>\n<td class=\"bc-supports-yes\"> 36</td>\n<td class=\"bc-supports-yes\"> 10</td>\n<td class=\"bc-supports-yes\"> 5.0</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 6.0.0</td>\n</tr></tbody>\n</table>\n</div>  <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"../../proxy\"><code>Proxy</code></a></li> <li><a href=\"../handler\"><code>handler</code></a></li> <li><a href=\"../../object/preventextensions\"><code>Object.preventExtensions()</code></a></li> <li><a href=\"../../reflect/preventextensions\"><code>Reflect.preventExtensions()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy/handler/preventExtensions$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy/handler/preventExtensions\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy/handler/preventExtensions</a>\n  </p>\n</div>\n","global_objects/proxy/handler/set":"<h1>Proxy.handler.set</h1> <p>The <code><strong>handler.set()</strong></code> method is a trap for setting a property value.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/proxyhandler-set.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js taller\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre data-language=\"js\">var p = new Proxy(target, {\n  set: function(target, property, value, receiver) {\n  }\n});\n</pre> <h3 id=\"Parameters\">Parameters</h3> <p>The following parameters are passed to the <code>set</code> method. <code>this</code> is bound to the handler.</p> <dl> <dt><code>target</code></dt> <dd>The target object.</dd> <dt><code>property</code></dt> <dd>The name or <a href=\"../../symbol\"><code>Symbol</code></a> of the property to set. </dd> <dt><code>value</code></dt> <dd>The new value of the property to set.</dd> <dt><code>receiver</code></dt> <dd>The object to which the assignment was originally directed. This is usually the proxy itself. But a <code>set</code> handler can also be called indirectly, via the prototype chain or various other ways.</dd> <dd>For example, suppose a script does <code>obj.name = \"jen\"</code>, and <code>obj</code> is not a proxy, and has no own property <code>.name</code>, but it has a proxy on its prototype chain. That proxy's <code>set</code> handler will be called, and <code>obj</code> will be passed as the receiver.</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p>The <code>set</code> method should return a boolean value. Return <code>true</code> to indicate that assignment succeeded. If the <code>set</code> method returns <code>false</code>, and the assignment happened in strict-mode code, a <code>TypeError</code> will be thrown.</p> <h2 id=\"Description\">Description</h2> <p>The <code><strong>handler.set</strong></code> method is a trap for setting property value.</p> <h3 id=\"Interceptions\">Interceptions</h3> <p>This trap can intercept these operations:</p> <ul> <li>Property assignment: <code>proxy[foo] = bar</code> and <code>proxy.foo = bar</code>\n</li> <li>Inherited property assignment: <code>Object.create(proxy)[foo] = bar</code>\n</li> <li><a href=\"../../reflect/set\"><code>Reflect.set()</code></a></li> </ul> <h3 id=\"Invariants\">Invariants</h3> <p>If the following invariants are violated, the proxy will throw a <a href=\"../../typeerror\"><code>TypeError</code></a>:</p> <ul> <li>Cannot change the value of a property to be different from the value of the corresponding target object property if the corresponding target object property is a non-writable, non-configurable data property.</li> <li>Cannot set the value of a property if the corresponding target object property is a non-configurable accessor property that has <code>undefined</code> as its [[Set]] attribute.</li> <li>In strict mode, a <code>false</code> return value from the <code>set</code> handler will throw a <a href=\"../../typeerror\"><code>TypeError</code></a> exception.</li> </ul> <h2 id=\"Examples\">Examples</h2> <p>The following code traps setting a property value.</p> <pre data-language=\"js\">var p = new Proxy({}, {\n  set: function(target, prop, value, receiver) {\n    target[prop] = value;\n    console.log('property set: ' + prop + ' = ' + value);\n    return true;\n  }\n})\n\nconsole.log('a' in p);  // false\n\np.a = 10;               // \"property set: a = 10\"\nconsole.log('a' in p);  // true\nconsole.log(p.a);       // 10\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-proxy-object-internal-methods-and-internal-slots-set-p-v-receiver\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of '[[Set]]' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-proxy-object-internal-methods-and-internal-slots-set-p-v-receiver\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of '[[Set]]' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>   <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 49</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 18</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 36</td>\n<td class=\"bc-supports-yes\"> 10</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 49</td>\n<td class=\"bc-supports-yes\"> 49</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 18</td>\n<td class=\"bc-supports-yes\"> 36</td>\n<td class=\"bc-supports-yes\"> 10</td>\n<td class=\"bc-supports-yes\"> 5.0</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 6.0.0</td>\n</tr></tbody>\n</table>\n</div>  <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"../../proxy\"><code>Proxy</code></a></li> <li><a href=\"../handler\"><code>handler</code></a></li> <li><a href=\"../../reflect/set\"><code>Reflect.set()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy/handler/set$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy/handler/set\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy/handler/set</a>\n  </p>\n</div>\n","global_objects/proxy/handler/has":"<h1>Proxy.handler.has</h1> <p>The <code>handler.has()</code> method is a trap for the <a href=\"../../../operators/in\"><code>in</code></a> operator.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/proxyhandler-has.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js taller\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre data-language=\"js\">var p = new Proxy(target, {\n  has: function(target, prop) {\n  }\n});\n</pre> <h3 id=\"Parameters\">Parameters</h3> <p>The following parameters are passed to <code>has</code> method. <code>this</code> is bound to the handler.</p> <dl> <dt><code>target</code></dt> <dd>The target object.</dd> <dt><code>prop</code></dt> <dd>The name or <a href=\"../../symbol\"><code>Symbol</code></a> of the property to check for existence.</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p>The <code>has</code> method must return a boolean value.</p> <h2 id=\"Description\">Description</h2> <p>The <code><strong>handler.has</strong></code> method is a trap for the <a href=\"../../../operators/in\"><code>in</code></a> operator.</p> <h3 id=\"Interceptions\">Interceptions</h3> <p>This trap can intercept these operations:</p> <ul> <li>Property query: <code>foo in proxy</code>\n</li> <li>Inherited property query: <code>foo in Object.create(proxy)</code>\n</li> <li>\n<code>with</code> check<code>: with(proxy) { (foo); }</code>\n</li> <li><a href=\"../../reflect/has\"><code>Reflect.has()</code></a></li> </ul> <h3 id=\"Invariants\">Invariants</h3> <p>If the following invariants are violated, the proxy will throw a <a href=\"../../typeerror\"><code>TypeError</code></a>:</p> <ul> <li>A property cannot be reported as non-existent, if it exists as a non-configurable own property of the target object.</li> <li>A property cannot be reported as non-existent, if it exists as an own property of the target object and the target object is not extensible.</li> </ul> <h2 id=\"Examples\">Examples</h2> <p>The following code traps the <a href=\"../../../operators/in\"><code>in</code></a> operator.</p> <pre data-language=\"js\">var p = new Proxy({}, {\n  has: function(target, prop) {\n    console.log('called: ' + prop);\n    return true;\n  }\n});\n\nconsole.log('a' in p); // \"called: a\"\n                       // true\n</pre> <p>The following code violates an invariant.</p> <pre data-language=\"js\">var obj = { a: 10 };\nObject.preventExtensions(obj);\nvar p = new Proxy(obj, {\n  has: function(target, prop) {\n    return false;\n  }\n});\n\n'a' in p; // TypeError is thrown\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-proxy-object-internal-methods-and-internal-slots-hasproperty-p\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of '[[HasProperty]]' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-proxy-object-internal-methods-and-internal-slots-hasproperty-p\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of '[[HasProperty]]' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>   <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 49</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 18</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 36</td>\n<td class=\"bc-supports-yes\"> 10</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 49</td>\n<td class=\"bc-supports-yes\"> 49</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 18</td>\n<td class=\"bc-supports-yes\"> 36</td>\n<td class=\"bc-supports-yes\"> 10</td>\n<td class=\"bc-supports-yes\"> 5.0</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 6.0.0</td>\n</tr></tbody>\n</table>\n</div>  <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"../../proxy\"><code>Proxy</code></a></li> <li><a href=\"../handler\"><code>handler</code></a></li> <li>\n<a href=\"../../../operators/in\"><code>in</code></a> operator</li> <li><a href=\"../../reflect/has\"><code>Reflect.has()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy/handler/has$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy/handler/has\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy/handler/has</a>\n  </p>\n</div>\n","global_objects/proxy/handler/setprototypeof":"<h1>Proxy.handler.setPrototypeOf</h1> <p>The <code>handler.setPrototypeOf()</code> method is a trap for <a href=\"../../object/setprototypeof\"><code>Object.setPrototypeOf()</code></a>.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/proxyhandler-setprototypeof.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js taller\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre data-language=\"js\">var p = new Proxy(target, {\n  setPrototypeOf: function(target, prototype) {\n  }\n});\n</pre> <h3 id=\"Parameters\">Parameters</h3> <p>The following parameters are passed to the <code>setPrototypeOf</code> method. <code>this</code> is bound to the handler.</p> <dl> <dt><code>target</code></dt> <dd>The target object.</dd> <dt><code>prototype</code></dt> <dd>The object's new prototype or <code>null</code>.</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p>The <code>setPrototypeOf</code> method returns <code>true</code> if the <code>[[Prototype]]</code> was successfully changed, otherwise <code>false</code>.</p> <h2 id=\"Description\">Description</h2> <p>The <code><strong>handler.setPrototypeOf</strong></code> method is a trap for <a href=\"../../object/setprototypeof\"><code>Object.setPrototypeOf()</code></a>.</p> <h3 id=\"Interceptions\">Interceptions</h3> <p>This trap can intercept these operations:</p> <ul> <li><a href=\"../../object/setprototypeof\"><code>Object.setPrototypeOf()</code></a></li> <li><a href=\"../../reflect/setprototypeof\"><code>Reflect.setPrototypeOf()</code></a></li> </ul> <h3 id=\"Invariants\">Invariants</h3> <p>If the following invariants are violated, the proxy will throw a <a href=\"../../typeerror\"><code>TypeError</code></a>:</p> <ul> <li>If <code>target</code> is not extensible, the <code>prototype</code> parameter must be the same value as <code>Object.getPrototypeOf(target)</code>.</li> </ul> <h2 id=\"Examples\">Examples</h2> <p>If you want to disallow setting a new prototype for your object, your handler's <code>setPrototypeOf</code> method can either return <code>false</code>, or it can throw an exception.</p> <p>The former approach means that any operation that performs such mutation, that throws an exception on failure to mutate, will have to create the exception itself. For example, <a href=\"../../object/setprototypeof\"><code>Object.setPrototypeOf()</code></a> will create and throw a <code>TypeError</code> itself. If the mutation is performed by an operation that <em>doesn't</em> ordinarily throw in case of failure, such as <a href=\"../../reflect/setprototypeof\"><code>Reflect.setPrototypeOf()</code></a>, no exception will be thrown.</p> <pre data-language=\"js\">var handlerReturnsFalse = {\n    setPrototypeOf(target, newProto) {\n        return false;\n    }\n};\n\nvar newProto = {}, target = {};\n\nvar p1 = new Proxy(target, handlerReturnsFalse);\nObject.setPrototypeOf(p1, newProto); // throws a TypeError\nReflect.setPrototypeOf(p1, newProto); // returns false\n</pre> <p>The latter approach will cause <em>any</em> operation that attempts to mutate, to throw. This approach is required if you want even non-throwing operations to throw on failure, or you want to throw a custom exception value.</p> <pre data-language=\"js\">var handlerThrows = {\n    setPrototypeOf(target, newProto) {\n        throw new Error('custom error');\n    }\n}; \n\nvar newProto = {}, target = {};\n\nvar p2 = new Proxy(target, handlerThrows);\nObject.setPrototypeOf(p2, newProto); // throws new Error(\"custom error\")\nReflect.setPrototypeOf(p2, newProto); // throws new Error(\"custom error\")</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-proxy-object-internal-methods-and-internal-slots-setprototypeof-v\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of '[[SetPrototypeOf]]' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-proxy-object-internal-methods-and-internal-slots-setprototypeof-v\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of '[[SetPrototypeOf]]' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>   <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td> ? </td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 49</td>\n<td class=\"bc-supports-no\"> No</td>\n<td> ? </td>\n<td> ? </td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td> ? </td>\n<td> ? </td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 49</td>\n<td> ? </td>\n<td> ? </td>\n<td> ? </td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 6.0.0</td>\n</tr></tbody>\n</table>\n</div>  <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"../../proxy\"><code>Proxy</code></a></li> <li><a href=\"../handler\"><code>handler</code></a></li> <li><a href=\"../../object/setprototypeof\"><code>Object.setPrototypeOf()</code></a></li> <li><a href=\"../../reflect/setprototypeof\"><code>Reflect.setPrototypeOf()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy/handler/setPrototypeOf$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy/handler/setPrototypeOf\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy/handler/setPrototypeOf</a>\n  </p>\n</div>\n","global_objects/object/getownpropertysymbols":"<h1>Object.getOwnPropertySymbols</h1> <p>The <code><strong>Object.getOwnPropertySymbols()</strong></code> method returns an array of all symbol properties found directly upon a given object.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/object-getownpropertysymbols.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\">Object.getOwnPropertySymbols(<var>obj</var>)</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><code>obj</code></dt> <dd>The object whose symbol properties are to be returned.</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p>An array of all symbol properties found directly upon the given object.</p> <h2 id=\"Description\">Description</h2> <p>Similar to <a href=\"getownpropertynames\"><code>Object.getOwnPropertyNames()</code></a>, you can get all symbol properties of a given object as an array of symbols. Note that <a href=\"getownpropertynames\"><code>Object.getOwnPropertyNames()</code></a> itself does not contain the symbol properties of an object and only the string properties.</p> <p>As all objects have no own symbol properties initially, <code>Object.getOwnPropertySymbols()</code> returns an empty array unless you have set symbol properties on your object.</p> <h2 id=\"Examples\">Examples</h2> <pre data-language=\"js\">var obj = {};\nvar a = Symbol('a');\nvar b = Symbol.for('b');\n\nobj[a] = 'localSymbol';\nobj[b] = 'globalSymbol';\n\nvar objectSymbols = Object.getOwnPropertySymbols(obj);\n\nconsole.log(objectSymbols.length); // 2\nconsole.log(objectSymbols);        // [Symbol(a), Symbol(b)]\nconsole.log(objectSymbols[0]);     // Symbol(a)\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-object.getownpropertysymbols\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Object.getOwnPropertySymbols' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-object.getownpropertysymbols\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Object.getOwnPropertySymbols' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>   <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 38</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 36</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 25</td>\n<td class=\"bc-supports-yes\"> 9</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 38</td>\n<td class=\"bc-supports-yes\"> 38</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 36</td>\n<td class=\"bc-supports-yes\"> 25</td>\n<td class=\"bc-supports-yes\"> 9</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 0.12</td>\n</tr></tbody>\n</table>\n</div>  <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"getownpropertynames\"><code>Object.getOwnPropertyNames()</code></a></li> <li><a href=\"../symbol\"><code>Symbol</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/getOwnPropertySymbols$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/getOwnPropertySymbols\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/getOwnPropertySymbols</a>\n  </p>\n</div>\n","global_objects/reflect/apply":"<h1>Reflect.apply</h1> <p>The static <code><strong>Reflect</strong></code><code>.apply()</code> method calls a target function with arguments as specified.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/reflect-apply.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\">Reflect.apply(target, thisArgument, argumentsList)\n</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt>target</dt> <dd>The target function to call.</dd> <dt>thisArgument</dt> <dd>The value of <code>this</code> provided for the call to <em><code>target</code></em>.</dd> <dt>argumentsList</dt> <dd>An array-like object specifying the arguments with which <em><code>target</code></em> should be called.</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p>The result of calling the given target function with the specified <code><strong>this</strong></code> value and arguments.</p> <h3 id=\"Exceptions\">Exceptions</h3> <p>A <a href=\"../typeerror\"><code>TypeError</code></a>, if the <em>target</em> is not callable.</p> <h2 id=\"Description\">Description</h2> <p>In ES5, you typically use the <a href=\"../function/apply\"><code>Function.prototype.apply()</code></a> method to call a function with a given <code>this</code> value and <code>arguments</code> provided as an array (or an <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Indexed_collections#Working_with_array-like_objects\">array-like object</a>).</p> <pre data-language=\"js\">Function.prototype.apply.call(Math.floor, undefined, [1.75]);</pre> <p>With <code>Reflect.apply</code> this becomes less verbose and easier to understand.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Using_Reflect.apply()\">Using <code>Reflect.apply()</code>\n</h3> <pre data-language=\"js\">Reflect.apply(Math.floor, undefined, [1.75]); \n// 1;\n\nReflect.apply(String.fromCharCode, undefined, [104, 101, 108, 108, 111]);\n// \"hello\"\n\nReflect.apply(RegExp.prototype.exec, /ab/, ['confabulation']).index;\n// 4\n\nReflect.apply(''.charAt, 'ponies', [3]);\n// \"i\"\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-reflect.apply\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Reflect.apply' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-reflect.apply\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Reflect.apply' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 49</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 42</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 36</td>\n<td class=\"bc-supports-yes\"> 10</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 49</td>\n<td class=\"bc-supports-yes\"> 49</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 42</td>\n<td class=\"bc-supports-yes\"> 36</td>\n<td class=\"bc-supports-yes\"> 10</td>\n<td class=\"bc-supports-yes\"> 5.0</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 6.0.0</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"../reflect\"><code>Reflect</code></a></li> <li><a href=\"../function/apply\"><code>Function.prototype.apply()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/apply$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/apply\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/apply</a>\n  </p>\n</div>\n","global_objects/reflect/deleteproperty":"<h1>Reflect.deleteProperty</h1> <p>The static <code><strong>Reflect</strong></code><code>.deleteProperty()</code> method allows to delete properties. It is like the <a href=\"../../operators/delete\"><code>delete</code> operator</a> as a function.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/reflect-deleteproperty.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js taller\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\">Reflect.deleteProperty(target, propertyKey)\n</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><code>target</code></dt> <dd>The target object on which to delete the property.</dd> <dt><code>propertyKey</code></dt> <dd>The name of the property to be deleted.</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p>A <a href=\"../boolean\"><code>Boolean</code></a> indicating whether or not the property was successfully deleted.</p> <h3 id=\"Exceptions\">Exceptions</h3> <p>A <a href=\"../typeerror\"><code>TypeError</code></a>, if <code>target</code> is not an <a href=\"../object\"><code>Object</code></a>.</p> <h2 id=\"Description\">Description</h2> <p>The <code>Reflect.deleteProperty</code> method allows you to delete a property on an object. It returns a <a href=\"../boolean\"><code>Boolean</code></a> indicating whether or not the property was successfully deleted. It is almost identical to the non-strict <a href=\"../../operators/delete\"><code>delete</code> operator</a>.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Using_Reflect.deleteProperty()\">Using <code>Reflect.deleteProperty()</code>\n</h3> <pre data-language=\"js\">var obj = { x: 1, y: 2 };\nReflect.deleteProperty(obj, 'x'); // true\nobj; // { y: 2 }\n\nvar arr = [1, 2, 3, 4, 5];\nReflect.deleteProperty(arr, '3'); // true\narr; // [1, 2, 3, , 5]\n\n// Returns true if no such property exists\nReflect.deleteProperty({}, 'foo'); // true\n\n// Returns false if a property is unconfigurable\nReflect.deleteProperty(Object.freeze({foo: 1}), 'foo'); // false\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-reflect.deleteproperty\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Reflect.deleteProperty' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-reflect.deleteproperty\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Reflect.deleteProperty' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 49</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 42</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 36</td>\n<td class=\"bc-supports-yes\"> 10</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 49</td>\n<td class=\"bc-supports-yes\"> 49</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 42</td>\n<td class=\"bc-supports-yes\"> 36</td>\n<td class=\"bc-supports-yes\"> 10</td>\n<td class=\"bc-supports-yes\"> 5.0</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 6.0.0</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"../reflect\"><code>Reflect</code></a></li> <li><a href=\"../../operators/delete\"><code>delete</code> operator</a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/deleteProperty$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/deleteProperty\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/deleteProperty</a>\n  </p>\n</div>\n","global_objects/object/getownpropertynames":"<h1>Object.getOwnPropertyNames</h1> <p>The <code>Object.getOwnPropertyNames()</code> method returns an array of all properties (including <em>non-</em>enumerable properties except for those which use Symbol) found directly upon a given object.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/object-getownpropertynames.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe> <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\">Object.getOwnPropertyNames(<var>obj</var>)</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><code>obj</code></dt> <dd>The object whose enumerable <em>and non-enumerable</em> own properties are to be returned.</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p>An array of strings that correspond to the properties found directly upon the given object.</p> <h2 id=\"Description\">Description</h2> <p><code>Object.getOwnPropertyNames()</code> returns an array whose elements are strings corresponding to the enumerable <em>and non-enumerable</em> properties found directly upon <code>obj</code>. The ordering of the enumerable properties in the array is consistent with the ordering exposed by a <a href=\"../../statements/for...in\"><code>for...in</code></a> loop (or by <a href=\"keys\"><code>Object.keys()</code></a>) over the properties of the object. The ordering of the non-enumerable properties in the array, and among the enumerable properties, is not defined.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Using_Object.getOwnPropertyNames()\">Using <code>Object.getOwnPropertyNames()</code>\n</h3> <pre data-language=\"js\">var arr = ['a', 'b', 'c'];\nconsole.log(Object.getOwnPropertyNames(arr).sort()); \n// logs [\"0\", \"1\", \"2\", \"length\"]\n\n// Array-like object\nvar obj = { 0: 'a', 1: 'b', 2: 'c' };\nconsole.log(Object.getOwnPropertyNames(obj).sort()); \n// logs [\"0\", \"1\", \"2\"]\n\n// Logging property names and values using Array.forEach\nObject.getOwnPropertyNames(obj).forEach(\n  function (val, idx, array) {\n    console.log(val + ' -&gt; ' + obj[val]);\n  }\n);\n// logs\n// 0 -&gt; a\n// 1 -&gt; b\n// 2 -&gt; c\n\n// non-enumerable property\nvar my_obj = Object.create({}, {\n  getFoo: {\n    value: function() { return this.foo; },\n    enumerable: false\n  }\n});\nmy_obj.foo = 1;\n\nconsole.log(Object.getOwnPropertyNames(my_obj).sort()); \n// logs [\"foo\", \"getFoo\"]\n</pre> <p>If you want only the enumerable properties, see <a href=\"keys\"><code>Object.keys()</code></a> or use a <a href=\"../../statements/for...in\"><code>for...in</code></a> loop (although note that this will return enumerable properties not only found directly upon that object but also along the prototype chain for the object unless the latter is filtered with <a href=\"hasownproperty\"><code>hasOwnProperty()</code></a>).</p> <p>Items on the prototype chain are not listed:</p> <pre data-language=\"js\">function ParentClass() {}\nParentClass.prototype.inheritedMethod = function() {};\n\nfunction ChildClass() {\n  this.prop = 5;\n  this.method = function() {};\n}\nChildClass.prototype = new ParentClass;\nChildClass.prototype.prototypeMethod = function() {};\n\nconsole.log(\n  Object.getOwnPropertyNames(\n    new ChildClass() // [\"prop\", \"method\"]\n  )\n);\n</pre> <h3 id=\"Get_Non-Enumerable_Only\">Get Non-Enumerable Only</h3> <p>This uses the <a href=\"../array/filter\"><code>Array.prototype.filter()</code></a> function to remove the enumerable keys (obtained with <a href=\"keys\"><code>Object.keys()</code></a>) from a list of all keys (obtained with <code>Object.getOwnPropertyNames()</code>) leaving only the non-enumerable keys.</p> <pre data-language=\"js\">var target = myObject;\nvar enum_and_nonenum = Object.getOwnPropertyNames(target);\nvar enum_only = Object.keys(target);\nvar nonenum_only = enum_and_nonenum.filter(function(key) {\n  var indexInEnum = enum_only.indexOf(key);\n  if (indexInEnum == -1) {\n    // Not found in enum_only keys,\n    // meaning that the key is non-enumerable,\n    // so return true so we keep this in the filter\n    return true;\n  } else {\n    return false;\n  }\n});\n\nconsole.log(nonenum_only);\n</pre> <h2 id=\"Notes\">Notes</h2> <p>In ES5, if the argument to this method is not an object (a primitive), then it will cause a <a href=\"../typeerror\"><code>TypeError</code></a>. In ES2015, a non-object argument will be coerced to an object.</p> <pre data-language=\"js\">Object.getOwnPropertyNames('foo');\n// TypeError: \"foo\" is not an object (ES5 code)\n\nObject.getOwnPropertyNames('foo');\n// [\"0\", \"1\", \"2\", \"length\"]  (ES2015 code)\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/5.1/#sec-15.2.3.4\" hreflang=\"en\">ECMAScript 5.1 (ECMA-262)<br><small>The definition of 'Object.getOwnPropertyNames' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition. Implemented in JavaScript 1.8.5.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-object.getownpropertynames\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Object.getOwnPropertyNames' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-object.getownpropertynames\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Object.getOwnPropertyNames' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>   <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 5</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> 9</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 5</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div>  <h2 id=\"Firefox-specific_notes\">Firefox-specific notes</h2> <p>Prior to Firefox 28, <code>Object.getOwnPropertyNames</code> did not see unresolved properties of <a href=\"../error\"><code>Error</code></a> objects. This has been fixed in later versions (<a href=\"https://bugzilla.mozilla.org/show_bug.cgi?id=724768\">bug 724768</a>).</p> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"https://developer.mozilla.org/en-US/docs/Enumerability_and_ownership_of_properties\">Enumerability and ownership of properties</a></li> <li><a href=\"hasownproperty\"><code>Object.prototype.hasOwnProperty()</code></a></li> <li><a href=\"propertyisenumerable\"><code>Object.prototype.propertyIsEnumerable()</code></a></li> <li><a href=\"create\"><code>Object.create()</code></a></li> <li><a href=\"keys\"><code>Object.keys()</code></a></li> <li><a href=\"../array/foreach\"><code>Array.forEach()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/getOwnPropertyNames$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/getOwnPropertyNames\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/getOwnPropertyNames</a>\n  </p>\n</div>\n","global_objects/reflect/defineproperty":"<h1>Reflect.defineProperty</h1> <p>The static <code><strong>Reflect</strong></code><code>.defineProperty()</code> method is like <a href=\"../object/defineproperty\"><code>Object.defineProperty()</code></a> but returns a <a href=\"../boolean\"><code>Boolean</code></a>.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/reflect-defineproperty.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\">Reflect.defineProperty(target, propertyKey, attributes)\n</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><code>target</code></dt> <dd>The target object on which to define the property.</dd> <dt><code>propertyKey</code></dt> <dd>The name of the property to be defined or modified.</dd> <dt><code>attributes</code></dt> <dd>The attributes for the property being defined or modified.</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p>A <a href=\"../boolean\"><code>Boolean</code></a> indicating whether or not the property was successfully defined.</p> <h3 id=\"Exceptions\">Exceptions</h3> <p>A <a href=\"../typeerror\"><code>TypeError</code></a>, if <code>target</code> is not an <a href=\"../object\"><code>Object</code></a>.</p> <h2 id=\"Description\">Description</h2> <p>The <code>Reflect.defineProperty</code> method allows precise addition to or modification of a property on an object. For more details see the <a href=\"../object/defineproperty\"><code>Object.defineProperty</code></a> which is similar. <code>Object.defineProperty</code> returns the object or throws a <a href=\"../typeerror\"><code>TypeError</code></a> if the property has not been successfully defined. <code>Reflect.defineProperty</code>, however, simply returns a <a href=\"../boolean\"><code>Boolean</code></a> indicating whether or not the property was successfully defined.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Using_Reflect.defineProperty()\">Using <code>Reflect.defineProperty()</code>\n</h3> <pre data-language=\"js\">var obj = {};\nReflect.defineProperty(obj, 'x', {value: 7}); // true\nobj.x; // 7\n</pre> <h3 id=\"Checking_if_property_definition_has_been_successful\">Checking if property definition has been successful</h3> <p>With <a href=\"../object/defineproperty\"><code>Object.defineProperty</code></a>, which returns an object if successful, or throws a <a href=\"../typeerror\"><code>TypeError</code></a> otherwise, you would use a <code><a href=\"../../statements/try...catch\">try...catch</a></code> block to catch any error that occurred while defining a property. Because <code>Reflect.defineProperty</code> returns a Boolean success status, you can just use an <code><a href=\"../../statements/if...else\">if...else</a></code> block here:</p> <pre data-language=\"js\">if (Reflect.defineProperty(target, property, attributes)) {\n  // success\n} else {\n  // failure\n}</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-reflect.defineproperty\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Reflect.defineProperty' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-reflect.defineproperty\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Reflect.defineProperty' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 49</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 42</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 36</td>\n<td class=\"bc-supports-yes\"> 10</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 49</td>\n<td class=\"bc-supports-yes\"> 49</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 42</td>\n<td class=\"bc-supports-yes\"> 36</td>\n<td class=\"bc-supports-yes\"> 10</td>\n<td class=\"bc-supports-yes\"> 5.0</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 6.0.0</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"../reflect\"><code>Reflect</code></a></li> <li><a href=\"../object/defineproperty\"><code>Object.defineProperty()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/defineProperty$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/defineProperty\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/defineProperty</a>\n  </p>\n</div>\n","global_objects/reflect/getprototypeof":"<h1>Reflect.getPrototypeOf</h1> <p>The static <code><strong>Reflect</strong></code><code>.getPrototypeOf()</code> method is almost the same method as <a href=\"../object/getprototypeof\"><code>Object.getPrototypeOf()</code></a>. It returns the prototype (i.e. the value of the internal <code>[[Prototype]]</code> property) of the specified object.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/reflect-getprototypeof.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\">Reflect.getPrototypeOf(target)\n</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><code>target</code></dt> <dd>The target object of which to get the prototype.</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p>The prototype of the given object. If there are no inherited properties, <a href=\"../null\"><code>null</code></a> is returned.</p> <h3 id=\"Exceptions\">Exceptions</h3> <p>A <a href=\"../typeerror\"><code>TypeError</code></a>, if <code>target</code> is not an <a href=\"../object\"><code>Object</code></a>.</p> <h2 id=\"Description\">Description</h2> <p>The <code>Reflect.getPrototypeOf</code> method returns the prototype (i.e. the value of the internal <code>[[Prototype]]</code> property) of the specified object.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Using_Reflect.getPrototypeOf()\">Using <code>Reflect.getPrototypeOf()</code>\n</h3> <pre data-language=\"js\">Reflect.getPrototypeOf({}); // Object.prototype\nReflect.getPrototypeOf(Object.prototype); // null\nReflect.getPrototypeOf(Object.create(null)); // null\n</pre> <h3 id=\"Compared_to_Object.getPrototypeOf()\">Compared to <code>Object.getPrototypeOf()</code>\n</h3> <pre data-language=\"js\">// Same result for Objects\nObject.getPrototypeOf({});  // Object.prototype\nReflect.getPrototypeOf({}); // Object.prototype\n\n// Both throw in ES5 for non-Objects\nObject.getPrototypeOf('foo');  // Throws TypeError\nReflect.getPrototypeOf('foo'); // Throws TypeError\n\n// In ES2015 only Reflect throws, Object coerces non-Objects\nObject.getPrototypeOf('foo');  // String.prototype\nReflect.getPrototypeOf('foo'); // Throws TypeError\n\n// To mimic the Object ES2015 behavior you need to coerce\nReflect.getPrototypeOf(Object('foo')); // String.prototype\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-reflect.getprototypeof\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Reflect.getPrototypeOf' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-reflect.getprototypeof\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Reflect.getPrototypeOf' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 49</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 42</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 36</td>\n<td class=\"bc-supports-yes\"> 10</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 49</td>\n<td class=\"bc-supports-yes\"> 49</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 42</td>\n<td class=\"bc-supports-yes\"> 36</td>\n<td class=\"bc-supports-yes\"> 10</td>\n<td class=\"bc-supports-yes\"> 5.0</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 6.0.0</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"../reflect\"><code>Reflect</code></a></li> <li><a href=\"../object/getprototypeof\"><code>Object.getPrototypeOf()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/getPrototypeOf$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/getPrototypeOf\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/getPrototypeOf</a>\n  </p>\n</div>\n","global_objects/reflect/has":"<h1>Reflect.has</h1> <p>The static <code><strong>Reflect</strong></code><code>.has()</code> method works like the <a href=\"../../operators/in\"><code>in</code> operator</a> as a function.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/reflect-has.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\">Reflect.has(target, propertyKey)\n</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><code>target</code></dt> <dd>The target object in which to look for the property.</dd> <dt><code>propertyKey</code></dt> <dd>The name of the property to check.</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p>A <a href=\"../boolean\"><code>Boolean</code></a> indicating whether or not the target has the property.</p> <h3 id=\"Exceptions\">Exceptions</h3> <p>A <a href=\"../typeerror\"><code>TypeError</code></a>, if <code>target</code> is not an <a href=\"../object\"><code>Object</code></a>.</p> <h2 id=\"Description\">Description</h2> <p>The <code>Reflect.has</code> method allows you to check if a property is in an object. It works like the <a href=\"../../operators/in\"><code>in</code> operator</a> as a function.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Using_Reflect.has()\">Using <code>Reflect.has()</code>\n</h3> <pre data-language=\"js\">Reflect.has({x: 0}, 'x'); // true\nReflect.has({x: 0}, 'y'); // false\n\n// returns true for properties in the prototype chain \nReflect.has({x: 0}, 'toString');\n\n// Proxy with .has() handler method\nobj = new Proxy({}, {\n  has(t, k) { return k.startsWith('door'); }\n});\nReflect.has(obj, 'doorbell'); // true\nReflect.has(obj, 'dormitory'); // false\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-reflect.has\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Reflect.has' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-reflect.has\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Reflect.has' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 49</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 42</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 36</td>\n<td class=\"bc-supports-yes\"> 10</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 49</td>\n<td class=\"bc-supports-yes\"> 49</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 42</td>\n<td class=\"bc-supports-yes\"> 36</td>\n<td class=\"bc-supports-yes\"> 10</td>\n<td class=\"bc-supports-yes\"> 5.0</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 6.0.0</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"../reflect\"><code>Reflect</code></a></li> <li><a href=\"../../operators/in\"><code>in</code> operator</a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/has$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/has\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/has</a>\n  </p>\n</div>\n","global_objects/reflect/isextensible":"<h1>Reflect.isExtensible</h1> <p>The static <code><strong>Reflect</strong></code><code>.isExtensible()</code> method determines if an object is extensible (whether it can have new properties added to it). It is similar to <a href=\"../object/isextensible\"><code>Object.isExtensible()</code></a>, but with some <a href=\"#Difference_to_Object.isExtensible()\">differences</a>.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/reflect-isextensible.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js taller\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\">Reflect.isExtensible(target)\n</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><code>target</code></dt> <dd>The target object which to check if it is extensible.</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p>A <a href=\"../boolean\"><code>Boolean</code></a> indicating whether or not the target is extensible.</p> <h3 id=\"Exceptions\">Exceptions</h3> <p>A <a href=\"../typeerror\"><code>TypeError</code></a>, if <code>target</code> is not an <a href=\"../object\"><code>Object</code></a>.</p> <h2 id=\"Description\">Description</h2> <p>The <code>Reflect.isExtensible</code> method allows you determine if an object is extensible (whether it can have new properties added to it). It is the same method as <a href=\"../object/isextensible\"><code>Object.isExtensible()</code></a>.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Using_Reflect.isExtensible()\">Using <code>Reflect.isExtensible()</code>\n</h3> <p>See also <a href=\"../object/isextensible\"><code>Object.isExtensible()</code></a>.</p> <pre data-language=\"js\">// New objects are extensible. \nvar empty = {};\nReflect.isExtensible(empty); // === true \n\n// ...but that can be changed. \nReflect.preventExtensions(empty); \nReflect.isExtensible(empty); // === false \n\n// Sealed objects are by definition non-extensible. \nvar sealed = Object.seal({}); \nReflect.isExtensible(sealed); // === false \n\n// Frozen objects are also by definition non-extensible. \nvar frozen = Object.freeze({}); \nReflect.isExtensible(frozen); // === false\n</pre> <h3 id=\"Difference_to_Object.isExtensible()\">Difference to <code>Object.isExtensible()</code>\n</h3> <p>If the first argument to this method is not an object (a primitive), then it will cause a <a href=\"../typeerror\"><code>TypeError</code></a>. With <a href=\"../object/isextensible\"><code>Object.isExtensible()</code></a>, a non-object first argument will be coerced to an object at first.</p> <pre data-language=\"js\">Reflect.isExtensible(1);\n// TypeError: 1 is not an object\n\nObject.isExtensible(1);\n// false\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-reflect.isextensible\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Reflect.isExtensible' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-reflect.isextensible\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Reflect.isExtensible' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 49</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 42</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 36</td>\n<td class=\"bc-supports-yes\"> 10</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 49</td>\n<td class=\"bc-supports-yes\"> 49</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 42</td>\n<td class=\"bc-supports-yes\"> 36</td>\n<td class=\"bc-supports-yes\"> 10</td>\n<td class=\"bc-supports-yes\"> 5.0</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 6.0.0</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"../reflect\"><code>Reflect</code></a></li> <li><a href=\"../object/isextensible\"><code>Object.isExtensible()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/isExtensible$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/isExtensible\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/isExtensible</a>\n  </p>\n</div>\n","global_objects/reflect/preventextensions":"<h1>Reflect.preventExtensions</h1> <p>The static <code><strong>Reflect</strong></code><code>.preventExtensions()</code> method prevents new properties from ever being added to an object (i.e. prevents future extensions to the object). It is similar to <a href=\"../object/preventextensions\"><code>Object.preventExtensions()</code></a>, but with some <a href=\"#Difference_to_Object.preventExtensions()\">differences</a>.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/reflect-preventextensions.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\">Reflect.preventExtensions(target)\n</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><code>target</code></dt> <dd>The target object on which to prevent extensions.</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p>A <a href=\"../boolean\"><code>Boolean</code></a> indicating whether or not the target was successfully set to prevent extensions.</p> <h3 id=\"Exceptions\">Exceptions</h3> <p>A <a href=\"../typeerror\"><code>TypeError</code></a>, if <code>target</code> is not an <a href=\"../object\"><code>Object</code></a>.</p> <h2 id=\"Description\">Description</h2> <p>The <code>Reflect.preventExtensions</code> method allows you to prevent new properties from ever being added to an object (i.e. prevents future extensions to the object). It is the same method as <a href=\"../object/preventextensions\"><code>Object.preventExtensions()</code></a>.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Using_Reflect.preventExtensions()\">Using <code>Reflect.preventExtensions()</code>\n</h3> <p>See also <a href=\"../object/preventextensions\"><code>Object.preventExtensions()</code></a>.</p> <pre data-language=\"js\">// Objects are extensible by default.\nvar empty = {};\nReflect.isExtensible(empty); // === true\n\n// ...but that can be changed.\nReflect.preventExtensions(empty);\nReflect.isExtensible(empty); // === false\n</pre> <h3 id=\"Difference_to_Object.preventExtensions()\">Difference to <code>Object.preventExtensions()</code>\n</h3> <p>If the first argument to this method is not an object (a primitive), then it will cause a <a href=\"../typeerror\"><code>TypeError</code></a>. With <a href=\"../object/preventextensions\"><code>Object.preventExtensions()</code></a>, a non-object first argument will be coerced to an object at first.</p> <pre data-language=\"js\">Reflect.preventExtensions(1);\n// TypeError: 1 is not an object\n\nObject.preventExtensions(1);\n// 1\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-reflect.preventextensions\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Reflect.preventExtensions' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-reflect.preventextensions\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Reflect.preventExtensions' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 49</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 42</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 36</td>\n<td class=\"bc-supports-yes\"> 10</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 49</td>\n<td class=\"bc-supports-yes\"> 49</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 42</td>\n<td class=\"bc-supports-yes\"> 36</td>\n<td class=\"bc-supports-yes\"> 10</td>\n<td class=\"bc-supports-yes\"> 5.0</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 6.0.0</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"../reflect\"><code>Reflect</code></a></li> <li><a href=\"../object/isextensible\"><code>Object.isExtensible()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/preventExtensions$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/preventExtensions\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/preventExtensions</a>\n  </p>\n</div>\n","global_objects/proxy/handler":"<h1>Proxy.handler</h1> <p>The proxy's handler object is a placeholder object which contains traps for <a href=\"../proxy\">proxies</a>.</p> <h2 id=\"Methods\">Methods</h2> <p>All traps are optional. If a trap has not been defined, the default behavior is to forward the operation to the target.</p> <dl> <dt><a href=\"handler/getprototypeof\"><code>handler.getPrototypeOf()</code></a></dt> <dd>A trap for <a href=\"../object/getprototypeof\"><code>Object.getPrototypeOf</code></a>.</dd> <dt><a href=\"handler/setprototypeof\"><code>handler.setPrototypeOf()</code></a></dt> <dd>A trap for <a href=\"../object/setprototypeof\"><code>Object.setPrototypeOf</code></a>.</dd> <dt><a href=\"handler/isextensible\"><code>handler.isExtensible()</code></a></dt> <dd>A trap for <a href=\"../object/isextensible\"><code>Object.isExtensible</code></a>.</dd> <dt><a href=\"handler/preventextensions\"><code>handler.preventExtensions()</code></a></dt> <dd>A trap for <a href=\"../object/preventextensions\"><code>Object.preventExtensions</code></a>.</dd> <dt><a href=\"handler/getownpropertydescriptor\"><code>handler.getOwnPropertyDescriptor()</code></a></dt> <dd>A trap for <a href=\"../object/getownpropertydescriptor\"><code>Object.getOwnPropertyDescriptor</code></a>.</dd> <dt><a href=\"handler/defineproperty\"><code>handler.defineProperty()</code></a></dt> <dd>A trap for <a href=\"../object/defineproperty\"><code>Object.defineProperty</code></a>.</dd> <dt><a href=\"handler/has\"><code>handler.has()</code></a></dt> <dd>A trap for the <a href=\"../../operators/in\"><code>in</code></a> operator.</dd> <dt><a href=\"handler/get\"><code>handler.get()</code></a></dt> <dd>A trap for getting property values.</dd> <dt><a href=\"handler/set\"><code>handler.set()</code></a></dt> <dd>A trap for setting property values.</dd> <dt><a href=\"handler/deleteproperty\"><code>handler.deleteProperty()</code></a></dt> <dd>A trap for the <a href=\"../../operators/delete\"><code>delete</code></a> operator.</dd> <dt><a href=\"handler/ownkeys\"><code>handler.ownKeys()</code></a></dt> <dd>A trap for <a href=\"../object/getownpropertynames\"><code>Object.getOwnPropertyNames</code></a> and <a href=\"../object/getownpropertysymbols\"><code>Object.getOwnPropertySymbols</code></a>.</dd> <dt><a href=\"handler/apply\"><code>handler.apply()</code></a></dt> <dd>A trap for a function call.</dd> <dt><a href=\"handler/construct\"><code>handler.construct()</code></a></dt> <dd>A trap for the <a href=\"../../operators/new\"><code>new</code></a> operator.</dd> </dl> <p>Some non-standard traps are <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Deprecated_and_obsolete_features#Proxy\">obsolete and have been removed</a>.</p> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-proxy-object-internal-methods-and-internal-slots\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Proxy Object Internal Methods and Internal Slots' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-proxy-object-internal-methods-and-internal-slots\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Proxy Object Internal Methods and Internal Slots' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td>The <code>enumerate</code> handler has been removed.</td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Proxy/handler/apply\"><code>apply</code></a></th>\n<td class=\"bc-supports-yes\"> 49</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 18</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 36</td>\n<td class=\"bc-supports-yes\"> 10</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Proxy/handler/construct\"><code>construct</code></a></th>\n<td class=\"bc-supports-yes\"> 49</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 18</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 36</td>\n<td class=\"bc-supports-yes\"> 10</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Proxy/handler/defineProperty\"><code>defineProperty</code></a></th>\n<td class=\"bc-supports-yes\"> 49</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 18</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 36</td>\n<td class=\"bc-supports-yes\"> 10</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Proxy/handler/deleteProperty\"><code>deleteProperty</code></a></th>\n<td class=\"bc-supports-yes\"> 49</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 18</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 36</td>\n<td class=\"bc-supports-yes\"> 10</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Proxy/handler/enumerate\"><code>enumerate</code></a> \n</th>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\">37 — 47</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Proxy/handler/get\"><code>get</code></a></th>\n<td class=\"bc-supports-yes\"> 49</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 18</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 36</td>\n<td class=\"bc-supports-yes\"> 10</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Proxy/handler/getOwnPropertyDescriptor\"><code>getOwnPropertyDescriptor</code></a></th>\n<td class=\"bc-supports-yes\"> 49</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 18</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 36</td>\n<td class=\"bc-supports-yes\"> 10</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Proxy/handler/getPrototypeOf\"><code>getPrototypeOf</code></a></th>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 49</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Proxy/handler/has\"><code>has</code></a></th>\n<td class=\"bc-supports-yes\"> 49</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 18</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 36</td>\n<td class=\"bc-supports-yes\"> 10</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Proxy/handler/isExtensible\"><code>isExtensible</code></a></th>\n<td> ? </td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 31</td>\n<td class=\"bc-supports-no\"> No</td>\n<td> ? </td>\n<td> ? </td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Proxy/handler/ownKeys\"><code>ownKeys</code></a></th>\n<td class=\"bc-supports-yes\"> 49</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes bc-has-history\"> 18\n<section class=\"bc-history\" id=\"sect1\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 18\n</dt>\n<dd> In Firefox 42, the implementation got updated to reflect the final ES2015 specification: The result is now checked if it is an array and if the array elements are either of type string or of type symbol. Enumerating duplicate own property names is not a failure anymore.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 36</td>\n<td class=\"bc-supports-yes\"> 10</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Proxy/handler/preventExtensions\"><code>preventExtensions</code></a></th>\n<td class=\"bc-supports-yes\"> 49</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 22</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 36</td>\n<td class=\"bc-supports-yes\"> 10</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Proxy/handler/set\"><code>set</code></a></th>\n<td class=\"bc-supports-yes\"> 49</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 18</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 36</td>\n<td class=\"bc-supports-yes\"> 10</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Proxy/handler/setPrototypeOf\"><code>setPrototypeOf</code></a></th>\n<td> ? </td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 49</td>\n<td class=\"bc-supports-no\"> No</td>\n<td> ? </td>\n<td> ? </td>\n</tr>\n</tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Proxy/handler/apply\"><code>apply</code></a></th>\n<td class=\"bc-supports-yes\"> 49</td>\n<td class=\"bc-supports-yes\"> 49</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 18</td>\n<td class=\"bc-supports-yes\"> 36</td>\n<td class=\"bc-supports-yes\"> 10</td>\n<td class=\"bc-supports-yes\"> 5.0</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Proxy/handler/construct\"><code>construct</code></a></th>\n<td class=\"bc-supports-yes\"> 49</td>\n<td class=\"bc-supports-yes\"> 49</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 18</td>\n<td class=\"bc-supports-yes\"> 36</td>\n<td class=\"bc-supports-yes\"> 10</td>\n<td class=\"bc-supports-yes\"> 5.0</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Proxy/handler/defineProperty\"><code>defineProperty</code></a></th>\n<td class=\"bc-supports-yes\"> 49</td>\n<td class=\"bc-supports-yes\"> 49</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 18</td>\n<td class=\"bc-supports-yes\"> 36</td>\n<td class=\"bc-supports-yes\"> 10</td>\n<td class=\"bc-supports-yes\"> 5.0</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Proxy/handler/deleteProperty\"><code>deleteProperty</code></a></th>\n<td class=\"bc-supports-yes\"> 49</td>\n<td class=\"bc-supports-yes\"> 49</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 18</td>\n<td class=\"bc-supports-yes\"> 36</td>\n<td class=\"bc-supports-yes\"> 10</td>\n<td class=\"bc-supports-yes\"> 5.0</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Proxy/handler/enumerate\"><code>enumerate</code></a> \n</th>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\">37 — 47</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Proxy/handler/get\"><code>get</code></a></th>\n<td class=\"bc-supports-yes\"> 49</td>\n<td class=\"bc-supports-yes\"> 49</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 18</td>\n<td class=\"bc-supports-yes\"> 36</td>\n<td class=\"bc-supports-yes\"> 10</td>\n<td class=\"bc-supports-yes\"> 5.0</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Proxy/handler/getOwnPropertyDescriptor\"><code>getOwnPropertyDescriptor</code></a></th>\n<td class=\"bc-supports-yes\"> 49</td>\n<td class=\"bc-supports-yes\"> 49</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 18</td>\n<td class=\"bc-supports-yes\"> 36</td>\n<td class=\"bc-supports-yes\"> 10</td>\n<td class=\"bc-supports-yes\"> 5.0</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Proxy/handler/getPrototypeOf\"><code>getPrototypeOf</code></a></th>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 49</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Proxy/handler/has\"><code>has</code></a></th>\n<td class=\"bc-supports-yes\"> 49</td>\n<td class=\"bc-supports-yes\"> 49</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 18</td>\n<td class=\"bc-supports-yes\"> 36</td>\n<td class=\"bc-supports-yes\"> 10</td>\n<td class=\"bc-supports-yes\"> 5.0</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Proxy/handler/isExtensible\"><code>isExtensible</code></a></th>\n<td> ? </td>\n<td> ? </td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 31</td>\n<td> ? </td>\n<td> ? </td>\n<td> ? </td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Proxy/handler/ownKeys\"><code>ownKeys</code></a></th>\n<td class=\"bc-supports-yes\"> 49</td>\n<td class=\"bc-supports-yes\"> 49</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes bc-has-history\"> 18\n<section class=\"bc-history\" id=\"sect2\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 18\n</dt>\n<dd> In Firefox 42, the implementation got updated to reflect the final ES2015 specification: The result is now checked if it is an array and if the array elements are either of type string or of type symbol. Enumerating duplicate own property names is not a failure anymore.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-yes\"> 36</td>\n<td class=\"bc-supports-yes\"> 10</td>\n<td class=\"bc-supports-yes\"> 5.0</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Proxy/handler/preventExtensions\"><code>preventExtensions</code></a></th>\n<td class=\"bc-supports-yes\"> 49</td>\n<td class=\"bc-supports-yes\"> 49</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 22</td>\n<td class=\"bc-supports-yes\"> 36</td>\n<td class=\"bc-supports-yes\"> 10</td>\n<td class=\"bc-supports-yes\"> 5.0</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Proxy/handler/set\"><code>set</code></a></th>\n<td class=\"bc-supports-yes\"> 49</td>\n<td class=\"bc-supports-yes\"> 49</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 18</td>\n<td class=\"bc-supports-yes\"> 36</td>\n<td class=\"bc-supports-yes\"> 10</td>\n<td class=\"bc-supports-yes\"> 5.0</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Proxy/handler/setPrototypeOf\"><code>setPrototypeOf</code></a></th>\n<td> ? </td>\n<td> ? </td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 49</td>\n<td> ? </td>\n<td> ? </td>\n<td> ? </td>\n</tr>\n</tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Proxy/handler/apply\"><code>apply</code></a></th>\n<td class=\"bc-supports-yes\"> 6.0.0</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Proxy/handler/construct\"><code>construct</code></a></th>\n<td class=\"bc-supports-yes\"> 6.0.0</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Proxy/handler/defineProperty\"><code>defineProperty</code></a></th>\n<td class=\"bc-supports-yes\"> 6.0.0</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Proxy/handler/deleteProperty\"><code>deleteProperty</code></a></th>\n<td class=\"bc-supports-yes\"> 6.0.0</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Proxy/handler/enumerate\"><code>enumerate</code></a> \n</th>\n<td class=\"bc-supports-no\"> No</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Proxy/handler/get\"><code>get</code></a></th>\n<td class=\"bc-supports-yes\"> 6.0.0</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Proxy/handler/getOwnPropertyDescriptor\"><code>getOwnPropertyDescriptor</code></a></th>\n<td class=\"bc-supports-yes\"> 6.0.0</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Proxy/handler/getPrototypeOf\"><code>getPrototypeOf</code></a></th>\n<td class=\"bc-supports-yes\"> 6.0.0</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Proxy/handler/has\"><code>has</code></a></th>\n<td class=\"bc-supports-yes\"> 6.0.0</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Proxy/handler/isExtensible\"><code>isExtensible</code></a></th>\n<td class=\"bc-supports-yes\"> 6.0.0</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Proxy/handler/ownKeys\"><code>ownKeys</code></a></th>\n<td class=\"bc-supports-yes\"> 6.0.0</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Proxy/handler/preventExtensions\"><code>preventExtensions</code></a></th>\n<td class=\"bc-supports-yes\"> 6.0.0</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Proxy/handler/set\"><code>set</code></a></th>\n<td class=\"bc-supports-yes\"> 6.0.0</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Proxy/handler/setPrototypeOf\"><code>setPrototypeOf</code></a></th>\n<td class=\"bc-supports-yes\"> 6.0.0</td>\n</tr>\n</tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"../proxy\"><code>Proxy</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy/handler$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy/handler\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy/handler</a>\n  </p>\n</div>\n","global_objects/object/preventextensions":"<h1>Object.preventExtensions</h1> <p>The <code><strong>Object.preventExtensions()</strong></code> method prevents new properties from ever being added to an object (i.e. prevents future extensions to the object).</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/object-preventextensions.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\">Object.preventExtensions(<var>obj</var>)</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><code>obj</code></dt> <dd>The object which should be made non-extensible.</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p>The object being made non-extensible.</p> <h2 id=\"Description\">Description</h2> <p>An object is extensible if new properties can be added to it. <code>Object.preventExtensions()</code> marks an object as no longer extensible, so that it will never have properties beyond the ones it had at the time it was marked as non-extensible. Note that the properties of a non-extensible object, in general, may still be <em>deleted</em>. Attempting to add new properties to a non-extensible object will fail, either silently or by throwing a <a href=\"../typeerror\"><code>TypeError</code></a> (most commonly, but not exclusively, when in <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Strict_mode\">strict mode</a>).</p> <p><code>Object.preventExtensions()</code> only prevents addition of own properties. Properties can still be added to the object prototype.<br> <br> This method makes the <code>[[prototype]]</code> of the target immutable; any <code>[[prototype]]</code> re-assignment will throw a <code>TypeError</code>. This behavior is specific to the internal <code>[[prototype]]</code> property, other properties of the target object will remain mutable.</p> <p>There is no way to make an object extensible again once it has been made non-extensible.</p> <h2 id=\"Examples\">Examples</h2> <pre data-language=\"js\">// Object.preventExtensions returns the object\n// being made non-extensible.\nvar obj = {};\nvar obj2 = Object.preventExtensions(obj);\nobj === obj2; // true\n\n// Objects are extensible by default.\nvar empty = {};\nObject.isExtensible(empty); // === true\n\n// ...but that can be changed.\nObject.preventExtensions(empty);\nObject.isExtensible(empty); // === false\n\n// Object.defineProperty throws when adding\n// a new property to a non-extensible object.\nvar nonExtensible = { removable: true };\nObject.preventExtensions(nonExtensible);\nObject.defineProperty(nonExtensible, 'new', {\n  value: 8675309\n}); // throws a TypeError\n\n// In strict mode, attempting to add new properties\n// to a non-extensible object throws a TypeError.\nfunction fail() {\n  'use strict';\n  // throws a TypeError\n  nonExtensible.newProperty = 'FAIL';\n}\nfail();\n</pre> <p>A non-extensible object's prototype is immutable:</p> <pre data-language=\"js\">var fixed = Object.preventExtensions({}); \n// throws a 'TypeError'.\nfixed.__proto__ = { oh: 'hai' };</pre> <h2 id=\"Notes\">Notes</h2> <p>In ES5, if the argument to this method is not an object (a primitive), then it will cause a <a href=\"../typeerror\"><code>TypeError</code></a>. In ES2015, a non-object argument will be treated as if it was a non-extensible ordinary object, simply return it.</p> <pre data-language=\"js\">Object.preventExtensions(1);\n// TypeError: 1 is not an object (ES5 code)\n\nObject.preventExtensions(1);\n// 1                             (ES2015 code)\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/5.1/#sec-15.2.3.10\" hreflang=\"en\">ECMAScript 5.1 (ECMA-262)<br><small>The definition of 'Object.preventExtensions' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition. Implemented in JavaScript 1.8.5.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-object.preventextensions\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Object.preventExtensions' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-object.preventextensions\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Object.preventExtensions' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>   <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 6</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> 9</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 5.1</td>\n</tr>\n<tr>\n<th scope=\"row\">ES2015 behavior for non-object argument</th>\n<td class=\"bc-supports-yes\"> 44</td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 35</td>\n<td class=\"bc-supports-yes\"> 11</td>\n<td class=\"bc-supports-yes\"> 31</td>\n<td class=\"bc-supports-yes\"> 9</td>\n</tr>\n</tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">ES2015 behavior for non-object argument</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 35</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 9</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n</tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">ES2015 behavior for non-object argument</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n</tbody>\n</table>\n</div>  <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"isextensible\"><code>Object.isExtensible()</code></a></li> <li><a href=\"seal\"><code>Object.seal()</code></a></li> <li><a href=\"issealed\"><code>Object.isSealed()</code></a></li> <li><a href=\"freeze\"><code>Object.freeze()</code></a></li> <li><a href=\"isfrozen\"><code>Object.isFrozen()</code></a></li> <li><a href=\"../reflect/preventextensions\"><code>Reflect.preventExtensions()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/preventExtensions$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/preventExtensions\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/preventExtensions</a>\n  </p>\n</div>\n","global_objects/object/getprototypeof":"<h1>Object.getPrototypeOf</h1> <p>The <code><strong>Object.getPrototypeOf()</strong></code> method returns the prototype (i.e. the value of the internal <code>[[Prototype]]</code> property) of the specified object.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/object-getprototypeof.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\">Object.getPrototypeOf(<var>obj</var>)</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt>\n<var>obj</var>)</dt> <dd>The object whose prototype is to be returned.</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p>The prototype of the given object. If there are no inherited properties, <a href=\"../null\"><code>null</code></a> is returned.</p> <h2 id=\"Examples\">Examples</h2> <pre data-language=\"js\">var proto = {};\nvar obj = Object.create(proto);\nObject.getPrototypeOf(obj) === proto; // true\n</pre> <h2 id=\"Notes\">Notes</h2> <p>In ES5, it will throw a <a href=\"../typeerror\"><code>TypeError</code></a> exception if the <var>obj</var> parameter isn't an object. In ES2015, the parameter will be coerced to an <a href=\"../object\"><code>Object</code></a>.</p> <pre data-language=\"js\">Object.getPrototypeOf('foo');\n// TypeError: \"foo\" is not an object (ES5 code)\nObject.getPrototypeOf('foo');\n// String.prototype                  (ES2015 code)\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <thead> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> </thead> <tbody> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/5.1/#sec-15.2.3.2\" hreflang=\"en\">ECMAScript 5.1 (ECMA-262)<br><small>The definition of 'Object.getPrototypeOf' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-object.getprototypeof\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Object.getPrototypeOf' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-object.getprototypeof\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Object.getPrototypeOf' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 5</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 3.5</td>\n<td class=\"bc-supports-yes\"> 9</td>\n<td class=\"bc-supports-yes\"> 12.1</td>\n<td class=\"bc-supports-yes\"> 5</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"Opera-specific_notes\">Opera-specific notes</h2> <p>Even though older Opera versions don't support <code>Object.getPrototypeOf()</code> yet, Opera supports the non-standard <a href=\"proto\"><code>__proto__</code></a> property since Opera 10.50.</p> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"isprototypeof\"><code>Object.prototype.isPrototypeOf()</code></a></li> <li><a href=\"setprototypeof\"><code>Object.setPrototypeOf()</code></a></li> <li><a href=\"proto\"><code>Object.prototype.__proto__</code></a></li> <li>John Resig's post on <a href=\"http://ejohn.org/blog/objectgetprototypeof/\">getPrototypeOf</a>\n</li> <li><a href=\"../reflect/getprototypeof\"><code>Reflect.getPrototypeOf()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/getPrototypeOf$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/getPrototypeOf\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/getPrototypeOf</a>\n  </p>\n</div>\n","global_objects/object/isextensible":"<h1>Object.isExtensible</h1> <p>The <code>Object.isExtensible()</code> method determines if an object is extensible (whether it can have new properties added to it).</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/object-isextensible.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\">Object.isExtensible(<var>obj</var>)</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><code>obj</code></dt> <dd>The object which should be checked.</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p>A <a href=\"../boolean\"><code>Boolean</code></a> indicating whether or not the given object is extensible.</p> <h2 id=\"Description\">Description</h2> <p>Objects are extensible by default: they can have new properties added to them, and (in engines that support <a href=\"proto\"><code>__proto__</code></a>  their __proto__ property) can be modified. An object can be marked as non-extensible using <a href=\"preventextensions\"><code>Object.preventExtensions()</code></a>, <a href=\"seal\"><code>Object.seal()</code></a>, or <a href=\"freeze\"><code>Object.freeze()</code></a>.</p> <h2 id=\"Examples\">Examples</h2> <pre data-language=\"js\">// New objects are extensible.\nvar empty = {};\nObject.isExtensible(empty); // === true\n\n// ...but that can be changed.\nObject.preventExtensions(empty);\nObject.isExtensible(empty); // === false\n\n// Sealed objects are by definition non-extensible.\nvar sealed = Object.seal({});\nObject.isExtensible(sealed); // === false\n\n// Frozen objects are also by definition non-extensible.\nvar frozen = Object.freeze({});\nObject.isExtensible(frozen); // === false\n</pre> <h2 id=\"Notes\">Notes</h2> <p>In ES5, if the argument to this method is not an object (a primitive), then it will cause a <a href=\"../typeerror\"><code>TypeError</code></a>. In ES2015, a non-object argument will be treated as if it was a non-extensible ordinary object, simply return <code>false</code>.</p> <pre data-language=\"js\">Object.isExtensible(1);\n// TypeError: 1 is not an object (ES5 code)\n\nObject.isExtensible(1);\n// false                         (ES2015 code)\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/5.1/#sec-15.2.3.13\" hreflang=\"en\">ECMAScript 5.1 (ECMA-262)<br><small>The definition of 'Object.isExtensible' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition. Implemented in JavaScript 1.8.5.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-object.isextensible\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Object.isExtensible' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-object.isextensible\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Object.isExtensible' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>   <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 6</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> 9</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 5.1</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div>  <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"preventextensions\"><code>Object.preventExtensions()</code></a></li> <li><a href=\"seal\"><code>Object.seal()</code></a></li> <li><a href=\"issealed\"><code>Object.isSealed()</code></a></li> <li><a href=\"freeze\"><code>Object.freeze()</code></a></li> <li><a href=\"isfrozen\"><code>Object.isFrozen()</code></a></li> <li><a href=\"../reflect/isextensible\"><code>Reflect.isExtensible()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/isExtensible$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/isExtensible\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/isExtensible</a>\n  </p>\n</div>\n","global_objects/object/getownpropertydescriptor":"<h1>Object.getOwnPropertyDescriptor</h1> <p>The <code><strong>Object.getOwnPropertyDescriptor()</strong></code> method returns a property descriptor for an <dfn>own property</dfn> (that is, one directly present on an object and not in the object's prototype chain) of a given object.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/object-getownpropertydescriptor.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\">Object.getOwnPropertyDescriptor(<var>obj</var>, <var>prop</var>)</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><code>obj</code></dt> <dd>The object in which to look for the property.</dd> <dt><code>prop</code></dt> <dd>The name or <a href=\"../symbol\"><code>Symbol</code></a> of the property whose description is to be retrieved.</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p>A property descriptor of the given property if it exists on the object, <a href=\"../undefined\"><code>undefined</code></a> otherwise.</p> <h2 id=\"Description\">Description</h2> <p>This method permits examination of the precise description of a property. A <dfn>property</dfn> in JavaScript consists of either a string-valued name or a <a href=\"../symbol\"><code>Symbol</code></a> and a property descriptor. Further information about property descriptor types and their attributes can be found in <a href=\"defineproperty\"><code>Object.defineProperty()</code></a>.</p> <p>A <dfn>property descriptor</dfn> is a record with some of the following attributes:</p> <dl> <dt><code>value</code></dt> <dd>The value associated with the property (data descriptors only).</dd> <dt><code>writable</code></dt> <dd>\n<code>true</code> if and only if the value associated with the property may be changed (data descriptors only).</dd> <dt><code>get</code></dt> <dd>A function which serves as a getter for the property, or <a href=\"../undefined\"><code>undefined</code></a> if there is no getter (accessor descriptors only).</dd> <dt><code>set</code></dt> <dd>A function which serves as a setter for the property, or <a href=\"../undefined\"><code>undefined</code></a> if there is no setter (accessor descriptors only).</dd> <dt><code>configurable</code></dt> <dd>\n<code>true</code> if and only if the type of this property descriptor may be changed and if the property may be deleted from the corresponding object.</dd> <dt><code>enumerable</code></dt> <dd>\n<code>true</code> if and only if this property shows up during enumeration of the properties on the corresponding object.</dd> </dl> <h2 id=\"Examples\">Examples</h2> <pre data-language=\"js\">var o, d;\n\no = { get foo() { return 17; } };\nd = Object.getOwnPropertyDescriptor(o, 'foo');\n// d is {\n//   configurable: true,\n//   enumerable: true,\n//   get: /*the getter function*/,\n//   set: undefined\n// }\n\no = { bar: 42 };\nd = Object.getOwnPropertyDescriptor(o, 'bar');\n// d is {\n//   configurable: true,\n//   enumerable: true,\n//   value: 42,\n//   writable: true\n// }\n\no = { [Symbol.for('baz')]: 73 }\nd = Object.getOwnPropertyDescriptor(o, Symbol.for('baz')); \n// d is {\n//   configurable: true,\n//   enumerable: true,\n//   value: 73,\n//   writable: true\n// }\n\no = {};\nObject.defineProperty(o, 'qux', {\n  value: 8675309,\n  writable: false,\n  enumerable: false\n});\nd = Object.getOwnPropertyDescriptor(o, 'qux');\n// d is {\n//   value: 8675309,\n//   writable: false,\n//   enumerable: false,\n//   configurable: false\n// }\n</pre> <h2 id=\"Notes\">Notes</h2> <p>In ES5, if the first argument to this method is not an object (a primitive), then it will cause a <a href=\"../typeerror\"><code>TypeError</code></a>. In ES2015, a non-object first argument will be coerced to an object at first.</p> <pre data-language=\"js\">Object.getOwnPropertyDescriptor('foo', 0);\n// TypeError: \"foo\" is not an object  // ES5 code\n\nObject.getOwnPropertyDescriptor('foo', 0);\n// Object returned by ES2015 code: {\n//   configurable: false,\n//   enumerable: true,\n//   value: \"f\",\n//   writable: false\n// }\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <thead> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> </thead> <tbody> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/5.1/#sec-15.2.3.3\" hreflang=\"en\">ECMAScript 5.1 (ECMA-262)<br><small>The definition of 'Object.getOwnPropertyDescriptor' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition. Implemented in JavaScript 1.8.5.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-object.getownpropertydescriptor\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Object.getOwnPropertyDescriptor' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-object.getownpropertydescriptor\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Object.getOwnPropertyDescriptor' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 5</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> 8</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 5</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"defineproperty\"><code>Object.defineProperty()</code></a></li> <li><a href=\"../reflect/getownpropertydescriptor\"><code>Reflect.getOwnPropertyDescriptor()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/getOwnPropertyDescriptor$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/getOwnPropertyDescriptor\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/getOwnPropertyDescriptor</a>\n  </p>\n</div>\n","global_objects/reflect/construct":"<h1>Reflect.construct</h1> <p>The static <code><strong>Reflect</strong></code><code>.construct()</code> method acts like the <a href=\"../../operators/new\"><code>new</code> operator</a>, but as a function. It is equivalent to calling <code>new target(...args)</code>. It gives also the added option to specify a different prototype.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/reflect-construct.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\">Reflect.construct(target, argumentsList[, newTarget])\n</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><code>target</code></dt> <dd>The target function to call.</dd> <dt><code>argumentsList</code></dt> <dd>An array-like object specifying the arguments with which <code>target</code> should be called.</dd> <dt>\n<code>newTarget</code> <span class=\"inlineIndicator optional optionalInline\">Optional</span>\n</dt> <dd>The constructor whose prototype should be used. See also the <code><a href=\"../../operators/new.target\">new.target</a></code> operator. If <code>newTarget</code> is not present, it is <code>target</code>.</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p>A new instance of <code>target</code> (or <code>newTarget</code>, if present), initialized by <code>target</code> as a constructor with the given arguments.</p> <h3 id=\"Exceptions\">Exceptions</h3> <p>A <a href=\"../typeerror\"><code>TypeError</code></a>, if <code>target</code> or <code>newTarget</code> are not constructors.</p> <h2 id=\"Description\">Description</h2> <p><code>Reflect.construct</code> allows you to invoke a constructor with a variable number of arguments (which would also be possible by using the <a href=\"../../operators/spread_syntax\">spread operator</a> combined with the <a href=\"../../operators/new\">new operator</a>).</p> <pre data-language=\"js\">var obj = new Foo(...args);\nvar obj = Reflect.construct(Foo, args);\n</pre>  <h3 id=\"Reflect.construct()_vs_Object.create()\">\n<code>Reflect.construct()</code> vs <code>Object.create()</code>\n</h3> <p>Prior to the introduction of <code>Reflect</code>, objects could be constructed using an arbitrary combination of constructor and prototype by using <code>Object.create()</code>.</p> <pre data-language=\"js\">function OneClass() {\n    this.name = 'one';\n}\n\nfunction OtherClass() {\n    this.name = 'other';\n}\n\n// Calling this:\nvar obj1 = Reflect.construct(OneClass, args, OtherClass);\n\n// ...has the same result as this:\nvar obj2 = Object.create(OtherClass.prototype);\nOneClass.apply(obj2, args);\n\nconsole.log(obj1.name); // 'one'\nconsole.log(obj2.name); // 'one'\n\nconsole.log(obj1 instanceof OneClass); // false\nconsole.log(obj2 instanceof OneClass); // false\n\nconsole.log(obj1 instanceof OtherClass); // true\nconsole.log(obj2 instanceof OtherClass); // true\n</pre> <p>However, while the end result is the same, there is one important difference in the process. When using <code>Object.create()</code> and <code>Function.prototype.apply()</code>, the <code>new.target</code> operator will point to <code>undefined</code> within the function used as the constructor, since the <code>new</code> keyword is not being used to create the object.</p> <p>When invoking <code>Reflect.construct()</code>, on the other hand, the <code>new.target</code> operator will point to the <code>newTarget</code> parameter if supplied, or <code>target</code> if not.</p> <pre data-language=\"js\">function OneClass() {\n    console.log('OneClass');\n    console.log(new.target);\n}\nfunction OtherClass() {\n    console.log('OtherClass');\n    console.log(new.target);\n}\n\nvar obj1 = Reflect.construct(OneClass, args);\n// Output:\n//     OneClass\n//     function OneClass { ... }\n\nvar obj2 = Reflect.construct(OneClass, args, OtherClass);\n// Output:\n//     OneClass\n//     function OtherClass { ... }\n\nvar obj3 = Object.create(OtherClass.prototype);\nOneClass.apply(obj2, args);\n// Output:\n//     OneClass\n//     undefined</pre>  <h2 id=\"Examples\">Examples</h2> <h3 id=\"Using_Reflect.construct()\">Using <code>Reflect.construct()</code>\n</h3> <pre data-language=\"js\">var d = Reflect.construct(Date, [1776, 6, 4]);\nd instanceof Date; // true\nd.getFullYear(); // 1776\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-reflect.construct\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Reflect.construct' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-reflect.construct\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Reflect.construct' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 49</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 42</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 36</td>\n<td class=\"bc-supports-yes\"> 10</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 49</td>\n<td class=\"bc-supports-yes\"> 49</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 42</td>\n<td class=\"bc-supports-yes\"> 36</td>\n<td class=\"bc-supports-yes\"> 10</td>\n<td class=\"bc-supports-yes\"> 5.0</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 6.0.0</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"../reflect\"><code>Reflect</code></a></li> <li><a href=\"../../operators/new\"><code>new</code></a></li> <li><code><a href=\"../../operators/new.target\">new.target</a></code></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/construct$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/construct\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/construct</a>\n  </p>\n</div>\n","global_objects/reflect/get":"<h1>Reflect.get</h1> <p>The static <code>Reflect.get()</code> method works like getting a property from an object (<code>target[propertyKey]</code>) as a function.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/reflect-get.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\">Reflect.get(target, propertyKey[, receiver])\n</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><code>target</code></dt> <dd>The target object on which to get the property.</dd> <dt><code>propertyKey</code></dt> <dd>The name of the property to get.</dd> <dt>receiver <span class=\"inlineIndicator optional optionalInline\">Optional</span>\n</dt> <dd>The value of <code>this</code> provided for the call to <code>target</code> if a getter is encountered. When used with <a href=\"../proxy\"><code>Proxy</code></a>, it can be an object that inherits from the target.</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p>The value of the property.</p> <h3 id=\"Exceptions\">Exceptions</h3> <p>A <a href=\"../typeerror\"><code>TypeError</code></a>, if <code>target</code> is not an <a href=\"../object\"><code>Object</code></a>.</p> <h2 id=\"Description\">Description</h2> <p>The <code>Reflect.get</code> method allows you to get a property on an object. It is like the <a href=\"../../operators/property_accessors\">property accessor</a> syntax as a function.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Using_Reflect.get()\">Using <code>Reflect.get()</code>\n</h3> <pre data-language=\"js\">// Object\nvar obj = { x: 1, y: 2 };\nReflect.get(obj, 'x'); // 1\n\n// Array\nReflect.get(['zero', 'one'], 1); // \"one\"\n\n// Proxy with a get handler\nvar x = {p: 1};\nvar obj = new Proxy(x, {\n  get(t, k, r) { return k + 'bar'; }\n});\nReflect.get(obj, 'foo'); // \"foobar\"\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-reflect.get\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Reflect.get' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-reflect.get\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Reflect.get' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 49</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 42</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 36</td>\n<td class=\"bc-supports-yes\"> 10</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 49</td>\n<td class=\"bc-supports-yes\"> 49</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 42</td>\n<td class=\"bc-supports-yes\"> 36</td>\n<td class=\"bc-supports-yes\"> 10</td>\n<td class=\"bc-supports-yes\"> 5.0</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 6.0.0</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"../reflect\"><code>Reflect</code></a></li> <li><a href=\"../../operators/property_accessors\">Property accessors</a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/get$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/get\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/get</a>\n  </p>\n</div>\n","global_objects/reflect/ownkeys":"<h1>Reflect.ownKeys</h1> <p>The static <code><strong>Reflect</strong></code><code>.ownKeys()</code> method returns an array of the <code>target</code> object's own property keys.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/reflect-ownkeys.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\">Reflect.ownKeys(target)\n</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><code>target</code></dt> <dd>The target object from which to get the own keys.</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p>An <a href=\"../array\"><code>Array</code></a> of the <code>target</code> object's own property keys.</p> <h3 id=\"Exceptions\">Exceptions</h3> <p>A <a href=\"../typeerror\"><code>TypeError</code></a>, if <code>target</code> is not an <a href=\"../object\"><code>Object</code></a>.</p> <h2 id=\"Description\">Description</h2> <p>The <code>Reflect.ownKeys</code> method returns an array of the <code>target</code> object's own property keys. Its return value is equivalent to <code><a href=\"../object/getownpropertynames\"><code>Object.getOwnPropertyNames</code></a>(target).concat(<a href=\"../object/getownpropertysymbols\"><code>Object.getOwnPropertySymbols</code></a>(target))</code>.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Using_Reflect.ownKeys()\">Using <code>Reflect.ownKeys()</code>\n</h3> <pre data-language=\"js\">Reflect.ownKeys({z: 3, y: 2, x: 1}); // [ \"z\", \"y\", \"x\" ]\nReflect.ownKeys([]); // [\"length\"]\n\nvar sym = Symbol.for('comet');\nvar sym2 = Symbol.for('meteor');\nvar obj = {[sym]: 0, 'str': 0, '773': 0, '0': 0,\n           [sym2]: 0, '-1': 0, '8': 0, 'second str': 0};\nReflect.ownKeys(obj);\n// [ \"0\", \"8\", \"773\", \"str\", \"-1\", \"second str\", Symbol(comet), Symbol(meteor) ]\n// Indexes in numeric order, \n// strings in insertion order, \n// symbols in insertion order\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-reflect.ownkeys\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Reflect.ownKeys' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-reflect.ownkeys\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Reflect.ownKeys' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 49</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 42</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 36</td>\n<td class=\"bc-supports-yes\"> 10</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 49</td>\n<td class=\"bc-supports-yes\"> 49</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 42</td>\n<td class=\"bc-supports-yes\"> 36</td>\n<td class=\"bc-supports-yes\"> 10</td>\n<td class=\"bc-supports-yes\"> 5.0</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 6.0.0</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"../reflect\"><code>Reflect</code></a></li> <li><a href=\"../object/getownpropertynames\"><code>Object.getOwnPropertyNames()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/ownKeys$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/ownKeys\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/ownKeys</a>\n  </p>\n</div>\n","global_objects/reflect/getownpropertydescriptor":"<h1>Reflect.getOwnPropertyDescriptor</h1> <p>The static <code><strong>Reflect</strong></code><code>.getOwnPropertyDescriptor()</code> method is similar to <a href=\"../object/getownpropertydescriptor\"><code>Object.getOwnPropertyDescriptor()</code></a>. It returns a property descriptor of the given property if it exists on the object, <a href=\"../undefined\"><code>undefined</code></a> otherwise.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/reflect-getownpropertydescriptor.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\">Reflect.getOwnPropertyDescriptor(target, propertyKey)\n</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><code>target</code></dt> <dd>The target object in which to look for the property.</dd> <dt><code>propertyKey</code></dt> <dd>The name of the property to get an own property descriptor for.</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p>A property descriptor object if the property exists in the given target object; otherwise, <a href=\"../undefined\"><code>undefined</code></a>.</p> <h3 id=\"Exceptions\">Exceptions</h3> <p>A <a href=\"../typeerror\"><code>TypeError</code></a>, if <code>target</code> is not an <a href=\"../object\"><code>Object</code></a>.</p> <h2 id=\"Description\">Description</h2> <p>The <code>Reflect.</code>getOwnPropertyDescriptor method returns a property descriptor of the given property if it exists on the object, <a href=\"../undefined\"><code>undefined</code></a> otherwise. The only difference to <a href=\"../object/getownpropertydescriptor\"><code>Object.getOwnPropertyDescriptor()</code></a> is how non-object targets are handled.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Using_Reflect.getOwnPropertyDescriptor()\">Using <code>Reflect.getOwnPropertyDescriptor()</code>\n</h3> <pre data-language=\"js\">Reflect.getOwnPropertyDescriptor({x: 'hello'}, 'x');\n// {value: \"hello\", writable: true, enumerable: true, configurable: true}\n\nReflect.getOwnPropertyDescriptor({x: 'hello'}, 'y');\n// undefined\n\nReflect.getOwnPropertyDescriptor([], 'length');\n// {value: 0, writable: true, enumerable: false, configurable: false}\n</pre> <h3 id=\"Difference_to_Object.getOwnPropertyDescriptor()\">Difference to <code>Object.getOwnPropertyDescriptor()</code>\n</h3> <p>If the first argument to this method is not an object (a primitive), then it will cause a <a href=\"../typeerror\"><code>TypeError</code></a>. With <a href=\"../object/getownpropertydescriptor\"><code>Object.getOwnPropertyDescriptor</code></a>, a non-object first argument will be coerced to an object at first.</p> <pre data-language=\"js\">Reflect.getOwnPropertyDescriptor('foo', 0);\n// TypeError: \"foo\" is not non-null object\n\nObject.getOwnPropertyDescriptor('foo', 0);\n// { value: \"f\", writable: false, enumerable: true, configurable: false }</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-reflect.getownpropertydescriptor\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Reflect.getOwnPropertyDescriptor' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-reflect.getownpropertydescriptor\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Reflect.getOwnPropertyDescriptor' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 49</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 42</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 36</td>\n<td class=\"bc-supports-yes\"> 10</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 49</td>\n<td class=\"bc-supports-yes\"> 49</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 42</td>\n<td class=\"bc-supports-yes\"> 36</td>\n<td class=\"bc-supports-yes\"> 10</td>\n<td class=\"bc-supports-yes\"> 5.0</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 6.0.0</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"../reflect\"><code>Reflect</code></a></li> <li><a href=\"../object/getownpropertydescriptor\"><code>Object.getOwnPropertyDescriptor()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/getOwnPropertyDescriptor$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/getOwnPropertyDescriptor\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/getOwnPropertyDescriptor</a>\n  </p>\n</div>\n","global_objects/reflect/setprototypeof":"<h1>Reflect.setPrototypeOf</h1> <p>The static <code><strong>Reflect</strong></code><code>.setPrototypeOf()</code> method is the same method as <a href=\"../object/setprototypeof\"><code>Object.setPrototypeOf()</code></a>. It sets the prototype (i.e., the internal <code>[[Prototype]]</code> property) of a specified object to another object or to <a href=\"../null\"><code>null</code></a>.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/reflect-setprototypeof.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\">Reflect.setPrototypeOf(target, prototype)\n</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><code>target</code></dt> <dd>The target object of which to set the prototype.</dd> <dt><code>prototype</code></dt> <dd>The object's new prototype (an object or <a href=\"../null\"><code>null</code></a>).</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p>A <a href=\"../boolean\"><code>Boolean</code></a> indicating whether or not the prototype was successfully set.</p> <h3 id=\"Exceptions\">Exceptions</h3> <p>A <a href=\"../typeerror\"><code>TypeError</code></a>, if <code>target</code> is not an <a href=\"../object\"><code>Object</code></a> or if <code>prototype</code> is neither an object nor <a href=\"../null\"><code>null</code></a>.</p> <h2 id=\"Description\">Description</h2> <p>The <code>Reflect.setPrototypeOf</code> method changes the prototype (i.e. the value of the internal <code>[[Prototype]]</code> property) of the specified object.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Using_Reflect.setPrototypeOf()\">Using <code>Reflect.setPrototypeOf()</code>\n</h3> <pre data-language=\"js\">Reflect.setPrototypeOf({}, Object.prototype); // true\n\n// It can change an object's [[Prototype]] to null.\nReflect.setPrototypeOf({}, null); // true\n\n// Returns false if target is not extensible.\nReflect.setPrototypeOf(Object.freeze({}), null); // false\n\n// Returns false if it cause a prototype chain cycle.\nvar target = {};\nvar proto = Object.create(target);\nReflect.setPrototypeOf(target, proto); // false\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-reflect.setprototypeof\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Reflect.setPrototypeOf' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-reflect.setprototypeof\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Reflect.setPrototypeOf' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 49</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 42</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 36</td>\n<td class=\"bc-supports-yes\"> 10</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 49</td>\n<td class=\"bc-supports-yes\"> 49</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 42</td>\n<td class=\"bc-supports-yes\"> 36</td>\n<td class=\"bc-supports-yes\"> 10</td>\n<td class=\"bc-supports-yes\"> 5.0</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 6.0.0</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"../reflect\"><code>Reflect</code></a></li> <li><a href=\"../object/setprototypeof\"><code>Object.setPrototypeOf()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/setPrototypeOf$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/setPrototypeOf\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/setPrototypeOf</a>\n  </p>\n</div>\n","global_objects/reflect/set":"<h1>Reflect.set</h1> <p>The static <code><strong>Reflect</strong></code><code>.set()</code> method works like setting a property on an object.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/reflect-set.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\">Reflect.set(target, propertyKey, value[, receiver])\n</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><code>target</code></dt> <dd>The target object on which to set the property.</dd> <dt><code>propertyKey</code></dt> <dd>The name of the property to set.</dd> <dt>value</dt> <dd>The value to set.</dd> <dt>receiver</dt> <dd>The value of <code>this</code> provided for the call to <code>target</code> if a setter is encountered.</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p>A <a href=\"../boolean\"><code>Boolean</code></a> indicating whether or not setting the property was successful.</p> <h3 id=\"Exceptions\">Exceptions</h3> <p>A <a href=\"../typeerror\"><code>TypeError</code></a>, if <code>target</code> is not an <a href=\"../object\"><code>Object</code></a>.</p> <h2 id=\"Description\">Description</h2> <p>The <code>Reflect.set</code> method allows you to set a property on an object. It does property assignment and is like the <a href=\"../../operators/property_accessors\">property accessor</a> syntax as a function.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Using_Reflect.set()\">Using <code>Reflect.set()</code>\n</h3> <pre data-language=\"js\">// Object\nvar obj = {};\nReflect.set(obj, 'prop', 'value'); // true\nobj.prop; // \"value\"\n\n// Array\nvar arr = ['duck', 'duck', 'duck'];\nReflect.set(arr, 2, 'goose'); // true\narr[2]; // \"goose\"\n\n// It can truncate an array.\nReflect.set(arr, 'length', 1); // true\narr; // [\"duck\"];\n\n// With just one argument, propertyKey and value are \"undefined\".\nvar obj = {};\nReflect.set(obj); // true\nReflect.getOwnPropertyDescriptor(obj, 'undefined');\n// { value: undefined, writable: true, enumerable: true, configurable: true }\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-reflect.set\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Reflect.set' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-reflect.set\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Reflect.set' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 49</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 42</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 36</td>\n<td class=\"bc-supports-yes\"> 10</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 49</td>\n<td class=\"bc-supports-yes\"> 49</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 42</td>\n<td class=\"bc-supports-yes\"> 36</td>\n<td class=\"bc-supports-yes\"> 10</td>\n<td class=\"bc-supports-yes\"> 5.0</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 6.0.0</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"../reflect\"><code>Reflect</code></a></li> <li><a href=\"../../operators/property_accessors\">Property accessors</a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/set$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/set\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/set</a>\n  </p>\n</div>\n","global_objects/number/epsilon":"<h1>Number.EPSILON</h1> <p>The <code>Number.EPSILON</code> property represents the difference between 1 and the smallest floating point number greater than 1.</p> <p>You do not have to create a <a href=\"../number\"><code>Number</code></a> object to access this static property (use <code>Number.EPSILON</code>).</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/number-epsilon.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <div class=\"_table\"><table class=\"standard-table\"> <thead> <tr> <th colspan=\"2\" class=\"header\">Property attributes of <code>Number.EPSILON</code>\n</th> </tr> </thead> <tbody> <tr> <td>Writable</td> <td>no</td> </tr> <tr> <td>Enumerable</td> <td>no</td> </tr> <tr> <td>Configurable</td> <td>no</td> </tr> </tbody> </table></div> <h2 id=\"Description\">Description</h2> <p>The <code>EPSILON</code> property has a value of approximately <code>2.2204460492503130808472633361816E-16</code>, or <code>2<sup>-52</sup></code>.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Testing_equality\">Testing equality</h3> <pre data-language=\"js\">x = 0.2;\ny = 0.3;\nz = 0.1;\nequal = (Math.abs(x - y + z) &lt; Number.EPSILON);\n</pre> <h2 id=\"Polyfill\">Polyfill</h2> <pre data-language=\"js\">if (Number.EPSILON === undefined) {\n    Number.EPSILON = Math.pow(2, -52);\n}\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-number.epsilon\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Number.EPSILON' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-number.epsilon\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Number.EPSILON' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 25</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 9</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 25</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 9</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 0.12</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li>The <a href=\"../number\"><code>Number</code></a> object it belongs to.</li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/EPSILON$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/EPSILON\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/EPSILON</a>\n  </p>\n</div>\n","global_objects/object/defineproperties":"<h1>Object.defineProperties</h1> <p>The <code><strong>Object.defineProperties()</strong></code> method defines new or modifies existing properties directly on an object, returning the object.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/object-defineproperties.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\">Object.defineProperties(<var>obj</var>, <var>props</var>)</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><code>obj</code></dt> <dd>The object on which to define or modify properties.</dd> <dt><code>props</code></dt> <dd>An object whose own enumerable properties constitute descriptors for the properties to be defined or modified. Property descriptors present in objects come in two main flavors: data descriptors and accessor descriptors (see <a href=\"defineproperty\"><code>Object.defineProperty()</code></a> for more details). Descriptors have the following keys:</dd> <dd> <dl> <dt><code>configurable</code></dt> <dd>\n<code>true</code> if and only if the type of this property descriptor may be changed and if the property may be deleted from the corresponding object.<br> <code>false</code>\n</dd> <dt><code>enumerable</code></dt> <dd>\n<code>true</code> if and only if this property shows up during enumeration of the properties on the corresponding object.<br> <code>false</code>\n</dd> </dl> <dl> <dt><code>value</code></dt> <dd>The value associated with the property. Can be any valid JavaScript value (number, object, function, etc).<br> <strong>Defaults to <a href=\"../undefined\"><code>undefined</code></a>.</strong>\n</dd> <dt><code>writable</code></dt> <dd>\n<code>true</code> if and only if the value associated with the property may be changed with an <a href=\"../../operators/assignment_operators\">assignment operator</a>.<br> <code>false</code>\n</dd> </dl> <dl> <dt><code>get</code></dt> <dd>A function which serves as a getter for the property, or <a href=\"../undefined\"><code>undefined</code></a> if there is no getter. The function's return value will be used as the value of the property.<br> <strong>Defaults to <a href=\"../undefined\"><code>undefined</code></a>.</strong>\n</dd> <dt><code>set</code></dt> <dd>A function which serves as a setter for the property, or <a href=\"../undefined\"><code>undefined</code></a> if there is no setter. The function will receive as its only argument the new value being assigned to the property.<br> <strong>Defaults to <a href=\"../undefined\"><code>undefined</code></a>.</strong>\n</dd> </dl> </dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p>The object that was passed to the function.</p> <h2 id=\"Description\">Description</h2> <p><code>Object.defineProperties</code>, in essence, defines all properties corresponding to the enumerable own properties of <code>props</code> on the object <code>obj</code> object.</p> <h2 id=\"Example\">Example</h2> <pre data-language=\"js\">var obj = {};\nObject.defineProperties(obj, {\n  'property1': {\n    value: true,\n    writable: true\n  },\n  'property2': {\n    value: 'Hello',\n    writable: false\n  }\n  // etc. etc.\n});\n</pre> <h2 id=\"Polyfill\">Polyfill</h2> <p>Assuming a pristine execution environment with all names and properties referring to their initial values, <code>Object.defineProperties</code> is almost completely equivalent (note the comment in <code>isCallable</code>) to the following reimplementation in JavaScript:</p> <pre data-language=\"js\">function defineProperties(obj, properties) {\n  function convertToDescriptor(desc) {\n    function hasProperty(obj, prop) {\n      return Object.prototype.hasOwnProperty.call(obj, prop);\n    }\n\n    function isCallable(v) {\n      // NB: modify as necessary if other values than functions are callable.\n      return typeof v === 'function';\n    }\n\n    if (typeof desc !== 'object' || desc === null)\n      throw new TypeError('bad desc');\n\n    var d = {};\n\n    if (hasProperty(desc, 'enumerable'))\n      d.enumerable = !!desc.enumerable;\n    if (hasProperty(desc, 'configurable'))\n      d.configurable = !!desc.configurable;\n    if (hasProperty(desc, 'value'))\n      d.value = desc.value;\n    if (hasProperty(desc, 'writable'))\n      d.writable = !!desc.writable;\n    if (hasProperty(desc, 'get')) {\n      var g = desc.get;\n\n      if (!isCallable(g) &amp;&amp; typeof g !== 'undefined')\n        throw new TypeError('bad get');\n      d.get = g;\n    }\n    if (hasProperty(desc, 'set')) {\n      var s = desc.set;\n      if (!isCallable(s) &amp;&amp; typeof s !== 'undefined')\n        throw new TypeError('bad set');\n      d.set = s;\n    }\n\n    if (('get' in d || 'set' in d) &amp;&amp; ('value' in d || 'writable' in d))\n      throw new TypeError('identity-confused descriptor');\n\n    return d;\n  }\n\n  if (typeof obj !== 'object' || obj === null)\n    throw new TypeError('bad obj');\n\n  properties = Object(properties);\n\n  var keys = Object.keys(properties);\n  var descs = [];\n\n  for (var i = 0; i &lt; keys.length; i++)\n    descs.push([keys[i], convertToDescriptor(properties[keys[i]])]);\n\n  for (var i = 0; i &lt; descs.length; i++)\n    Object.defineProperty(obj, descs[i][0], descs[i][1]);\n\n  return obj;\n}\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/5.1/#sec-15.2.3.7\" hreflang=\"en\">ECMAScript 5.1 (ECMA-262)<br><small>The definition of 'Object.defineProperties' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition. Implemented in JavaScript 1.8.5</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-object.defineproperties\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Object.defineProperties' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-object.defineproperties\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Object.defineProperties' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>   <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 5</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> 9</td>\n<td class=\"bc-supports-yes\"> 11.6</td>\n<td class=\"bc-supports-yes\"> 5</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> 11.5</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div>  <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"defineproperty\"><code>Object.defineProperty()</code></a></li> <li><a href=\"keys\"><code>Object.keys()</code></a></li> <li><a href=\"https://developer.mozilla.org/en-US/docs/Enumerability_and_ownership_of_properties\">Enumerability and ownership of properties</a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/defineProperties$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/defineProperties\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/defineProperties</a>\n  </p>\n</div>\n","global_objects/syntaxerror/prototype":"<h1>SyntaxError.prototype</h1> <p>The <code><strong>SyntaxError.prototype</strong></code> property represents the prototype for the <a href=\"../syntaxerror\"><code>SyntaxError</code></a> constructor.</p> <h2 id=\"Description\">Description</h2> <p>All <a href=\"../syntaxerror\"><code>SyntaxError</code></a> instances inherit from <code>SyntaxError.prototype</code>. You can use the prototype to add properties or methods to all instances.</p> <h2 id=\"Properties\">Properties</h2> <dl> <dt><code>SyntaxError.prototype.constructor</code></dt> <dd>Specifies the function that created an instance's prototype.</dd> <dt><a href=\"../error/message\"><code>SyntaxError.prototype.message</code></a></dt> <dd>Error message. Although ECMA-262 specifies that <a href=\"../syntaxerror\"><code>SyntaxError</code></a> should provide its own <code>message</code> property, in <a href=\"https://developer.mozilla.org/en-US/docs/Mozilla/Projects/SpiderMonkey\">SpiderMonkey</a>, it inherits <a href=\"../error/message\"><code>Error.prototype.message</code></a>.</dd> <dt><a href=\"../error/name\"><code>SyntaxError.prototype.name</code></a></dt> <dd>Error name. Inherited from <a href=\"../error\"><code>Error</code></a>.</dd> <dt><a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/fileName\"><code>SyntaxError.prototype.fileName</code></a></dt> <dd>Path to file that raised this error. Inherited from <a href=\"../error\"><code>Error</code></a>.</dd> <dt><a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/lineNumber\"><code>SyntaxError.prototype.lineNumber</code></a></dt> <dd>Line number in file that raised this error. Inherited from <a href=\"../error\"><code>Error</code></a>.</dd> <dt><a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/columnNumber\"><code>SyntaxError.prototype.columnNumber</code></a></dt> <dd>Column number in line that raised this error. Inherited from <a href=\"../error\"><code>Error</code></a>.</dd> <dt><a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/stack\"><code>SyntaxError.prototype.stack</code></a></dt> <dd>Stack trace. Inherited from <a href=\"../error\"><code>Error</code></a>.</dd> </dl> <h2 id=\"Methods\">Methods</h2> <p>Although the <a href=\"../syntaxerror\"><code>SyntaxError</code></a> prototype object does not contain any methods of its own, <a href=\"../syntaxerror\"><code>SyntaxError</code></a> instances do inherit some methods through the prototype chain.</p> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/publications/files/ECMA-ST-ARCH/ECMA-262,%203rd%20edition,%20December%201999.pdf\" hreflang=\"en\">ECMAScript 3rd Edition (ECMA-262)</a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/5.1/#sec-15.11.7.6\" hreflang=\"en\">ECMAScript 5.1 (ECMA-262)<br><small>The definition of 'NativeError.prototype' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Defined as <code><em>NativeError</em>.prototype</code>.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-nativeerror.prototype\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'NativeError.prototype' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Defined as <code><em>NativeError</em>.prototype</code>.</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-nativeerror.prototype\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'NativeError.prototype' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td>Defined as <code><em>NativeError</em>.prototype</code>.</td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>   <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/SyntaxError\">Basic support</a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/SyntaxError\">Basic support</a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/SyntaxError\">Basic support</a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div>  <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"../error/prototype\"><code>Error.prototype</code></a></li> <li><a href=\"../function/prototype\"><code>Function.prototype</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SyntaxError/prototype$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SyntaxError/prototype\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SyntaxError/prototype</a>\n  </p>\n</div>\n","global_objects/number/min_safe_integer":"<h1>Number.MIN_SAFE_INTEGER</h1> <p>The <code>Number.MIN_SAFE_INTEGER</code> constant represents the minimum safe integer in JavaScript (<code>-(2<sup>53</sup> - 1)</code>).</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/number-min-safe-integer.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <div class=\"_table\"><table class=\"standard-table\"> <thead> <tr> <th colspan=\"2\" class=\"header\">Property attributes of <code>Number.MIN_SAFE_INTEGER</code>\n</th> </tr> </thead> <tbody> <tr> <td>Writable</td> <td>no</td> </tr> <tr> <td>Enumerable</td> <td>no</td> </tr> <tr> <td>Configurable</td> <td>no</td> </tr> </tbody> </table></div> <h2 id=\"Description\">Description</h2> <p>The <code>MIN_SAFE_INTEGER</code> constant has a value of <code>-9007199254740991</code> (-9,007,199,254,740,991 or about -9 quadrillion). The reasoning behind that number is that JavaScript uses <a href=\"http://en.wikipedia.org/wiki/Double_precision_floating-point_format\">double-precision floating-point format numbers</a> as specified in <a href=\"http://en.wikipedia.org/wiki/IEEE_floating_point\">IEEE 754</a> and can only safely represent numbers between <code>-(2<sup>53</sup> - 1)</code> and <code>2<sup>53</sup> - 1</code>. See <a href=\"issafeinteger\"><code>Number.isSafeInteger()</code></a> for more information.</p> <p>Because <code>MIN_SAFE_INTEGER</code> is a static property of <a href=\"../number\"><code>Number</code></a>, you always use it as <code>Number.MIN_SAFE_INTEGER</code>, rather than as a property of a <a href=\"../number\"><code>Number</code></a> object you created.</p> <h2 id=\"Examples\">Examples</h2> <pre data-language=\"js\">Number.MIN_SAFE_INTEGER // -9007199254740991\n-(Math.pow(2, 53) - 1)  // -9007199254740991\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-number.min_safe_integer\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Number.MIN_SAFE_INTEGER' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-number.min_safe_integer\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Number.MIN_SAFE_INTEGER' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 34</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 31</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 9</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 31</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 9</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 0.12</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"max_safe_integer\"><code>Number.MAX_SAFE_INTEGER</code></a></li> <li><a href=\"issafeinteger\"><code>Number.isSafeInteger()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/MIN_SAFE_INTEGER$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/MIN_SAFE_INTEGER\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/MIN_SAFE_INTEGER</a>\n  </p>\n</div>\n","global_objects/number/max_value":"<h1>Number.MAX_VALUE</h1> <p>The <code>Number.MAX_VALUE</code> property represents the maximum numeric value representable in JavaScript.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/number-maxvalue.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <div class=\"_table\"><table class=\"standard-table\"> <thead> <tr> <th colspan=\"2\" class=\"header\">Property attributes of <code>Number.MAX_VALUE</code>\n</th> </tr> </thead> <tbody> <tr> <td>Writable</td> <td>no</td> </tr> <tr> <td>Enumerable</td> <td>no</td> </tr> <tr> <td>Configurable</td> <td>no</td> </tr> </tbody> </table></div> <h2 id=\"Description\">Description</h2> <p>The <code>MAX_VALUE</code> property has a value of approximately <code>1.79E+308</code>, or 2<sup>1024</sup>. Values larger than <code>MAX_VALUE</code> are represented as \"<code>Infinity</code>\".</p> <p>Because <code>MAX_VALUE</code> is a static property of <a href=\"../number\"><code>Number</code></a>, you always use it as <code>Number.MAX_VALUE</code>, rather than as a property of a <a href=\"../number\"><code>Number</code></a> object you created. Calling it on the object you created(rather than <a href=\"../number\"><code>Number</code></a> itself), will result in <strong>undefined</strong> value.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Using_MAX_VALUE\">Using <code>MAX_VALUE</code>\n</h3> <p>The following code multiplies two numeric values. If the result is less than or equal to <code>MAX_VALUE</code>, the <code>func1</code> function is called; otherwise, the <code>func2</code> function is called.</p> <pre data-language=\"js\">if (num1 * num2 &lt;= Number.MAX_VALUE) {\n  func1();\n} else {\n  func2();\n}\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/publications/files/ECMA-ST-ARCH/ECMA-262,%201st%20edition,%20June%201997.pdf\" hreflang=\"en\">ECMAScript 1st Edition (ECMA-262)</a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition. Implemented in JavaScript 1.1.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/5.1/#sec-15.7.3.2\" hreflang=\"en\">ECMAScript 5.1 (ECMA-262)<br><small>The definition of 'Number.MAX_VALUE' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-number.max_value\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Number.MAX_VALUE' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-number.max_value\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Number.MAX_VALUE' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"min_value\"><code>Number.MIN_VALUE</code></a></li> <li>The <a href=\"../number\"><code>Number</code></a> object it belongs to</li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/MAX_VALUE$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/MAX_VALUE\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/MAX_VALUE</a>\n  </p>\n</div>\n","global_objects/urierror/prototype":"<h1>URIError.prototype</h1> <p>The <code><strong>URIError.prototype</strong></code> property represents the prototype for the <a href=\"../urierror\"><code>URIError</code></a> constructor.</p> <h2 id=\"Description\">Description</h2> <p>All <a href=\"../urierror\"><code>URIError</code></a> instances inherit from <code>URIError.prototype</code>. You can use the prototype to add properties or methods to all instances.</p> <h2 id=\"Properties\">Properties</h2> <dl> <dt><code>URIError.prototype.constructor</code></dt> <dd>Specifies the function that created an instance's prototype.</dd> <dt><a href=\"../error/message\"><code>URIError.prototype.message</code></a></dt> <dd>Error message. Although ECMA-262 specifies that <a href=\"../urierror\"><code>URIError</code></a> should provide its own <code>message</code> property, in <a href=\"https://developer.mozilla.org/en-US/docs/Mozilla/Projects/SpiderMonkey\">SpiderMonkey</a>, it inherits <a href=\"../error/message\"><code>Error.prototype.message</code></a>.</dd> <dt><a href=\"../error/name\"><code>URIError.prototype.name</code></a></dt> <dd>Error name. Inherited from <a href=\"../error\"><code>Error</code></a>.</dd> <dt><a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/fileName\"><code>URIError.prototype.fileName</code></a></dt> <dd>Path to file that raised this error. Inherited from <a href=\"../error\"><code>Error</code></a>.</dd> <dt><a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/lineNumber\"><code>URIError.prototype.lineNumber</code></a></dt> <dd>Line number in file that raised this error. Inherited from <a href=\"../error\"><code>Error</code></a>.</dd> <dt><a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/columnNumber\"><code>URIError.prototype.columnNumber</code></a></dt> <dd>Column number in line that raised this error. Inherited from <a href=\"../error\"><code>Error</code></a>.</dd> <dt><a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/stack\"><code>URIError.prototype.stack</code></a></dt> <dd>Stack trace. Inherited from <a href=\"../error\"><code>Error</code></a>.</dd> </dl> <h2 id=\"Methods\">Methods</h2> <p>Although the <a href=\"../urierror\"><code>URIError</code></a> prototype object does not contain any methods of its own, <a href=\"../urierror\"><code>URIError</code></a> instances do inherit some methods through the prototype chain.</p> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/publications/files/ECMA-ST-ARCH/ECMA-262,%203rd%20edition,%20December%201999.pdf#sec-15.11.7.6\" hreflang=\"en\">ECMAScript 3rd Edition (ECMA-262)<br><small>The definition of 'NativeError.prototype' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/5.1/#sec-15.11.7.6\" hreflang=\"en\">ECMAScript 5.1 (ECMA-262)<br><small>The definition of 'NativeError.prototype' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Defined as <code><em>NativeError</em>.prototype</code>.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-nativeerror.prototype\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'NativeError.prototype' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Defined as <code><em>NativeError</em>.prototype</code>.</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-nativeerror.prototype\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'NativeError.prototype' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td>Defined as <code><em>NativeError</em>.prototype</code>.</td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>   <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/URIError\">Basic support</a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/URIError\">Basic support</a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/URIError\">Basic support</a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div>  <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"../error/prototype\"><code>Error.prototype</code></a></li> <li><a href=\"../function/prototype\"><code>Function.prototype</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/URIError/prototype$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/URIError/prototype\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/URIError/prototype</a>\n  </p>\n</div>\n","global_objects/number/min_value":"<h1>Number.MIN_VALUE</h1> <p>The <code>Number.MIN_VALUE</code> property represents the smallest positive numeric value representable in JavaScript.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/number-min-value.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <div class=\"_table\"><table class=\"standard-table\"> <thead> <tr> <th colspan=\"2\" class=\"header\">Property attributes of <code>Number.MIN_VALUE</code>\n</th> </tr> </thead> <tbody> <tr> <td>Writable</td> <td>no</td> </tr> <tr> <td>Enumerable</td> <td>no</td> </tr> <tr> <td>Configurable</td> <td>no</td> </tr> </tbody> </table></div> <h2 id=\"Description\">Description</h2> <p>The <code>MIN_VALUE</code> property is the number closest to 0, not the most negative number, that JavaScript can represent.</p> <p><code>MIN_VALUE</code> has a value of approximately <code>5e-324</code>. Values smaller than <code>MIN_VALUE</code> (\"underflow values\") are converted to 0.</p> <p>Because <code>MIN_VALUE</code> is a static property of <a href=\"../number\"><code>Number</code></a>, you always use it as <code>Number.MIN_VALUE</code>, rather than as a property of a <a href=\"../number\"><code>Number</code></a> object you created.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Using_MIN_VALUE\">Using <code>MIN_VALUE</code>\n</h3> <p>The following code divides two numeric values. If the result is greater than or equal to <code>MIN_VALUE</code>, the <code>func1</code> function is called; otherwise, the <code>func2</code> function is called.</p> <pre data-language=\"js\">if (num1 / num2 &gt;= Number.MIN_VALUE) {\n  func1();\n} else {\n  func2();\n}\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/publications/files/ECMA-ST-ARCH/ECMA-262,%201st%20edition,%20June%201997.pdf\" hreflang=\"en\">ECMAScript 1st Edition (ECMA-262)</a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition. Implemented in JavaScript 1.1.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/5.1/#sec-15.7.3.3\" hreflang=\"en\">ECMAScript 5.1 (ECMA-262)<br><small>The definition of 'Number.MIN_VALUE' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-number.min_value\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Number.MIN_VALUE' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-number.min_value\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Number.MIN_VALUE' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"max_value\"><code>Number.MAX_VALUE</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/MIN_VALUE$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/MIN_VALUE\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/MIN_VALUE</a>\n  </p>\n</div>\n","global_objects/typeerror/prototype":"<h1>TypeError.prototype</h1> <p>The <code><strong>TypeError.prototype</strong></code> property represents the prototype for the <a href=\"../typeerror\"><code>TypeError</code></a> constructor.</p> <h2 id=\"Description\">Description</h2> <p>All <a href=\"../typeerror\"><code>TypeError</code></a> instances inherit from <code>TypeError.prototype</code>. You can use the prototype to add properties or methods to all instances.</p> <h2 id=\"Properties\">Properties</h2> <dl> <dt><code>TypeError.prototype.constructor</code></dt> <dd>Specifies the function that created an instance's prototype.</dd> <dt><a href=\"../error/message\"><code>TypeError.prototype.message</code></a></dt> <dd>Error message. Although ECMA-262 specifies that <a href=\"../typeerror\"><code>TypeError</code></a> should provide its own <code>message</code> property, in <a href=\"https://developer.mozilla.org/en-US/docs/Mozilla/Projects/SpiderMonkey\">SpiderMonkey</a>, it inherits <a href=\"../error/message\"><code>Error.prototype.message</code></a>.</dd> <dt><a href=\"../error/name\"><code>TypeError.prototype.name</code></a></dt> <dd>Error name. Inherited from <a href=\"../error\"><code>Error</code></a>.</dd> <dt><a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/fileName\"><code>TypeError.prototype.fileName</code></a></dt> <dd>Path to file that raised this error. Inherited from <a href=\"../error\"><code>Error</code></a>.</dd> <dt><a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/lineNumber\"><code>TypeError.prototype.lineNumber</code></a></dt> <dd>Line number in file that raised this error. Inherited from <a href=\"../error\"><code>Error</code></a>.</dd> <dt><a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/columnNumber\"><code>TypeError.prototype.columnNumber</code></a></dt> <dd>Column number in line that raised this error. Inherited from <a href=\"../error\"><code>Error</code></a>.</dd> <dt><a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/stack\"><code>TypeError.prototype.stack</code></a></dt> <dd>Stack trace. Inherited from <a href=\"../error\"><code>Error</code></a>.</dd> </dl> <h2 id=\"Methods\">Methods</h2> <p>Although the <a href=\"../typeerror\"><code>TypeError</code></a> prototype object does not contain any methods of its own, <a href=\"../typeerror\"><code>TypeError</code></a> instances do inherit some methods through the prototype chain.</p> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/publications/files/ECMA-ST-ARCH/ECMA-262,%203rd%20edition,%20December%201999.pdf#sec-15.11.7.6\" hreflang=\"en\">ECMAScript 3rd Edition (ECMA-262)<br><small>The definition of 'NativeError.prototype' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/5.1/#sec-15.11.7.6\" hreflang=\"en\">ECMAScript 5.1 (ECMA-262)<br><small>The definition of 'NativeError.prototype' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Defined as <code><em>NativeError</em>.prototype</code>.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-nativeerror.prototype\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'NativeError.prototype' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Defined as <code><em>NativeError</em>.prototype</code>.</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-nativeerror.prototype\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'NativeError.prototype' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>   <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/TypeError\">Basic support</a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/TypeError\">Basic support</a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/TypeError\">Basic support</a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div>  <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"../error/prototype\"><code>Error.prototype</code></a></li> <li><a href=\"../function/prototype\"><code>Function.prototype</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypeError/prototype$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypeError/prototype\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypeError/prototype</a>\n  </p>\n</div>\n","global_objects/number/isinteger":"<h1>Number.isInteger</h1> <p>The <code>Number.isInteger()</code> method determines whether the passed value is an integer.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/number-isinteger.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\">Number.isInteger(v<var>alue</var>)</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><code>value</code></dt> <dd>The value to be tested for being an integer.</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p>A <a href=\"../boolean\"><code>Boolean</code></a> indicating whether or not the given value is an integer.</p> <h2 id=\"Description\">Description</h2> <p>If the target value is an integer, return <code>true</code>, otherwise return <code>false</code>. If the value is <a href=\"../nan\"><code>NaN</code></a> or infinite, return <code>false</code>.</p> <h2 id=\"Examples\">Examples</h2> <pre data-language=\"js\">Number.isInteger(0);         // true\nNumber.isInteger(1);         // true\nNumber.isInteger(-100000);   // true\nNumber.isInteger(99999999999999999999999); // true\n\nNumber.isInteger(0.1);       // false\nNumber.isInteger(Math.PI);   // false\n\nNumber.isInteger(NaN);       // false\nNumber.isInteger(Infinity);  // false\nNumber.isInteger(-Infinity); // false\nNumber.isInteger('10');      // false\nNumber.isInteger(true);      // false\nNumber.isInteger(false);     // false\nNumber.isInteger([1]);       // false\n</pre> <h2 id=\"Polyfill\">Polyfill</h2> <pre data-language=\"js\">Number.isInteger = Number.isInteger || function(value) {\n  return typeof value === 'number' &amp;&amp; \n    isFinite(value) &amp;&amp; \n    Math.floor(value) === value;\n};\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-number.isinteger\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Number.isInteger' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-number.isinteger\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Number.isInteger' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 16</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 16</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 0.12</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li>The <a href=\"../number\"><code>Number</code></a> object it belongs to.</li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/isInteger$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/isInteger\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/isInteger</a>\n  </p>\n</div>\n","global_objects/number/issafeinteger":"<h1>Number.isSafeInteger</h1> <p>The <code>Number.isSafeInteger()</code> method determines whether the provided value is a number that is a <dfn>safe integer</dfn>.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/number-issafeinteger.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <p>A safe integer is an integer that</p> <ul> <li>can be exactly represented as an IEEE-754 double precision number, and</li> <li>whose IEEE-754 representation cannot be the result of rounding any other integer to fit the IEEE-754 representation.</li> </ul> <p>For example, <code>2<sup>53</sup> - 1</code> is a safe integer: it can be exactly represented, and no other integer rounds to it under any IEEE-754 rounding mode. In contrast, <code>2<sup>53</sup></code> is <em>not</em> a safe integer: it can be exactly represented in IEEE-754, but the integer <code>2<sup>53</sup> + 1</code> can't be directly represented in IEEE-754 but instead rounds to <code>2<sup>53</sup></code> under round-to-nearest and round-to-zero rounding. The safe integers consist of all integers from <code>-(2<sup>53</sup> - 1)</code> inclusive to <code>2<sup>53</sup> - 1</code> inclusive (± <code>9007199254740991</code> or ± 9,007,199,254,740,991). </p> <p>Handling values larger or smaller than ~9 quadrillion with full precision requires using an <a href=\"https://en.wikipedia.org/wiki/Arbitrary-precision_arithmetic\">arbitrary precision arithmetic library</a>. See <a href=\"http://floating-point-gui.de/\">What Every Programmer Needs to Know about Floating Point Arithmetic</a> for more information on floating point representations of numbers.</p> <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\">Number.isSafeInteger(<var>testValue</var>)\n</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><code>testValue</code></dt> <dd>The value to be tested for being a safe integer.</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p>A <a href=\"../boolean\"><code>Boolean</code></a> indicating whether or not the given value is a number that is a safe integer.</p> <h2 id=\"Examples\">Examples</h2> <pre data-language=\"js\">Number.isSafeInteger(3);                    // true\nNumber.isSafeInteger(Math.pow(2, 53));      // false\nNumber.isSafeInteger(Math.pow(2, 53) - 1);  // true\nNumber.isSafeInteger(NaN);                  // false\nNumber.isSafeInteger(Infinity);             // false\nNumber.isSafeInteger('3');                  // false\nNumber.isSafeInteger(3.1);                  // false\nNumber.isSafeInteger(3.0);                  // true\n</pre> <h2 id=\"Polyfill\">Polyfill</h2> <pre data-language=\"js\">Number.isSafeInteger = Number.isSafeInteger || function (value) {\n   return Number.isInteger(value) &amp;&amp; Math.abs(value) &lt;= Number.MAX_SAFE_INTEGER;\n};\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-number.issafeinteger\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Number.isSafeInteger' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-number.issafeinteger\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Number.isSafeInteger' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 32</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 10</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 32</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 0.12</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li>The <a href=\"../number\"><code>Number</code></a> object it belongs to.</li> <li><a href=\"min_safe_integer\"><code>Number.MIN_SAFE_INTEGER</code></a></li> <li><a href=\"max_safe_integer\"><code>Number.MAX_SAFE_INTEGER</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/isSafeInteger$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/isSafeInteger\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/isSafeInteger</a>\n  </p>\n</div>\n","global_objects/number/parseint":"<h1>Number.parseInt</h1> <p>The <code>Number.parseInt()</code> method parses a string argument and returns an integer of the specified radix or base.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/number-parseint.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\">Number.parseInt(<var>string,</var>[ <var>radix </var>])</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><code>string</code></dt> <dd>The value to parse. If the <code>string</code> argument is not a string, then it is converted to a string (using the <code><a href=\"http://www.ecma-international.org/ecma-262/6.0/#sec-tostring\">ToString</a></code> abstract operation). Leading whitespace in the string argument is ignored.</dd> <dt><code>radix</code></dt> <dd>An integer between 2 and 36 that represents the <var>radix</var> (the base in mathematical numeral systems) of the above mentioned string. </dd> </dl>  <h3 id=\"Return_value\">Return value</h3> <p>An integer number parsed from the given string. If the first character cannot be converted to a number, <a href=\"../nan\"><code>NaN</code></a> is returned.</p> <h2 id=\"Description\">Description</h2> <p>This method has the same functionality as the global <a href=\"../parseint\"><code>parseInt()</code></a> function:</p> <pre data-language=\"js\">Number.parseInt === parseInt; // true</pre> <p>and is part of ECMAScript 2015 (its purpose is modularization of globals). Please see <a href=\"../parseint\"><code>parseInt()</code></a> for more detail and examples.</p> <h2 id=\"Polyfill\">Polyfill</h2> <pre data-language=\"js\">if (Number.parseInt === undefined) {\n    Number.parseInt = window.parseInt;\n}\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-number.parseint\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Number.parseInt' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-number.parseint\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Number.parseInt' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 25</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 9</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 25</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 9</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 0.12</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li>The <a href=\"../number\"><code>Number</code></a> object it belongs to.</li> <li>The global <a href=\"../parseint\"><code>parseInt()</code></a> method.</li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/parseInt$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/parseInt\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/parseInt</a>\n  </p>\n</div>\n","global_objects/number/tostring":"<h1>number.toString</h1> <p>The <code>toString()</code> method returns a string representing the specified <a href=\"../number\"><code>Number</code></a> object.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/number-tostring.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\"><var>numObj</var>.toString([<var>radix</var>])</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><code>radix</code></dt> <dd>Optional. An integer in the range 2 through 36 specifying the base to use for representing numeric values.</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p>A string representing the specified <a href=\"../number\"><code>Number</code></a> object.</p> <h3 id=\"Exceptions\">Exceptions</h3> <dl> <dt><a href=\"../rangeerror\"><code>RangeError</code></a></dt> <dd>If <code>toString()</code> is given a radix less than 2 or greater than 36, a <a href=\"../rangeerror\"><code>RangeError</code></a> is thrown.</dd> </dl> <h2 id=\"Description\">Description</h2> <p>The <a href=\"../number\"><code>Number</code></a> object overrides the <code>toString()</code> method of the <a href=\"../object\"><code>Object</code></a> object; it does not inherit <a href=\"../object/tostring\"><code>Object.prototype.toString()</code></a>. For <a href=\"../number\"><code>Number</code></a> objects, the <code>toString()</code> method returns a string representation of the object in the specified radix.</p> <p>The <code>toString()</code> method parses its first argument, and attempts to return a string representation in the specified radix (base). For radixes above 10, the letters of the alphabet indicate numerals greater than 9. For example, for hexadecimal numbers (base 16), <code>a</code> through <code>f</code> are used.</p> <p>If the <code>radix</code> is not specified, the preferred radix is assumed to be 10.</p> <p>If the <code>numObj</code> is negative, the sign is preserved. This is the case even if the radix is 2; the string returned is the positive binary representation of the <code>numObj</code> preceded by a <code>-</code> sign, <strong>not</strong> the two's complement of the <code>numObj</code>.</p> <p>If the <code>numObj</code> is not a whole number, the 'dot' sign is used to separate the decimal places.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Using_toString\">Using <code>toString</code>\n</h3> <pre data-language=\"js\">var count = 10;\n\nconsole.log(count.toString());    // displays '10'\nconsole.log((17).toString());     // displays '17'\nconsole.log((17.2).toString());   // displays '17.2'\n\nvar x = 6;\n\nconsole.log(x.toString(2));       // displays '110'\nconsole.log((254).toString(16));  // displays 'fe'\n\nconsole.log((-10).toString(2));   // displays '-1010'\nconsole.log((-0xff).toString(2)); // displays '-11111111'\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/publications/files/ECMA-ST-ARCH/ECMA-262,%201st%20edition,%20June%201997.pdf\" hreflang=\"en\">ECMAScript 1st Edition (ECMA-262)</a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition. Implemented in JavaScript 1.1.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/5.1/#sec-15.7.4.2\" hreflang=\"en\">ECMAScript 5.1 (ECMA-262)<br><small>The definition of 'Number.prototype.tostring' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-number.prototype.tostring\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Number.prototype.tostring' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-number.prototype.tostring\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Number.prototype.tostring' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"tofixed\"><code>Number.prototype.toFixed()</code></a></li> <li><a href=\"toexponential\"><code>Number.prototype.toExponential()</code></a></li> <li><a href=\"toprecision\"><code>Number.prototype.toPrecision()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toString$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toString\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toString</a>\n  </p>\n</div>\n","global_objects/number/prototype":"<h1>Number.prototype</h1> <p>The <code>Number.prototype</code> property represents the prototype for the <a href=\"../number\"><code>Number</code></a> constructor.</p> <div class=\"_table\"><table class=\"standard-table\"> <thead> <tr> <th colspan=\"2\" class=\"header\">Property attributes of <code>Number.prototype</code>\n</th> </tr> </thead> <tbody> <tr> <td>Writable</td> <td>no</td> </tr> <tr> <td>Enumerable</td> <td>no</td> </tr> <tr> <td>Configurable</td> <td>no</td> </tr> </tbody> </table></div> <h2 id=\"Description\">Description</h2> <p>All <a href=\"../number\"><code>Number</code></a> instances inherit from <code>Number.prototype</code>. The prototype object of the <a href=\"../number\"><code>Number</code></a> constructor can be modified to affect all <a href=\"../number\"><code>Number</code></a> instances.</p> <h2 id=\"Properties\">Properties</h2> <dl> <dt><code>Number.prototype.constructor</code></dt> <dd>Returns the function that created this object's instance. By default this is the <a href=\"../number\"><code>Number</code></a> object.</dd> </dl> <h2 id=\"Methods\">Methods</h2> <dl> <dt><a href=\"toexponential\"><code>Number.prototype.toExponential()</code></a></dt> <dd>Returns a string representing the number in exponential notation.</dd> <dt><a href=\"tofixed\"><code>Number.prototype.toFixed()</code></a></dt> <dd>Returns a string representing the number in fixed-point notation.</dd> <dt><a href=\"tolocalestring\"><code>Number.prototype.toLocaleString()</code></a></dt> <dd>Returns a string with a language sensitive representation of this number. Overrides the <a href=\"../object/tolocalestring\"><code>Object.prototype.toLocaleString()</code></a> method.</dd> <dt><a href=\"toprecision\"><code>Number.prototype.toPrecision()</code></a></dt> <dd>Returns a string representing the number to a specified precision in fixed-point or exponential notation.</dd> <dt>\n<a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toSource\"><code>Number.prototype.toSource()</code></a> \n</dt> <dd>Returns an object literal representing the specified <a href=\"../number\"><code>Number</code></a> object; you can use this value to create a new object. Overrides the <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/toSource\"><code>Object.prototype.toSource()</code></a> method.</dd> <dt><a href=\"tostring\"><code>Number.prototype.toString()</code></a></dt> <dd>Returns a string representing the specified object in the specified radix (base). Overrides the <a href=\"../object/tostring\"><code>Object.prototype.toString()</code></a> method.</dd> <dt><a href=\"valueof\"><code>Number.prototype.valueOf()</code></a></dt> <dd>Returns the primitive value of the specified object. Overrides the <a href=\"../object/valueof\"><code>Object.prototype.valueOf()</code></a> method.</dd> </dl> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/publications/files/ECMA-ST-ARCH/ECMA-262,%201st%20edition,%20June%201997.pdf\" hreflang=\"en\">ECMAScript 1st Edition (ECMA-262)</a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition. Implemented in JavaScript 1.1.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/5.1/#sec-15.7.4\" hreflang=\"en\">ECMAScript 5.1 (ECMA-262)<br><small>The definition of 'Number' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-properties-of-the-number-prototype-object\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Number' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-properties-of-the-number-prototype-object\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Number' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"../number\"><code>Number</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/prototype$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/prototype\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/prototype</a>\n  </p>\n</div>\n","global_objects/number/valueof":"<h1>number.valueOf</h1> <p>The <code>valueOf()</code> method returns the wrapped primitive value of a <a href=\"../number\"><code>Number</code></a> object.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/number-valueof.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\"><var>numObj</var>.valueOf()</pre> <h3 id=\"Return_value\">Return value</h3> <p>A number representing the primitive value of the specified <a href=\"../number\"><code>Number</code></a> object.</p> <h2 id=\"Description\">Description</h2> <p>This method is usually called internally by JavaScript and not explicitly in web code.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Using_valueOf\">Using <code>valueOf</code>\n</h3> <pre data-language=\"js\">var numObj = new Number(10);\nconsole.log(typeof numObj); // object\n\nvar num = numObj.valueOf();\nconsole.log(num);           // 10\nconsole.log(typeof num);    // number\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/publications/files/ECMA-ST-ARCH/ECMA-262,%201st%20edition,%20June%201997.pdf\" hreflang=\"en\">ECMAScript 1st Edition (ECMA-262)</a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition. Implemented in JavaScript 1.1.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/5.1/#sec-15.7.4.4\" hreflang=\"en\">ECMAScript 5.1 (ECMA-262)<br><small>The definition of 'Number.prototype.valueOf' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-number.prototype.valueof\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Number.prototype.valueOf' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-number.prototype.valueof\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Number.prototype.valueOf' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toSource\"><code>Number.prototype.toSource()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/valueOf$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/valueOf\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/valueOf</a>\n  </p>\n</div>\n","global_objects/set/size":"<h1>set.size</h1> <p>The <code><strong>size</strong></code> accessor property returns the number of elements in a <a href=\"../set\"><code>Set</code></a> object.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/set-prototype-size.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Description\">Description</h2> <p>The value of <code>size</code> is an integer representing how many entries the <code>Set</code> object has. A set accessor function for <code>size</code> is <code>undefined</code>; you cannot change this property.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Using_size\">Using <code>size</code>\n</h3> <pre data-language=\"js\">var mySet = new Set();\nmySet.add(1);\nmySet.add(5);\nmySet.add('some text')\n\nmySet.size; // 3\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-get-set.prototype.size\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Set.prototype.size' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-get-set.prototype.size\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Set.prototype.size' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 38</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes bc-has-history\"> 19\n<section class=\"bc-history\" id=\"sect1\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 19\n</dt>\n<dd> From Firefox 13 to Firefox 18, the <code>size</code> property was implemented as a <code>Set.prototype.size()</code> method, this has been changed to a property in later versions conform to the ECMAScript 2015 specification.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-yes\"> 11</td>\n<td class=\"bc-supports-yes\"> 25</td>\n<td class=\"bc-supports-yes\"> 8</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 38</td>\n<td class=\"bc-supports-yes\"> 38</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes bc-has-history\"> 19\n<section class=\"bc-history\" id=\"sect2\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 19\n</dt>\n<dd> From Firefox 13 to Firefox 18, the <code>size</code> property was implemented as a <code>Set.prototype.size()</code> method, this has been changed to a property in later versions conform to the ECMAScript 2015 specification.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-yes\"> 25</td>\n<td class=\"bc-supports-yes\"> 8</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 0.12</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"../set\"><code>Set</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set/size$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set/size\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set/size</a>\n  </p>\n</div>\n","global_objects/set/@@species":"<h1>Set.@@species</h1> <p>The <code><strong>Set[@@species]</strong></code> accessor property returns the <code>Set</code> constructor.</p> <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\">Set[Symbol.species]\n</pre> <h2 id=\"Description\">Description</h2> <p>The species accessor property returns the default constructor for <code>Set</code> objects. Subclass constructors may over-ride it to change the constructor assignment.</p> <h2 id=\"Examples\">Examples</h2> <p>The species property returns the default constructor function, which is the <code>Set</code> constructor for <code>Set</code> objects:</p> <pre data-language=\"js\">Set[Symbol.species]; // function Set()</pre> <p>In a derived collection object (e.g. your custom set <code>MySet</code>), the <code>MySet</code> species is the <code>MySet</code> constructor. However, you might want to overwrite this, in order to return parent <code>Set</code> objects in your derived class methods:</p> <pre data-language=\"js\">class MySet extends Set {\n  // Overwrite MySet species to the parent Set constructor\n  static get [Symbol.species]() { return Set; }\n}</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-get-set-@@species\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'get Set [ @@species ]' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-get-set-@@species\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'get Set [ @@species ]' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>   <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 51</td>\n<td class=\"bc-supports-yes\"> 13</td>\n<td class=\"bc-supports-yes\"> 41</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 38</td>\n<td class=\"bc-supports-yes\"> 10</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 51</td>\n<td class=\"bc-supports-yes\"> 51</td>\n<td class=\"bc-supports-yes\"> 13</td>\n<td class=\"bc-supports-yes\"> 41</td>\n<td class=\"bc-supports-yes\"> 38</td>\n<td class=\"bc-supports-yes\"> 10</td>\n<td class=\"bc-supports-yes\"> 5.0</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes bc-has-history\"> 6.5.0\n<section class=\"bc-history\" id=\"sect1\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 6.5.0\n</dt>\n\n<dt class=\"bc-supports-yes bc-supports\"> 6.0.0<div class=\"bc-icons\">Disabled </div>\n</dt>\n<dd>Disabled From version 6.0.0: this feature is behind the <code>--harmony</code> runtime flag.</dd>\n</dl></section>\n</td>\n</tr></tbody>\n</table>\n</div>  <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"../set\"><code>Set</code></a></li> <li><a href=\"../symbol/species\"><code>Symbol.species</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set/@@species$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set/@@species\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set/@@species</a>\n  </p>\n</div>\n","global_objects/set/clear":"<h1>set.clear</h1> <p>The <code><strong>clear()</strong></code> method removes all elements from a <code>Set</code> object.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/set-prototype-clear.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\"><em>mySet</em>.clear();</pre> <h3 id=\"Return_value\">Return value</h3> <p><a href=\"../undefined\"><code>undefined</code></a>.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Using_the_clear_method\">Using the <code>clear</code> method</h3> <pre data-language=\"js\">var mySet = new Set();\nmySet.add(1);\nmySet.add('foo');\n\nmySet.size;       // 2\nmySet.has('foo'); // true\n\nmySet.clear();\n\nmySet.size;       // 0\nmySet.has('bar')  // false\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-set.prototype.clear\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Set.prototype.clear' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-set.prototype.clear\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Set.prototype.clear' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 38</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 19</td>\n<td class=\"bc-supports-yes\"> 11</td>\n<td class=\"bc-supports-yes\"> 25</td>\n<td class=\"bc-supports-yes\"> 8</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 38</td>\n<td class=\"bc-supports-yes\"> 38</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 19</td>\n<td class=\"bc-supports-yes\"> 25</td>\n<td class=\"bc-supports-yes\"> 8</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 0.12</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"../set\"><code>Set</code></a></li> <li><a href=\"delete\"><code>Set.prototype.delete()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set/clear$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set/clear\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set/clear</a>\n  </p>\n</div>\n","global_objects/set/delete":"<h1>set.delete</h1> <p>The <code><strong>delete()</strong></code> method removes the specified element from a <code>Set</code> object.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/set-prototype-delete.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\"><em>mySet</em>.delete(value);</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt>value</dt> <dd>Required. The value of the element to remove from the <code>Set</code> object.</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p><code>true</code> if an element in the <code>Set</code> object has been removed successfully; otherwise <code>false</code>.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Using_the_delete_method\">Using the <code>delete</code> method</h3> <pre data-language=\"js\">var mySet = new Set();\nmySet.add('foo');\n\nmySet.delete('bar'); // Returns false. No \"bar\" element found to be deleted.\nmySet.delete('foo'); // Returns true.  Successfully removed.\n\nmySet.has('foo');    // Returns false. The \"foo\" element is no longer present.\n</pre> <p>Let's checkout below how to delete an Object from a Set.</p> <pre data-language=\"js\">var setObj = new Set(); // Create a New Set.\n\nsetObj.add({x: 10, y: 20}); // Add object in the set.\n\nsetObj.add({x: 20, y: 30}); // Add object in the set.\n\n// Delete any point with `x &gt; 10`.\nsetObj.forEach(function(point){\n  if(point.x &gt; 10){\n    setObj.delete(point)\n  }\n})\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-set.prototype.delete\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Set.prototype.delete' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-set.prototype.delete\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Set.prototype.delete' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 38</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 13</td>\n<td class=\"bc-supports-yes\"> 11</td>\n<td class=\"bc-supports-yes\"> 25</td>\n<td class=\"bc-supports-yes\"> 8</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 38</td>\n<td class=\"bc-supports-yes\"> 38</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 14</td>\n<td class=\"bc-supports-yes\"> 25</td>\n<td class=\"bc-supports-yes\"> 8</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes bc-has-history\"> 0.12\n<section class=\"bc-history\" id=\"sect1\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 0.12\n</dt>\n\n<dt class=\"bc-supports-yes bc-supports\"> 0.10<div class=\"bc-icons\">Disabled </div>\n</dt>\n<dd>Disabled From version 0.10: this feature is behind the <code>--harmony</code> runtime flag.</dd>\n</dl></section>\n</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"../set\"><code>Set</code></a></li> <li><a href=\"clear\"><code>Set.prototype.clear()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set/delete$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set/delete\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set/delete</a>\n  </p>\n</div>\n","global_objects/number/parsefloat":"<h1>Number.parseFloat</h1> <p>The <code>Number.parseFloat()</code> method parses a string argument and returns a floating point number. This method behaves identically to the global function <a href=\"../parsefloat\"><code>parseFloat()</code></a> and is part of ECMAScript 2015 (its purpose is modularization of globals).</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/number-parsefloat.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\">Number.parseFloat(<var>string</var>)</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><code>value</code></dt> <dd>The value you want to parse.</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p>A floating point number parsed from the given value. If the value cannot be converted to a number, <a href=\"../nan\"><code>NaN</code></a> is returned.</p> <h2 id=\"Description\">Description</h2> <p>Please see <a href=\"../parsefloat\"><code>parseFloat()</code></a> for more details and examples.</p> <h2 id=\"Polyfill\">Polyfill</h2> <pre data-language=\"js\">if (Number.parseFloat === void 0) {\n    Number.parseFloat = parseFloat;\n}\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-number.parsefloat\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Number.parseFloat' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-number.parsefloat\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Number.parseFloat' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 25</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 9</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 25</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 9</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 0.12</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li>The <a href=\"../number\"><code>Number</code></a> object it belongs to.</li> <li>The global <a href=\"../parsefloat\"><code>parseFloat()</code></a> method.</li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/parseFloat$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/parseFloat\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/parseFloat</a>\n  </p>\n</div>\n","global_objects/set/prototype":"<h1>Set.prototype</h1> <p>The <code><strong>Set</strong></code><code>.prototype</code> property represents the prototype for the <a href=\"../set\"><code>Set</code></a> constructor.</p> <div class=\"_table\"><table class=\"standard-table\"> <thead> <tr> <th colspan=\"2\" class=\"header\">Property attributes of <code>Set.prototype</code>\n</th> </tr> </thead> <tbody> <tr> <td>Writable</td> <td>no</td> </tr> <tr> <td>Enumerable</td> <td>no</td> </tr> <tr> <td>Configurable</td> <td>no</td> </tr> </tbody> </table></div> <h2 id=\"Description\">Description</h2> <p><a href=\"../set\"><code>Set</code></a> instances inherit from <a href=\"prototype\"><code>Set.prototype</code></a>. You can use the constructor's prototype object to add properties or methods to all <code>Set</code> instances.</p> <h2 id=\"Properties\">Properties</h2> <dl> <dt><code>Set.prototype.constructor</code></dt> <dd>Returns the function that created an instance's prototype. This is the <a href=\"../set\"><code>Set</code></a> function by default.</dd> <dt><a href=\"size\"><code>Set.prototype.size</code></a></dt> <dd>Returns the number of values in the <code>Set</code> object.</dd> </dl> <h2 id=\"Methods\">Methods</h2> <dl> <dt><a href=\"add\"><code>Set.prototype.add(value)</code></a></dt> <dd>Appends a new element with the given value to the <code>Set</code> object. Returns the <code>Set</code> object.</dd> <dt><a href=\"clear\"><code>Set.prototype.clear()</code></a></dt> <dd>Removes all elements from the <code>Set</code> object.</dd> <dt><a href=\"delete\"><code>Set.prototype.delete(value)</code></a></dt> <dd>Removes the element associated to the <code>value</code> and returns the value that <code>Set.prototype.has(value)</code> would have previously returned. <code>Set.prototype.has(value)</code> will return <code>false</code> afterwards.</dd> <dt><a href=\"entries\"><code>Set.prototype.entries()</code></a></dt> <dd>Returns a new <code>Iterator</code> object that contains<code>[value, value]</code> for each element in the <code>Set</code> object, in insertion order. This is kept similar to the <code>Map</code> object, so that each entry has the same value for its <em>key</em> and <em>value</em> here.</dd> <dt><a href=\"foreach\"><code>Set.prototype.forEach(callbackFn[, thisArg])</code></a></dt> <dd>Calls <code>callbackFn</code> once for each value present in the <code>Set</code> object, in insertion order. If a <code>thisArg</code> parameter is provided to <code>forEach</code>, it will be used as the <code>this</code> value for each callback.</dd> <dt><a href=\"has\"><code>Set.prototype.has(value)</code></a></dt> <dd>Returns a boolean asserting whether an element is present with the given value in the <code>Set</code> object or not.</dd> <dt><a href=\"values\"><code>Set.prototype.keys()</code></a></dt> <dd>Is the same function as the <code>values()</code> function and returns a new <code>Iterator</code> object that contains the values for each element in the <code>Set</code> object in insertion order.</dd> <dt><a href=\"values\"><code>Set.prototype.values()</code></a></dt> <dd>Returns a new <code>Iterator</code> object that contains the <strong>values</strong> for each element in the <code>Set</code> object in insertion order.</dd> <dt><a href=\"@@iterator\"><code>Set.prototype[@@iterator]()</code></a></dt> <dd>Returns a new <code>Iterator</code> object that contains the <strong>values</strong> for each element in the <code>Set</code> object in insertion order.</dd> </dl> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-set.prototype\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Set.prototype' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-set.prototype\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Set.prototype' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 38</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 13</td>\n<td class=\"bc-supports-yes\"> 11</td>\n<td class=\"bc-supports-yes\"> 25</td>\n<td class=\"bc-supports-yes\"> 8</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 38</td>\n<td class=\"bc-supports-yes\"> 38</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 14</td>\n<td class=\"bc-supports-yes\"> 25</td>\n<td class=\"bc-supports-yes\"> 8</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"../map/prototype\"><code>Map.prototype</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set/prototype$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set/prototype\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set/prototype</a>\n  </p>\n</div>\n","global_objects/set/add":"<h1>set.add</h1> <p>The <code><strong>add()</strong></code> method appends a new element with a specified <code>value</code> to the end of a <code>Set</code> object.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/set-prototype-add.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\"><em>mySet</em>.add(value);</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt>value</dt> <dd>Required. The value of the element to add to the <code>Set</code> object.</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p>The <code>Set</code> object.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Using_the_add_method\">Using the <code>add</code> method</h3> <pre data-language=\"js\">var mySet = new Set();\n\nmySet.add(1);\nmySet.add(5).add('some text'); // chainable\n\nconsole.log(mySet);\n// Set [1, 5, \"some text\"]\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-set.prototype.add\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Set.prototype.add' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-set.prototype.add\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Set.prototype.add' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 38</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 13</td>\n<td class=\"bc-supports-partial bc-has-history\">11\n<section class=\"bc-history\" id=\"sect1\"><dl>\n<dt class=\"bc-supports-partial bc-supports\">11\n</dt>\n<dd> Returns 'undefined' instead of the 'Set' object.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-yes\"> 25</td>\n<td class=\"bc-supports-yes\"> 8</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 38</td>\n<td class=\"bc-supports-yes\"> 38</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 14</td>\n<td class=\"bc-supports-yes\"> 25</td>\n<td class=\"bc-supports-yes\"> 8</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"../set\"><code>Set</code></a></li> <li><a href=\"delete\"><code>Set.prototype.delete()</code></a></li> <li><a href=\"has\"><code>Set.prototype.has()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set/add$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set/add\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set/add</a>\n  </p>\n</div>\n","global_objects/set/entries":"<h1>set.entries</h1> <p>The <code><strong>entries()</strong></code> method returns a new <code>Iterator</code> object that contains<code>[value, value]</code> for each element in the <code>Set</code> object, in insertion order. For <code>Set</code> objects there is no <code>key</code> like in <code>Map</code> objects. However, to keep the API similar to the <code>Map</code> object, each <em>entry</em> has the same value for its <em>key</em> and <em>value</em> here, so that an array <code>[value, value]</code> is returned.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/set-prototype-entries.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\"><em>mySet</em>.entries()</pre> <h3 id=\"Return_value\">Return value</h3> <p>A new <code>Iterator</code> object that contains an array of <code>[value, value]</code> for each element in the given <code>Set</code>, in insertion order.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Using_entries()\">Using <code>entries()</code>\n</h3> <pre data-language=\"js\">var mySet = new Set();\nmySet.add('foobar');\nmySet.add(1);\nmySet.add('baz');\n\nvar setIter = mySet.entries();\n\nconsole.log(setIter.next().value); // [\"foobar\", \"foobar\"]\nconsole.log(setIter.next().value); // [1, 1]\nconsole.log(setIter.next().value); // [\"baz\", \"baz\"]\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-set.prototype.entries\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Set.prototype.entries' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-set.prototype.entries\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Set.prototype.entries' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 38</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 24</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 25</td>\n<td class=\"bc-supports-yes\"> 8</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 38</td>\n<td class=\"bc-supports-yes\"> 38</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 24</td>\n<td class=\"bc-supports-yes\"> 25</td>\n<td class=\"bc-supports-yes\"> 8</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 0.12</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"values\"><code>Set.prototype.keys()</code></a></li> <li><a href=\"values\"><code>Set.prototype.values()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set/entries$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set/entries\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set/entries</a>\n  </p>\n</div>\n","global_objects/set/foreach":"<h1>set.forEach</h1> <p>The <code><strong>forEach()</strong></code> method executes a provided function once for each value in the <code>Set</code> object, in insertion order.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/set-prototype-foreach.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\"><em>mySet</em>.forEach(function <var>callback(value1, value2, Set) { \n    //your iterator\n}</var>[, <var>thisArg</var>])</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><code>callback</code></dt> <dd>Function to execute for each element. See <a href=\"#Description\">Description</a> for details.</dd> <dd><code>value1, value2</code></dd> <dd> The value contained in the the current position in the Set. The same value is passed for both arguments.</dd> <dd><code>Set</code></dd> <dd> The Set object that's being traversed.</dd> <dt><code>thisArg</code></dt> <dd>Value to use as <code>this</code> when executing <code>callback</code>.</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p><a href=\"../undefined\"><code>undefined</code></a>.</p> <h2 id=\"Description\">Description</h2> <p>The <code>forEach()</code> method executes the provided <code>callback</code> once for each value which actually exists in the <code>Set</code> object. It is not invoked for values which have been deleted. However, it is executed for values which are present but have the value <code>undefined</code>.</p> <p><code>callback</code> is invoked with <strong>three arguments</strong>:</p> <ul> <li>the <strong>element value</strong>\n</li> <li>the <strong>element key</strong>\n</li> <li>the <code>Set</code>\n</li> </ul> <p>There are no keys in <code>Set</code> objects. However, the first two arguments are both <strong>values</strong> contained in the <a href=\"../set\"><code>Set</code></a>, so that the callback function is consistent with the <code>forEach()</code> methods for <a href=\"../map/foreach\"><code>Map</code></a> and <a href=\"../array/foreach\"><code>Array</code></a>.</p> <p>If a <code>thisArg</code> parameter is provided to <code>forEach()</code>, it will be passed to <code>callback</code> when invoked, for use as its <code>this</code> value. Otherwise, the value <code>undefined</code> will be passed for use as its <code>this</code> value. The <code>this</code> value ultimately observable by <code>callback</code> is determined according to <a href=\"../../operators/this\">the usual rules for determining the <code>this</code> seen by a function</a>.</p> <p>Each value is visited once, except in the case when it was deleted and re-added before <code>forEach()</code> has finished. <code>callback</code> is not invoked for values deleted before being visited. New values added before <code>forEach()</code> has finished will be visited.</p> <p><code>forEach()</code> executes the <code>callback</code> function once for each element in the <code>Set</code> object; it does not return a value.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Logging_the_contents_of_a_Set_object\">Logging the contents of a <code>Set</code> object</h3> <p>The following code logs a line for each element in a <code>Set</code> object:</p> <pre data-language=\"js\">function logSetElements(value1, value2, set) {\n    console.log('s[' + value1 + '] = ' + value2);\n}\n\nnew Set(['foo', 'bar', undefined]).forEach(logSetElements);\n\n// logs:\n// \"s[foo] = foo\"\n// \"s[bar] = bar\"\n// \"s[undefined] = undefined\"\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-set.prototype.foreach\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Set.prototype.forEach' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-set.prototype.foreach\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Set.prototype.forEach' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 38</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 25</td>\n<td class=\"bc-supports-yes\"> 11</td>\n<td class=\"bc-supports-yes\"> 25</td>\n<td class=\"bc-supports-yes\"> 8</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 38</td>\n<td class=\"bc-supports-yes\"> 38</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 25</td>\n<td class=\"bc-supports-yes\"> 25</td>\n<td class=\"bc-supports-yes\"> 8</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 0.12</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"../array/foreach\"><code>Array.prototype.forEach()</code></a></li> <li><a href=\"../map/foreach\"><code>Map.prototype.forEach()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set/forEach$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set/forEach\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set/forEach</a>\n  </p>\n</div>\n","global_objects/set/has":"<h1>set.has</h1> <p>The <code><strong>has()</strong></code> method returns a boolean indicating whether an element with the specified value exists in a <code>Set</code> object or not.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/set-prototype-has.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\"><em>mySet</em>.has(value);</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt>value</dt> <dd>Required. The value to test for presence in the <code>Set</code> object.</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <dl> <dt>Boolean</dt> <dd> <p>Returns <code>true</code> if an element with the specified value exists in the <code>Set</code> object; otherwise <code>false</code>.</p> <div class=\"note\"> <p><strong>Note:</strong> Technically speaking, <code>has()</code> uses the <code><a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Equality_comparisons_and_sameness#Same-value-zero_equality\">sameValueZero</a></code> algorithm to determine whether the given element is found.</p> </div> </dd> </dl> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Using_the_has_method\">Using the <code>has</code> method</h3> <pre data-language=\"js\">var mySet = new Set();\nmySet.add('foo');\n\nmySet.has('foo');  // returns true\nmySet.has('bar');  // returns false\n\nvar set1 = new Set();\nvar obj1 = {'key1': 1};\nset1.add(obj1);\n\nset1.has(obj1);        // returns true\nset1.has({'key1': 1}); // returns false because they are different object references\nset1.add({'key1': 1}); // now set1 contains 2 entries\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-set.prototype.has\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Set.prototype.has' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-set.prototype.has\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Set.prototype.has' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 38</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 13</td>\n<td class=\"bc-supports-yes\"> 11</td>\n<td class=\"bc-supports-yes\"> 25</td>\n<td class=\"bc-supports-yes\"> 8</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 38</td>\n<td class=\"bc-supports-yes\"> 38</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 14</td>\n<td class=\"bc-supports-yes\"> 25</td>\n<td class=\"bc-supports-yes\"> 8</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"../set\"><code>Set</code></a></li> <li><a href=\"add\"><code>Set.prototype.add()</code></a></li> <li><a href=\"delete\"><code>Set.prototype.delete()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set/has$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set/has\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set/has</a>\n  </p>\n</div>\n","global_objects/set/values":"<h1>set.values</h1> <p>The <code><strong>values()</strong></code> method returns a new <code>Iterator</code> object that contains the values for each element in the <code>Set</code> object in insertion order.</p> <p>The <code>keys()</code> method is an alias for this method (for similarity with <a href=\"../map\"><code>Map</code></a> objects); it behaves exactly the same and returns <strong>values</strong> of <code>Set</code> elements.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/set-prototype-values.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\"><em>mySet</em>.values();\n</pre> <h3 id=\"Return_value\">Return value</h3> <p>A new <code><strong>Iterator</strong></code> object containing the values for each element in the given <code>Set</code>, in insertion order.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Using_values()\">Using <code>values()</code>\n</h3> <pre data-language=\"js\">var mySet = new Set();\nmySet.add('foo');\nmySet.add('bar');\nmySet.add('baz');\n\nvar setIter = mySet.values();\n\nconsole.log(setIter.next().value); // \"foo\"\nconsole.log(setIter.next().value); // \"bar\"\nconsole.log(setIter.next().value); // \"baz\"</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-set.prototype.values\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Set.prototype.values' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-set.prototype.values\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Set.prototype.values' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 38</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 24</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 25</td>\n<td class=\"bc-supports-yes\"> 8</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 38</td>\n<td class=\"bc-supports-yes\"> 38</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 24</td>\n<td class=\"bc-supports-yes\"> 25</td>\n<td class=\"bc-supports-yes\"> 8</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 0.12</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"entries\"><code>Set.prototype.entries()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set/values$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set/values\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set/values</a>\n  </p>\n</div>\n","global_objects/array/isarray":"<h1>Array.isArray</h1> <p>The <code><strong>Array.isArray()</strong></code> method determines whether the passed value is an <a href=\"../array\"><code>Array</code></a>.</p> <pre data-language=\"js\">Array.isArray([1, 2, 3]);  // true\nArray.isArray({foo: 123}); // false\nArray.isArray('foobar');   // false\nArray.isArray(undefined);  // false\n</pre> <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\">Array.isArray(<var>value</var>)</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><code>value</code></dt> <dd>The value to be checked.</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p><code>true</code> if the value is an <a href=\"../array\"><code>Array</code></a>; otherwise, <code>false</code>.</p> <h2 id=\"Description\">Description</h2> <p>If the value is an <a href=\"../array\"><code>Array</code></a>, <code>true</code> is returned; otherwise, <code>false</code> is. </p> <p>See the article <a href=\"http://web.mit.edu/jwalden/www/isArray.html\">“Determining with absolute accuracy whether or not a JavaScript object is an array”</a> for more details. Given a <a href=\"../typedarray\"><code>TypedArray</code></a> instance, <code>false</code> is always returned.</p> <h2 id=\"Examples\">Examples</h2> <pre data-language=\"js\">// all following calls return true\nArray.isArray([]);\nArray.isArray([1]);\nArray.isArray(new Array());\nArray.isArray(new Array('a', 'b', 'c', 'd'));\nArray.isArray(new Array(3));\n// Little known fact: Array.prototype itself is an array:\nArray.isArray(Array.prototype); \n\n// all following calls return false\nArray.isArray();\nArray.isArray({});\nArray.isArray(null);\nArray.isArray(undefined);\nArray.isArray(17);\nArray.isArray('Array');\nArray.isArray(true);\nArray.isArray(false);\nArray.isArray({ __proto__: Array.prototype });\n</pre> <h3 id=\"instanceof_vs_isArray\">\n<code>instanceof</code> vs <code>isArray</code>\n</h3> <p>When checking for <code>Array</code> instance, <code>Array.isArray</code> is preferred over <code>instanceof</code> because it works through <code>iframes</code>.</p> <pre data-language=\"js\">var iframe = document.createElement('iframe');\ndocument.body.appendChild(iframe);\nxArray = window.frames[window.frames.length-1].Array;\nvar arr = new xArray(1,2,3); // [1,2,3]\n\n// Correctly checking for Array\nArray.isArray(arr);  // true\n// Considered harmful, because doesn't work through iframes\narr instanceof Array; // false\n</pre> <h2 id=\"Polyfill\">Polyfill</h2> <p>Running the following code before any other code will create <code>Array.isArray()</code> if it's not natively available.</p> <pre data-language=\"js\">if (!Array.isArray) {\n  Array.isArray = function(arg) {\n    return Object.prototype.toString.call(arg) === '[object Array]';\n  };\n}\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/5.1/#sec-15.4.3.2\" hreflang=\"en\">ECMAScript 5.1 (ECMA-262)<br><small>The definition of 'Array.isArray' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition. Implemented in JavaScript 1.8.5.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-array.isarray\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Array.isArray' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-array.isarray\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Array.isArray' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>   <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 5</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> 9</td>\n<td class=\"bc-supports-yes\"> 10.5</td>\n<td class=\"bc-supports-yes\"> 5</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div>  <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"../array\"><code>Array</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/isArray$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/isArray\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/isArray</a>\n  </p>\n</div>\n","global_objects/set/@@iterator":"<h1>set.@@iterator</h1> <p>The initial value of the <code><strong>@@iterator</strong></code> property is the same function object as the initial value of the <a href=\"values\"><code>values</code></a> property.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/set-prototype-@@iterator.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\"><em>mySet</em>[Symbol.iterator]</pre> <h3 id=\"Return_value\">Return value</h3> <p>The <code>Set</code> <strong>iterator</strong> function, which is the <a href=\"values\"><code>values()</code></a> function by default.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Using_iterator()\">Using <code>[@@iterator]()</code>\n</h3> <pre data-language=\"js\">var mySet = new Set();\nmySet.add('0');\nmySet.add(1);\nmySet.add({});\n\nvar setIter = mySet[Symbol.iterator]();\n\nconsole.log(setIter.next().value); // \"0\"\nconsole.log(setIter.next().value); // 1\nconsole.log(setIter.next().value); // Object\n</pre> <h3 id=\"Using_iterator()_with_for..of\">Using <code>[@@iterator]()</code> with <code>for..of</code>\n</h3> <pre data-language=\"js\">var mySet = new Set();\nmySet.add('0');\nmySet.add(1);\nmySet.add({});\n\nfor (var v of mySet) {\n  console.log(v);\n}\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-set.prototype-@@iterator\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Set.prototype[@@iterator]' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-set.prototype-@@iterator\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Set.prototype[@@iterator]' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes bc-has-history\"> 36\n<section class=\"bc-history\" id=\"sect1\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 36\n</dt>\n\n<dt class=\"bc-supports-no bc-supports\">27 — 36\n</dt>\n<dd> A placeholder property named <code>@@iterator</code> is used.</dd>\n<dd> Uses the non-standard name: <code>@@iterator</code>\n</dd>\n<dt class=\"bc-supports-no bc-supports\">17 — 27\n</dt>\n<dd> A placeholder property named <code>iterator</code> is used.</dd>\n<dd> Uses the non-standard name: <code>iterator</code>\n</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes bc-has-history\"> 36\n<section class=\"bc-history\" id=\"sect2\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 36\n</dt>\n\n<dt class=\"bc-supports-no bc-supports\">27 — 36\n</dt>\n<dd> A placeholder property named <code>@@iterator</code> is used.</dd>\n<dd> Uses the non-standard name: <code>@@iterator</code>\n</dd>\n<dt class=\"bc-supports-no bc-supports\">17 — 27\n</dt>\n<dd> A placeholder property named <code>iterator</code> is used.</dd>\n<dd> Uses the non-standard name: <code>iterator</code>\n</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 0.12</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"entries\"><code>Set.prototype.entries()</code></a></li> <li><a href=\"values\"><code>Set.prototype.keys()</code></a></li> <li><a href=\"values\"><code>Set.prototype.values()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set/@@iterator$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set/@@iterator\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set/@@iterator</a>\n  </p>\n</div>\n","global_objects/array/concat":"<h1>array.concat</h1> <p>The <code><strong>concat()</strong></code> method is used to merge two or more arrays. This method does not change the existing arrays, but instead returns a new array.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/array-concat.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\">var <var>new_array</var> = <var>old_array</var>.concat([<var>value1</var>[, <var>value2</var>[, ...[, <var>valueN</var>]]]])</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt>\n<code>value<em>N</em></code> <span class=\"inlineIndicator optional optionalInline\">Optional</span>\n</dt> <dd>Arrays and/or values to concatenate into a new array. If <code>value<em>N</em></code> is <code>undefined</code>, <code>concat</code> returns a shallow copy of the existing array on which it is called. See the description below for more details.</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p>A new <a href=\"../array\"><code>Array</code></a> instance.</p> <h2 id=\"Description\">Description</h2> <p>The <code>concat</code> method creates a new array consisting of the elements in the object on which it is called, followed in order by, for each argument, the elements of that argument (if the argument is an array) or the argument itself (if the argument is not an array). It does not recurse into nested array arguments.</p> <p>The <code>concat</code> method does not alter <code>this</code> or any of the arrays provided as arguments but instead returns a shallow copy that contains copies of the same elements combined from the original arrays. Elements of the original arrays are copied into the new array as follows:</p> <ul> <li>Object references (and not the actual object): <code>concat</code> copies object references into the new array. Both the original and new array refer to the same object. That is, if a referenced object is modified, the changes are visible to both the new and original arrays. This includes elements of array arguments that are also arrays.</li> <li>Data types such as strings, numbers and booleans (not <a href=\"../string\"><code>String</code></a>, <a href=\"../number\"><code>Number</code></a>, and <a href=\"../boolean\"><code>Boolean</code></a> objects): <code>concat</code> copies the values of strings and numbers into the new array.</li> </ul> <div class=\"note\"> <p><strong>Note:</strong> Concatenating array(s)/value(s) will leave the originals untouched. Furthermore, any operation on the new array (except operations on elements which are object references) will have no effect on the original arrays, and vice versa.</p> </div> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Concatenating_two_arrays\">Concatenating two arrays</h3> <p>The following code concatenates two arrays:</p> <pre data-language=\"js\">var alpha = ['a', 'b', 'c'];\nvar numeric = [1, 2, 3];\n\nalpha.concat(numeric);\n// result in ['a', 'b', 'c', 1, 2, 3]\n</pre> <h3 id=\"Concatenating_three_arrays\">Concatenating three arrays</h3> <p>The following code concatenates three arrays:</p> <pre data-language=\"js\">var num1 = [1, 2, 3],\n    num2 = [4, 5, 6],\n    num3 = [7, 8, 9];\n\nvar nums = num1.concat(num2, num3);\n\nconsole.log(nums); \n// results in [1, 2, 3, 4, 5, 6, 7, 8, 9]\n</pre> <h3 id=\"Concatenating_values_to_an_array\">Concatenating values to an array</h3> <p>The following code concatenates three values to an array:</p> <pre data-language=\"js\">var alpha = ['a', 'b', 'c'];\n\nvar alphaNumeric = alpha.concat(1, [2, 3]);\n\nconsole.log(alphaNumeric); \n// results in ['a', 'b', 'c', 1, 2, 3]\n</pre> <h3 id=\"Concatenating_nested_arrays\">Concatenating nested arrays</h3> <p>The following code concatenates nested arrays and demonstrates retention of references:</p> <pre data-language=\"js\">var num1 = [[1]];\nvar num2 = [2, [3]];\n\nvar nums = num1.concat(num2);\n\nconsole.log(nums);\n// results in [[1], 2, [3]]\n\n// modify the first element of num1\nnum1[0].push(4);\n\nconsole.log(nums);\n// results in [[1, 4], 2, [3]]\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <thead> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> </thead> <tbody> <tr> <td><a href=\"https://www.ecma-international.org/publications/files/ECMA-ST-ARCH/ECMA-262,%203rd%20edition,%20December%201999.pdf\" hreflang=\"en\">ECMAScript 3rd Edition (ECMA-262)</a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition. Implemented in JavaScript 1.2.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/5.1/#sec-15.4.4.4\" hreflang=\"en\">ECMAScript 5.1 (ECMA-262)<br><small>The definition of 'Array.prototype.concat' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-array.prototype.concat\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Array.prototype.concat' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-array.prototype.concat\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Array.prototype.concat' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>   <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> 5.5</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div>  <h2 id=\"See_also\">See also</h2> <ul> <li>\n<a href=\"push\"><code>push</code></a> / <a href=\"pop\"><code>pop</code></a> — add/remove elements from the end of the array</li> <li>\n<a href=\"unshift\"><code>unshift</code></a> / <a href=\"shift\"><code>shift</code></a> — add/remove elements from the beginning of the array</li> <li>\n<a href=\"splice\"><code>splice</code></a> — add/remove elements from the specified location of the array</li> <li><a href=\"../string/concat\"><code>String.prototype.concat()</code></a></li> <li>\n<a href=\"../symbol/isconcatspreadable\"><code>Symbol.isConcatSpreadable</code></a> – control flattening.</li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/concat$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/concat\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/concat</a>\n  </p>\n</div>\n","global_objects/array/flat":"<h1>array.flat</h1> <div class=\"blockIndicator experimental indicator-warning\"> <p> <strong>This is an <a href=\"https://developer.mozilla.org/en-US/docs/MDN/Contribute/Guidelines/Conventions_definitions#Experimental\">experimental technology</a></strong><br>Check the <a href=\"#Browser_compatibility\">Browser compatibility table</a> carefully before using this in production.</p> </div> <p>The <code><strong>flat()</strong></code> method creates a new array with all sub-array elements concatenated into it recursively up to the specified depth.</p>   <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\"><var>var newArray = arr</var>.flat(<em>[depth]</em>);</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt>\n<code>depth</code> <span class=\"inlineIndicator optional optionalInline\">Optional</span>\n</dt> <dd>The depth level specifying how deep a nested array structure should be flattened. Defaults to 1.</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p>A new array with the sub-array elements concatenated into it.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Flattening_nested_arrays\">Flattening nested arrays</h3> <pre data-language=\"js\">var arr1 = [1, 2, [3, 4]];\narr1.flat(); \n// [1, 2, 3, 4]\n\nvar arr2 = [1, 2, [3, 4, [5, 6]]];\narr2.flat();\n// [1, 2, 3, 4, [5, 6]]\n\nvar arr3 = [1, 2, [3, 4, [5, 6]]];\narr3.flat(2);\n// [1, 2, 3, 4, 5, 6]\n</pre> <h3 id=\"Flattening_and_array_holes\">Flattening and array holes</h3> <p>The flat method removes empty slots in arrays:</p> <pre data-language=\"js\">var arr4 = [1, 2, , 4, 5];\narr4.flat();\n// [1, 2, 4, 5]\n</pre> <h2 id=\"Alternative\">Alternative</h2> <h3 id=\"reduce_and_concat\">\n<code>reduce</code> and <code>concat</code>\n</h3> <pre data-language=\"js\">var arr1 = [1, 2, [3, 4]];\narr1.flat();\n\n//to flat single level array\narr1.reduce((acc, val) =&gt; acc.concat(val), []);// [1, 2, 3, 4]\n\n//or\nconst flatSingle = arr =&gt; [].concat(...arr);\n</pre>  <pre data-language=\"js\">//to enable deep level flatten use recursion with reduce and concat\nvar arr1 = [1,2,3,[1,2,3,4, [2,3,4]]];\n\nfunction flattenDeep(arr1) {\n   return arr1.reduce((acc, val) =&gt; Array.isArray(val) ? acc.concat(flattenDeep(val)) : acc.concat(val), []);\n}\nflattenDeep(arr1);// [1, 2, 3, 1, 2, 3, 4, 2, 3, 4]\n</pre>  <pre data-language=\"js\">//non recursive flatten deep using a stack\nvar arr1 = [1,2,3,[1,2,3,4, [2,3,4]]];\nfunction flatten(input) {\n  const stack = [...input];\n  const res = [];\n  while (stack.length) {\n    // pop value from stack\n    const next = stack.pop();\n    if (Array.isArray(next)) {\n      // push back array items, won't modify the original input\n      stack.push(...next);\n    } else {\n      res.push(next);\n    }\n  }\n  //reverse to restore input order\n  return res.reverse();\n}\nflatten(arr1);// [1, 2, 3, 1, 2, 3, 4, 2, 3, 4]\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://tc39.github.io/proposal-flatMap/#sec-Array.prototype.flat\"><code>Array.prototype.flat</code> proposal</a></td> <td>Candidate (3)</td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>   <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support \n</th>\n<td class=\"bc-supports-yes\"> 69</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 62</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 56</td>\n<td class=\"bc-supports-yes\"> 12</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support \n</th>\n<td class=\"bc-supports-yes\"> 69</td>\n<td class=\"bc-supports-yes\"> 69</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 62</td>\n<td class=\"bc-supports-yes\"> 56</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-no\"> No</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support \n</th>\n<td class=\"bc-supports-no\"> No</td>\n</tr></tbody>\n</table>\n</div>  <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"flatmap\"><code>Array.prototype.flatMap()</code></a></li> <li><a href=\"map\"><code>Array.prototype.map()</code></a></li> <li><a href=\"reduce\"><code>Array.prototype.reduce()</code></a></li> <li><a href=\"concat\"><code>Array.prototype.concat()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/flat$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/flat\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/flat</a>\n  </p>\n</div>\n","global_objects/array/length":"<h1>Array.length</h1> <p>The <code><strong>length</strong></code> property of an object which is an instance of type <code>Array</code> sets or returns the number of elements in that array. The value is an unsigned, 32-bit integer that is always numerically greater than the highest index in the array.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/array-length.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Description\">Description</h2> <p>The value of the <code>length</code> property is an integer with a positive sign and a value less than 2 to the 32nd power (2<sup>32</sup>).</p> <pre data-language=\"js\">var namelistA = new Array(4294967296); //2 to the 32nd power<sup> = </sup>4294967296 \nvar namelistC = new Array(-100) //negative sign\n\nconsole.log(namelistA.length); //RangeError: Invalid array length \nconsole.log(namelistC.length); //RangeError: Invalid array length \n\n\n\nvar namelistB = []; \nnamelistB.length = Math.pow(2,32)-1; //set array length less than 2 to the 32nd power \nconsole.log(namelistB.length); \n\n//4294967295\n</pre> <p>You can set the <code>length</code> property to truncate an array at any time. When you extend an array by changing its <code>length</code> property, the number of actual elements increases; for example, if you set <code>length</code> to 3 when it is currently 2, the array now contains 3 elements, which causes the third element to be <code>undefined</code>.</p> <pre data-language=\"js\">var arr = [1, 2, 3];\nprintEntries(arr);\n\narr.length = 5; // set array length to 5 while currently 3.\nprintEntries(arr);\n\nfunction printEntries(arr) {\n  var length = arr.length;\n  for (var i = 0; i &lt; length; i++) {\n    console.log(arr[i]);\n  }\n  console.log('=== printed ===');\n}\n\n// 1\n// 2\n// 3\n// === printed ===\n// 1\n// 2\n// 3\n// undefined\n// undefined\n// === printed ===</pre> <p>But, the <code>length</code> property does not necessarily indicate the number of defined values in the array. See also <a href=\"../array#Relationship_between_length_and_numerical_properties\">Relationship between <code>length</code> and numerical properties</a>.</p> <div class=\"_table\"><table class=\"standard-table\"> <thead> <tr> <th colspan=\"2\" class=\"header\">Property attributes of <code>Array.length</code>\n</th> </tr> </thead> <tbody> <tr> <td>Writable</td> <td>yes</td> </tr> <tr> <td>Enumerable</td> <td>no</td> </tr> <tr> <td>Configurable</td> <td>no</td> </tr> </tbody> </table></div>  <ul> <li>\n<code>Writable</code>: If this attribute set to <code>false</code>, the value of the property cannot be changed.</li> <li>\n<code>Configurable</code>: If this attribute set to <code>false</code>, any attempts to delete the property or change its attributes (<code>Writable</code>, <code>Configurable</code>, or <code>Enumerable</code>) will fail.</li> <li>\n<code>Enumerable</code>: If this attribute set to <code>true</code>, the property will be iterated over during <a href=\"../../statements/for\">for</a> or <a href=\"../../statements/for...in\">for..in</a> loops.</li> </ul>  <h2 id=\"Examples\">Examples</h2> <h3 id=\"Iterating_over_an_array\">Iterating over an array</h3> <p>In the following example, the array <code>numbers</code> is iterated through by looking at the <code>length</code> property. The value in each element is then doubled.</p> <pre data-language=\"js\">var numbers = [1, 2, 3, 4, 5];\nvar length = numbers.length;\nfor (var i = 0; i &lt; length; i++) {\n  numbers[i] *= 2;\n}\n// numbers is now [2, 4, 6, 8, 10]\n</pre> <h3 id=\"Shortening_an_array\">Shortening an array</h3> <p>The following example shortens the array <code>numbers</code> to a length of 3 if the current length is greater than 3.</p> <pre data-language=\"js\">var numbers = [1, 2, 3, 4, 5];\n\nif (numbers.length &gt; 3) {\n  numbers.length = 3;\n}\n\nconsole.log(numbers); // [1, 2, 3]\nconsole.log(numbers.length); // 3\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/publications/files/ECMA-ST-ARCH/ECMA-262,%201st%20edition,%20June%201997.pdf\" hreflang=\"en\">ECMAScript 1st Edition (ECMA-262)</a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/5.1/#sec-15.4.5.2\" hreflang=\"en\">ECMAScript 5.1 (ECMA-262)<br><small>The definition of 'Array.length' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-properties-of-array-instances-length\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Array.length' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-properties-of-array-instances-length\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Array.length' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>   <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div>  <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"../array\"><code>Array</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/length$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/length\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/length</a>\n  </p>\n</div>\n","global_objects/array/@@unscopables":"<h1>array.@@unscopables</h1> <p>The <code><strong>@@unscopable</strong></code> symbol property contains property names that were not included in the ECMAScript standard prior to the ES2015 version. These properties are excluded from <code><a href=\"../../statements/with\">with</a></code> statement bindings.</p> <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\"><var>arr</var>[Symbol.unscopables]</pre> <h2 id=\"Description\">Description</h2> <p>The default array properties that are excluded from <code>with</code> bindings are: copyWithin, entries, fill, find, findIndex, includes, keys, and values.</p> <p>See <a href=\"../symbol/unscopables\"><code>Symbol.unscopables</code></a> for how to set <code>unscopables</code> for your own objects.</p> <div class=\"_table\"><table class=\"standard-table\"> <thead> <tr> <th colspan=\"2\" class=\"header\">Property attributes of <code>Array.prototype[@@unscopables]</code>\n</th> </tr> </thead> <tbody> <tr> <td>Writable</td> <td>no</td> </tr> <tr> <td>Enumerable</td> <td>no</td> </tr> <tr> <td>Configurable</td> <td>yes</td> </tr> </tbody> </table></div> <h2 id=\"Examples\">Examples</h2> <p>The following code works fine in ES5 and below. However, in ECMAScript 2015 and later, the <a href=\"keys\"><code>Array.prototype.keys()</code></a> method was introduced. That means that inside <code>with</code> environments, \"keys\" would now be the method and not the variable. This is where now the built-in <code>@@unscopables</code> <code>Array.prototype[@@unscopables]</code> symbol property comes into play and prevents that some of the Array methods are being scoped into the <code>with</code> statement.</p> <pre data-language=\"js\">var keys = [];\n\nwith (Array.prototype) {\n  keys.push('something');\n}\n\nObject.keys(Array.prototype[Symbol.unscopables]); \n// [\"copyWithin\", \"entries\", \"fill\", \"find\", \"findIndex\", \n//  \"includes\", \"keys\", \"values\"]</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-array.prototype-@@unscopables\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Array.prototype[@@unscopables]' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-array.prototype-@@unscopables\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Array.prototype[@@unscopables]' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>   <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td> ? </td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 48</td>\n<td> ? </td>\n<td> ? </td>\n<td> ? </td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td> ? </td>\n<td> ? </td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 48</td>\n<td> ? </td>\n<td> ? </td>\n<td> ? </td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 0.12</td>\n</tr></tbody>\n</table>\n</div>  <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"../symbol/unscopables\"><code>Symbol.unscopables</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/@@unscopables$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/@@unscopables\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/@@unscopables</a>\n  </p>\n</div>\n","global_objects/array/splice":"<h1>array.splice</h1> <p>The <code>splice()</code> method changes the contents of an array by removing existing elements and/or adding new elements.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/array-splice.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\"><var>array</var>.splice(<var>start[</var>, <var>deleteCount[</var>, <var>item1[</var>, <var>item2[</var>, <em>...]]]]</em>)\n</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><code>start</code></dt> <dd>Index at which to start changing the array (with origin 0). If greater than the length of the array, actual starting index will be set to the length of the array. If negative, will begin that many elements from the end of the array (with origin -1) and will be set to 0 if absolute value is greater than the length of the array.</dd> <dt>\n<code>deleteCount</code> <span class=\"inlineIndicator optional optionalInline\">Optional</span>\n</dt> <dd>An integer indicating the number of old array elements to remove.</dd> <dd>If <code>deleteCount</code> is omitted, or if its value is larger than <code>array.length - start</code> (that is, if it is greater than the number of elements left in the array, starting at <code>start</code>), then all of the elements from <code>start</code> through the end of the array will be deleted.</dd> <dd>If <code>deleteCount</code> is 0 or negative, no elements are removed. In this case, you should specify at least one new element (see below).</dd> <dt>\n<code>item1, item2, <em>...</em></code> <span class=\"inlineIndicator optional optionalInline\">Optional</span>\n</dt> <dd>The elements to add to the array, beginning at the <code>start</code> index. If you don't specify any elements, <code>splice()</code> will only remove elements from the array.</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p>An array containing the deleted elements. If only one element is removed, an array of one element is returned. If no elements are removed, an empty array is returned.</p> <h2 id=\"Description\">Description</h2> <p>If you specify a different number of elements to insert than the number you're removing, the array will have a different length at the end of the call.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Remove_0_(zero)_elements_from_index_2_and_insert_drum\">Remove 0 (zero) elements from index 2, and insert \"drum\"</h3> <pre data-language=\"js\">var myFish = ['angel', 'clown', 'mandarin', 'sturgeon'];\nvar removed = myFish.splice(2, 0, 'drum');\n\n// myFish is [\"angel\", \"clown\", \"drum\", \"mandarin\", \"sturgeon\"] \n// removed is [], no elements removed\n</pre> <h3 id=\"Remove_1_element_from_index_3\">Remove 1 element from index 3</h3> <pre data-language=\"js\">var myFish = ['angel', 'clown', 'drum', 'mandarin', 'sturgeon'];\nvar removed = myFish.splice(3, 1);\n\n// removed is [\"mandarin\"]\n// myFish is [\"angel\", \"clown\", \"drum\", \"sturgeon\"] \n</pre> <h3 id=\"Remove_1_element_from_index_2_and_insert_trumpet\">Remove 1 element from index 2, and insert \"trumpet\"</h3> <pre data-language=\"js\">var myFish = ['angel', 'clown', 'drum', 'sturgeon'];\nvar removed = myFish.splice(2, 1, 'trumpet');\n\n// myFish is [\"angel\", \"clown\", \"trumpet\", \"sturgeon\"]\n// removed is [\"drum\"]</pre> <h3 id=\"Remove_2_elements_from_index_0_and_insert_parrot_anemone_and_blue\">Remove 2 elements from index 0, and insert \"parrot\", \"anemone\" and \"blue\"</h3> <pre data-language=\"js\">var myFish = ['angel', 'clown', 'trumpet', 'sturgeon'];\nvar removed = myFish.splice(0, 2, 'parrot', 'anemone', 'blue');\n\n// myFish is [\"parrot\", \"anemone\", \"blue\", \"trumpet\", \"sturgeon\"] \n// removed is [\"angel\", \"clown\"]</pre> <h3 id=\"Remove_2_elements_from_index_2\">Remove 2 elements from index 2</h3> <pre data-language=\"js\">var myFish = ['parrot', 'anemone', 'blue', 'trumpet', 'sturgeon'];\nvar removed = myFish.splice(myFish.length - 3, 2);\n\n// myFish is [\"parrot\", \"anemone\", \"sturgeon\"] \n// removed is [\"blue\", \"trumpet\"]</pre> <h3 id=\"Remove_1_element_from_index_-2\">Remove 1 element from index -2</h3> <pre data-language=\"js\">var myFish = ['angel', 'clown', 'mandarin', 'sturgeon'];\nvar removed = myFish.splice(-2, 1);\n\n// myFish is [\"angel\", \"clown\", \"sturgeon\"] \n// removed is [\"mandarin\"]</pre> <h3 id=\"Remove_all_elements_after_index_2_(incl.)\">Remove all elements after index 2 (incl.)</h3> <pre data-language=\"js\">var myFish = ['angel', 'clown', 'mandarin', 'sturgeon'];\nvar removed = myFish.splice(2);\n\n// myFish is [\"angel\", \"clown\"] \n// removed is [\"mandarin\", \"sturgeon\"]</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/publications/files/ECMA-ST-ARCH/ECMA-262,%203rd%20edition,%20December%201999.pdf\" hreflang=\"en\">ECMAScript 3rd Edition (ECMA-262)</a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition. Implemented in JavaScript 1.2.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/5.1/#sec-15.4.4.12\" hreflang=\"en\">ECMAScript 5.1 (ECMA-262)<br><small>The definition of 'Array.prototype.splice' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-array.prototype.splice\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Array.prototype.splice' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-array.prototype.splice\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Array.prototype.splice' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>   <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> 5.5</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div>  <h2 id=\"See_also\">See also</h2> <ul> <li>\n<a href=\"push\"><code>push()</code></a> / <a href=\"pop\"><code>pop()</code></a> — add/remove elements from the end of the array</li> <li>\n<a href=\"unshift\"><code>unshift()</code></a> / <a href=\"shift\"><code>shift()</code></a> — add/remove elements from the beginning of the array</li> <li>\n<a href=\"concat\"><code>concat()</code></a> — returns a new array comprised of this array joined with other array(s) and/or value(s)</li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/splice$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/splice\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/splice</a>\n  </p>\n</div>\n","global_objects/array/flatmap":"<h1>array.flatMap</h1> <div class=\"blockIndicator experimental indicator-warning\"> <p> <strong>This is an <a href=\"https://developer.mozilla.org/en-US/docs/MDN/Contribute/Guidelines/Conventions_definitions#Experimental\">experimental technology</a></strong><br>Check the <a href=\"#Browser_compatibility\">Browser compatibility table</a> carefully before using this in production.</p> </div> <p>The <code><strong>flatMap()</strong></code> method first maps each element using a mapping function, then flattens the result into a new array. It is identical to a <a href=\"map\">map</a> followed by a <a href=\"flat\">flat</a> of depth 1, but <code>flatMap</code> is often quite useful, as merging both into one method is slightly more efficient.</p>   <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\"><var>var new_array = arr</var>.flatMap(function <var>callback(currentValue[, index[, array]]) {\n    // return element for new_array\n}</var>[, <var>thisArg</var>])</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><code>callback</code></dt> <dd>Function that produces an element of the new Array, taking three arguments: <dl>  <dt><code>currentValue</code></dt> <dd>The current element being processed in the array.</dd> <dt>\n<code>index</code><span class=\"inlineIndicator optional optionalInline\">Optional</span>\n</dt> <dd>The index of the current element being processed in the array.</dd> <dt>\n<code>array</code><span class=\"inlineIndicator optional optionalInline\">Optional</span>\n</dt> <dd>The array <code>map</code> was called upon.</dd> </dl> </dd> <dt>\n<code>thisArg</code><span class=\"inlineIndicator optional optionalInline\">Optional</span>\n</dt> <dd>Value to use as <code>this</code> when executing <code>callback</code>.</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p>A new array with each element being the result of the callback function and flattened to a depth of 1.</p> <h2 id=\"Description\">Description</h2> <p>See <a href=\"map\"><code>Array.prototype.map()</code></a> for a detailed description of the callback function. The <code>flatMap</code> method is identical to a <code><a href=\"map\">map</a></code> followed by a call to <code><a href=\"flat\">flat</a></code> of depth 1.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"map_and_flatMap\">\n<code>map</code> and <code>flatMap</code>\n</h3> <pre data-language=\"js\">let arr1 = <span class=\"js source\"><span class=\"function-call js meta\"><span class=\"js meta\"><span class=\"brace js meta square\"><span>[</span></span><span class=\"constant decimal js numeric\"><span>1</span></span><span class=\"comma delimiter js meta object\"><span>,</span></span><span class=\"brace js meta square\"><span>2, 3, 4];\n\narr1.map(</span></span></span></span></span>x =&gt; [x * 2]<span class=\"js source\"><span class=\"function-call js meta\"><span class=\"js meta\"><span class=\"brace js meta square\"><span>);</span></span></span></span></span> \n// [[2], [4], [6], [8]]\n\narr1.flatMap(x =&gt; [x * 2]<span class=\"js source\"><span class=\"function-call js meta\"><span class=\"js meta\"><span class=\"brace js meta square\"><span>);\n// [2, 4, 6, 8]</span></span></span></span></span>\n\n// only one level is flattened\narr1.flatMap(x =&gt; [[x * 2]]);\n// [[2], [4], [6], [8]]\n</pre> <p>While the above could have been achieved by using map itself, here is an example showing usecase of <code>flatMap</code> better.</p> <p>Let's generate a list of words from a list of sentences.</p> <pre data-language=\"js\">let arr1 = [\"it's Sunny in\", \"\", \"California\"];\n\narr1.map(x =&gt; x.split(\" \"));\n// [[\"it's\",\"Sunny\",\"in\"],[\"\"],[\"California\"]]\n\narr1.flatMap(x =&gt; x.split(\" \")<span class=\"js source\"><span class=\"function-call js meta\"><span class=\"js meta\"><span class=\"brace js meta square\"><span>);\n// [\"it's\",\"Sunny\",\"in\", \"\", \"California\"]</span></span></span></span></span></pre> <p>Notice, the output list length can be different from the input list length.</p> <div class=\"line\"><span class=\"js source\"><span class=\"comment double-slash js line\"><span class=\"comment definition js punctuation\"><span>//</span></span><span>=&gt; [1, 2, 3, 4, 5, 6, 7, 8, 9]</span></span></span></div> <h2 id=\"Alternative\">Alternative</h2> <h3 id=\"reduce_and_concat\">\n<code>reduce</code> and <code>concat</code>\n</h3> <pre data-language=\"js\">var arr1 = <span class=\"js source\"><span class=\"function-call js meta\"><span class=\"js meta\"><span class=\"brace js meta square\"><span>[</span></span><span class=\"constant decimal js numeric\"><span>1</span></span><span class=\"comma delimiter js meta object\"><span>,</span></span><span class=\"brace js meta square\"><span>2, 3, 4];\n</span></span></span></span></span>\narr1.flatMap(x =&gt; [x * 2]<span class=\"js source\"><span class=\"function-call js meta\"><span class=\"js meta\"><span class=\"brace js meta square\"><span>);</span></span></span></span></span>\n// is equivalent to\narr1.reduce((acc, x) =&gt; acc.concat([x * 2]<span class=\"js source\"><span class=\"function-call js meta\"><span class=\"js meta\"><span class=\"brace js meta square\"><span>), []);</span></span></span></span></span>\n<span class=\"js source\"><span class=\"function-call js meta\"><span class=\"js meta\"><span class=\"brace js meta square\"><span>// [2, 4, 6, 8]</span></span></span></span></span>\n</pre> <div class=\"line\"><span class=\"js source\"><span class=\"comment double-slash js line\"><span class=\"comment definition js punctuation\"><span>//</span></span><span>=&gt; [1, 2, 3, 4, 5, 6, 7, 8, 9]</span></span></span></div> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://tc39.github.io/proposal-flatMap/#sec-Array.prototype.flatMap\"><code>Array.prototype.flatMap</code> proposal</a></td> <td>Candidate (3)</td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>   <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support \n</th>\n<td class=\"bc-supports-yes\"> 69</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 62</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 56</td>\n<td class=\"bc-supports-yes\"> 12</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support \n</th>\n<td class=\"bc-supports-yes\"> 69</td>\n<td class=\"bc-supports-yes\"> 69</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 62</td>\n<td class=\"bc-supports-yes\"> 56</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-no\"> No</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support \n</th>\n<td class=\"bc-supports-no\"> No</td>\n</tr></tbody>\n</table>\n</div>  <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"flat\"><code>Array.prototype.flat()</code></a></li> <li><a href=\"map\"><code>Array.prototype.map()</code></a></li> <li><a href=\"reduce\"><code>Array.prototype.reduce()</code></a></li> <li><a href=\"concat\"><code>Array.prototype.concat()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/flatMap$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/flatMap\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/flatMap</a>\n  </p>\n</div>\n","global_objects/array/pop":"<h1>array.pop</h1> <p>The <code><strong>pop()</strong></code> method removes the <strong>last</strong> element from an array and returns that element. This method changes the length of the array.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/array-pop.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\"><var>arr</var>.pop()</pre> <h3 id=\"Return_value\">Return value</h3> <p>The removed element from the array; <a href=\"../undefined\"><code>undefined</code></a> if the array is empty.</p> <h2 id=\"Description\">Description</h2> <p>The <code>pop</code> method removes the last element from an array and returns that value to the caller.</p> <p><code>pop</code> is intentionally generic; this method can be <a href=\"../function/call\">called</a> or <a href=\"../function/apply\">applied</a> to objects resembling arrays. Objects which do not contain a <code>length</code> property reflecting the last in a series of consecutive, zero-based numerical properties may not behave in any meaningful manner.</p> <p>If you call <code>pop()</code> on an empty array, it returns <a href=\"../undefined\"><code>undefined</code></a>.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Removing_the_last_element_of_an_array\">Removing the last element of an array</h3> <p>The following code creates the <code>myFish</code> array containing four elements, then removes its last element.</p> <pre data-language=\"js\">var myFish = ['angel', 'clown', 'mandarin', 'sturgeon'];\n\nvar popped = myFish.pop();\n\nconsole.log(myFish); // ['angel', 'clown', 'mandarin' ] \n\nconsole.log(popped); // 'sturgeon'</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/publications/files/ECMA-ST-ARCH/ECMA-262,%203rd%20edition,%20December%201999.pdf\" hreflang=\"en\">ECMAScript 3rd Edition (ECMA-262)</a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition. Implemented in JavaScript 1.2.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/5.1/#sec-15.4.4.6\" hreflang=\"en\">ECMAScript 5.1 (ECMA-262)<br><small>The definition of 'Array.prototype.pop' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-array.prototype.pop\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Array.prototype.pop' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-array.prototype.pop\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Array.prototype.pop' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>   <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> 5.5</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div>  <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"push\"><code>Array.prototype.push()</code></a></li> <li><a href=\"shift\"><code>Array.prototype.shift()</code></a></li> <li><a href=\"unshift\"><code>Array.prototype.unshift()</code></a></li> <li><a href=\"concat\"><code>Array.prototype.concat()</code></a></li> <li><a href=\"splice\"><code>Array.prototype.splice()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/pop$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/pop\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/pop</a>\n  </p>\n</div>\n","global_objects/array/push":"<h1>array.push</h1> <p>The <code><strong>push()</strong></code> method adds one or more elements to the end of an array and returns the new length of the array.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/array-push.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\"><var>arr</var>.push(<var>element1</var>[, ...[, <var>elementN</var>]])</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><code>element<em>N</em></code></dt> <dd>The elements to add to the end of the array.</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p>The new <a href=\"length\"><code>length</code></a> property of the object upon which the method was called.</p> <h2 id=\"Description\">Description</h2> <p>The <code>push</code> method appends values to an array.</p> <p><code>push</code> is intentionally generic. This method can be used with <a href=\"../function/call\"><code>call()</code></a> or <a href=\"../function/apply\"><code>apply()</code></a> on objects resembling arrays. The <code>push</code> method relies on a <code>length</code> property to determine where to start inserting the given values. If the <code>length</code> property cannot be converted into a number, the index used is 0. This includes the possibility of <code>length</code> being nonexistent, in which case <code>length</code> will also be created.</p> <p>Although <a href=\"../string\">strings</a> are native, Array-like objects, they are not suitable in applications of this method, as strings are immutable. Similarly for the native, Array-like object <a href=\"../../functions/arguments\">arguments</a>.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Adding_elements_to_an_array\">Adding elements to an array</h3> <p>The following code creates the <code>sports</code> array containing two elements, then appends two elements to it. The <code>total</code> variable contains the new length of the array.</p> <pre data-language=\"js\">var sports = ['soccer', 'baseball'];\nvar total = sports.push('football', 'swimming');\n\nconsole.log(sports); // ['soccer', 'baseball', 'football', 'swimming']\nconsole.log(total);  // 4\n</pre> <h3 id=\"Merging_two_arrays\">Merging two arrays</h3> <p>This example uses <a href=\"../function/apply\"><code>apply()</code></a> to push all elements from a second array.</p> <p>Do <em>not</em> use this method if the second array (<code>moreVegs</code> in the example) is very large, because the maximum number of parameters that one function can take is limited in practice. See <a href=\"../function/apply\"><code>apply()</code></a> for more details.</p> <pre data-language=\"js\">var vegetables = ['parsnip', 'potato'];\nvar moreVegs = ['celery', 'beetroot'];\n\n// Merge the second array into the first one\n// Equivalent to vegetables.push('celery', 'beetroot');\nArray.prototype.push.apply(vegetables, moreVegs);\n\nconsole.log(vegetables); // ['parsnip', 'potato', 'celery', 'beetroot']\n</pre> <h3 id=\"Using_an_object_in_an_array-like_fashion\">Using an object in an array-like fashion</h3> <p>As mentioned above, <code>push</code> is intentionally generic, and we can use that to our advantage. <code>Array.prototype.push</code> can work on an object just fine, as this example shows. Note that we don't create an array to store a collection of objects. Instead, we store the collection on the object itself and use <code>call</code> on <code>Array.prototype.push</code> to trick the method into thinking we are dealing with an array, and it just works, thanks to the way JavaScript allows us to establish the execution context however we please.</p> <pre data-language=\"js\">var obj = {\n    length: 0,\n\n    addElem: function addElem(elem) {\n        // obj.length is automatically incremented \n        // every time an element is added.\n        [].push.call(this, elem);\n    }\n};\n\n// Let's add some empty objects just to illustrate.\nobj.addElem({});\nobj.addElem({});\nconsole.log(obj.length);\n// → 2\n</pre> <p>Note that although <code>obj</code> is not an array, the method <code>push</code> successfully incremented <code>obj</code>'s <code>length</code> property just like if we were dealing with an actual array.</p> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/publications/files/ECMA-ST-ARCH/ECMA-262,%203rd%20edition,%20December%201999.pdf\" hreflang=\"en\">ECMAScript 3rd Edition (ECMA-262)</a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition. Implemented in JavaScript 1.2.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/5.1/#sec-15.4.4.7\" hreflang=\"en\">ECMAScript 5.1 (ECMA-262)<br><small>The definition of 'Array.prototype.push' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-array.prototype.push\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Array.prototype.push' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-array.prototype.push\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Array.prototype.push' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>   <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> 5.5</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div>  <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"pop\"><code>Array.prototype.pop()</code></a></li> <li><a href=\"shift\"><code>Array.prototype.shift()</code></a></li> <li><a href=\"unshift\"><code>Array.prototype.unshift()</code></a></li> <li><a href=\"concat\"><code>Array.prototype.concat()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/push$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/push\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/push</a>\n  </p>\n</div>\n","global_objects/array/@@iterator":"<h1>array.@@iterator</h1> <p>The initial value of the <code><strong>@@iterator</strong></code> property is the same function object as the initial value of the <a href=\"values\"><code>values()</code></a> property.</p> <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\"><var>arr</var>[Symbol.iterator]()</pre> <h3 id=\"Return_value\">Return value</h3> <p>The initial value given by the <a href=\"values\"><code>values()</code></a> <strong>iterator</strong>. By default, using <code>arr[Symbol.iterator]</code> will return the <a href=\"values\"><code>values()</code></a> function.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Iteration_using_for...of_loop\">Iteration using <code>for...of</code> loop</h3> <pre data-language=\"js\">var arr = ['w', 'y', 'k', 'o', 'p'];\nvar eArr = arr[Symbol.iterator]();\n// your browser must support for..of loop\n// and let-scoped variables in for loops\n// const and var could also be used\nfor (let letter of eArr) {\n  console.log(letter);\n}\n</pre> <h3 id=\"Alternative_iteration\">Alternative iteration</h3> <pre data-language=\"js\">var arr = ['w', 'y', 'k', 'o', 'p'];\nvar eArr = arr[Symbol.iterator]();\nconsole.log(eArr.next().value); // w\nconsole.log(eArr.next().value); // y\nconsole.log(eArr.next().value); // k\nconsole.log(eArr.next().value); // o\nconsole.log(eArr.next().value); // p\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <thead> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> </thead> <tbody> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-array.prototype-@@iterator\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Array.prototype[@@iterator]()' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-array.prototype-@@iterator\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Array.prototype[@@iterator]()' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 38</td>\n<td> ? </td>\n<td class=\"bc-supports-yes bc-has-history\"> 36\n<section class=\"bc-history\" id=\"sect1\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 36\n</dt>\n\n<dt class=\"bc-supports-no bc-supports\">27 — 36\n</dt>\n<dd> A placeholder property named <code>@@iterator</code> is used.</dd>\n<dd> Uses the non-standard name: <code>@@iterator</code>\n</dd>\n<dt class=\"bc-supports-no bc-supports\">17 — 27\n</dt>\n<dd> A placeholder property named <code>iterator</code> is used.</dd>\n<dd> Uses the non-standard name: <code>iterator</code>\n</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 25</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td> ? </td>\n<td class=\"bc-supports-yes bc-has-history\"> 36\n<section class=\"bc-history\" id=\"sect2\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 36\n</dt>\n\n<dt class=\"bc-supports-no bc-supports\">27 — 36\n</dt>\n<dd> A placeholder property named <code>@@iterator</code> is used.</dd>\n<dd> Uses the non-standard name: <code>@@iterator</code>\n</dd>\n<dt class=\"bc-supports-no bc-supports\">17 — 27\n</dt>\n<dd> A placeholder property named <code>iterator</code> is used.</dd>\n<dd> Uses the non-standard name: <code>iterator</code>\n</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 0.12</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"keys\"><code>Array.prototype.keys()</code></a></li> <li><a href=\"entries\"><code>Array.prototype.entries()</code></a></li> <li><a href=\"foreach\"><code>Array.prototype.forEach()</code></a></li> <li><a href=\"every\"><code>Array.prototype.every()</code></a></li> <li><a href=\"some\"><code>Array.prototype.some()</code></a></li> <li><a href=\"values\"><code>Array.prototype.values()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/@@iterator$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/@@iterator\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/@@iterator</a>\n  </p>\n</div>\n","global_objects/regexp/exec":"<h1>regExp.exec</h1> <p>The <code>exec()</code> method executes a search for a match in a specified string. Returns a result array, or <a href=\"../null\"><code>null</code></a>.</p> <p>If you are executing a match simply to find true or false, use the <a href=\"test\"><code>RegExp.prototype.test()</code></a> method or the <a href=\"../string/search\"><code>String.prototype.search()</code></a> method.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/regexp-prototype-exec.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\"><var>regexObj</var>.exec(<var>str</var>)</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><code>str</code></dt> <dd>The string against which to match the regular expression.</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p>If the match succeeds, the <code>exec()</code> method returns an array and updates properties of the regular expression object. The returned array has the matched text as the first item, and then one item for each capturing parenthesis that matched containing the text that was captured.</p> <p>If the match fails, the <code>exec()</code> method returns <a href=\"../null\"><code>null</code></a>.</p> <h2 id=\"Description\">Description</h2> <p>Consider the following example:</p> <pre data-language=\"js\">// Match \"quick brown\" followed by \"jumps\", ignoring characters in between\n// Remember \"brown\" and \"jumps\"\n// Ignore case\nvar re = /quick\\s(brown).+?(jumps)/ig;\nvar result = re.exec('The Quick Brown Fox Jumps Over The Lazy Dog');\n</pre> <p>The following table shows the results for this script:</p> <div class=\"_table\"><table class=\"fullwidth-table\"> <tbody> <tr> <th class=\"header\">Object</th> <th class=\"header\">Property/Index</th> <th class=\"header\">Description</th> <th class=\"header\">Example</th> </tr> <tr> <td rowspan=\"4\"><code>result</code></td> <td><code>[0]</code></td> <td>The full string of characters matched</td> <td><code>\"Quick Brown Fox Jumps\"</code></td> </tr> <tr> <td><code>[1], ...[<em>n</em>]</code></td> <td>The parenthesized substring matches, if any. The number of possible parenthesized substrings is unlimited.</td> <td><code>result[1] === \"Brown\"<br>\n\t\t\tresult[2] === \"Jumps\"</code></td> </tr> <tr> <td><code>index</code></td> <td>The 0-based index of the match in the string.</td> <td><code>4</code></td> </tr> <tr> <td><code>input</code></td> <td>The original string that was matched against.</td> <td><code>\"The Quick Brown Fox Jumps Over The Lazy Dog\"</code></td> </tr> <tr> <td rowspan=\"5\"><code>re</code></td> <td><code>lastIndex</code></td> <td>The index at which to start the next match. If <code>g</code> is absent, this will always be <code>0</code>.</td> <td><code>25</code></td> </tr> <tr> <td><code>ignoreCase</code></td> <td>Indicates if the <code>i</code> flag was used to ignore case.</td> <td><code>true</code></td> </tr> <tr> <td><code>global</code></td> <td>Indicates if the <code>g</code> flag was used for a global match.</td> <td><code>true</code></td> </tr> <tr> <td><code>multiline</code></td> <td>Indicates if the <code>m</code> flag was used to search across multiple lines.</td> <td><code>false</code></td> </tr> <tr> <td><code>source</code></td> <td>The text of the pattern.</td> <td><code>\"quick\\s(brown).+?(jumps)\"</code></td> </tr> </tbody> </table></div> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Finding_successive_matches\">Finding successive matches</h3> <p>If your regular expression uses the \"<code>g</code>\" flag, you can use the <code>exec()</code> method multiple times to find successive matches in the same string. When you do so, the search starts at the substring of <code>str</code> specified by the regular expression's <a href=\"lastindex\"><code>lastIndex</code></a> property (<a href=\"test\"><code>test()</code></a> will also advance the <a href=\"lastindex\"><code>lastIndex</code></a> property). Note that the <a href=\"lastindex\"><code>lastIndex</code></a> property will not be reset when searching a different string it will start its search at its existing <a href=\"lastindex\"><code>lastIndex</code></a> .</p> <p>For example, assume you have this script:</p> <pre data-language=\"js\">var myRe = /ab*/g;\nvar str = 'abbcdefabh';\nvar myArray;\nwhile ((myArray = myRe.exec(str)) !== null) {\n  var msg = 'Found ' + myArray[0] + '. ';\n  msg += 'Next match starts at ' + myRe.lastIndex;\n  console.log(msg);\n}\n</pre> <p>This script displays the following text:</p> <pre>Found abb. Next match starts at 3\nFound ab. Next match starts at 9\n</pre> <div class=\"warning\"> <p>Note: Do not place the regular expression literal (or <a href=\"../regexp\"><code>RegExp</code></a> constructor) within the <code>while</code> condition or it will create an infinite loop if there is a match due to the <a href=\"lastindex\"><code>lastIndex</code></a> property being reset upon each iteration. Also be sure that the global flag (\"<code>g</code>\") is set or an infinite loop will occur here also.</p> </div> <h3 id=\"Using_exec()_with_RegExp_literals\">Using <code>exec()</code> with <code>RegExp</code> literals</h3> <p>You can also use <code>exec()</code> without creating a <a href=\"../regexp\"><code>RegExp</code></a> object:</p> <pre data-language=\"js\">var matches = /(hello \\S+)/.exec('This is a hello world!');\nconsole.log(matches[1]);\n</pre> <p>This will log a message containing 'hello world!'.</p> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <thead> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> </thead> <tbody> <tr> <td><a href=\"https://www.ecma-international.org/publications/files/ECMA-ST-ARCH/ECMA-262,%203rd%20edition,%20December%201999.pdf\" hreflang=\"en\">ECMAScript 3rd Edition (ECMA-262)</a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition. Implemented in JavaScript 1.2.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/5.1/#sec-15.10.6.21\" hreflang=\"en\">ECMAScript 5.1 (ECMA-262)<br><small>The definition of 'RegExp.exec' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-regexp.prototype.exec\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'RegExp.exec' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-regexp.prototype.exec\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'RegExp.exec' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>   <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div>  <h2 id=\"See_also\">See also</h2> <ul> <li>\n<a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions\">Regular Expressions</a> chapter in the <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide\">JavaScript Guide</a>\n</li> <li><a href=\"../regexp\"><code>RegExp</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/exec$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/exec\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/exec</a>\n  </p>\n</div>\n","global_objects/array/shift":"<h1>array.shift</h1> <p>The <code><strong>shift()</strong></code> method removes the <strong>first</strong> element from an array and returns that removed element. This method changes the length of the array.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/array-shift.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\"><var>arr</var>.shift()</pre> <h3 id=\"Return_value\">Return value</h3> <p>The removed element from the array; <a href=\"../undefined\"><code>undefined</code></a> if the array is empty.</p> <h2 id=\"Description\">Description</h2> <p>The <code>shift</code> method removes the element at the zeroeth index and shifts the values at consecutive indexes down, then returns the removed value. If the <a href=\"length\"><code>length</code></a> property is 0, <a href=\"../undefined\"><code>undefined</code></a> is returned.</p> <p><code>shift</code> is intentionally generic; this method can be <a href=\"../function/call\">called</a> or <a href=\"../function/apply\">applied</a> to objects resembling arrays. Objects which do not contain a <code>length</code> property reflecting the last in a series of consecutive, zero-based numerical properties may not behave in any meaningful manner.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Removing_an_element_from_an_array\">Removing an element from an array</h3> <p>The following code displays the <code>myFish</code> array before and after removing its first element. It also displays the removed element:</p> <pre data-language=\"js\">var myFish = ['angel', 'clown', 'mandarin', 'surgeon'];\n\nconsole.log('myFish before:', JSON.stringify(myFish));\n// myFish before: ['angel', 'clown', 'mandarin', 'surgeon']\n\nvar shifted = myFish.shift(); \n\nconsole.log('myFish after:', myFish); \n// myFish after: ['clown', 'mandarin', 'surgeon']\n\nconsole.log('Removed this element:', shifted); \n// Removed this element: angel\n</pre> <h3 id=\"Using_shift()_method_in_while_loop\">Using shift() method in while loop</h3> <p>The shift() method is often used in condition inside while loop. In the following example every iteration will remove the next element from an array, until it is empty:</p> <pre data-language=\"js\">var names = [\"Andrew\", \"Edward\", \"Paul\", \"Chris\" ,\"John\"];\n\nwhile( (i = names.shift()) !== undefined ) {\n    console.log(i);\n}\n// Andrew, Edward, Paul, Chris, John\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/publications/files/ECMA-ST-ARCH/ECMA-262,%203rd%20edition,%20December%201999.pdf\" hreflang=\"en\">ECMAScript 3rd Edition (ECMA-262)</a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition. Implemented in JavaScript 1.2.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/5.1/#sec-15.4.4.9\" hreflang=\"en\">ECMAScript 5.1 (ECMA-262)<br><small>The definition of 'Array.prototype.shift' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-array.prototype.shift\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Array.prototype.shift' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-array.prototype.shift\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Array.prototype.shift' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>   <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> 5.5</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div>  <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"push\"><code>Array.prototype.push()</code></a></li> <li><a href=\"pop\"><code>Array.prototype.pop()</code></a></li> <li><a href=\"unshift\"><code>Array.prototype.unshift()</code></a></li> <li><a href=\"concat\"><code>Array.prototype.concat()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/shift$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/shift\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/shift</a>\n  </p>\n</div>\n","global_objects/array/unshift":"<h1>array.unshift</h1> <p>The <code><strong>unshift()</strong></code> method adds one or more elements to the beginning of an array and returns the new length of the array.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/array-unshift.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe> <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\"><var>arr</var>.unshift(<var>element1</var>[, ...[, <var>elementN</var>]])</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><code>element<em>N</em></code></dt> <dd>The elements to add to the front of the array.</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p>The new <a href=\"length\"><code>length</code></a> property of the object upon which the method was called.</p> <h2 id=\"Description\">Description</h2> <p>The <code>unshift</code> method inserts the given values to the beginning of an array-like object.</p> <p><code>unshift</code> is intentionally generic; this method can be <a href=\"../function/call\">called</a> or <a href=\"../function/apply\">applied</a> to objects resembling arrays. Objects which do not contain a <code>length</code> property reflecting the last in a series of consecutive, zero-based numerical properties may not behave in any meaningful manner.</p> <h2 id=\"Examples\">Examples</h2> <pre data-language=\"js\">var arr = [1, 2];\n\narr.unshift(0); // result of call is 3, the new array length\n// arr is [0, 1, 2]\n\narr.unshift(-2, -1); // = 5\n// arr is [-2, -1, 0, 1, 2]\n\narr.unshift([-3]);\n// arr is [[-3], -2, -1, 0, 1, 2]\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/publications/files/ECMA-ST-ARCH/ECMA-262,%203rd%20edition,%20December%201999.pdf\" hreflang=\"en\">ECMAScript 3rd Edition (ECMA-262)</a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition. Implemented in JavaScript 1.2.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/5.1/#sec-15.4.4.13\" hreflang=\"en\">ECMAScript 5.1 (ECMA-262)<br><small>The definition of 'Array.prototype.unshift' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-array.prototype.unshift\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Array.prototype.unshift' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-array.prototype.unshift\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Array.prototype.unshift' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>   <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> 5.5</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div>  <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"push\"><code>Array.prototype.push()</code></a></li> <li><a href=\"pop\"><code>Array.prototype.pop()</code></a></li> <li><a href=\"shift\"><code>Array.prototype.shift()</code></a></li> <li><a href=\"concat\"><code>Array.prototype.concat()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/unshift$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/unshift\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/unshift</a>\n  </p>\n</div>\n","global_objects/array/@@species":"<h1>Array.@@species</h1> <p>The <code><strong>Array[@@species]</strong></code> accessor property returns the <code>Array</code> constructor.</p> <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\">Array[Symbol.species]\n</pre> <h3 id=\"Return_value\">Return value</h3> <p>The <a href=\"../array\"><code>Array</code></a> constructor.</p> <h2 id=\"Description\">Description</h2> <p>The <code>species</code> accessor property returns the default constructor for <code>Array</code> objects. Subclass constructors may override it to change the constructor assignment.</p> <h2 id=\"Examples\">Examples</h2> <p>The <code>species</code> property returns the default constructor function, which is the <code>Array</code> constructor for <code>Array</code> objects:</p> <pre data-language=\"js\">Array[Symbol.species]; // function Array()</pre> <p>In a derived collection object (e.g. your custom array <code>MyArray</code>), the <code>MyArray</code> species is the <code>MyArray</code> constructor. However, you might want to overwrite this, in order to return parent <code>Array</code> objects in your derived class methods:</p> <pre data-language=\"js\">class MyArray extends Array {\n  // Overwrite MyArray species to the parent Array constructor\n  static get [Symbol.species]() { return Array; }\n}</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-get-array-@@species\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'get Array [ @@species ]' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-get-array-@@species\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'get Array [ @@species ]' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>   <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td> ? </td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 48</td>\n<td> ? </td>\n<td> ? </td>\n<td> ? </td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td> ? </td>\n<td> ? </td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 48</td>\n<td> ? </td>\n<td> ? </td>\n<td> ? </td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes bc-has-history\"> 6.5.0\n<section class=\"bc-history\" id=\"sect1\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 6.5.0\n</dt>\n\n<dt class=\"bc-supports-yes bc-supports\"> 6.0.0<div class=\"bc-icons\">Disabled </div>\n</dt>\n<dd>Disabled From version 6.0.0: this feature is behind the <code>--harmony</code> runtime flag.</dd>\n</dl></section>\n</td>\n</tr></tbody>\n</table>\n</div>  <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"../array\"><code>Array</code></a></li> <li><a href=\"../symbol/species\"><code>Symbol.species</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/@@species$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/@@species\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/@@species</a>\n  </p>\n</div>\n","global_objects/array/prototype":"<h1>Array.prototype</h1> <h2 id=\"Description\">Description</h2> <p><a href=\"../array\"><code>Array</code></a> instances inherit from <code>Array.prototype</code>. As with all constructors, you can change the constructor's prototype object to make changes to all <a href=\"../array\"><code>Array</code></a> instances. For example, you can add new methods and properties to extend all <code>Array</code> objects. This is used for <a href=\"https://developer.mozilla.org/en-US/docs/Glossary/Polyfill\">polyfilling</a>, for example.</p> <p>However, adding non-standard methods to the array object can cause issues later, either with your own code, or when <a href=\"https://developers.google.com/web/updates/2018/03/smooshgate\">adding features to JavaScript</a>.</p> <p>Little known fact: <code>Array.prototype</code> itself is an <a href=\"../array\"><code>Array</code></a>:</p> <pre data-language=\"js\">Array.isArray(Array.prototype); // true\n</pre> <div class=\"_table\"><table class=\"standard-table\"> <thead> <tr> <th colspan=\"2\" class=\"header\">Property attributes of <code>Array.prototype</code>\n</th> </tr> </thead> <tbody> <tr> <td>Writable</td> <td>no</td> </tr> <tr> <td>Enumerable</td> <td>no</td> </tr> <tr> <td>Configurable</td> <td>no</td> </tr> </tbody> </table></div> <h2 id=\"Properties\">Properties</h2> <dl> <dt><code>Array.prototype.constructor</code></dt> <dd>Specifies the function that creates an object's prototype.</dd> <dt><a href=\"length\"><code>Array.prototype.length</code></a></dt> <dd>Reflects the number of elements in an array.</dd> <dt><a href=\"@@unscopables\"><code>Array.prototype[@@unscopables]</code></a></dt> <dd>A symbol containing property names to exclude from a <code><a href=\"../../statements/with\">with</a></code> binding scope.</dd> </dl> <h2 id=\"Methods\">Methods</h2> <h3 id=\"Mutator_methods\">Mutator methods</h3> <p>These methods modify the array:</p> <dl> <dt><a href=\"copywithin\"><code>Array.prototype.copyWithin()</code></a></dt> <dd>Copies a sequence of array elements within the array.</dd> <dt><a href=\"fill\"><code>Array.prototype.fill()</code></a></dt> <dd>Fills all the elements of an array from a start index to an end index with a static value.</dd> <dt><a href=\"pop\"><code>Array.prototype.pop()</code></a></dt> <dd>Removes the last element from an array and returns that element.</dd> <dt><a href=\"push\"><code>Array.prototype.push()</code></a></dt> <dd>Adds one or more elements to the end of an array and returns the new length of the array.</dd> <dt><a href=\"reverse\"><code>Array.prototype.reverse()</code></a></dt> <dd>Reverses the order of the elements of an array in place — the first becomes the last, and the last becomes the first.</dd> <dt><a href=\"shift\"><code>Array.prototype.shift()</code></a></dt> <dd>Removes the first element from an array and returns that element.</dd> <dt><a href=\"sort\"><code>Array.prototype.sort()</code></a></dt> <dd>Sorts the elements of an array in place and returns the array.</dd> <dt><a href=\"splice\"><code>Array.prototype.splice()</code></a></dt> <dd>Adds and/or removes elements from an array.</dd> <dt><a href=\"unshift\"><code>Array.prototype.unshift()</code></a></dt> <dd>Adds one or more elements to the front of an array and returns the new length of the array.</dd> </dl> <h3 id=\"Accessor_methods\">Accessor methods</h3> <p>These methods do not modify the array and return some representation of the array.</p> <dl> <dt><a href=\"concat\"><code>Array.prototype.concat()</code></a></dt> <dd>Returns a new array comprised of this array joined with other array(s) and/or value(s).</dd> <dt><a href=\"includes\"><code>Array.prototype.includes()</code></a></dt> <dd>Determines whether an array contains a certain element, returning <code>true</code> or <code>false</code> as appropriate.</dd> <dt><a href=\"indexof\"><code>Array.prototype.indexOf()</code></a></dt> <dd>Returns the first (least) index of an element within the array equal to the specified value, or -1 if none is found.</dd> <dt><a href=\"join\"><code>Array.prototype.join()</code></a></dt> <dd>Joins all elements of an array into a string.</dd> <dt><a href=\"lastindexof\"><code>Array.prototype.lastIndexOf()</code></a></dt> <dd>Returns the last (greatest) index of an element within the array equal to the specified value, or -1 if none is found.</dd> <dt><a href=\"slice\"><code>Array.prototype.slice()</code></a></dt> <dd>Extracts a section of an array and returns a new array.</dd> <dt>\n<a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/toSource\"><code>Array.prototype.toSource()</code></a> \n</dt> <dd>Returns an array literal representing the specified array; you can use this value to create a new array. Overrides the <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/toSource\"><code>Object.prototype.toSource()</code></a> method.</dd> <dt><a href=\"tostring\"><code>Array.prototype.toString()</code></a></dt> <dd>Returns a string representing the array and its elements. Overrides the <a href=\"../object/tostring\"><code>Object.prototype.toString()</code></a> method.</dd> <dt><a href=\"tolocalestring\"><code>Array.prototype.toLocaleString()</code></a></dt> <dd>Returns a localized string representing the array and its elements. Overrides the <a href=\"../object/tolocalestring\"><code>Object.prototype.toLocaleString()</code></a> method.</dd> </dl> <h3 id=\"Iteration_methods\">Iteration methods</h3> <p>Several methods take as arguments functions to be called back while processing the array. When these methods are called, the <code>length</code> of the array is sampled, and any element added beyond this length from within the callback is not visited. Other changes to the array (setting the value of or deleting an element) may affect the results of the operation if the method visits the changed element afterwards. While the specific behavior of these methods in such cases is well-defined, you should not rely upon it so as not to confuse others who might read your code. If you must mutate the array, copy into a new array instead.</p> <dl> <dt><a href=\"entries\"><code>Array.prototype.entries()</code></a></dt> <dd>Returns a new <code>Array Iterator</code> object that contains the key/value pairs for each index in the array.</dd> <dt><a href=\"every\"><code>Array.prototype.every()</code></a></dt> <dd>Returns true if every element in this array satisfies the provided testing function.</dd> <dt><a href=\"filter\"><code>Array.prototype.filter()</code></a></dt> <dd>Creates a new array with all of the elements of this array for which the provided filtering function returns true.</dd> <dt><a href=\"find\"><code>Array.prototype.find()</code></a></dt> <dd>Returns the found value in the array, if an element in the array satisfies the provided testing function or <code>undefined</code> if not found.</dd> <dt><a href=\"findindex\"><code>Array.prototype.findIndex()</code></a></dt> <dd>Returns the found index in the array, if an element in the array satisfies the provided testing function or -1 if not found.</dd> <dt><a href=\"foreach\"><code>Array.prototype.forEach()</code></a></dt> <dd>Calls a function for each element in the array.</dd> <dt><a href=\"keys\"><code>Array.prototype.keys()</code></a></dt> <dd>Returns a new <code>Array Iterator</code> that contains the keys for each index in the array.</dd> <dt><a href=\"map\"><code>Array.prototype.map()</code></a></dt> <dd>Creates a new array with the results of calling a provided function on every element in this array.</dd> <dt><a href=\"reduce\"><code>Array.prototype.reduce()</code></a></dt> <dd>Apply a function against an accumulator and each value of the array (from left-to-right) as to reduce it to a single value.</dd> <dt><a href=\"reduceright\"><code>Array.prototype.reduceRight()</code></a></dt> <dd>Apply a function against an accumulator and each value of the array (from right-to-left) as to reduce it to a single value.</dd> <dt><a href=\"some\"><code>Array.prototype.some()</code></a></dt> <dd>Returns true if at least one element in this array satisfies the provided testing function.</dd> <dt><a href=\"values\"><code>Array.prototype.values()</code></a></dt> <dd>Returns a new <code>Array Iterator</code> object that contains the values for each index in the array.</dd> <dt><a href=\"@@iterator\"><code>Array.prototype[@@iterator]()</code></a></dt> <dd>Returns a new <code>Array Iterator</code> object that contains the values for each index in the array.</dd> </dl> <h3 id=\"Generic_methods_(non-standard)\">Generic methods (non-standard)</h3> <p>Many methods on the JavaScript Array object are designed to be generally applied to all objects which “look like” Arrays. That is, they can be used on any object which has a <code>length</code> property, and which can usefully be accessed using numeric property names (as with <code>array[5]</code> indexing). Some methods, such as <a href=\"join\"><code>join</code></a>, only read the <code>length</code> and numeric properties of the object they are called on. Others, like <a href=\"reverse\"><code>reverse</code></a>, require that the object's numeric properties and <code>length</code> be mutable; these methods can therefore not be called on objects like <a href=\"../string\"><code>String</code></a>, which does not permit its <code>length</code> property or synthesized numeric properties to be set.</p> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <thead> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> </thead> <tbody> <tr> <td><a href=\"https://www.ecma-international.org/publications/files/ECMA-ST-ARCH/ECMA-262,%201st%20edition,%20June%201997.pdf\" hreflang=\"en\">ECMAScript 1st Edition (ECMA-262)</a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/5.1/#sec-15.4.3.1\" hreflang=\"en\">ECMAScript 5.1 (ECMA-262)<br><small>The definition of 'Array.prototype' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-array.prototype\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Array.prototype' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Added the <code>copyWithin()</code>, <code>fill()</code>, <code>entries()</code>, <code>keys()</code>, <code>values()</code>, <code>find()</code>, <code>findIndex()</code> methods.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/7.0/#sec-array.prototype\" hreflang=\"en\">ECMAScript 2016 (ECMA-262)<br><small>The definition of 'Array.prototype' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Added the <code>includes()</code> method.</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-array.prototype\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Array.prototype' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"../array\"><code>Array</code></a></li> <li><a href=\"../function/prototype\"><code>Function.prototype</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/prototype$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/prototype\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/prototype</a>\n  </p>\n</div>\n","global_objects/sharedarraybuffer/bytelength":"<h1>sharedArrayBuffer.byteLength</h1> <p>The <code><strong>byteLength</strong></code> accessor property represents the length of an <a href=\"../sharedarraybuffer\"><code>SharedArrayBuffer</code></a> in bytes.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/sharedarraybuffer-bytelength.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\"><var>sab</var>.byteLength</pre> <h2 id=\"Description\">Description</h2> <p>The <code>byteLength</code> property is an accessor property whose set accessor function is <code>undefined</code>, meaning that you can only read this property. The value is established when the shared array is constructed and cannot be changed.</p> <h2 id=\"Examples\">Examples</h2> <pre data-language=\"js\">var sab = new SharedArrayBuffer(1024);\nsab.byteLength; // 1024\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-get-sharedarraybuffer.prototype.bytelength\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'SharedArrayBuffer.prototype.byteLength' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td>Initial definition in ES2017.</td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes bc-has-history\"> 68\n<section class=\"bc-history\" id=\"sect1\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 68\n</dt>\n\n<dt class=\"bc-supports-no bc-supports\">60 — 63\n</dt>\n<dd> Chrome disabled SharedArrayBuffer on January 5, 2018 to help reduce the efficacy of <a href=\"https://www.chromium.org/Home/chromium-security/ssca\">speculative side-channel attacks</a>. This was a temporary removal while mitigations were put in place.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-yes bc-has-history\"> 16\n<section class=\"bc-history\" id=\"sect2\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 16\n</dt>\n<dd> Support was removed to mitigate <a href=\"https://blogs.windows.com/msedgedev/2018/01/03/speculative-execution-mitigations-microsoft-edge-internet-explorer\">speculative execution side-channel attacks (Windows blog)</a>.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-yes bc-has-history\"> 57<div class=\"bc-icons\"> Disabled </div>\n<section class=\"bc-history\" id=\"sect3\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 57<div class=\"bc-icons\"> Disabled </div>\n</dt>\n<dd> Support was disabled by default to mitigate <a href=\"https://blog.mozilla.org/security/2018/01/03/mitigations-landing-new-class-timing-attack/\">speculative execution side-channel attacks (Mozilla Security Blog)</a>.</dd>\n<dd>Disabled From version 57: this feature is behind the <code>javascript.options.shared_memory</code> preference (needs to be set to <code>true</code>). To change preferences in Firefox, visit about:config.</dd>\n<dt class=\"bc-supports-no bc-supports\">55 — 57\n</dt>\n\n<dt class=\"bc-supports-no bc-supports\">46 — 55<div class=\"bc-icons\">Disabled </div>\n</dt>\n<dd>Disabled From version 46 until version 55 (exclusive): this feature is behind the <code>javascript.options.shared_memory</code> preference (needs to be set to <code>true</code>). To change preferences in Firefox, visit about:config.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\">10.1 — ?</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-no bc-has-history\">60 — 63\n<section class=\"bc-history\" id=\"sect4\"><dl>\n<dt class=\"bc-supports-no bc-supports\">60 — 63\n</dt>\n<dd> Chrome disabled SharedArrayBuffer on January 5, 2018 to help reduce the efficacy of <a href=\"https://www.chromium.org/Home/chromium-security/ssca\">speculative side-channel attacks</a>. This is intended as a temporary measure until other mitigations are in place.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-no bc-has-history\">60 — 63\n<section class=\"bc-history\" id=\"sect5\"><dl>\n<dt class=\"bc-supports-no bc-supports\">60 — 63\n</dt>\n<dd> Chrome disabled SharedArrayBuffer on January 5, 2018 to help reduce the efficacy of <a href=\"https://www.chromium.org/Home/chromium-security/ssca\">speculative side-channel attacks</a>. This is intended as a temporary measure until other mitigations are in place.</dd>\n</dl></section>\n</td>\n<td> ? </td>\n<td class=\"bc-supports-yes bc-has-history\"> 57<div class=\"bc-icons\"> Disabled </div>\n<section class=\"bc-history\" id=\"sect6\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 57<div class=\"bc-icons\"> Disabled </div>\n</dt>\n<dd> Support was disabled by default to mitigate <a href=\"https://blog.mozilla.org/security/2018/01/03/mitigations-landing-new-class-timing-attack/\">speculative execution side-channel attacks (Mozilla Security Blog)</a>.</dd>\n<dd>Disabled From version 57: this feature is behind the <code>javascript.options.shared_memory</code> preference (needs to be set to <code>true</code>). To change preferences in Firefox, visit about:config.</dd>\n<dt class=\"bc-supports-no bc-supports\">55 — 57\n</dt>\n\n<dt class=\"bc-supports-no bc-supports\">46 — 55<div class=\"bc-icons\">Disabled </div>\n</dt>\n<dd>Disabled From version 46 until version 55 (exclusive): this feature is behind the <code>javascript.options.shared_memory</code> preference (needs to be set to <code>true</code>). To change preferences in Firefox, visit about:config.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 8.10.0</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"../sharedarraybuffer\"><code>SharedArrayBuffer</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SharedArrayBuffer/byteLength$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SharedArrayBuffer/byteLength\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SharedArrayBuffer/byteLength</a>\n  </p>\n</div>\n","global_objects/sharedarraybuffer/prototype":"<h1>SharedArrayBuffer.prototype</h1> <p>The <code>SharedArrayBuffer.prototype</code> property represents the prototype for the <a href=\"../sharedarraybuffer\"><code>SharedArrayBuffer</code></a> object.</p> <div class=\"_table\"><table class=\"standard-table\"> <thead> <tr> <th colspan=\"2\" class=\"header\">Property attributes of <code>SharedArrayBuffer.prototype</code>\n</th> </tr> </thead> <tbody> <tr> <td>Writable</td> <td>no</td> </tr> <tr> <td>Enumerable</td> <td>no</td> </tr> <tr> <td>Configurable</td> <td>no</td> </tr> </tbody> </table></div> <h2 id=\"Description\">Description</h2> <p><code>SharedArrayBuffer</code> instances inherit from <code>SharedArrayBuffer.prototype</code>. As with all constructors, you can change the constructor's prototype object to make changes to all <code>SharedArrayBuffer</code> instances.</p> <h2 id=\"Properties\">Properties</h2> <dl> <dt>SharedArrayBuffer.prototype.constructor</dt> <dd>Specifies the function that creates an object's prototype. The initial value is the standard built-in <code>SharedArrayBuffer</code> constructor.</dd> <dt>\n<a href=\"bytelength\"><code>SharedArrayBuffer.prototype.byteLength</code></a> <span class=\"inlineIndicator readOnly readOnlyInline\">Read only </span>\n</dt> <dd>The size, in bytes, of the array. This is established when the array is constructed and cannot be changed. <strong>Read only.</strong>\n</dd> </dl> <h2 id=\"Methods\">Methods</h2> <dl> <dt><a href=\"slice\"><code>SharedArrayBuffer.prototype.slice(begin, end)</code></a></dt> <dd>Returns a new <code>SharedArrayBuffer</code> whose contents are a copy of this <code>SharedArrayBuffer</code>'s bytes from <code>begin</code>, inclusive, up to <code>end</code>, exclusive. If either <code>begin</code> or <code>end</code> is negative, it refers to an index from the end of the array, as opposed to from the beginning.</dd> </dl> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-sharedarraybuffer.prototype\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'SharedArrayBuffer.prototype' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td>Initial definition in ES2017.</td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes bc-has-history\"> 68\n<section class=\"bc-history\" id=\"sect1\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 68\n</dt>\n\n<dt class=\"bc-supports-no bc-supports\">60 — 63\n</dt>\n<dd> Chrome disabled SharedArrayBuffer on January 5, 2018 to help reduce the efficacy of <a href=\"https://www.chromium.org/Home/chromium-security/ssca\">speculative side-channel attacks</a>. This was a temporary removal while mitigations were put in place.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-no bc-has-history\"> No\n<section class=\"bc-history\" id=\"sect2\"><dl>\n<dt class=\"bc-supports-no bc-supports\"> No\n</dt>\n<dd> Support was removed to mitigate <a href=\"https://blogs.windows.com/msedgedev/2018/01/03/speculative-execution-mitigations-microsoft-edge-internet-explorer\">speculative execution side-channel attacks (Windows blog)</a>.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-yes bc-has-history\"> 57<div class=\"bc-icons\"> Disabled </div>\n<section class=\"bc-history\" id=\"sect3\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 57<div class=\"bc-icons\"> Disabled </div>\n</dt>\n<dd> Support was disabled by default to mitigate <a href=\"https://blog.mozilla.org/security/2018/01/03/mitigations-landing-new-class-timing-attack/\">speculative execution side-channel attacks (Mozilla Security Blog)</a>.</dd>\n<dd>Disabled From version 57: this feature is behind the <code>javascript.options.shared_memory</code> preference (needs to be set to <code>true</code>). To change preferences in Firefox, visit about:config.</dd>\n<dt class=\"bc-supports-no bc-supports\">55 — 57\n</dt>\n\n<dt class=\"bc-supports-no bc-supports\">46 — 55<div class=\"bc-icons\">Disabled </div>\n</dt>\n<dd>Disabled From version 46 until version 55 (exclusive): this feature is behind the <code>javascript.options.shared_memory</code> preference (needs to be set to <code>true</code>). To change preferences in Firefox, visit about:config.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\">10.1 — ?</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-no bc-has-history\">60 — 63\n<section class=\"bc-history\" id=\"sect4\"><dl>\n<dt class=\"bc-supports-no bc-supports\">60 — 63\n</dt>\n<dd> Chrome disabled SharedArrayBuffer on January 5, 2018 to help reduce the efficacy of <a href=\"https://www.chromium.org/Home/chromium-security/ssca\">speculative side-channel attacks</a>. This is intended as a temporary measure until other mitigations are in place.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-no bc-has-history\">60 — 63\n<section class=\"bc-history\" id=\"sect5\"><dl>\n<dt class=\"bc-supports-no bc-supports\">60 — 63\n</dt>\n<dd> Chrome disabled SharedArrayBuffer on January 5, 2018 to help reduce the efficacy of <a href=\"https://www.chromium.org/Home/chromium-security/ssca\">speculative side-channel attacks</a>. This is intended as a temporary measure until other mitigations are in place.</dd>\n</dl></section>\n</td>\n<td> ? </td>\n<td class=\"bc-supports-yes bc-has-history\"> 57<div class=\"bc-icons\"> Disabled </div>\n<section class=\"bc-history\" id=\"sect6\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 57<div class=\"bc-icons\"> Disabled </div>\n</dt>\n<dd> Support was disabled by default to mitigate <a href=\"https://blog.mozilla.org/security/2018/01/03/mitigations-landing-new-class-timing-attack/\">speculative execution side-channel attacks (Mozilla Security Blog)</a>.</dd>\n<dd>Disabled From version 57: this feature is behind the <code>javascript.options.shared_memory</code> preference (needs to be set to <code>true</code>). To change preferences in Firefox, visit about:config.</dd>\n<dt class=\"bc-supports-no bc-supports\">55 — 57\n</dt>\n\n<dt class=\"bc-supports-no bc-supports\">46 — 55<div class=\"bc-icons\">Disabled </div>\n</dt>\n<dd>Disabled From version 46 until version 55 (exclusive): this feature is behind the <code>javascript.options.shared_memory</code> preference (needs to be set to <code>true</code>). To change preferences in Firefox, visit about:config.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-no\"> No</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"../sharedarraybuffer\"><code>SharedArrayBuffer</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SharedArrayBuffer/prototype$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SharedArrayBuffer/prototype\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SharedArrayBuffer/prototype</a>\n  </p>\n</div>\n","global_objects/sharedarraybuffer/slice":"<h1>sharedArrayBuffer.slice</h1> <p>The <code><strong>SharedArrayBuffer.prototype.slice()</strong></code> method returns a new <a href=\"../sharedarraybuffer\"><code>SharedArrayBuffer</code></a> whose contents are a copy of <code>this SharedArrayBuffer</code>'s bytes from begin, inclusive, up to end, exclusive. If either begin or end is negative, it refers to an index from the end of the array, as opposed to from the beginning. This method has the same algorithm as <a href=\"../array/slice\"><code>Array.prototype.slice()</code></a><em>.</em></p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/sharedarraybuffer-slice.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\"><var>sab</var>.slice()\n<var>sab</var>.slice(begin)\n<var>sab</var>.slice(begin, end)</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt>\n<code>begin</code> <span class=\"inlineIndicator optional optionalInline\">Optional</span>\n</dt> <dd>Zero-based index at which to begin extraction.</dd> <dd>A negative index can be used, indicating an offset from the end of the sequence. <code>slice(-2)</code> extracts the last two elements in the sequence.</dd> <dd>If <code>begin</code> is undefined, <code>slice</code> begins from index <code>0</code>.</dd> <dt>\n<code>end</code> <span class=\"inlineIndicator optional optionalInline\">Optional</span>\n</dt> <dd>Zero-based index <em>before</em> which to end extraction. <code>slice</code> extracts up to but not including <code>end</code>.</dd> <dd>For example, <code>slice(1,4)</code> extracts the second element through the fourth element (elements indexed 1, 2, and 3).</dd> <dd>A negative index can be used, indicating an offset from the end of the sequence. <code>slice(2,-1)</code> extracts the third element through the second-to-last element in the sequence.</dd> <dd>If <code>end</code> is omitted, <code>slice</code> extracts through the end of the sequence (<code>sab.byteLength</code>)<code>.</code>\n</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p>A new <a href=\"../sharedarraybuffer\"><code>SharedArrayBuffer</code></a> containing the extracted elements.</p> <h2 id=\"Examples\">Examples</h2> <pre data-language=\"js\">var sab = new SharedArrayBuffer(1024);\nsab.slice();    // SharedArrayBuffer { byteLength: 1024 }\nsab.slice(2);   // SharedArrayBuffer { byteLength: 1022 }\nsab.slice(-2);  // SharedArrayBuffer { byteLength: 2 }\nsab.slice(0, 1); // SharedArrayBuffer { byteLength: 1 }\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-sharedarraybuffer.prototype.slice\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'SharedArrayBuffer.prototype.slice' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td>Initial definition in ES2017.</td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes bc-has-history\"> 68\n<section class=\"bc-history\" id=\"sect1\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 68\n</dt>\n\n<dt class=\"bc-supports-no bc-supports\">60 — 63\n</dt>\n<dd> Chrome disabled SharedArrayBuffer on January 5, 2018 to help reduce the efficacy of <a href=\"https://www.chromium.org/Home/chromium-security/ssca\">speculative side-channel attacks</a>. This was a temporary removal while mitigations were put in place.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-yes bc-has-history\"> 16\n<section class=\"bc-history\" id=\"sect2\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 16\n</dt>\n<dd> Support was removed to mitigate <a href=\"https://blogs.windows.com/msedgedev/2018/01/03/speculative-execution-mitigations-microsoft-edge-internet-explorer\">speculative execution side-channel attacks (Windows blog)</a>.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-yes bc-has-history\"> 57<div class=\"bc-icons\"> Disabled </div>\n<section class=\"bc-history\" id=\"sect3\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 57<div class=\"bc-icons\"> Disabled </div>\n</dt>\n<dd> Support was disabled by default to mitigate <a href=\"https://blog.mozilla.org/security/2018/01/03/mitigations-landing-new-class-timing-attack/\">speculative execution side-channel attacks (Mozilla Security Blog)</a>.</dd>\n<dd>Disabled From version 57: this feature is behind the <code>javascript.options.shared_memory</code> preference (needs to be set to <code>true</code>). To change preferences in Firefox, visit about:config.</dd>\n<dt class=\"bc-supports-no bc-supports\">55 — 57\n</dt>\n\n<dt class=\"bc-supports-no bc-supports\">46 — 55<div class=\"bc-icons\">Disabled </div>\n</dt>\n<dd>Disabled From version 46 until version 55 (exclusive): this feature is behind the <code>javascript.options.shared_memory</code> preference (needs to be set to <code>true</code>). To change preferences in Firefox, visit about:config.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\">10.1 — ?</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-no bc-has-history\">60 — 63\n<section class=\"bc-history\" id=\"sect4\"><dl>\n<dt class=\"bc-supports-no bc-supports\">60 — 63\n</dt>\n<dd> Chrome disabled SharedArrayBuffer on January 5, 2018 to help reduce the efficacy of <a href=\"https://www.chromium.org/Home/chromium-security/ssca\">speculative side-channel attacks</a>. This is intended as a temporary measure until other mitigations are in place.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-no bc-has-history\">60 — 63\n<section class=\"bc-history\" id=\"sect5\"><dl>\n<dt class=\"bc-supports-no bc-supports\">60 — 63\n</dt>\n<dd> Chrome disabled SharedArrayBuffer on January 5, 2018 to help reduce the efficacy of <a href=\"https://www.chromium.org/Home/chromium-security/ssca\">speculative side-channel attacks</a>. This is intended as a temporary measure until other mitigations are in place.</dd>\n</dl></section>\n</td>\n<td> ? </td>\n<td class=\"bc-supports-yes bc-has-history\"> 57<div class=\"bc-icons\"> Disabled </div>\n<section class=\"bc-history\" id=\"sect6\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 57<div class=\"bc-icons\"> Disabled </div>\n</dt>\n<dd> Support was disabled by default to mitigate <a href=\"https://blog.mozilla.org/security/2018/01/03/mitigations-landing-new-class-timing-attack/\">speculative execution side-channel attacks (Mozilla Security Blog)</a>.</dd>\n<dd>Disabled From version 57: this feature is behind the <code>javascript.options.shared_memory</code> preference (needs to be set to <code>true</code>). To change preferences in Firefox, visit about:config.</dd>\n<dt class=\"bc-supports-no bc-supports\">55 — 57\n</dt>\n\n<dt class=\"bc-supports-no bc-supports\">46 — 55<div class=\"bc-icons\">Disabled </div>\n</dt>\n<dd>Disabled From version 46 until version 55 (exclusive): this feature is behind the <code>javascript.options.shared_memory</code> preference (needs to be set to <code>true</code>). To change preferences in Firefox, visit about:config.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 8.10.0</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"../sharedarraybuffer\"><code>SharedArrayBuffer</code></a></li> <li><a href=\"../array/slice\"><code>Array.prototype.slice()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SharedArrayBuffer/slice$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SharedArrayBuffer/slice\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SharedArrayBuffer/slice</a>\n  </p>\n</div>\n","global_objects/regexp/prototype":"<h1>RegExp.prototype</h1> <p>The <code>RegExp.prototype</code> property represents the prototype object for the <a href=\"../regexp\"><code>RegExp</code></a> constructor.</p> <div class=\"_table\"><table class=\"standard-table\"> <thead> <tr> <th colspan=\"2\" class=\"header\">Property attributes of <code>RegExp.prototype</code>\n</th> </tr> </thead> <tbody> <tr> <td>Writable</td> <td>no</td> </tr> <tr> <td>Enumerable</td> <td>no</td> </tr> <tr> <td>Configurable</td> <td>no</td> </tr> </tbody> </table></div> <h2 id=\"Description\">Description</h2> <p>See <a href=\"../regexp\"><code>RegExp</code></a> for a description of <code>RegExp</code> instances. <code>RegExp</code> instances inherit from <code>RegExp.prototype</code>. Modifications to the prototype object are propagated to all <code>RegExp</code> instances.</p> <h2 id=\"Properties\">Properties</h2> <p>See also <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Deprecated_and_obsolete_features#RegExp_Properties\">deprecated <code>RegExp</code> properties.</a></p> <p>Note that several of the <a href=\"../regexp\"><code>RegExp</code></a> properties have both long and short (Perl-like) names. Both names always refer to the same value. Perl is the programming language from which JavaScript modeled its regular expressions.</p> <dl> <dt><code>RegExp.prototype.constructor</code></dt> <dd>Specifies the function that creates an object's prototype.</dd> <dt><a href=\"flags\"><code>RegExp.prototype.flags</code></a></dt> <dd>A string that contains the flags of the <code>RegExp</code> object.</dd> <dt><a href=\"global\"><code>RegExp.prototype.global</code></a></dt> <dd>Whether to test the regular expression against all possible matches in a string, or only against the first.</dd> <dt><a href=\"ignorecase\"><code>RegExp.prototype.ignoreCase</code></a></dt> <dd>Whether to ignore case while attempting a match in a string.</dd> <dt><a href=\"multiline\"><code>RegExp.prototype.multiline</code></a></dt> <dd>Whether or not to search in strings across multiple lines.</dd> <dt><a href=\"source\"><code>RegExp.prototype.source</code></a></dt> <dd>The text of the pattern.</dd> <dt><a href=\"sticky\"><code>RegExp.prototype.sticky</code></a></dt> <dd>Whether or not the search is sticky.</dd> <dt><a href=\"unicode\"><code>RegExp.prototype.unicode</code></a></dt> <dd>Whether or not Unicode features are enabled.</dd> </dl> <h2 id=\"Methods\">Methods</h2> <dl> <dt>\n<a href=\"compile\"><code>RegExp.prototype.compile()</code></a> \n</dt> <dd>(Re-)compiles a regular expression during execution of a script.</dd> <dt><a href=\"exec\"><code>RegExp.prototype.exec()</code></a></dt> <dd>Executes a search for a match in its string parameter.</dd> <dt><a href=\"test\"><code>RegExp.prototype.test()</code></a></dt> <dd>Tests for a match in its string parameter.</dd> <dt><a href=\"@@match\"><code>RegExp.prototype[@@match]()</code></a></dt> <dd>Performs match to given string and returns match result.</dd> <dt><a href=\"@@replace\"><code>RegExp.prototype[@@replace]()</code></a></dt> <dd>Replaces matches in given string with new substring.</dd> <dt><a href=\"@@search\"><code>RegExp.prototype[@@search]()</code></a></dt> <dd>Searches the match in given string and returns the index the pattern found in the string.</dd> <dt><a href=\"@@split\"><code>RegExp.prototype[@@split]()</code></a></dt> <dd>Splits given string into an array by separating the string into substring.</dd> <dt>\n<a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/toSource\"><code>RegExp.prototype.toSource()</code></a> \n</dt> <dd>Returns an object literal representing the specified object; you can use this value to create a new object. Overrides the <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/toSource\"><code>Object.prototype.toSource()</code></a> method.</dd> <dt><a href=\"tostring\"><code>RegExp.prototype.toString()</code></a></dt> <dd>Returns a string representing the specified object. Overrides the <a href=\"../object/tostring\"><code>Object.prototype.toString()</code></a> method.</dd> </dl> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/publications/files/ECMA-ST-ARCH/ECMA-262,%203rd%20edition,%20December%201999.pdf\" hreflang=\"en\">ECMAScript 3rd Edition (ECMA-262)</a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition. Implemented in JavaScript 1.1.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/5.1/#sec-15.10.5.1\" hreflang=\"en\">ECMAScript 5.1 (ECMA-262)<br><small>The definition of 'RegExp' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-regexp.prototype\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'RegExp.prototype' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Added <code>flags</code>, <code>sticky</code> and <code>unicode</code> properties.</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-regexp.prototype\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'RegExp.prototype' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>   <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div>  <h2 id=\"See_also\">See also</h2> <ul> <li>\n<a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions\">Regular Expressions</a> chapter in the <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide\">JavaScript Guide</a>\n</li> <li><a href=\"../regexp\"><code>RegExp</code></a></li> <li><a href=\"../function/prototype\"><code>Function.prototype</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/prototype$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/prototype\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/prototype</a>\n  </p>\n</div>\n","global_objects/regexp/flags":"<h1>regExp.flags</h1> <p>The <code>flags</code> property returns a string consisting of the flags of the current regular expression object.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/regexp-prototype-flags.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <div class=\"_table\"><table class=\"standard-table\"> <thead> <tr> <th colspan=\"2\" class=\"header\">Property attributes of <code>RegExp.prototype.flags</code>\n</th> </tr> </thead> <tbody> <tr> <td>Writable</td> <td>no</td> </tr> <tr> <td>Enumerable</td> <td>no</td> </tr> <tr> <td>Configurable</td> <td>yes</td> </tr> </tbody> </table></div> <h2 id=\"Description\">Description</h2> <p>Flags in the <code>flags</code> property are sorted alphabetically (from left to right, e.g. <code>\"gimuy\"</code>).</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Using_flags\">Using <code>flags</code>\n</h3> <pre data-language=\"js\">/foo/ig.flags;   // \"gi\"\n/bar/myu.flags;  // \"muy\"\n</pre> <h2 id=\"Polyfill\">Polyfill</h2> <pre data-language=\"js\">if (RegExp.prototype.flags === undefined) {\n  Object.defineProperty(RegExp.prototype, 'flags', {\n    configurable: true,\n    get: function() {\n      return this.toString().match(/[gimuy]*$/)[0];\n    }\n  });\n}\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-get-regexp.prototype.flags\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'RegExp.prototype.flags' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-get-regexp.prototype.flags\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'RegExp.prototype.flags' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>   <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 37</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 37</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 6.0.0</td>\n</tr></tbody>\n</table>\n</div>  <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"source\"><code>RegExp.prototype.source</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/flags$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/flags\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/flags</a>\n  </p>\n</div>\n","global_objects/regexp/multiline":"<h1>regExp.multiline</h1> <p>The <code>multiline</code> property indicates whether or not the \"<code>m</code>\" flag is used with the regular expression. <code>multiline</code> is a read-only property of an individual regular expression instance.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/regexp-prototype-multiline.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js taller\" height=\"250\"></iframe>  <div class=\"_table\"><table class=\"standard-table\"> <thead> <tr> <th colspan=\"2\" class=\"header\">Property attributes of <code>RegExp.prototype.multiline</code>\n</th> </tr> </thead> <tbody> <tr> <td>Writable</td> <td>no</td> </tr> <tr> <td>Enumerable</td> <td>no</td> </tr> <tr> <td>Configurable</td> <td>yes</td> </tr> </tbody> </table></div> <h2 id=\"Description\">Description</h2> <p>The value of <code>multiline</code> is a <a href=\"../boolean\"><code>Boolean</code></a> and is true if the \"<code>m</code>\" flag was used; otherwise, false. The \"<code>m</code>\" flag indicates that a multiline input string should be treated as multiple lines. For example, if \"<code>m</code>\" is used, \"<code>^</code>\" and \"<code>$</code>\" change from matching at only the start or end of the entire string to the start or end of any line within the string.</p> <p>You cannot change this property directly.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Using_multiline\">Using <code>multiline</code>\n</h3> <pre data-language=\"js\">var regex = new RegExp('foo', 'm');\n\nconsole.log(regex.multiline); // true\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/publications/files/ECMA-ST-ARCH/ECMA-262,%203rd%20edition,%20December%201999.pdf\" hreflang=\"en\">ECMAScript 3rd Edition (ECMA-262)</a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition. Implemented in JavaScript 1.2. JavaScript 1.5: <code>multiline</code> is a property of a <a href=\"../regexp\"><code>RegExp</code></a> instance, not the <a href=\"../regexp\"><code>RegExp</code></a> object.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/5.1/#sec-15.10.7.4\" hreflang=\"en\">ECMAScript 5.1 (ECMA-262)<br><small>The definition of 'RegExp.prototype.multiline' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-get-regexp.prototype.multiline\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'RegExp.prototype.multiline' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>\n<code>multiline</code> is now a prototype accessor property rather than an instance's own data property.</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-get-regexp.prototype.multiline\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'RegExp.prototype.multiline' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>   <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">Prototype accessor property (ES2015)</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 38</td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n</tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">Prototype accessor property (ES2015)</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 38</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n</tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">Prototype accessor property (ES2015)</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n</tbody>\n</table>\n</div>  <h2 id=\"Compatibility_notes\">Compatibility notes</h2> <ul> <li>Prior to Firefox 48, a non-standard, global <code>RegExp.multiline</code> property existed in addition to this <code>RegExp.prototype.multiline</code> property. It is removed in newer versions (see <a href=\"https://bugzilla.mozilla.org/show_bug.cgi?id=1219757\">bug 1219757</a>). Use the property described on this page or the <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions#Advanced_searching_with_flags\">m flag</a> instead.</li> </ul> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"lastindex\"><code>RegExp.lastIndex</code></a></li> <li><a href=\"global\"><code>RegExp.prototype.global</code></a></li> <li><a href=\"ignorecase\"><code>RegExp.prototype.ignoreCase</code></a></li> <li><a href=\"source\"><code>RegExp.prototype.source</code></a></li> <li><a href=\"sticky\"><code>RegExp.prototype.sticky</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/multiline$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/multiline\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/multiline</a>\n  </p>\n</div>\n","global_objects/regexp/unicode":"<h1>regExp.unicode</h1> <p>The <code>unicode</code> property indicates whether or not the \"<code>u</code>\" flag is used with a regular expression. <code>unicode</code> is a read-only property of an individual regular expression instance.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/regexp-prototype-unicode.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js taller\" height=\"250\"></iframe>  <div class=\"_table\"><table class=\"standard-table\"> <thead> <tr> <th colspan=\"2\" class=\"header\">Property attributes of <code>RegExp.prototype.unicode</code>\n</th> </tr> </thead> <tbody> <tr> <td>Writable</td> <td>no</td> </tr> <tr> <td>Enumerable</td> <td>no</td> </tr> <tr> <td>Configurable</td> <td>yes</td> </tr> </tbody> </table></div> <h2 id=\"Description\">Description</h2> <p>The value of <code>unicode</code> is a <a href=\"../boolean\"><code>Boolean</code></a> and <code>true</code> if the \"<code>u</code>\" flag was used; otherwise <code>false</code>. The \"<code>u</code>\" flag enables various Unicode-related features. With the \"u\" flag, any Unicode code point escapes will be interpreted as such, for example.</p> <p>You cannot change this property directly. It is read-only.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Using_the_unicode_property\">Using the <code>unicode</code> property</h3> <pre data-language=\"js\">var regex = new RegExp('\\u{61}', 'u');\n\nconsole.log(regex.unicode); // true\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-get-regexp.prototype.unicode\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'RegExp.prototype.unicode' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-get-regexp.prototype.unicode\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'RegExp.prototype.unicode' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>   <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 50</td>\n<td class=\"bc-supports-yes bc-has-history\"> 12\n<section class=\"bc-history\" id=\"sect1\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 12\n</dt>\n<dd> Case folding is implemented in version 13</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-yes\"> 46</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 37</td>\n<td class=\"bc-supports-yes\"> 10</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 50</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 46</td>\n<td class=\"bc-supports-yes\"> 37</td>\n<td class=\"bc-supports-yes\"> 10</td>\n<td class=\"bc-supports-yes\"> 5.0</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div>  <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"lastindex\"><code>RegExp.lastIndex</code></a></li> <li><a href=\"global\"><code>RegExp.prototype.global</code></a></li> <li><a href=\"ignorecase\"><code>RegExp.prototype.ignoreCase</code></a></li> <li><a href=\"multiline\"><code>RegExp.prototype.multiline</code></a></li> <li><a href=\"source\"><code>RegExp.prototype.source</code></a></li> <li><a href=\"sticky\"><code>RegExp.prototype.sticky</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/unicode$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/unicode\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/unicode</a>\n  </p>\n</div>\n","global_objects/string/match":"<h1>string.match</h1> <p>The <code>match()</code> method retrieves the matches when matching a <em>string</em> against a <em>regular expression</em>.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/string-match.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\"><var>str</var>.match(<var>regexp</var>)</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><code>regexp</code></dt> <dd>A regular expression object. If a non-RegExp object <code>obj</code> is passed, it is implicitly converted to a <a href=\"../regexp\"><code>RegExp</code></a> by using <code>new RegExp(obj)</code>. If you don't give any parameter and use the match() method directly, you will get an <a href=\"../array\"><code>Array</code></a> with an empty string:[\"\"].</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p>If the string matches the expression, it will return an <a href=\"../array\"><code>Array</code></a> containing the entire matched string as the first element, followed by any results captured in parentheses. If there were no matches, <a href=\"../null\"><code>null</code></a> is returned.</p> <h2 id=\"Description\">Description</h2> <p>If the regular expression does not include the <code>g</code> flag, <code>str.match()</code> will return the same result as <a href=\"../regexp/exec\"><code>RegExp.exec()</code></a>. The returned <a href=\"../array\"><code>Array</code></a> has an extra <code>input</code> property, which contains the original string that was parsed. In addition, it has an <code>index</code> property, which represents the zero-based index of the match in the string.</p> <p>If the regular expression includes the <code>g</code> flag, the method returns an <a href=\"../array\"><code>Array</code></a> containing all matched substrings rather than match objects. Captured groups are not returned. If there were no matches, the method returns <a href=\"../null\"><code>null</code></a>.</p> <h3 id=\"See_also_RegExp_methods\">See also: <code>RegExp</code> methods</h3> <ul> <li>If you need to know if a string matches a regular expression <a href=\"../regexp\"><code>RegExp</code></a>, use <a href=\"../regexp/test\"><code>RegExp.test()</code></a>.</li> <li>If you only want the first match found, you might want to use <a href=\"../regexp/exec\"><code>RegExp.exec()</code></a> instead.</li> <li>if you want to obtain capture groups and the global flag is set, you need to use <a href=\"../regexp/exec\"><code>RegExp.exec()</code></a> instead.</li> </ul> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Using_match()\">Using <code>match()</code>\n</h3> <p>In the following example, <code>match()</code> is used to find <code>'Chapter'</code> followed by 1 or more numeric characters followed by a decimal point and numeric character 0 or more times. The regular expression includes the <code>i</code> flag so that upper/lower case differences will be ignored.</p> <pre data-language=\"js\">var str = 'For more information, see Chapter 3.4.5.1';\nvar re = /see (chapter \\d+(\\.\\d)*)/i;\nvar found = str.match(re);\n\nconsole.log(found);\n\n// logs [ 'see Chapter 3.4.5.1',\n//        'Chapter 3.4.5.1',\n//        '.1',\n//        index: 22,\n//        input: 'For more information, see Chapter 3.4.5.1' ]\n\n// 'see Chapter 3.4.5.1' is the whole match.\n// 'Chapter 3.4.5.1' was captured by '(chapter \\d+(\\.\\d)*)'.\n// '.1' was the last value captured by '(\\.\\d)'.\n// The 'index' property (22) is the zero-based index of the whole match.\n// The 'input' property is the original string that was parsed.</pre> <h3 id=\"Using_global_and_ignore_case_flags_with_match()\">Using global and ignore case flags with <code>match()</code>\n</h3> <p>The following example demonstrates the use of the global and ignore case flags with <code>match()</code>. All letters A through E and a through e are returned, each its own element in the array.</p> <pre data-language=\"js\">var str = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';\nvar regexp = /[A-E]/gi;\nvar matches_array = str.match(regexp);\n\nconsole.log(matches_array);\n// ['A', 'B', 'C', 'D', 'E', 'a', 'b', 'c', 'd', 'e']\n</pre> <h3 id=\"Using_match()_with_no_parameter\">Using <code>match()</code> with no parameter</h3> <pre data-language=\"js\">var str = \"Nothing will come of nothing.\";\n\nstr.match();   // returns [\"\"]</pre> <h3 id=\"A_non-RegExp_object_as_the_parameter\">A non-RegExp object as the parameter</h3> <p>When the parameter is a string or a number, it is implicitly converted to a <a href=\"../regexp\"><code>RegExp</code></a> by using new RegExp(obj). If it is a positive number with a positive sign,the RegExp() method will ignore the positive sign. </p> <pre data-language=\"js\">var str1 = \"NaN means not a number. Infinity contains -Infinity and +Infinity in JavaScript.\",\n    str2 = \"My grandfather is 65 years old and My grandmother is 63 years old.\",\n    str3 = \"The contract was declared null and void.\";\nstr1.match(\"number\");   // \"number\" is a string. returns [\"number\"]\nstr1.match(NaN);        // the type of NaN is the number. returns [\"NaN\"]\nstr1.match(Infinity);   // the type of Infinity is the number. returns [\"Infinity\"]\nstr1.match(+Infinity);  // returns [\"Infinity\"]\nstr1.match(-Infinity);  // returns [\"-Infinity\"]\nstr2.match(65);         // returns [\"65\"]\nstr2.match(+65);        // A number with a positive sign. returns [\"65\"]\nstr3.match(null);       // returns [\"null\"]</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/publications/files/ECMA-ST-ARCH/ECMA-262,%203rd%20edition,%20December%201999.pdf\" hreflang=\"en\">ECMAScript 3rd Edition (ECMA-262)</a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition. Implemented in JavaScript 1.2.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/5.1/#sec-15.5.4.10\" hreflang=\"en\">ECMAScript 5.1 (ECMA-262)<br><small>The definition of 'String.prototype.match' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-string.prototype.match\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'String.prototype.match' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-string.prototype.match\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'String.prototype.match' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<code>flags</code> \n</th>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\">1 — 49</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n</tr>\n</tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<code>flags</code> \n</th>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\">4 — 49</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n</tr>\n</tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<code>flags</code> \n</th>\n<td class=\"bc-supports-no\"> No</td>\n</tr>\n</tbody>\n</table>\n</div> <h2 id=\"Firefox-specific_notes\">Firefox-specific notes</h2> <ul> <li>\n<code>flags</code> was a non standard second argument only available in Gecko : <var>str</var>.match(<var>regexp, flags</var>)</li> <li>Starting with Gecko 27 (Firefox 27 / Thunderbird 27 / SeaMonkey 2.24), this method has been adjusted to conform with the ECMAScript specification. When <code>match()</code> is called with a global regular expression, the <a href=\"../regexp/lastindex\"><code>RegExp.lastIndex</code></a> property (if specified) will be reset to <code>0</code> (<a href=\"https://bugzilla.mozilla.org/show_bug.cgi?id=501739\">bug 501739</a>).</li> <li>Starting with Gecko 39 (Firefox 39 / Thunderbird 39 / SeaMonkey 2.36), the non-standard <code>flags</code> argument is deprecated and throws a console warning (<a href=\"https://bugzilla.mozilla.org/show_bug.cgi?id=1142351\">bug 1142351</a>).</li> <li>Starting with Gecko 47 (Firefox 47 / Thunderbird 47 / SeaMonkey 2.44), the non-standard <code>flags</code> argument is no longer supported in non-release builds and will soon be removed entirely (<a href=\"https://bugzilla.mozilla.org/show_bug.cgi?id=1245801\">bug 1245801</a>).</li> <li>Starting with Gecko 49 (Firefox 49 / Thunderbird 49 / SeaMonkey 2.46), the non-standard <code>flags</code> argument is no longer supported (<a href=\"https://bugzilla.mozilla.org/show_bug.cgi?id=1108382\">bug 1108382</a>).</li> </ul> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"../regexp\"><code>RegExp</code></a></li> <li><a href=\"../regexp/exec\"><code>RegExp.prototype.exec()</code></a></li> <li><a href=\"../regexp/test\"><code>RegExp.prototype.test()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/match$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/match\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/match</a>\n  </p>\n</div>\n","global_objects/regexp/global":"<h1>regExp.global</h1> <p>The <code>global</code> property indicates whether or not the \"<code>g</code>\" flag is used with the regular expression. <code>global</code> is a read-only property of an individual regular expression instance.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/regexp-prototype-global.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <div class=\"_table\"><table class=\"standard-table\"> <thead> <tr> <th colspan=\"2\" class=\"header\">Property attributes of <code>RegExp.prototype.global</code>\n</th> </tr> </thead> <tbody> <tr> <td>Writable</td> <td>no</td> </tr> <tr> <td>Enumerable</td> <td>no</td> </tr> <tr> <td>Configurable</td> <td>yes</td> </tr> </tbody> </table></div> <h2 id=\"Description\">Description</h2> <p>The value of <code>global</code> is a <a href=\"../boolean\"><code>Boolean</code></a> and <code>true</code> if the \"<code>g</code>\" flag was used; otherwise, <code>false</code>. The \"<code>g</code>\" flag indicates that the regular expression should be tested against all possible matches in a string. A regular expression defined as both <code>global</code> (\"<code>g</code>\") and <code>sticky</code> (\"<code>y</code>\") will ignore the <code>global</code> flag and perform sticky matches.</p> <p>You cannot change this property directly.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Using_global\">Using <code>global</code>\n</h3> <pre data-language=\"js\">var regex = new RegExp('foo', 'g');\n\nconsole.log(regex.global); // true\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/publications/files/ECMA-ST-ARCH/ECMA-262,%203rd%20edition,%20December%201999.pdf\" hreflang=\"en\">ECMAScript 3rd Edition (ECMA-262)</a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition. Implemented in JavaScript 1.2. JavaScript 1.5: <code>global</code> is a property of a <a href=\"../regexp\"><code>RegExp</code></a> instance, not the <a href=\"../regexp\"><code>RegExp</code></a> object.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/5.1/#sec-15.10.7.2\" hreflang=\"en\">ECMAScript 5.1 (ECMA-262)<br><small>The definition of 'RegExp.prototype.global' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-get-regexp.prototype.global\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'RegExp.prototype.global' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>\n<code>global</code> is now a prototype accessor property rather than an instance's own data property.</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-get-regexp.prototype.global\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'RegExp.prototype.global' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>   <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">Prototype accessor property (ES2015)</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 38</td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n</tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">Prototype accessor property (ES2015)</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 38</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n</tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">Prototype accessor property (ES2015)</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n</tbody>\n</table>\n</div>  <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"lastindex\"><code>RegExp.lastIndex</code></a></li> <li><a href=\"ignorecase\"><code>RegExp.prototype.ignoreCase</code></a></li> <li><a href=\"multiline\"><code>RegExp.prototype.multiline</code></a></li> <li><a href=\"source\"><code>RegExp.prototype.source</code></a></li> <li><a href=\"sticky\"><code>RegExp.prototype.sticky</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/global$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/global\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/global</a>\n  </p>\n</div>\n","global_objects/regexp/ignorecase":"<h1>regExp.ignoreCase</h1> <p>The <code>ignoreCase</code> property indicates whether or not the \"<code>i</code>\" flag is used with the regular expression. <code>ignoreCase</code> is a read-only property of an individual regular expression instance.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/regexp-prototype-ignorecase.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <div class=\"_table\"><table class=\"standard-table\"> <thead> <tr> <th colspan=\"2\" class=\"header\">Property attributes of <code>RegExp.prototype.ignoreCase</code>\n</th> </tr> </thead> <tbody> <tr> <td>Writable</td> <td>no</td> </tr> <tr> <td>Enumerable</td> <td>no</td> </tr> <tr> <td>Configurable</td> <td>yes</td> </tr> </tbody> </table></div> <h2 id=\"Description\">Description</h2> <p>The value of <code>ignoreCase</code> is a <a href=\"../boolean\"><code>Boolean</code></a> and <code>true</code> if the \"<code>i</code>\" flag was used; otherwise, <code>false</code>. The \"<code>i</code>\" flag indicates that case should be ignored while attempting a match in a string.</p> <p>You cannot change this property directly.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Using_ignoreCase\">Using <code>ignoreCase</code>\n</h3> <pre data-language=\"js\">var regex = new RegExp('foo', 'i');\n\nconsole.log(regex.ignoreCase); // true\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/publications/files/ECMA-ST-ARCH/ECMA-262,%203rd%20edition,%20December%201999.pdf\" hreflang=\"en\">ECMAScript 3rd Edition (ECMA-262)</a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition. Implemented in JavaScript 1.2. JavaScript 1.5: <code>ignoreCase</code> is a property of a <a href=\"../regexp\"><code>RegExp</code></a> instance, not the <a href=\"../regexp\"><code>RegExp</code></a> object.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/5.1/#sec-15.10.7.3\" hreflang=\"en\">ECMAScript 5.1 (ECMA-262)<br><small>The definition of 'RegExp.prototype.ignoreCase' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-get-regexp.prototype.ignorecase\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'RegExp.prototype.ignoreCase' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>\n<code>ignoreCase</code> is now a prototype accessor property rather than an instance's own data property.</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-get-regexp.prototype.ignorecase\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'RegExp.prototype.ignoreCase' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>   <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">Prototype accessor property (ES2015)</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 38</td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n</tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">Prototype accessor property (ES2015)</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 38</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n</tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">Prototype accessor property (ES2015)</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n</tbody>\n</table>\n</div>  <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"lastindex\"><code>RegExp.lastIndex</code></a></li> <li><a href=\"global\"><code>RegExp.prototype.global</code></a></li> <li><a href=\"multiline\"><code>RegExp.prototype.multiline</code></a></li> <li><a href=\"source\"><code>RegExp.prototype.source</code></a></li> <li><a href=\"sticky\"><code>RegExp.prototype.sticky</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/ignoreCase$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/ignoreCase\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/ignoreCase</a>\n  </p>\n</div>\n","global_objects/regexp/sticky":"<h1>regExp.sticky</h1> <p>The <code>sticky</code> property reflects whether or not the search is sticky (searches in strings only from the index indicated by the <a href=\"lastindex\"><code>lastIndex</code></a> property of this regular expression). <code>sticky</code> is a read-only property of an individual regular expression object.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/regexp-prototype-sticky.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <div class=\"_table\"><table class=\"standard-table\"> <thead> <tr> <th colspan=\"2\" class=\"header\">Property attributes of <code>RegExp.prototype.sticky</code>\n</th> </tr> </thead> <tbody> <tr> <td>Writable</td> <td>no</td> </tr> <tr> <td>Enumerable</td> <td>no</td> </tr> <tr> <td>Configurable</td> <td>yes</td> </tr> </tbody> </table></div> <h2 id=\"Description\">Description</h2> <p>The value of <code>sticky</code> is a <a href=\"../boolean\"><code>Boolean</code></a> and true if the \"<code>y</code>\" flag was used; otherwise, false. The \"<code>y</code>\" flag indicates that it matches only from the index indicated by the <a href=\"lastindex\"><code>lastIndex</code></a> property of this regular expression in the target string (and does not attempt to match from any later indexes). A regular expression defined as both <code>sticky</code> and <code>global</code> ignores the <code>global</code> flag.</p> <p>You cannot change this property directly. It is read-only.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Using_a_regular_expression_with_the_sticky_flag\">Using a regular expression with the sticky flag</h3> <pre data-language=\"js\">var str = '#foo#';\nvar regex = /foo/y;\n\nregex.lastIndex = 1;\nregex.test(str); // true\nregex.lastIndex = 5;\nregex.test(str); // false (lastIndex is taken into account with sticky flag)\nregex.lastIndex; // 0 (reset after match failure)\n</pre> <h3 id=\"Anchored_sticky_flag\">Anchored sticky flag</h3> <p>For several versions, Firefox's SpiderMonkey engine had <a href=\"https://bugzilla.mozilla.org/show_bug.cgi?id=773687\">a bug</a> with regard to the <code>^</code> assertion and the sticky flag which allowed expressions starting with the <code>^</code> assertion and using the sticky flag to match when they shouldn't. The bug was introduced some time after Firefox 3.6 (which had the sticky flag but not the bug) and fixed in 2015. Perhaps because of the bug, the ES2015 specification <a href=\"http://www.ecma-international.org/ecma-262/7.0/index.html#sec-assertion\">specifically calls out</a> the fact that:</p> <blockquote> <p>When the <code>y</code> flag is used with a pattern, ^ always matches only at the beginning of the input, or (if <code>multiline</code> is <code>true</code>) at the beginning of a line.</p> </blockquote> <p>Examples of correct behavior:</p> <pre data-language=\"js\">var regex = /^foo/y;\nregex.lastIndex = 2;\nregex.test('..foo');   // false - index 2 is not the beginning of the string\n\nvar regex2 = /^foo/my;\nregex2.lastIndex = 2;\nregex2.test('..foo');  // false - index 2 is not the beginning of the string or line\nregex2.lastIndex = 2;\nregex2.test('.\\nfoo'); // true - index 2 is the beginning of a line\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-get-regexp.prototype.sticky\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'RegExp.prototype.sticky' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-get-regexp.prototype.sticky\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'RegExp.prototype.sticky' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>   <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 49</td>\n<td class=\"bc-supports-yes\"> 13</td>\n<td class=\"bc-supports-yes\"> 3</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 36</td>\n<td class=\"bc-supports-yes\"> 10</td>\n</tr>\n<tr>\n<th scope=\"row\">Prototype accessor property (ES2015)</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 38</td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">Anchored sticky flag behavior per ES2015</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 44</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n</tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 49</td>\n<td class=\"bc-supports-yes\"> 49</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> 36</td>\n<td class=\"bc-supports-yes\"> 10</td>\n<td class=\"bc-supports-yes\"> 5.0</td>\n</tr>\n<tr>\n<th scope=\"row\">Prototype accessor property (ES2015)</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 38</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">Anchored sticky flag behavior per ES2015</th>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 44</td>\n<td> ? </td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n</tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">Prototype accessor property (ES2015)</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">Anchored sticky flag behavior per ES2015</th>\n<td> ? </td>\n</tr>\n</tbody>\n</table>\n</div>  <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"lastindex\"><code>RegExp.lastIndex</code></a></li> <li><a href=\"global\"><code>RegExp.prototype.global</code></a></li> <li><a href=\"ignorecase\"><code>RegExp.prototype.ignoreCase</code></a></li> <li><a href=\"multiline\"><code>RegExp.prototype.multiline</code></a></li> <li><a href=\"source\"><code>RegExp.prototype.source</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/sticky$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/sticky\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/sticky</a>\n  </p>\n</div>\n","global_objects/regexp/test":"<h1>regExp.test</h1> <p>The <code>test()</code> method executes a search for a match between a regular expression and a specified string. Returns <code>true</code> or <code>false</code>.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/regexp-prototype-test.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js taller\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\"><var>regexObj</var>.test(<var>str</var>)</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><code>str</code></dt> <dd>The string against which to match the regular expression.</dd> </dl> <h3 id=\"Returns\">Returns</h3> <p><code>true</code> if there is a match between the regular expression and the specified string; otherwise, <code>false</code>.</p> <h2 id=\"Description\">Description</h2> <p>Use <code>test()</code> whenever you want to know whether a pattern is found in a string. <code>test()</code> returns a boolean, unlike the <a href=\"../string/search\"><code>String.prototype.search()</code></a> method, which returns the index (or -1 if not found). To get more information (but with slower execution), use the <a href=\"exec\"><code>exec()</code></a> method (similar to the <a href=\"../string/match\"><code>String.prototype.match()</code></a> method). As with <code>exec()</code> (or in combination with it), <code>test()</code> called multiple times on the same global regular expression instance will advance past the previous match.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Using_test()\">Using <code>test()</code>\n</h3> <p>Simple example that tests if \"hello\" is contained at the very beginning of a string, returning a boolean result.</p> <pre data-language=\"js\">var str = 'hello world!';\nvar result = /^hello/.test(str);\nconsole.log(result); // true\n</pre> <p>The following example logs a message which depends on the success of the test:</p> <pre data-language=\"js\">function testinput(re, str) {\n  var midstring;\n  if (re.test(str)) {\n    midstring = ' contains ';\n  } else {\n    midstring = ' does not contain ';\n  }\n  console.log(str + midstring + re.source);\n}\n</pre> <h3 id=\"Using_test()_on_a_regex_with_the_global_flag\">Using <code>test()</code> on a regex with the global flag</h3> <p>If the regex has the global flag set, <code>test()</code> will advance the <a href=\"lastindex\"><code>lastIndex</code></a> of the regex. A subsequent use of <code>test()</code> will start the search at the substring of <code>str</code> specified by <code>lastIndex</code> (<a href=\"exec\"><code>exec()</code></a> will also advance the <code>lastIndex</code> property). It is worth noting that the <code>lastIndex</code> will not reset when testing a different string.</p> <p>The following example demonstrates this behaviour:</p> <pre data-language=\"js\">var regex = /foo/g;\n\n// regex.lastIndex is at 0\nregex.test('foo'); // true\n\n// regex.lastIndex is now at 3\nregex.test('foo'); // false\n\n// regex.lastIndex is at 0\nregex.test('barfoo') // true\n\n// regex.lastIndex is at 6\nregex.test('foobar') //false</pre> <p>Using the same mechanism the following example counts the total number of words in a string:</p> <pre data-language=\"js\">function countWords (sText) {\n\n  for (var rWord = /\\w+/g, nCount = 0; rWord.test(sText); nCount++);\n\n  return nCount;\n\n}\n\nconsole.log(countWords(\"What a beautiful day!\")); // 4\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <thead> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> </thead> <tbody> <tr> <td><a href=\"https://www.ecma-international.org/publications/files/ECMA-ST-ARCH/ECMA-262,%203rd%20edition,%20December%201999.pdf\" hreflang=\"en\">ECMAScript 3rd Edition (ECMA-262)</a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition. Implemented in JavaScript 1.2.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/5.1/#sec-15.10.6.3\" hreflang=\"en\">ECMAScript 5.1 (ECMA-262)<br><small>The definition of 'RegExp.test' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-regexp.prototype.test\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'RegExp.test' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-regexp.prototype.test\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'RegExp.test' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"Firefox-specific_notes\">Firefox-specific notes</h2> <p>Prior to Firefox 8, <code>test()</code> was implemented incorrectly; when it was called with no parameters, it would match against the value of the previous input (<code>RegExp.input</code> property) instead of against the string <code>\"undefined\"</code>. This is fixed; now <code>/undefined/.test()</code> correctly results in <code>true</code>, instead of an error.</p> <h2 id=\"See_also\">See also</h2> <ul> <li>\n<a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions\">Regular Expressions</a> chapter in the <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide\">JavaScript Guide</a>\n</li> <li><a href=\"../regexp\"><code>RegExp</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/test$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/test\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/test</a>\n  </p>\n</div>\n","global_objects/regexp/source":"<h1>regExp.source</h1> <p>The <code>source</code> property returns a <a href=\"../string\"><code>String</code></a> containing the source text of the regexp object, and it doesn't contain the two forward slashes on both sides and any flags.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/regexp-prototype-source.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <div class=\"_table\"><table class=\"standard-table\"> <thead> <tr> <th colspan=\"2\" class=\"header\">Property attributes of <code>RegExp.prototype.source</code>\n</th> </tr> </thead> <tbody> <tr> <td>Writable</td> <td>no</td> </tr> <tr> <td>Enumerable</td> <td>no</td> </tr> <tr> <td>Configurable</td> <td>yes</td> </tr> </tbody> </table></div> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Using_source\">Using <code>source</code>\n</h3> <pre data-language=\"js\">var regex = /fooBar/ig;\n\nconsole.log(regex.source); // \"fooBar\", doesn't contain /.../ and \"ig\".\n</pre> <h3 id=\"Empty_regular_expressions_and_escaping\">Empty regular expressions and escaping</h3> <p>Starting with ECMAScript 5, the <code>source</code> property no longer returns an empty string for empty regular expressions. Instead, the string <code>\"(?:)\"</code> is returned. In addition, line terminators (such as \"\\n\") are escaped now.</p> <pre data-language=\"js\">new RegExp().source; // \"(?:)\"\n\nnew RegExp('\\n').source === '\\n';  // true, prior to ES5\nnew RegExp('\\n').source === '\\\\n'; // true, starting with ES5\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/publications/files/ECMA-ST-ARCH/ECMA-262,%203rd%20edition,%20December%201999.pdf\" hreflang=\"en\">ECMAScript 3rd Edition (ECMA-262)</a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition. Implemented in JavaScript 1.2. JavaScript 1.5: <code>source</code> is a property of a <a href=\"../regexp\"><code>RegExp</code></a> instance, not the <a href=\"../regexp\"><code>RegExp</code></a> object.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/5.1/#sec-15.10.7.1\" hreflang=\"en\">ECMAScript 5.1 (ECMA-262)<br><small>The definition of 'RegExp.prototype.source' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>The <code>source</code> property for empty regular expressions now returns \"(?:)\" instead of an empty string. A definition for the escaping behavior has been added.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-get-regexp.prototype.source\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'RegExp.prototype.source' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>\n<code>source</code> is now a prototype accessor property rather than an instance's own data property.</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-get-regexp.prototype.source\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'RegExp.prototype.source' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>   <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">Prototype accessor property (ES2015)</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 41</td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">Escaping</th>\n<td> ? </td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 38</td>\n<td> ? </td>\n<td> ? </td>\n<td> ? </td>\n</tr>\n<tr>\n<th scope=\"row\">\"(?:)\" for empty regexps</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 38</td>\n<td> ? </td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n</tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">Prototype accessor property (ES2015)</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 41</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">Escaping</th>\n<td> ? </td>\n<td> ? </td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 38</td>\n<td> ? </td>\n<td> ? </td>\n<td> ? </td>\n</tr>\n<tr>\n<th scope=\"row\">\"(?:)\" for empty regexps</th>\n<td> ? </td>\n<td> ? </td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 38</td>\n<td> ? </td>\n<td> ? </td>\n<td> ? </td>\n</tr>\n</tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">Prototype accessor property (ES2015)</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">Escaping</th>\n<td> ? </td>\n</tr>\n<tr>\n<th scope=\"row\">\"(?:)\" for empty regexps</th>\n<td> ? </td>\n</tr>\n</tbody>\n</table>\n</div>  <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"flags\"><code>RegExp.prototype.flags</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/source$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/source\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/source</a>\n  </p>\n</div>\n","global_objects/regexp/@@species":"<h1>RegExp.@@species</h1> <p>The <code><strong>RegExp[@@species]</strong></code> accessor property returns the <code>RegExp</code> constructor.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/regexp-getregexp-@@species.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\">RegExp[Symbol.species]\n</pre> <h2 id=\"Description\">Description</h2> <p>The <code>species</code> accessor property returns the default constructor for <code>RegExp</code> objects. Subclass constructors may over-ride it to change the constructor assignment.</p> <h2 id=\"Examples\">Examples</h2> <p>The <code>species</code> property returns the default constructor function, which is the <code>RegExp</code> constructor for <code>RegExp</code> objects:</p> <pre data-language=\"js\">RegExp[Symbol.species]; // function RegExp()</pre> <p>In a derived collection object (e.g. your custom regexp <code>MyRegExp</code>), the <code>MyRegExp</code> species is the <code>MyRegExp</code> constructor. However, you might want to overwrite this, in order to return parent <code>RegExp</code> objects in your derived class methods:</p> <pre data-language=\"js\">class MyRegExp extends RegExp {\n  // Overwrite MyRegExp species to the parent RegExp constructor\n  static get [Symbol.species]() { return RegExp; }\n}</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-get-regexp-@@species\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'get RegExp [ @@species ]' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-get-regexp-@@species\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'get RegExp [ @@species ]' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>   <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 49</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 49</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes bc-has-history\"> 6.5.0\n<section class=\"bc-history\" id=\"sect1\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 6.5.0\n</dt>\n\n<dt class=\"bc-supports-yes bc-supports\"> 6.0.0<div class=\"bc-icons\">Disabled </div>\n</dt>\n<dd>Disabled From version 6.0.0: this feature is behind the <code>--harmony</code> runtime flag.</dd>\n</dl></section>\n</td>\n</tr></tbody>\n</table>\n</div>  <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"../regexp\"><code>RegExp</code></a></li> <li><a href=\"../symbol/species\"><code>Symbol.species</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/@@species$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/@@species\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/@@species</a>\n  </p>\n</div>\n","global_objects/regexp/compile":"<h1>regExp.compile</h1> <div class=\"blockIndicator deprecated deprecatedHeader\"> <p><strong> Deprecated</strong><br>This feature is no longer recommended. Though some browsers might still support it, it may have already been removed from the relevant web standards, may be in the process of being dropped, or may only be kept for compatibility purposes. Avoid using it, and update existing code if possible; see the <a href=\"#Browser_compatibility\">compatibility table</a> at the bottom of this page to guide your decision. Be aware that this feature may cease to work at any time.</p> </div> <p>The deprecated <code><strong>compile</strong></code><code>()</code> method is used to (re-)compile a regular expression during execution of a script. It is basically the same as the <code>RegExp</code> constructor.</p> <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\"><var>regexObj</var>.compile(<var>pattern, flags</var>)</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><code>pattern</code></dt> <dd>The text of the regular expression.</dd> <dt><code>flags</code></dt> <dd> <p>If specified, flags can have any combination of the following values:</p> <dl> <dt><code>g</code></dt> <dd>global match</dd> <dt><code>i</code></dt> <dd>ignore case</dd> <dt><code>m</code></dt> <dd>multiline; treat beginning and end characters (^ and $) as working over multiple lines (i.e., match the beginning or end of <em>each</em> line (delimited by \\n or \\r), not only the very beginning or end of the whole input string)</dd> <dt><code>y</code></dt> <dd>sticky; matches only from the index indicated by the <code>lastIndex</code> property of this regular expression in the target string (and does not attempt to match from any later indexes).</dd> </dl> </dd> </dl> <h2 id=\"Description\">Description</h2> <p> The <code>compile</code> method is deprecated. You can just use the <code>RegExp</code> constructor to achieve the same effect.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Using_compile()\">Using <code>compile()</code>\n</h3> <p>The following example shows how to recompile a regular expression with a new pattern and a new flag.</p> <pre data-language=\"js\">var regexObj = new RegExp('foo', 'gi'); \nregexObj.compile('new foo', 'g');\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-regexp.prototype.compile\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'RegExp.prototype.compile' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition. Defined in the (normative) Annex B for Additional ECMAScript Features for Web Browsers.</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-regexp.prototype.compile\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'RegExp.prototype.compile' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td>Defined in the (normative) Annex B for Additional ECMAScript Features for Web Browsers.</td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>   <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support \n</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support \n</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support \n</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div>  <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"../regexp\"><code>RegExp</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/compile$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/compile\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/compile</a>\n  </p>\n</div>\n","global_objects/regexp/lastindex":"<h1>regExp.lastIndex</h1> <p>The <code>lastIndex</code> is a read/write integer property of regular expression instances that specifies the index at which to start the next match.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/regexp-lastindex.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe> <div class=\"_table\"><table class=\"standard-table\"> <thead> <tr> <th colspan=\"2\" class=\"header\">Property attributes of <code>regexp.lastIndex</code>\n</th> </tr> </thead> <tbody> <tr> <td>Writable</td> <td>yes</td> </tr> <tr> <td>Enumerable</td> <td>no</td> </tr> <tr> <td>Configurable</td> <td>no</td> </tr> </tbody> </table></div> <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\"><var>regExpObj</var>.lastIndex</pre> <h2 id=\"Description\">Description</h2> <p>This property is set only if the regular expression instance used the <code>\"g\"</code> flag to indicate a global search, or the <code>\"y\"</code> flag to indicate a sticky search. The following rules apply:</p> <ul> <li>If <code>lastIndex</code> is greater than the length of the string, <a href=\"test\"><code>test()</code></a> and <a href=\"exec\"><code>exec()</code></a> fail, then <code>lastIndex</code> is set to 0.</li> <li>If <code>lastIndex</code> is equal to the length of the string and if the regular expression matches the empty string, then the regular expression matches input starting at <code>lastIndex</code>.</li> <li>If <code>lastIndex</code> is equal to the length of the string and if the regular expression does not match the empty string, then the regular expression mismatches input, and <code>lastIndex</code> is reset to 0.</li> <li>Otherwise, <code>lastIndex</code> is set to the next position following the most recent match.</li> </ul> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Using_lastIndex\">Using <code>lastIndex</code>\n</h3> <p>Consider the following sequence of statements:</p> <pre data-language=\"js\">var re = /(hi)?/g;\n</pre> <p>Matches the empty string.</p> <pre data-language=\"js\">console.log(re.exec('hi'));\nconsole.log(re.lastIndex);\n</pre> <p>Returns <code>[\"hi\", \"hi\"]</code> with <code>lastIndex</code> equal to 2.</p> <pre data-language=\"js\">console.log(re.exec('hi'));\nconsole.log(re.lastIndex);\n</pre> <p>Returns <code>[\"\", undefined]</code>, an empty array whose zeroth element is the match string. In this case, the empty string because <code>lastIndex</code> was 2 (and still is 2) and <code>\"hi\"</code> has length 2.</p> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/publications/files/ECMA-ST-ARCH/ECMA-262,%203rd%20edition,%20December%201999.pdf\" hreflang=\"en\">ECMAScript 3rd Edition (ECMA-262)</a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition. Implemented in JavaScript 1.2. JavaScript 1.5: <code>lastIndex</code> is a property of a <a href=\"../regexp\"><code>RegExp</code></a> instance, not the <a href=\"../regexp\"><code>RegExp</code></a> object.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/5.1/#sec-15.10.7.5\" hreflang=\"en\">ECMAScript 5.1 (ECMA-262)<br><small>The definition of 'RegExp.lastIndex' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-properties-of-regexp-instances\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'RegExp.lastIndex' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-properties-of-regexp-instances\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'RegExp.lastIndex' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>   <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div>  <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"ignorecase\"><code>RegExp.prototype.ignoreCase</code></a></li> <li><a href=\"global\"><code>RegExp.prototype.global</code></a></li> <li><a href=\"multiline\"><code>RegExp.prototype.multiline</code></a></li> <li><a href=\"source\"><code>RegExp.prototype.source</code></a></li> <li><a href=\"sticky\"><code>RegExp.prototype.sticky</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/lastIndex$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/lastIndex\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/lastIndex</a>\n  </p>\n</div>\n","global_objects/symbol/hasinstance":"<h1>Symbol.hasInstance</h1> <p>The <code>Symbol.hasInstance</code> well-known symbol is used to determine if a constructor object recognizes an object as its instance. The <a href=\"../../operators/instanceof\"><code>instanceof</code></a> operator's behavior can be customized by this symbol.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/symbol-hasinstance.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <div class=\"_table\"><table class=\"standard-table\"> <thead> <tr> <th colspan=\"2\" class=\"header\">Property attributes of <code>Symbol.hasInstance</code>\n</th> </tr> </thead> <tbody> <tr> <td>Writable</td> <td>no</td> </tr> <tr> <td>Enumerable</td> <td>no</td> </tr> <tr> <td>Configurable</td> <td>no</td> </tr> </tbody> </table></div> <h2 id=\"Examples\">Examples</h2> <p>You could implement your custom <code>instanceof</code> behavior like this, for example:</p> <pre data-language=\"js\">class MyArray {  \n  static [Symbol.hasInstance](instance) {\n    return Array.isArray(instance);\n  }\n}\nconsole.log([] instanceof MyArray); // true</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-symbol.hasinstance\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Symbol.hasInstance' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-symbol.hasinstance\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Symbol.hasInstance' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 51</td>\n<td class=\"bc-supports-yes\"> 15</td>\n<td class=\"bc-supports-yes\"> 50</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 50</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes bc-has-history\"> 6.5.0\n<section class=\"bc-history\" id=\"sect1\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 6.5.0\n</dt>\n\n<dt class=\"bc-supports-yes bc-supports\"> 6.0.0<div class=\"bc-icons\">Disabled </div>\n</dt>\n<dd>Disabled From version 6.0.0: this feature is behind the <code>--harmony</code> runtime flag.</dd>\n</dl></section>\n</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"../../operators/instanceof\"><code>instanceof</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/hasInstance$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/hasInstance\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/hasInstance</a>\n  </p>\n</div>\n","global_objects/string/replace":"<h1>string.replace</h1> <p>The <code>replace()</code> method returns a new string with some or all matches of a <code>pattern</code> replaced by a <code>replacement</code>. The <code>pattern</code> can be a string or a <a href=\"../regexp\"><code>RegExp</code></a>, and the <code>replacement</code> can be a string or a function to be called for each match. If <code>pattern</code> is a string, only the first occurrence will be replaced.</p> <p>The original string is left unchanged.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/string-replace.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\"><var>str</var>.replace(<var>regexp</var>|<var>substr</var>, <var>newSubstr</var>|<var>function</var>)</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt>\n<code>regexp</code> (pattern)</dt> <dd>A <a href=\"../regexp\"><code>RegExp</code></a> object or literal. The match or matches are replaced with <code>newSubStr</code> or the value returned by the specified <code>function</code>.</dd> <dt>\n<code>substr</code> (pattern)</dt> <dd>A <a href=\"../string\"><code>String</code></a> that is to be replaced by <code>newSubStr</code>. It is treated as a verbatim string and is <em>not</em> interpreted as a regular expression. Only the first occurrence will be replaced.</dd> <dt>\n<code>newSubStr</code> (replacement)</dt> <dd>The <a href=\"../string\"><code>String</code></a> that replaces the substring specified by the specified <code>regexp</code> or <code>substr</code> parameter. A number of special replacement patterns are supported; see the \"<a href=\"#Specifying_a_string_as_a_parameter\">Specifying a string as a parameter</a>\" section below.</dd> <dt>\n<code>function</code> (replacement)</dt> <dd>A function to be invoked to create the new substring to be used to replace the matches to the given <code>regexp</code> or <code>substr</code>. The arguments supplied to this function are described in the \"<a href=\"#Specifying_a_function_as_a_parameter\">Specifying a function as a parameter</a>\" section below.</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p>A new string with some or all matches of a pattern replaced by a replacement.</p> <h2 id=\"Description\">Description</h2> <p>This method does not change the <a href=\"../string\"><code>String</code></a> object it is called on. It simply returns a new string.</p> <p>To perform a global search and replace, include the <code>g</code> switch in the regular expression.</p> <h3 id=\"Specifying_a_string_as_a_parameter\">Specifying a string as a parameter</h3> <p>The replacement string can include the following special replacement patterns:</p> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th class=\"header\">Pattern</th> <th class=\"header\">Inserts</th> </tr> <tr> <td><code>$$</code></td> <td>Inserts a \"$\".</td> </tr> <tr> <td><code>$&amp;</code></td> <td>Inserts the matched substring.</td> </tr> <tr> <td><code>$`</code></td> <td>Inserts the portion of the string that precedes the matched substring.</td> </tr> <tr> <td><code>$'</code></td> <td>Inserts the portion of the string that follows the matched substring.</td> </tr> <tr> <td><code>$<em>n</em></code></td> <td>Where <code><em>n</em></code> is a positive integer less than 100, inserts the <em>n</em>th parenthesized submatch string, provided the first argument was a <a href=\"../regexp\"><code>RegExp</code></a> object. Note that this is 1-indexed.</td> </tr> </tbody> </table></div> <h3 id=\"Specifying_a_function_as_a_parameter\">Specifying a function as a parameter</h3> <p>You can specify a function as the second parameter. In this case, the function will be invoked after the match has been performed. The function's result (return value) will be used as the replacement string. (Note: the above-mentioned special replacement patterns do <em>not</em> apply in this case.) Note that the function will be invoked multiple times for each full match to be replaced if the regular expression in the first parameter is global.</p> <p>The arguments to the function are as follows:</p> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th class=\"header\">Possible name</th> <th class=\"header\">Supplied value</th> </tr> <tr> <td><code>match</code></td> <td>The matched substring. (Corresponds to <code>$&amp;</code> above.)</td> </tr> <tr> <td><code>p1, p2, ...</code></td> <td>The <em>n</em>th string found by a parenthesized capture group, provided the first argument to <code>replace()</code> was a <a href=\"../regexp\"><code>RegExp</code></a> object. (Corresponds to <code>$1</code>, <code>$2</code>, etc. above.) For example, if <code>/(\\a+)(\\b+)/</code>, was given, <code>p1</code> is the match for <code>\\a+</code>, and <code>p2</code> for <code>\\b+</code>.</td> </tr> <tr> <td><code>offset</code></td> <td>The offset of the matched substring within the whole string being examined. (For example, if the whole string was <code>'abcd'</code>, and the matched substring was <code>'bc'</code>, then this argument will be 1.)</td> </tr> <tr> <td><code>string</code></td> <td>The whole string being examined.</td> </tr> </tbody> </table></div> <p>(The exact number of arguments will depend on whether the first argument was a <a href=\"../regexp\"><code>RegExp</code></a> object and, if so, how many parenthesized submatches it specifies.)</p> <p>The following example will set <code>newString</code> to <code>'abc - 12345 - #$*%'</code>:</p> <pre data-language=\"js\">function replacer(match, p1, p2, p3, offset, string) {\n  // p1 is nondigits, p2 digits, and p3 non-alphanumerics\n  return [p1, p2, p3].join(' - ');\n}\nvar newString = 'abc12345#$*%'.replace(/([^\\d]*)(\\d*)([^\\w]*)/, replacer);\nconsole.log(newString);  // abc - 12345 - #$*%\n</pre> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Defining_the_regular_expression_in_replace()\">Defining the regular expression in <code>replace()</code>\n</h3> <p>In the following example, the regular expression is defined in <code>replace()</code> and includes the ignore case flag.</p> <pre data-language=\"js\">var str = 'Twas the night before Xmas...';\nvar newstr = str.replace(/xmas/i, 'Christmas');\nconsole.log(newstr);  // Twas the night before Christmas...\n</pre> <p>This logs 'Twas the night before Christmas...'</p> <h3 id=\"Using_global_and_ignore_with_replace()\">Using <code>global</code> and <code>ignore</code> with <code>replace()</code>\n</h3> <p>Global replace can only be done with a regular expression. In the following example, the regular expression includes the global and ignore case flags which permits <code>replace()</code> to replace each occurrence of 'apples' in the string with 'oranges'.</p> <pre data-language=\"js\">var re = /apples/gi;\nvar str = 'Apples are round, and apples are juicy.';\nvar newstr = str.replace(re, 'oranges');\nconsole.log(newstr);  // oranges are round, and oranges are juicy.\n</pre> <p>This logs 'oranges are round, and oranges are juicy'.</p> <h3 id=\"Switching_words_in_a_string\">Switching words in a string</h3> <p>The following script switches the words in the string. For the replacement text, the script uses the <code>$1</code> and <code>$2</code> replacement patterns.</p> <pre data-language=\"js\">var re = /(\\w+)\\s(\\w+)/;\nvar str = 'John Smith';\nvar newstr = str.replace(re, '$2, $1');\nconsole.log(newstr);  // Smith, John\n</pre> <p>This logs 'Smith, John'.</p> <h3 id=\"Using_an_inline_function_that_modifies_the_matched_characters\">Using an inline function that modifies the matched characters</h3> <p>In this example, all occurrences of capital letters in the string are converted to lower case, and a hyphen is inserted just before the match location. The important thing here is that additional operations are needed on the matched item before it is given back as a replacement.</p> <p>The replacement function accepts the matched snippet as its parameter, and uses it to transform the case and concatenate the hyphen before returning.</p> <pre data-language=\"js\">function styleHyphenFormat(propertyName) {\n  function upperToHyphenLower(match, offset, string) {\n    return (offset &gt; 0 ? '-' : '') + match.toLowerCase();\n  }\n  return propertyName.replace(/[A-Z]/g, upperToHyphenLower);\n}\n</pre> <p>Given <code>styleHyphenFormat('borderTop')</code>, this returns 'border-top'.</p> <p>Because we want to further transform the <em>result</em> of the match before the final substitution is made, we must use a function. This forces the evaluation of the match prior to the <a href=\"tolowercase\"><code>toLowerCase()</code></a> method. If we had tried to do this using the match without a function, the <a href=\"tolowercase\"><code>toLowerCase()</code></a> would have no effect.</p> <pre data-language=\"js\">var newString = propertyName.replace(/[A-Z]/g, '-' + '$&amp;'.toLowerCase());  // won't work\n</pre> <p>This is because <code>'$&amp;'.toLowerCase()</code> would be evaluated first as a string literal (resulting in the same <code>'$&amp;'</code>) before using the characters as a pattern.</p> <h3 id=\"Replacing_a_Fahrenheit_degree_with_its_Celsius_equivalent\">Replacing a Fahrenheit degree with its Celsius equivalent</h3> <p>The following example replaces a Fahrenheit degree with its equivalent Celsius degree. The Fahrenheit degree should be a number ending with F. The function returns the Celsius number ending with C. For example, if the input number is 212F, the function returns 100C. If the number is 0F, the function returns -17.77777777777778C.</p> <p>The regular expression <code>test</code> checks for any number that ends with F. The number of Fahrenheit degree is accessible to the function through its second parameter, <code>p1</code>. The function sets the Celsius number based on the Fahrenheit degree passed in a string to the <code>f2c()</code> function. <code>f2c()</code> then returns the Celsius number. This function approximates Perl's <code>s///e</code> flag.</p> <pre data-language=\"js\">function f2c(x) {\n  function convert(str, p1, offset, s) {\n    return ((p1 - 32) * 5/9) + 'C';\n  }\n  var s = String(x);\n  var test = /(-?\\d+(?:\\.\\d*)?)F\\b/g;\n  return s.replace(test, convert);\n}\n</pre> <h3 id=\"Use_an_inline_function_with_a_regular_expression_to_avoid_for_loops\">Use an inline function with a regular expression to avoid <code>for</code> loops</h3> <p>The following example takes a string pattern and converts it into an array of objects.</p> <p><strong>Input:</strong></p> <p>A string made out of the characters <code>x</code>, <code>-</code> and <code>_</code></p> <pre>x-x_\nx---x---x---x---\nx-xxx-xx-x-\nx_x_x___x___x___\n</pre> <p><strong>Output:</strong></p> <p>An array of objects. An <code>'x'</code> denotes an <code>'on'</code> state, a <code>'-'</code> (hyphen) denotes an <code>'off'</code> state and an <code>'_'</code> (underscore) denotes the length of an <code>'on'</code> state.</p> <pre data-language=\"json\">[\n  { on: true, length: 1 },\n  { on: false, length: 1 },\n  { on: true, length: 2 }\n  ...\n]\n</pre> <p><strong>Snippet:</strong></p> <pre data-language=\"js\">var str = 'x-x_';\nvar retArr = [];\nstr.replace(/(x_*)|(-)/g, function(match, p1, p2) {\n  if (p1) { retArr.push({ on: true, length: p1.length }); }\n  if (p2) { retArr.push({ on: false, length: 1 }); }\n});\n\nconsole.log(retArr);\n</pre> <p>This snippet generates an array of 3 objects in the desired format without using a <code>for</code> loop.</p> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/publications/files/ECMA-ST-ARCH/ECMA-262,%203rd%20edition,%20December%201999.pdf\" hreflang=\"en\">ECMAScript 3rd Edition (ECMA-262)</a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition. Implemented in JavaScript 1.2.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/5.1/#sec-15.5.4.11\" hreflang=\"en\">ECMAScript 5.1 (ECMA-262)<br><small>The definition of 'String.prototype.replace' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-string.prototype.replace\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'String.prototype.replace' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-string.prototype.replace\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'String.prototype.replace' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<code>flags</code> \n</th>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\">1 — 49</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n</tr>\n</tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<code>flags</code> \n</th>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\">4 — 49</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n</tr>\n</tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<code>flags</code> \n</th>\n<td class=\"bc-supports-no\"> No</td>\n</tr>\n</tbody>\n</table>\n</div> <h2 id=\"Firefox-specific_notes\">Firefox-specific notes</h2> <ul> <li>\n<code>flags</code> was a non standard third argument only available in Gecko : <var>str</var>.replace(<var>regexp</var>|<var>substr</var>, <var>newSubStr</var>|<var>function, flags</var>)</li> <li>Starting with Gecko 27 (Firefox 27 / Thunderbird 27 / SeaMonkey 2.24), this method has been adjusted to conform with the ECMAScript specification. When <code>replace()</code> is called with a global regular expression, the <a href=\"../regexp/lastindex\"><code>RegExp.lastIndex</code></a> property (if specified) will be reset to <code>0</code> (<a href=\"https://bugzilla.mozilla.org/show_bug.cgi?id=501739\">bug 501739</a>).</li> <li>Starting with Gecko 39 (Firefox 39 / Thunderbird 39 / SeaMonkey 2.36), the non-standard <code>flags</code> argument is deprecated and throws a console warning (<a href=\"https://bugzilla.mozilla.org/show_bug.cgi?id=1142351\">bug 1142351</a>).</li> <li>Starting with Gecko 47 (Firefox 47 / Thunderbird 47 / SeaMonkey 2.44), the non-standard <code>flags</code> argument is no longer supported in non-release builds and will soon be removed entirely (<a href=\"https://bugzilla.mozilla.org/show_bug.cgi?id=1245801\">bug 1245801</a>).</li> <li>Starting with Gecko 49 (Firefox 49 / Thunderbird 49 / SeaMonkey 2.46), the non-standard <code>flags</code> argument is no longer supported (<a href=\"https://bugzilla.mozilla.org/show_bug.cgi?id=1108382\">bug 1108382</a>).</li> </ul> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"match\"><code>String.prototype.match()</code></a></li> <li><a href=\"../regexp/exec\"><code>RegExp.prototype.exec()</code></a></li> <li><a href=\"../regexp/test\"><code>RegExp.prototype.test()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replace$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replace\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replace</a>\n  </p>\n</div>\n","global_objects/regexp/@@search":"<h1>regExp.@@search</h1> <p>The <code>[@@search]()</code> method executes a search for a match between a <code>this</code> regular expression and a string.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/regexp-prototype-@@search.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\"><var>regexp</var>[Symbol.search](str)</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><code>str</code></dt> <dd>A <a href=\"../string\"><code>String</code></a> that is a target of the search.</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <dl> <dt>integer</dt> <dd>If successful, <code>[@@search]()</code> returns the index of the first match of the regular expression inside the string. Otherwise, it returns -1.</dd> </dl> <h2 id=\"Description\">Description</h2> <p>This method is called internally in <a href=\"../string/search\"><code>String.prototype.search()</code></a>. For example, the following two examples return the same result.</p> <pre data-language=\"js\">'abc'.search(/a/);\n\n/a/[Symbol.search]('abc');</pre> <p>This method exists for customizing the search behavior in <code>RegExp</code> subclasses.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Direct_call\">Direct call</h3> <p>This method can be used in almost the same way as <a href=\"../string/search\"><code>String.prototype.search()</code></a>, except the different <code>this</code> and the different arguments order.</p> <pre data-language=\"js\">var re = /-/g;\nvar str = '2016-01-02';\nvar result = re[Symbol.search](str);\nconsole.log(result);  // 4\n</pre> <h3 id=\"Using_search_in_subclasses\">Using <code>@@search</code> in subclasses</h3> <p>Subclass of <a href=\"../regexp\"><code>RegExp</code></a> can override <code>[@@search]()</code> method to modify the behavior.</p> <pre data-language=\"js\">class MyRegExp extends RegExp {\n  constructor(str) {\n    super(str)\n    this.pattern = str;\n  }\n  [Symbol.search](str) {\n    return str.indexOf(this.pattern);\n  }\n}\n\nvar re = new MyRegExp('a+b');\nvar str = 'ab a+b';\nvar result = str.search(re); // String.prototype.search calls re[@@search].\nconsole.log(result); // 3\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-regexp.prototype-@@search\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'RegExp.prototype[@@search]' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-regexp.prototype-@@search\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'RegExp.prototype[@@search]' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>   <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 49</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 49</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 6.0.0</td>\n</tr></tbody>\n</table>\n</div>  <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"../string/search\"><code>String.prototype.search()</code></a></li> <li><a href=\"@@match\"><code>RegExp.prototype[@@match]()</code></a></li> <li><a href=\"@@replace\"><code>RegExp.prototype[@@replace]()</code></a></li> <li><a href=\"@@split\"><code>RegExp.prototype[@@split]()</code></a></li> <li><a href=\"exec\"><code>RegExp.prototype.exec()</code></a></li> <li><a href=\"test\"><code>RegExp.prototype.test()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/@@search$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/@@search\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/@@search</a>\n  </p>\n</div>\n","global_objects/regexp/@@match":"<h1>regExp.@@match</h1> <p>The <code>[@@match]()</code> method retrieves the matches when matching a <em>string</em> against a <em>regular expression</em>.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/regexp-prototype-@@match.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>   <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\"><var>regexp</var>[Symbol.match](str)</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><code>str</code></dt> <dd>A <a href=\"../string\"><code>String</code></a> that is a target of the match.</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p>An <a href=\"../array\"><code>Array</code></a> containing the entire match result and any parentheses-captured matched results, or <a href=\"../null\"><code>null</code></a> if there were no matches.</p> <h2 id=\"Description\">Description</h2> <p>This method is called internally in <a href=\"../string/match\"><code>String.prototype.match()</code></a>. For example, the following two examples return same result.</p> <pre data-language=\"js\">'abc'.match(/a/);\n\n/a/[Symbol.match]('abc');</pre> <p>This method exists for customizing match behavior within <code>RegExp</code> subclasses.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Direct_call\">Direct call</h3> <p>This method can be used in almost the same way as <a href=\"../string/match\"><code>String.prototype.match()</code></a>, except the different <code>this</code> and the different arguments order.</p> <pre data-language=\"js\">var re = /[0-9]+/g;\nvar str = '2016-01-02';\nvar result = re[Symbol.match](str);\nconsole.log(result);  // [\"2016\", \"01\", \"02\"]\n</pre> <h3 id=\"Using_match_in_subclasses\">Using <code>@@match</code> in subclasses</h3> <p>Subclasses of <a href=\"../regexp\"><code>RegExp</code></a> can override the <code>[@@match]()</code> method to modify the default behavior.</p> <pre data-language=\"js\">class MyRegExp extends RegExp {\n  [Symbol.match](str) {\n    var result = RegExp.prototype[Symbol.match].call(this, str);\n    if (!result) return null;\n    return {\n      group(n) {\n        return result[n];\n      }\n    };\n  }\n}\n\nvar re = new MyRegExp('([0-9]+)-([0-9]+)-([0-9]+)');\nvar str = '2016-01-02';\nvar result = str.match(re); // String.prototype.match calls re[@@match].\nconsole.log(result.group(1)); // 2016\nconsole.log(result.group(2)); // 01\nconsole.log(result.group(3)); // 02\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-regexp.prototype-@@match\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'RegExp.prototype[@@match]' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial defintion.</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-regexp.prototype-@@match\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'RegExp.prototype[@@match]' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>   <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 49</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 49</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 6.0.0</td>\n</tr></tbody>\n</table>\n</div>  <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"../string/match\"><code>String.prototype.match()</code></a></li> <li><a href=\"@@replace\"><code>RegExp.prototype[@@replace]()</code></a></li> <li><a href=\"@@search\"><code>RegExp.prototype[@@search]()</code></a></li> <li><a href=\"@@split\"><code>RegExp.prototype[@@split]()</code></a></li> <li><a href=\"exec\"><code>RegExp.prototype.exec()</code></a></li> <li><a href=\"test\"><code>RegExp.prototype.test()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/@@match$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/@@match\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/@@match</a>\n  </p>\n</div>\n","global_objects/symbol/iterator":"<h1>Symbol.iterator</h1> <p>The <code><strong>Symbol.iterator</strong></code> well-known symbol specifies the default iterator for an object. Used by <a href=\"../../statements/for...of\"><code>for...of</code></a>.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/symbol-iterator.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <div class=\"_table\"><table class=\"standard-table\"> <thead> <tr> <th colspan=\"2\" class=\"header\">Property attributes of <code>Symbol.iterator</code>\n</th> </tr> </thead> <tbody> <tr> <td>Writable</td> <td>no</td> </tr> <tr> <td>Enumerable</td> <td>no</td> </tr> <tr> <td>Configurable</td> <td>no</td> </tr> </tbody> </table></div> <h2 id=\"Description\">Description</h2> <p>Whenever an object needs to be iterated (such as at the beginning of a <code>for..of</code> loop), its <code>@@iterator</code> method is called with no arguments, and the returned <strong>iterator</strong> is used to obtain the values to be iterated.</p> <p>Some built-in types have a default iteration behavior, while other types (such as <a href=\"../object\"><code>Object</code></a>) do not. The built-in types with a <code>@@iterator</code> method are:</p> <ul> <li><a href=\"../array/@@iterator\"><code>Array.prototype[@@iterator]()</code></a></li> <li><a href=\"../typedarray/@@iterator\"><code>TypedArray.prototype[@@iterator]()</code></a></li> <li><a href=\"../string/@@iterator\"><code>String.prototype[@@iterator]()</code></a></li> <li><a href=\"../map/@@iterator\"><code>Map.prototype[@@iterator]()</code></a></li> <li><a href=\"../set/@@iterator\"><code>Set.prototype[@@iterator]()</code></a></li> </ul> <p>See also <a href=\"../../iteration_protocols\">Iteration protocols</a> for more information.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"User-defined_iterables\">User-defined iterables</h3> <p>We can make our own iterables like this:</p> <pre data-language=\"js\">var myIterable = {}\nmyIterable[Symbol.iterator] = function* () {\n    yield 1;\n    yield 2;\n    yield 3;\n};\n[...myIterable] // [1, 2, 3]\n</pre> <h3 id=\"Non-well-formed_iterables\">Non-well-formed iterables</h3> <p>If an iterable's <code>@@iterator</code> method does not return an iterator object, then it is a non-well-formed iterable. Using it as such is likely to result in runtime exceptions or buggy behavior:</p> <pre data-language=\"js\">var nonWellFormedIterable = {}\nnonWellFormedIterable[Symbol.iterator] = () =&gt; 1\n[...nonWellFormedIterable] // TypeError: [] is not a function\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <thead> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> </thead> <tbody> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-symbol.iterator\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Symbol.iterator' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-symbol.iterator\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Symbol.iterator' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 43</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 36</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 30</td>\n<td class=\"bc-supports-yes\"> 10</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 36</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 10</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 0.12</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"../../iteration_protocols\">Iteration protocols</a></li> <li><a href=\"../array/@@iterator\"><code>Array.prototype[@@iterator]()</code></a></li> <li><a href=\"../typedarray/@@iterator\"><code>TypedArray.prototype[@@iterator]()</code></a></li> <li><a href=\"../string/@@iterator\"><code>String.prototype[@@iterator]()</code></a></li> <li><a href=\"../map/@@iterator\"><code>Map.prototype[@@iterator]()</code></a></li> <li><a href=\"../set/@@iterator\"><code>Set.prototype[@@iterator]()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/iterator$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/iterator\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/iterator</a>\n  </p>\n</div>\n","global_objects/symbol/isconcatspreadable":"<h1>Symbol.isConcatSpreadable</h1> <p>The <code>Symbol.isConcatSpreadable</code> well-known symbol is used to configure if an object should be flattened to its array elements when using the <a href=\"../array/concat\"><code>Array.prototype.concat()</code></a> method.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/symbol-isconcatspreadable.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <div class=\"_table\"><table class=\"standard-table\"> <thead> <tr> <th colspan=\"2\" class=\"header\">Property attributes of <code>Symbol.isConcatSpreadable</code>\n</th> </tr> </thead> <tbody> <tr> <td>Writable</td> <td>no</td> </tr> <tr> <td>Enumerable</td> <td>no</td> </tr> <tr> <td>Configurable</td> <td>no</td> </tr> </tbody> </table></div> <h2 id=\"Description\">Description</h2> <p>The <code>@@isConcatSpreadable</code> symbol (<code>Symbol.isConcatSpreadable</code>) can be defined as an own or inherited property and its value is a boolean. It can control behavior for arrays and array-like objects:</p> <ul> <li>For array objects, the default behavior is to spread (flatten) elements. <code>Symbol.isConcatSpreadable</code> can avoid flattening in these cases.</li> <li>For array-like objects, the default behavior is no spreading or flattening. <code>Symbol.isConcatSpreadable</code> can force flattening in these cases.</li> </ul> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Arrays\">Arrays</h3> <p>By default, <a href=\"../array/concat\"><code>Array.prototype.concat()</code></a> spreads (flattens) arrays into its result:</p> <pre data-language=\"js\">var alpha = ['a', 'b', 'c'], \n    numeric = [1, 2, 3]; \n\nvar alphaNumeric = alpha.concat(numeric); \n\nconsole.log(alphaNumeric); // Result: ['a', 'b', 'c', 1, 2, 3]\n</pre> <p>When setting <code>Symbol.isConcatSpreadable</code> to <code>false</code>, you can disable the default behavior:</p> <pre data-language=\"js\">var alpha = ['a', 'b', 'c'], \n    numeric = [1, 2, 3]; \n\nnumeric[Symbol.isConcatSpreadable] = false;\nvar alphaNumeric = alpha.concat(numeric); \n\nconsole.log(alphaNumeric); // Result: ['a', 'b', 'c', [1, 2, 3] ]\n</pre> <h3 id=\"Array-like_objects\">Array-like objects</h3> <p>For array-like objects, the default is to not spread. <code>Symbol.isConcatSpreadable</code> needs to be set to <code>true</code> in order to get a flattened array:</p> <pre data-language=\"js\">var x = [1, 2, 3];\n\nvar fakeArray = { \n  [Symbol.isConcatSpreadable]: true, \n  length: 2, \n  0: 'hello', \n  1: 'world' \n}\n\nx.concat(fakeArray); // [1, 2, 3, \"hello\", \"world\"]\n</pre> <p>Note: The length property is used to control the number of object properties to be added. In the above example, length:2 indicates two properties has to be added.</p> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-symbol.isconcatspreadable\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Symbol.isconcatspreadable' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-symbol.isconcatspreadable\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Symbol.isconcatspreadable' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td>No change.</td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 48</td>\n<td class=\"bc-supports-yes\"> 15</td>\n<td class=\"bc-supports-yes\"> 48</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 48</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 6.0.0</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"../array/concat\"><code>Array.prototype.concat()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/isConcatSpreadable$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/isConcatSpreadable\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/isConcatSpreadable</a>\n  </p>\n</div>\n","global_objects/regexp/@@split":"<h1>regExp.@@split</h1> <p>The <code>[@@split]()</code> method splits a <a href=\"../string\"><code>String</code></a> object into an array of strings by separating the string into substrings.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/regexp-prototype-@@split.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\"><var>regexp</var>[Symbol.split](str[, <var>limit</var>])</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><code>str</code></dt> <dd>The target of the split operation.</dd> <dt><code>limit</code></dt> <dd> <p>Optional. Integer specifying a limit on the number of splits to be found. The <code>[@@split]()</code> method still splits on every match of <code>this</code> RegExp pattern, until the number of split items match the <code>limit</code> or the string falls short of <code>this</code> pattern.</p> </dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p>An <a href=\"../array\"><code>Array</code></a> containing substrings as its elements.</p> <h2 id=\"Description\">Description</h2> <p>This method is called internally in <a href=\"../string/split\"><code>String.prototype.split()</code></a> if the <code>separator</code> argument is a <a href=\"../regexp\"><code>RegExp</code></a> object. For example, the following two examples return the same result.</p> <pre data-language=\"js\">'a-b-c'.split(/-/);\n\n/-/[Symbol.split]('a-b-c');</pre> <p>This method exists for customizing the split behavior in <code>RegExp</code> subclass.</p> <p>If the <code>str</code> argument is <strong>not</strong> a <a href=\"../regexp\"><code>RegExp</code></a> object, <a href=\"../string/split\"><code>String.prototype.split()</code></a> doesn't call this method, nor create a <a href=\"../regexp\"><code>RegExp</code></a> object.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Direct_call\">Direct call</h3> <p>This method can be used in almost the same way as <a href=\"../string/split\"><code>String.prototype.split()</code></a>, except the different <code>this</code> and the different arguments order.</p> <pre data-language=\"js\">var re = /-/g;\nvar str = '2016-01-02';\nvar result = re[Symbol.split](str);\nconsole.log(result);  // [\"2016\", \"01\", \"02\"]\n</pre> <h3 id=\"Using_split_in_subclasses\">Using <code>@@split</code> in subclasses</h3> <p>Subclasses of <a href=\"../regexp\"><code>RegExp</code></a> can override the <code>[@@split]()</code> method to modify the default behavior.</p> <pre data-language=\"js\">class MyRegExp extends RegExp {\n  [Symbol.split](str, limit) {\n    var result = RegExp.prototype[Symbol.split].call(this, str, limit);\n    return result.map(x =&gt; \"(\" + x + \")\");\n  }\n}\n\nvar re = new MyRegExp('-');\nvar str = '2016-01-02';\nvar result = str.split(re); // String.prototype.split calls re[@@split].\nconsole.log(result); // [\"(2016)\", \"(01)\", \"(02)\"]\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-regexp.prototype-@@split\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'RegExp.prototype[@@split]' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-regexp.prototype-@@split\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'RegExp.prototype[@@split]' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>   <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 49</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 49</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 6.0.0</td>\n</tr></tbody>\n</table>\n</div>  <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"../string/split\"><code>String.prototype.split()</code></a></li> <li><a href=\"@@match\"><code>RegExp.prototype[@@match]()</code></a></li> <li><a href=\"@@replace\"><code>RegExp.prototype[@@replace]()</code></a></li> <li><a href=\"@@search\"><code>RegExp.prototype[@@search]()</code></a></li> <li><a href=\"exec\"><code>RegExp.prototype.exec()</code></a></li> <li><a href=\"test\"><code>RegExp.prototype.test()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/@@split$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/@@split\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/@@split</a>\n  </p>\n</div>\n","global_objects/symbol/match":"<h1>Symbol.match</h1> <p>The <code><strong>Symbol.match</strong></code> well-known symbol specifies the matching of a regular expression against a string. This function is called by the <a href=\"../string/match\"><code>String.prototype.match()</code></a> method.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/symbol-match.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <div class=\"_table\"><table class=\"standard-table\"> <thead> <tr> <th colspan=\"2\" class=\"header\">Property attributes of <code>Symbol.match</code>\n</th> </tr> </thead> <tbody> <tr> <td>Writable</td> <td>no</td> </tr> <tr> <td>Enumerable</td> <td>no</td> </tr> <tr> <td>Configurable</td> <td>no</td> </tr> </tbody> </table></div> <h2 id=\"Description\">Description</h2> <p>This function is also used to identify if objects have the behavior of regular expressions. For example, the methods <a href=\"../string/startswith\"><code>String.prototype.startsWith()</code></a>, <a href=\"../string/endswith\"><code>String.prototype.endsWith()</code></a> and <a href=\"../string/includes\"><code>String.prototype.includes()</code></a>, check if their first argument is a regular expression and will throw a <a href=\"../typeerror\"><code>TypeError</code></a> if they are. Now, if the <code>match</code> symbol is set to <code>false</code> (or a <a href=\"https://developer.mozilla.org/en-US/docs/Glossary/Falsy\">Falsy</a> value), it indicates that the object is not intended to be used as a regular expression object.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Disabling_the_isRegExp_check\">Disabling the <code>isRegExp</code> check</h3> <p>The following code will throw a <a href=\"../typeerror\"><code>TypeError</code></a>:</p> <pre data-language=\"js\">'/bar/'.startsWith(/bar/); \n\n// Throws TypeError, as /bar/ is a regular expression\n// and Symbol.match is not modified.</pre> <p>However, if you set <code>Symbol.match</code> to <code>false</code>, the <code>isRegExp</code> check (that uses the <code>match</code> property) will indicate that the object is not a regular expression object. The methods <code>startsWith</code> and <code>endsWith</code> won't throw a <code>TypeError</code> as a consequence.</p> <pre data-language=\"js\">var re = /foo/;\nre[Symbol.match] = false;\n'/foo/'.startsWith(re); // true\n'/baz/'.endsWith(re);   // false\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-symbol.match\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Symbol.match' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-symbol.match\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Symbol.match' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 50</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 40</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 40</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 6.0.0</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"replace\"><code>Symbol.replace</code></a></li> <li><a href=\"search\"><code>Symbol.search</code></a></li> <li><a href=\"split\"><code>Symbol.split</code></a></li> <li><a href=\"../regexp/@@match\"><code>RegExp.prototype[@@match]()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/match$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/match\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/match</a>\n  </p>\n</div>\n","global_objects/symbol/replace":"<h1>Symbol.replace</h1> <p>The <code><strong>Symbol.replace</strong></code> well-known symbol specifies the method that replaces matched substrings of a string. This function is called by the <a href=\"../string/replace\"><code>String.prototype.replace()</code></a> method.</p> <p>For more information, see <a href=\"../regexp/@@replace\"><code>RegExp.prototype[@@replace]()</code></a> and <a href=\"../string/replace\"><code>String.prototype.replace()</code></a>.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/symbol-replace.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <div class=\"_table\"><table class=\"standard-table\"> <thead> <tr> <th colspan=\"2\" class=\"header\">Property attributes of <code>Symbol.replace</code>\n</th> </tr> </thead> <tbody> <tr> <td>Writable</td> <td>no</td> </tr> <tr> <td>Enumerable</td> <td>no</td> </tr> <tr> <td>Configurable</td> <td>no</td> </tr> </tbody> </table></div> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-symbol.replace\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Symbol.replace' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-symbol.replace\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Symbol.replace' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 50</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 49</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 49</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 6.0.0</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"match\"><code>Symbol.match</code></a></li> <li><a href=\"search\"><code>Symbol.search</code></a></li> <li><a href=\"split\"><code>Symbol.split</code></a></li> <li><a href=\"../regexp/@@replace\"><code>RegExp.prototype[@@replace]()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/replace$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/replace\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/replace</a>\n  </p>\n</div>\n","global_objects/symbol/search":"<h1>Symbol.search</h1> <p>The <code><strong>Symbol.search</strong></code> well-known symbol specifies the method that returns the index within a string that matches the regular expression. This function is called by the <a href=\"../string/search\"><code>String.prototype.search()</code></a> method.</p> <p>For more information, see <a href=\"../regexp/@@search\"><code>RegExp.prototype[@@search]()</code></a> and <a href=\"../string/search\"><code>String.prototype.search()</code></a>.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/symbol-search.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <div class=\"_table\"><table class=\"standard-table\"> <thead> <tr> <th colspan=\"2\" class=\"header\">Property attributes of <code>Symbol.search</code>\n</th> </tr> </thead> <tbody> <tr> <td>Writable</td> <td>no</td> </tr> <tr> <td>Enumerable</td> <td>no</td> </tr> <tr> <td>Configurable</td> <td>no</td> </tr> </tbody> </table></div> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-symbol.search\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Symbol.search' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-symbol.search\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Symbol.search' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 50</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 49</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 49</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 6.0.0</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"match\"><code>Symbol.match</code></a></li> <li><a href=\"replace\"><code>Symbol.replace</code></a></li> <li><a href=\"split\"><code>Symbol.split</code></a></li> <li><a href=\"../regexp/@@search\"><code>RegExp.prototype[@@search]()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/search$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/search\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/search</a>\n  </p>\n</div>\n","global_objects/symbol/species":"<h1>Symbol.species</h1> <p>The well-known symbol <code><strong>Symbol.species</strong></code> specifies a function-valued property that the constructor function uses to create derived objects.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/symbol-species.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <div class=\"_table\"><table class=\"standard-table\"> <thead> <tr> <th colspan=\"2\" class=\"header\">Property attributes of <code>Symbol.species</code>\n</th> </tr> </thead> <tbody> <tr> <td>Writable</td> <td>no</td> </tr> <tr> <td>Enumerable</td> <td>no</td> </tr> <tr> <td>Configurable</td> <td>no</td> </tr> </tbody> </table></div> <h2 id=\"Description\">Description</h2> <p>The species accessor property allows subclasses to override the default constructor for objects.</p> <h2 id=\"Examples\">Examples</h2> <p>You might want to return <a href=\"../array\"><code>Array</code></a> objects in your derived array class <code>MyArray</code>. For example, when using methods such as <a href=\"../array/map\"><code>map()</code></a> that return the default constructor, you want these methods to return a parent <code>Array</code> object, instead of the <code>MyArray</code> object. The species symbol lets you do this:</p> <pre data-language=\"js\">class MyArray extends Array {\n  // Overwrite species to the parent Array constructor\n  static get [Symbol.species]() { return Array; }\n}\nvar a = new MyArray(1,2,3);\nvar mapped = a.map(x =&gt; x * x);\n\nconsole.log(mapped instanceof MyArray); // false\nconsole.log(mapped instanceof Array);   // true\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-symbol.species\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Symbol.species' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-symbol.species\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Symbol.species' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 51</td>\n<td class=\"bc-supports-yes\"> 14</td>\n<td class=\"bc-supports-yes\"> 41</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 38</td>\n<td class=\"bc-supports-yes\"> 10</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 14</td>\n<td class=\"bc-supports-yes\"> 41</td>\n<td class=\"bc-supports-yes\"> 38</td>\n<td class=\"bc-supports-yes\"> 10</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes bc-has-history\"> 6.5.0\n<section class=\"bc-history\" id=\"sect1\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 6.5.0\n</dt>\n\n<dt class=\"bc-supports-yes bc-supports\"> 6.0.0<div class=\"bc-icons\">Disabled </div>\n</dt>\n<dd>Disabled From version 6.0.0: this feature is behind the <code>--harmony</code> runtime flag.</dd>\n</dl></section>\n</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"../map/@@species\"><code>Map[@@species]</code></a></li> <li><a href=\"../set/@@species\"><code>Set[@@species]</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/species$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/species\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/species</a>\n  </p>\n</div>\n","global_objects/symbol/split":"<h1>Symbol.split</h1> <p>The <code><strong>Symbol.split</strong></code> well-known symbol specifies the method that splits a string at the indices that match a regular expression. This function is called by the <a href=\"../string/split\"><code>String.prototype.split()</code></a> method.</p> <p>For more information, see <a href=\"../regexp/@@split\"><code>RegExp.prototype[@@split]()</code></a> and <a href=\"../string/split\"><code>String.prototype.split()</code></a>.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/symbol-split.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <div class=\"_table\"><table class=\"standard-table\"> <thead> <tr> <th colspan=\"2\" class=\"header\">Property attributes of <code>Symbol.split</code>\n</th> </tr> </thead> <tbody> <tr> <td>Writable</td> <td>no</td> </tr> <tr> <td>Enumerable</td> <td>no</td> </tr> <tr> <td>Configurable</td> <td>no</td> </tr> </tbody> </table></div> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-symbol.split\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Symbol.split' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-symbol.split\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Symbol.split' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 50</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 49</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 49</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 6.0.0</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"match\"><code>Symbol.match</code></a></li> <li><a href=\"replace\"><code>Symbol.replace</code></a></li> <li><a href=\"search\"><code>Symbol.search</code></a></li> <li><a href=\"../regexp/@@split\"><code>RegExp.prototype[@@split]()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/split$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/split\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/split</a>\n  </p>\n</div>\n","global_objects/symbol/prototype":"<h1>Symbol.prototype</h1> <p>The <code><strong>Symbol</strong></code><code>.prototype</code> property represents the prototype for the <a href=\"../symbol\"><code>Symbol</code></a> constructor.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/symbol-prototype.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <div class=\"_table\"><table class=\"standard-table\"> <thead> <tr> <th colspan=\"2\" class=\"header\">Property attributes of <code>Symbol.prototype</code>\n</th> </tr> </thead> <tbody> <tr> <td>Writable</td> <td>no</td> </tr> <tr> <td>Enumerable</td> <td>no</td> </tr> <tr> <td>Configurable</td> <td>no</td> </tr> </tbody> </table></div> <h2 id=\"Description\">Description</h2> <p><a href=\"../symbol\"><code>Symbol</code></a> instances inherit from <a href=\"prototype\"><code>Symbol.prototype</code></a>. You can use the constructor's prototype object to add properties or methods to all <code>Symbol</code> instances.</p> <h2 id=\"Properties\">Properties</h2> <dl> <dt><code>Symbol.prototype.constructor</code></dt> <dd>Returns the function that created an instance's prototype. This is the <a href=\"../symbol\"><code>Symbol</code></a> function by default.</dd> <dt><a href=\"description\"><code>Symbol.prototype.description</code></a></dt> <dd>A read-only string containing the description of the symbol.</dd> </dl> <h2 id=\"Methods\">Methods</h2> <dl> <dt>\n<a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/toSource\"><code>Symbol.prototype.toSource()</code></a> \n</dt> <dd>Returns a string containing the source of the <a href=\"../symbol\"><code>Symbol</code></a> object. Overrides the <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/toSource\"><code>Object.prototype.toSource()</code></a> method.</dd> <dt><a href=\"tostring\"><code>Symbol.prototype.toString()</code></a></dt> <dd>Returns a string containing the description of the Symbol. Overrides the <a href=\"../object/tostring\"><code>Object.prototype.toString()</code></a> method.</dd> <dt><a href=\"valueof\"><code>Symbol.prototype.valueOf()</code></a></dt> <dd>Returns the primitive value of the <a href=\"../symbol\"><code>Symbol</code></a> object. Overrides the <a href=\"../object/valueof\"><code>Object.prototype.valueOf()</code></a> method.</dd> <dt><a href=\"@@toprimitive\"><code>Symbol.prototype[@@toPrimitive]</code></a></dt> <dd>Returns the primitive value of the <a href=\"../symbol\"><code>Symbol</code></a> object.</dd> </dl> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-symbol.prototype\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Symbol.prototype' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-symbol.prototype\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Symbol.prototype' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 38</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 36</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 25</td>\n<td class=\"bc-supports-yes\"> 9</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 38</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 36</td>\n<td class=\"bc-supports-yes\"> 25</td>\n<td class=\"bc-supports-yes\"> 9</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/prototype$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/prototype\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/prototype</a>\n  </p>\n</div>\n","global_objects/symbol/description":"<h1>symbol.description</h1> <p>The read-only <code><strong>description</strong></code> property is a string returning the optional description of <a href=\"../symbol\"><code>Symbol</code></a> objects.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/symbol-prototype-description.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\">Symbol('myDescription').description;\nSymbol.iterator.description;\nSymbol.for('foo').description;\n</pre> <h2 id=\"Description\">Description</h2> <p><a href=\"../symbol\"><code>Symbol</code></a> objects can be created with an optional description which can be used for debugging but not to access the symbol itself. The <code>Symbol.prototype.description</code> property can be used to read that description. It is different to <code>Symbol.prototype.toString()</code> as it does not contain the enclosing \"<code>Symbol()</code>\" string. See the examples.</p> <h2 id=\"Examples\">Examples</h2> <pre data-language=\"js\">Symbol('desc').toString();   // \"Symbol(desc)\"\nSymbol('desc').description;  // \"desc\"\nSymbol('').description;      // \"\"\nSymbol().description;        // undefined\n\n// well-known symbols\nSymbol.iterator.toString();  // \"Symbol(Symbol.iterator)\"\nSymbol.iterator.description; // \"Symbol.iterator\"\n\n// global symbols\nSymbol.for('foo').toString();  // \"Symbol(foo)\"\nSymbol.for('foo').description; // \"foo\"\n\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> </tr> <tr> <td>\n<code><a href=\"https://tc39.github.io/proposal-Symbol-description/#sec-symbol.prototype.description\">get Symbol.prototype.description</a></code> proposal</td> <td>Stage 3</td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 70</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 63</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 57</td>\n<td class=\"bc-supports-no\"> No</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 70</td>\n<td class=\"bc-supports-yes\"> 70</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 63</td>\n<td class=\"bc-supports-yes\"> 57</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-no\"> No</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"tostring\"><code>Symbol.prototype.toString()</code></a></li> <li>Polyfill: <a href=\"https://npmjs.com/symbol.prototype.description\">https://npmjs.com/symbol.prototype.description</a>\n</li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/description$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/description\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/description</a>\n  </p>\n</div>\n","global_objects/symbol/tostringtag":"<h1>Symbol.toStringTag</h1> <p>The <code>Symbol.toStringTag</code> well-known symbol is a string valued property that is used in the creation of the default string description of an object. It is accessed internally by the <a href=\"../object/tostring\"><code>Object.prototype.toString()</code></a> method.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/symbol-tostringtag.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <div class=\"_table\"><table class=\"standard-table\"> <thead> <tr> <th colspan=\"2\" class=\"header\">Property attributes of <code>Symbol.toStringTag</code>\n</th> </tr> </thead> <tbody> <tr> <td>Writable</td> <td>no</td> </tr> <tr> <td>Enumerable</td> <td>no</td> </tr> <tr> <td>Configurable</td> <td>no</td> </tr> </tbody> </table></div> <h2 id=\"Description\">Description</h2> <p>Many JavaScript types have tags by default:</p> <pre data-language=\"js\">Object.prototype.toString.call('foo');     // \"[object String]\"\nObject.prototype.toString.call([1, 2]);    // \"[object Array]\"\nObject.prototype.toString.call(3);         // \"[object Number]\"\nObject.prototype.toString.call(true);      // \"[object Boolean]\"\nObject.prototype.toString.call(undefined); // \"[object Undefined]\"\nObject.prototype.toString.call(null);      // \"[object Null]\"\n// ... and more\n</pre> <p>Others have a built-in <code>toStringTag</code> symbol defined:</p> <pre data-language=\"js\">Object.prototype.toString.call(new Map());       // \"[object Map]\"\nObject.prototype.toString.call(function* () {}); // \"[object GeneratorFunction]\"\nObject.prototype.toString.call(Promise.resolve()); // \"[object Promise]\"\n// ... and more\n</pre> <p>When creating your own class, JavaScript defaults to the \"Object\" tag:</p> <pre data-language=\"js\">class ValidatorClass {}\n\nObject.prototype.toString.call(new ValidatorClass()); // \"[object Object]\"\n</pre> <p>Now, with the help of <code>toStringTag</code>, you are able to set your own custom tag:</p> <pre data-language=\"js\">class ValidatorClass {\n  get [Symbol.toStringTag]() {\n    return 'Validator';\n  }\n}\n\nObject.prototype.toString.call(new ValidatorClass()); // \"[object Validator]\"\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-symbol.tostringtag\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Symbol.toStringTag' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-symbol.tostringtag\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Symbol.toStringTag' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 49</td>\n<td class=\"bc-supports-yes\"> 15</td>\n<td class=\"bc-supports-yes\"> 51</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 51</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes bc-has-history\"> 6.0.0\n<section class=\"bc-history\" id=\"sect1\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 6.0.0\n</dt>\n\n<dt class=\"bc-supports-yes bc-supports\"> 4.0.0<div class=\"bc-icons\">Disabled </div>\n</dt>\n<dd>Disabled From version 4.0.0: this feature is behind the <code>--harmony</code> runtime flag.</dd>\n</dl></section>\n</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"../object/tostring\"><code>Object.prototype.toString()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/toStringTag$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/toStringTag\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/toStringTag</a>\n  </p>\n</div>\n","global_objects/regexp/@@replace":"<h1>regExp.@@replace</h1> <p>The <code>[@@replace]()</code> method replaces some or all matches of a <code>this</code> pattern in a string by a <code>replacement</code>, and returns the result of the replacement as a new string. The <code>replacement</code> can be a string or a function to be called for each match.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/regexp-prototype-@@replace.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\"><var>regexp</var>[Symbol.replace](str, <var>newSubStr</var>|<var>function</var>)</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><code>str</code></dt> <dd>A <a href=\"../string\"><code>String</code></a> that is a target of the replacement.</dd> <dt><code>newSubStr (replacement)</code></dt> <dd>The <a href=\"../string\"><code>String</code></a> that replaces the substring. A number of special replacement patterns are supported; see the <a href=\"../string/replace#Specifying_a_string_as_a_parameter\">Specifying a string as a parameter</a> section in <a href=\"../string/replace\"><code>String.prototype.replace()</code></a> page.</dd> <dt><code>function (replacement)</code></dt> <dd>A function to be invoked to create the new substring. The arguments supplied to this function are described in the <a href=\"../string/replace#Specifying_a_function_as_a_parameter\">Specifying a function as a parameter</a> section in <a href=\"../string/replace\"><code>String.prototype.replace()</code></a> page.</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p>A new string with some or all matches of a pattern replaced by a replacement.</p> <h2 id=\"Description\">Description</h2> <p>This method is called internally in <a href=\"../string/replace\"><code>String.prototype.replace()</code></a> if the <code>pattern</code> argument is a <a href=\"../regexp\"><code>RegExp</code></a> object. For example, following two examples return same result.</p> <pre data-language=\"js\">'abc'.replace(/a/, 'A');\n\n/a/[Symbol.replace]('abc', 'A');</pre> <p>This method exists for customizing replace behavior in <code>RegExp</code> subclass.</p> <p>If pattern argument is <strong>not</strong> a <a href=\"../regexp\"><code>RegExp</code></a> object, <a href=\"../string/replace\"><code>String.prototype.replace()</code></a> doesn't call this method, nor creates a <a href=\"../regexp\"><code>RegExp</code></a> object.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Direct_call\">Direct call</h3> <p>This method can be used in almost the same way as <a href=\"../string/replace\"><code>String.prototype.replace()</code></a>, except the different <code>this</code> and the different arguments order.</p> <pre data-language=\"js\">var re = /-/g; \nvar str = '2016-01-01';\nvar newstr = re[Symbol.replace](str, '.');\nconsole.log(newstr);  // 2016.01.01\n</pre> <h3 id=\"Using_replace_in_subclasses\">Using @@replace in subclasses</h3> <p>Subclasses of <a href=\"../regexp\"><code>RegExp</code></a> can override the <code>[@@replace]()</code> method to modify the default behavior.</p> <pre data-language=\"js\">class MyRegExp extends RegExp {\n  constructor(pattern, flags, count) {\n    super(pattern, flags);\n    this.count = count;\n  }\n  [Symbol.replace](str, replacement) {\n    // Perform @@replace |count| times.\n    var result = str;\n    for (var i = 0; i &lt; this.count; i++) {\n      result = RegExp.prototype[Symbol.replace].call(this, result, replacement);\n    }\n    return result;\n  }\n}\n\nvar re = new MyRegExp('\\\\d', '', 3);\nvar str = '01234567';\nvar newstr = str.replace(re, '#'); // String.prototype.replace calls re[@@replace].\nconsole.log(newstr); // ###34567</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-regexp.prototype-@@replace\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'RegExp.prototype[@@replace]' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-regexp.prototype-@@replace\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'RegExp.prototype[@@replace]' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>   <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 49</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 49</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 6.0.0</td>\n</tr></tbody>\n</table>\n</div>  <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"../string/replace\"><code>String.prototype.replace()</code></a></li> <li><a href=\"@@match\"><code>RegExp.prototype[@@match]()</code></a></li> <li><a href=\"@@search\"><code>RegExp.prototype[@@search]()</code></a></li> <li><a href=\"@@split\"><code>RegExp.prototype[@@split]()</code></a></li> <li><a href=\"exec\"><code>RegExp.prototype.exec()</code></a></li> <li><a href=\"test\"><code>RegExp.prototype.test()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/@@replace$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/@@replace\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/@@replace</a>\n  </p>\n</div>\n","global_objects/regexp/tostring":"<h1>regExp.toString</h1> <p>The <code>toString()</code> method returns a string representing the regular expression.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/regexp-prototype-tostring.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js taller\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\"><var>regexObj</var>.toString();</pre> <h3 id=\"Return_value\">Return value</h3> <p>A string representing the given object.</p> <h2 id=\"Description\">Description</h2> <p>The <a href=\"../regexp\"><code>RegExp</code></a> object overrides the <code>toString()</code> method of the <a href=\"../object\"><code>Object</code></a> object; it does not inherit <a href=\"../object/tostring\"><code>Object.prototype.toString()</code></a>. For <a href=\"../regexp\"><code>RegExp</code></a> objects, the <code>toString()</code> method returns a string representation of the regular expression.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Using_toString()\">Using <code>toString()</code>\n</h3> <p>The following example displays the string value of a <a href=\"../regexp\"><code>RegExp</code></a> object:</p> <pre data-language=\"js\">var myExp = new RegExp('a+b+c');\nconsole.log(myExp.toString());  // logs '/a+b+c/'\n\nvar foo = new RegExp('bar', 'g');\nconsole.log(foo.toString());    // logs '/bar/g'\n</pre> <h3 id=\"Empty_regular_expressions_and_escaping\">Empty regular expressions and escaping</h3> <p>Starting with ECMAScript 5, an empty regular expression returns the string \"/(?:)/\" and line terminators such as \"\\n\" are escaped:</p> <pre data-language=\"js\">new RegExp().toString(); // \"/(?:)/\"\n\nnew RegExp('\\n').toString() === '/\\n/';  // true, prior to ES5\nnew RegExp('\\n').toString() === '/\\\\n/'; // true, starting with ES5\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/publications/files/ECMA-ST-ARCH/ECMA-262,%203rd%20edition,%20December%201999.pdf\" hreflang=\"en\">ECMAScript 3rd Edition (ECMA-262)</a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition. Implemented in JavaScript 1.1.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/5.1/#sec-15.9.5.2\" hreflang=\"en\">ECMAScript 5.1 (ECMA-262)<br><small>The definition of 'RegExp.prototype.toString' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Added definition for escaping behavior and \"(?:)\" for empty regular expressions.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-regexp.prototype.tostring\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'RegExp.prototype.toString' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-regexp.prototype.tostring\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'RegExp.prototype.toString' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>   <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">Escaping</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 38</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">Generic function</th>\n<td> ? </td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 39</td>\n<td> ? </td>\n<td> ? </td>\n<td> ? </td>\n</tr>\n</tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">Escaping</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 38</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">Generic function</th>\n<td> ? </td>\n<td> ? </td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 39</td>\n<td> ? </td>\n<td> ? </td>\n<td> ? </td>\n</tr>\n</tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">Escaping</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">Generic function</th>\n<td> ? </td>\n</tr>\n</tbody>\n</table>\n</div>  <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"../object/tostring\"><code>Object.prototype.toString()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/toString$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/toString\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/toString</a>\n  </p>\n</div>\n","global_objects/symbol/unscopables":"<h1>Symbol.unscopables</h1> <p>The <code>Symbol.unscopables</code> well-known symbol is used to specify an object value of whose own and inherited property names are excluded from the <code><a href=\"../../statements/with\">with</a></code> environment bindings of the associated object.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/symbol-unscopables.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <div class=\"_table\"><table class=\"standard-table\"> <thead> <tr> <th colspan=\"2\" class=\"header\">Property attributes of <code>Symbol.unscopables</code>\n</th> </tr> </thead> <tbody> <tr> <td>Writable</td> <td>no</td> </tr> <tr> <td>Enumerable</td> <td>no</td> </tr> <tr> <td>Configurable</td> <td>no</td> </tr> </tbody> </table></div> <h2 id=\"Description\">Description</h2> <p>The <code>@@unscopables</code> symbol (<code>Symbol.unscopables</code>) can be defined on any object to exclude property names from being exposed as lexical variables in with <code><a href=\"../../statements/with\">with</a></code> environment bindings. Note that if using <a href=\"../../strict_mode\">Strict mode</a>, <code>with</code> statements are not available and will likely also not need this symbol.</p> <p>Setting a property to <code>true</code> in an <code>unscopables</code> object will make it <em>unscopable</em> and therefore it won't appear in lexical scope variables. Setting a property to <code>false</code> will make it <code>scopable</code> and thus it will appear in lexical scope variables.</p> <h2 id=\"Examples\">Examples</h2> <p>The following code works fine in ES5 and below. However, in ECMAScript 2015 and later, the <a href=\"../array/keys\"><code>Array.prototype.keys()</code></a> method was introduced. That means that inside <code>with</code> environment \"keys\" would now be the method and not the variable. That's when the <code>unscopable</code>s symbol was introduced. A built-in <code>unscopables</code> setting is implemented as <a href=\"../array/@@unscopables\"><code>Array.prototype[@@unscopables]</code></a> to prevent that some of the Array methods are being scoped into the <code>with</code> statement.</p> <pre data-language=\"js\">var keys = [];\n\nwith (Array.prototype) {\n  keys.push('something');\n}\n\nObject.keys(Array.prototype[Symbol.unscopables]); \n// [\"copyWithin\", \"entries\", \"fill\", \"find\", \"findIndex\", \n//  \"includes\", \"keys\", \"values\"]\n</pre> <p>You can also set <code>unscopables</code> for your own objects.</p> <pre data-language=\"js\">var obj = { \n  foo: 1, \n  bar: 2 \n};\n\nobj[Symbol.unscopables] = { \n  foo: false, \n  bar: true \n};\n\nwith (obj) {\n  console.log(foo); // 1\n  console.log(bar); // ReferenceError: bar is not defined\n}\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-symbol.unscopables\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Symbol.unscopables' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-symbol.unscopables\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Symbol.unscopables' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 38</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 48</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 9</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 48</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 9</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 0.12</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"../array/@@unscopables\"><code>Array.prototype[@@unscopables]</code></a></li> <li>\n<code><a href=\"../../statements/with\">with</a></code> statement (not available in <a href=\"../../strict_mode\">Strict mode</a>)</li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/unscopables$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/unscopables\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/unscopables</a>\n  </p>\n</div>\n","global_objects/symbol/for":"<h1>Symbol.for</h1> <p>The <code><strong>Symbol.for(key)</strong></code> method searches for existing symbols in a runtime-wide symbol registry with the given key and returns it if found. Otherwise a new symbol gets created in the global symbol registry with this key.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/symbol-for.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\"><var>Symbol.for(key)</var>;</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt>key</dt> <dd>String, required. The key for the symbol (and also used for the description of the symbol).</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p>An existing symbol with the given key if found; otherwise, a new symbol is created and returned.</p> <h2 id=\"Description\">Description</h2> <p>In contrast to <code>Symbol()</code>, the <code>Symbol.for()</code> function creates a symbol available in a global symbol registry list. <code>Symbol.for()</code> does also not necessarily create a new symbol on every call, but checks first if a symbol with the given <code>key</code> is already present in the registry. In that case, that symbol is returned. If no symbol with the given key is found, <code>Symbol.for()</code> will create a new global symbol.</p> <h3 id=\"Global_symbol_registry\">Global symbol registry</h3> <p>The global symbol registry is a list with the following record structure and it is initialized empty:</p> <div class=\"_table\"><table class=\"standard-table\"> <caption>A record in the global symbol registry</caption> <tbody> <tr> <th>Field name</th> <th>Value</th> </tr> <tr> <td>[[key]]</td> <td>A string key used to identify a symbol.</td> </tr> <tr> <td>[[symbol]]</td> <td>A symbol that is stored globally.</td> </tr> </tbody> </table></div> <h2 id=\"Examples\">Examples</h2> <pre data-language=\"js\">Symbol.for('foo'); // create a new global symbol\nSymbol.for('foo'); // retrieve the already created symbol\n\n// Same global symbol, but not locally\nSymbol.for('bar') === Symbol.for('bar'); // true\nSymbol('bar') === Symbol('bar'); // false\n\n// The key is also used as the description\nvar sym = Symbol.for('mario');\nsym.toString(); // \"Symbol(mario)\"\n</pre> <p>To avoid name clashes with your global symbol keys and other (library code) global symbols, it might be a good idea to prefix your symbols:</p> <pre data-language=\"js\">Symbol.for('mdn.foo');\nSymbol.for('mdn.bar');\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-symbol.for\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Symbol.for' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-symbol.for\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Symbol.for' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 40</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 36</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 9</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 36</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 9</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"keyfor\"><code>Symbol.keyFor()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/for$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/for\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/for</a>\n  </p>\n</div>\n","global_objects/symbol/toprimitive":"<h1>Symbol.toPrimitive</h1> <p>The <code><strong>Symbol.toPrimitive</strong></code> is a symbol that specifies a function valued property that is called to convert an object to a corresponding primitive value.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/symbol-toprimitive.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <div class=\"_table\"><table class=\"standard-table\"> <thead> <tr> <th colspan=\"2\" class=\"header\">Property attributes of <code>Symbol.toPrimitive</code>\n</th> </tr> </thead> <tbody> <tr> <td>Writable</td> <td>no</td> </tr> <tr> <td>Enumerable</td> <td>no</td> </tr> <tr> <td>Configurable</td> <td>no</td> </tr> </tbody> </table></div> <h2 id=\"Description\">Description</h2> <p>With the help of the <code>Symbol.toPrimitive</code> property (used as a function value), an object can be converted to a primitive value. The function is called with a string argument <code>hint</code>, which specifies the preferred type of the result primitive value. The <code>hint</code> argument can be one of <code>\"<em>number</em>\"</code>, <code>\"<em>string</em>\"</code>, and <code>\"<em>default</em>\"</code>.</p> <h2 id=\"Examples\">Examples</h2> <p>Following example describes how <code>Symbol.toPrimitive</code> property can modify the primitive value converted from an object.</p> <pre data-language=\"js\">// An object without Symbol.toPrimitive property.\nvar obj1 = {};\nconsole.log(+obj1);     // NaN\nconsole.log(`${obj1}`); // \"[object Object]\"\nconsole.log(obj1 + ''); // \"[object Object]\"\n\n// An object with Symbol.toPrimitive property.\nvar obj2 = {\n  [Symbol.toPrimitive](hint) {\n    if (hint == 'number') {\n      return 10;\n    }\n    if (hint == 'string') {\n      return 'hello';\n    }\n    return true;\n  }\n};\nconsole.log(+obj2);     // 10        -- hint is \"number\"\nconsole.log(`${obj2}`); // \"hello\"   -- hint is \"string\"\nconsole.log(obj2 + ''); // \"true\"    -- hint is \"default\"\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-symbol.toprimitive\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Symbol.toPrimitive' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-symbol.toprimitive\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Symbol.toPrimitive' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 48</td>\n<td class=\"bc-supports-yes\"> 15</td>\n<td class=\"bc-supports-yes\"> 44</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 44</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 6.0.0</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"../date/@@toprimitive\"><code>Date.prototype[@@toPrimitive]</code></a></li> <li><a href=\"@@toprimitive\"><code>Symbol.prototype[@@toPrimitive]</code></a></li> <li><a href=\"../object/tostring\"><code>Object.prototype.toString()</code></a></li> <li><a href=\"../object/valueof\"><code>Object.prototype.valueOf()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/toPrimitive$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/toPrimitive\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/toPrimitive</a>\n  </p>\n</div>\n","global_objects/symbol/keyfor":"<h1>Symbol.keyFor</h1> <p>The <code><strong>Symbol.keyFor(sym)</strong></code> method retrieves a shared symbol key from the global symbol registry for the given symbol.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/symbol-keyfor.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\"><var>Symbol.keyFor(sym)</var>;</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt>sym</dt> <dd>Symbol, required. The symbol to find a key for.</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p>A string representing the key for the given symbol if one is found on the global registry; otherwise, <a href=\"../undefined\"><code>undefined</code></a>.</p> <h2 id=\"Examples\">Examples</h2> <pre data-language=\"js\">var globalSym = Symbol.for('foo'); // create a new global symbol\nSymbol.keyFor(globalSym); // \"foo\"\n\nvar localSym = Symbol();\nSymbol.keyFor(localSym); // undefined\n\n// well-known symbols are not symbols registered \n// in the global symbol registry\nSymbol.keyFor(Symbol.iterator) // undefined\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-symbol.keyfor\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Symbol.keyFor' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-symbol.keyfor\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Symbol.keyFor' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 40</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 36</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 9</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 36</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 9</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"for\"><code>Symbol.for()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/keyFor$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/keyFor\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/keyFor</a>\n  </p>\n</div>\n","global_objects/symbol/tostring":"<h1>symbol.toString</h1> <p>The <code><strong>toString()</strong></code> method returns a string representing the specified <a href=\"../symbol\"><code>Symbol</code></a> object.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/symbol-prototype-tostring.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\"><var>Symbol().toString()</var>;</pre> <h3 id=\"Return_value\">Return value</h3> <p>A string representing the specified <a href=\"../symbol\"><code>Symbol</code></a> object.</p> <h2 id=\"Description\">Description</h2> <p>The <a href=\"../symbol\"><code>Symbol</code></a> object overrides the <code>toString</code> method of the <a href=\"../object\"><code>Object</code></a> object; it does not inherit <a href=\"../object/tostring\"><code>Object.prototype.toString()</code></a>. For <code>Symbol</code> objects, the <code>toString</code> method returns a string representation of the object.</p> <h3 id=\"No_string_concatenation\">No string concatenation</h3> <p>While you can call <code>toString()</code> on Symbols, you can't use string concatenation with them:</p> <pre data-language=\"js\">Symbol('foo') + 'bar';       // TypeError: Can't convert symbol to string</pre> <h2 id=\"Examples\">Examples</h2> <pre data-language=\"js\">Symbol('desc').toString();   // \"Symbol(desc)\"\n\n// well-known symbols\nSymbol.iterator.toString();  // \"Symbol(Symbol.iterator)\n\n// global symbols\nSymbol.for('foo').toString() // \"Symbol(foo)\"\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-symbol.prototype.tostring\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Symbol.prototype.toString' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-symbol.prototype.tostring\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Symbol.prototype.toString' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 38</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 36</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 25</td>\n<td class=\"bc-supports-yes\"> 9</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 38</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 36</td>\n<td class=\"bc-supports-yes\"> 25</td>\n<td class=\"bc-supports-yes\"> 9</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"../object/tostring\"><code>Object.prototype.toString()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/toString$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/toString\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/toString</a>\n  </p>\n</div>\n","global_objects/symbol/valueof":"<h1>symbol.valueOf</h1> <p>The <code><strong>valueOf()</strong></code> method returns the primitive value of a Symbol object.</p> <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\"><var>Symbol().valueOf();\n</var></pre> <h3 id=\"Return_value\">Return value</h3> <p>The primitive value of the specified <a href=\"../symbol\"><code>Symbol</code></a> object.</p> <h2 id=\"Description\">Description</h2> <p>The <code>valueOf</code> method of <a href=\"../symbol\"><code>Symbol</code></a> returns the primitive value of a Symbol object as a Symbol data type.</p> <p>JavaScript calls the <code>valueOf</code> method to convert an object to a primitive value. You rarely need to invoke the <code>valueOf</code> method yourself; JavaScript automatically invokes it when encountering an object where a primitive value is expected.</p> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-symbol.prototype.valueof\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Symbol.prototype.valueOf' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-symbol.prototype.valueof\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Symbol.prototype.valueOf' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 38</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 36</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 25</td>\n<td class=\"bc-supports-yes\"> 9</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 38</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 36</td>\n<td class=\"bc-supports-yes\"> 25</td>\n<td class=\"bc-supports-yes\"> 9</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"../object/valueof\"><code>Object.prototype.valueOf()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/valueOf$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/valueOf\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/valueOf</a>\n  </p>\n</div>\n","global_objects/symbol/@@toprimitive":"<h1>symbol.@@toPrimitive</h1> <p>The <code><strong>[@@toPrimitive]()</strong></code> method converts a Symbol object to a primitive value.</p> <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\"><var>Symbol()[Symbol.toPrimitive](hint);\n</var></pre> <h3 id=\"Return_value\">Return value</h3> <p>The primitive value of the specified <a href=\"../symbol\"><code>Symbol</code></a> object.</p> <h2 id=\"Description\">Description</h2> <p>The <code>[@@toPrimitive]()</code> method of <a href=\"../symbol\"><code>Symbol</code></a> returns the primitive value of a Symbol object as a Symbol data type. The <code>hint</code> argument is not used.</p> <p>JavaScript calls the <code>[@@toPrimitive]()</code> method to convert an object to a primitive value. You rarely need to invoke the <code>[@@toPrimitive]()</code> method yourself; JavaScript automatically invokes it when encountering an object where a primitive value is expected.</p> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-symbol.prototype-@@toprimitive\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Symbol.prototype.@@toPrimitive' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-symbol.prototype-@@toprimitive\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Symbol.prototype.@@toPrimitive' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td> ? </td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 44</td>\n<td class=\"bc-supports-no\"> No</td>\n<td> ? </td>\n<td> ? </td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td> ? </td>\n<td> ? </td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 44</td>\n<td> ? </td>\n<td> ? </td>\n<td> ? </td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td> ? </td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"toprimitive\"><code>Symbol.toPrimitive</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/@@toPrimitive$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/@@toPrimitive\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/@@toPrimitive</a>\n  </p>\n</div>\n","global_objects/string/search":"<h1>string.search</h1> <p>The <code>search()</code> method executes a search for a match between a regular expression and this <a href=\"../string\"><code>String</code></a> object.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/string-search.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\"><var>str</var>.search(<var>regexp</var>)</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><code>regexp</code></dt> <dd>A regular expression object. If a non-RegExp object <code>obj</code> is passed, it is implicitly converted to a <a href=\"../regexp\"><code>RegExp</code></a> by using <code>new RegExp(obj)</code>.</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p>The index of the first match between the regular expression and the given string; if not found, <strong>-1</strong>.</p> <h2 id=\"Description\">Description</h2> <p>When you want to know whether a pattern is found and also its index in a string use <code>search()</code> (if you only want to know if it exists, use the similar <a href=\"../regexp/test\"><code>test()</code></a> method on the RegExp prototype, which returns a boolean); for more information (but slower execution) use <a href=\"match\"><code>match()</code></a> (similar to the regular expression <a href=\"../regexp/exec\"><code>exec()</code></a> method).</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Using_search()\">Using <code>search()</code>\n</h3> <p>The following example searches a string with 2 different regex objects to show a successful search (positive value) vs. an unsuccessful search (-1)</p> <pre data-language=\"js\">var str = \"hey JudE\";\nvar re = /[A-Z]/g;\nvar re2 = /[.]/g;\nconsole.log(str.search(re)); // returns 4, which is the index of the first capital letter \"J\"\nconsole.log(str.search(re2)); // returns -1 cannot find '.' dot punctuation</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/publications/files/ECMA-ST-ARCH/ECMA-262,%203rd%20edition,%20December%201999.pdf\" hreflang=\"en\">ECMAScript 3rd Edition (ECMA-262)</a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition. Implemented in JavaScript 1.2.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/5.1/#sec-15.5.4.12\" hreflang=\"en\">ECMAScript 5.1 (ECMA-262)<br><small>The definition of 'String.prototype.search' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-string.prototype.search\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'String.prototype.search' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-string.prototype.search\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'String.prototype.search' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<code>flags</code> \n</th>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\">1 — 49</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n</tr>\n</tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<code>flags</code> \n</th>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\">4 — 49</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n</tr>\n</tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">\n<code>flags</code> \n</th>\n<td class=\"bc-supports-no\"> No</td>\n</tr>\n</tbody>\n</table>\n</div> <h2 id=\"Gecko-specific_notes\">Gecko-specific notes</h2> <ul> <li>\n<code>flags</code> was a non standard second argument only available in Gecko : <var>str</var>.search(<var>regexp, flags</var>)</li> <li>Prior to <span>Gecko 8.0</span>, <code>search()</code> was implemented incorrectly; when it was called with no parameters or with <a href=\"../undefined\"><code>undefined</code></a>, it would match against the string 'undefined', instead of matching against the empty string. This is fixed; now <code>'a'.search()</code> and <code>'a'.search(undefined)</code> correctly return 0.</li> <li>Starting with Gecko 39 (Firefox 39 / Thunderbird 39 / SeaMonkey 2.36), the non-standard <code>flags</code> argument is deprecated and throws a console warning (<a href=\"https://bugzilla.mozilla.org/show_bug.cgi?id=1142351\">bug 1142351</a>).</li> <li>Starting with Gecko 47 (Firefox 47 / Thunderbird 47 / SeaMonkey 2.44), the non-standard <code>flags</code> argument is no longer supported in non-release builds and will soon be removed entirely (<a href=\"https://bugzilla.mozilla.org/show_bug.cgi?id=1245801\">bug 1245801</a>).</li> <li>Starting with Gecko 49 (Firefox 49 / Thunderbird 49 / SeaMonkey 2.46), the non-standard <code>flags</code> argument is no longer supported (<a href=\"https://bugzilla.mozilla.org/show_bug.cgi?id=1108382\">bug 1108382</a>).</li> </ul> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"match\"><code>String.prototype.match()</code></a></li> <li><a href=\"../regexp/exec\"><code>RegExp.prototype.exec()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/search$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/search\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/search</a>\n  </p>\n</div>\n","global_objects/string/split":"<h1>string.split</h1> <p>The <code>split()</code> method splits a <a href=\"../string\"><code>String</code></a> object into an array of strings by separating the string into substrings, using a specified separator string to determine where to make each split.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/string-split.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\"><var>str</var>.split([<var>separator</var>[, <var>limit</var>]])</pre> <div class=\"warning\"> <p>Attention: If an empty string (\"\") is used as the separator, the string is <strong>not</strong> split between each <em>user-perceived character</em> (<a href=\"https://unicode.org/reports/tr29/#Grapheme_Cluster_Boundaries\">grapheme cluster</a>) or between each unicode character (codepoint) but between each UTF-16 codeunit. This destroys <a href=\"http://unicode.org/faq/utf_bom.html#utf16-2\">surrogate pairs</a>. See also <a href=\"https://stackoverflow.com/a/34717402\">How do you get a string to a character array in JavaScript?</a> on stackoverflow.</p> </div> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt>\n<code>separator</code> <span class=\"inlineIndicator optional optionalInline\">Optional</span>\n</dt> <dd>Specifies the string which denotes the points at which each split should occur. The <code>separator</code> is treated as a string or as a <a href=\"../regexp\">regular expression</a>. If a plain-text <code>separator</code> contains more than one character, that entire string must be found to represent a split point. If <code>separator</code> is omitted or does not occur in <code>str</code>, the array returned contains one element consisting of the entire string. If <code>separator</code> is an empty string, <code>str</code> is converted to an array of characters.</dd> <dt>\n<code>limit</code> <span class=\"inlineIndicator optional optionalInline\">Optional</span>\n</dt> <dd> <p>Integer specifying a limit on the number of splits to be found. When this parameter is provided, the <code>split()</code> method splits the string at each occurrence of the specified <code>separator</code> but stops when <code>limit</code> entries have been placed into the array. It may still contain fewer entries than <code>limit</code> if the end of the string is reached before the specified limit is reached. The left-over text is not returned in the new array.</p> </dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p>An <a href=\"../array\"><code>Array</code></a> of strings split at each point where the separator occurs in the given string.</p> <h2 id=\"Description\">Description</h2> <p>When found, <code>separator</code> is removed from the string and the substrings are returned in an array. If <code>separator</code> is not found or is omitted, the array contains one element consisting of the entire string. If <code>separator</code> is an empty string, <code>str</code> is converted to an array of characters. If <code>separator</code> appears at the beginning or end of the string, or both, the array begins, ends, or both begins and ends, respectively, with an empty string. Thus, if the string consists solely of one instance of <code>separator</code>, the array consists of two empty strings.</p> <p>If <code>separator</code> is a regular expression that contains capturing parentheses, then each time <code>separator</code> is matched, the results (including any undefined results) of the capturing parentheses are spliced into the output array.</p> <div class=\"blockIndicator note\">\n<strong>Note:</strong> if separator is an array, then Array is coerced to String and used as separator.</div> <div class=\"blockIndicator note\">\n<strong>Note:</strong> When the string is empty, <code>split()</code> returns an array containing one empty string, rather than an empty array. If the string and separator are both empty strings, an empty array is returned.</div> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Using_split()\">Using <code>split()</code>\n</h3> <p>The following example defines a function that splits a string into an array of strings using the specified separator. After splitting the string, the function logs messages indicating the original string (before the split), the separator used, the number of elements in the array, and the individual array elements.</p> <pre data-language=\"js\">function splitString(stringToSplit, separator) {\n  var arrayOfStrings = stringToSplit.split(separator);\n\n  console.log('The original string is: \"' + stringToSplit + '\"');\n  console.log('The separator is: \"' + separator + '\"');\n  console.log('The array has ' + arrayOfStrings.length + ' elements: ' + arrayOfStrings.join(' / '));\n}\n\nvar tempestString = 'Oh brave new world that has such people in it.';\nvar monthString = 'Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec';\n\nvar space = ' ';\nvar comma = ',';\n\nsplitString(tempestString, space);\nsplitString(tempestString);\nsplitString(monthString, comma);\n</pre> <p>This example produces the following output:</p> <pre>The original string is: \"Oh brave new world that has such people in it.\"\nThe separator is: \" \"\nThe array has 10 elements: Oh / brave / new / world / that / has / such / people / in / it.\n\nThe original string is: \"Oh brave new world that has such people in it.\"\nThe separator is: \"undefined\"\nThe array has 1 elements: Oh brave new world that has such people in it.\n\nThe original string is: \"Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec\"\nThe separator is: \",\"\nThe array has 12 elements: Jan / Feb / Mar / Apr / May / Jun / Jul / Aug / Sep / Oct / Nov / Dec\n</pre> <h3 id=\"Removing_spaces_from_a_string\">Removing spaces from a string</h3> <p>In the following example, <code>split()</code> looks for 0 or more spaces followed by a semicolon followed by 0 or more spaces and, when found, removes the spaces and the semicolon from the string. <code>nameList</code> is the array returned as a result of <code>split()</code>.</p> <pre data-language=\"js\">var names = 'Harry Trump ;Fred Barney; Helen Rigby ; Bill Abel ;Chris Hand ';\n\nconsole.log(names);\n\nvar re = /\\s*(?:;|$)\\s*/;\nvar nameList = names.split(re);\n\nconsole.log(nameList);\n</pre> <p>This logs two lines; the first line logs the original string, and the second line logs the resulting array.</p> <pre>Harry Trump ;Fred Barney; Helen Rigby ; Bill Abel ;Chris Hand \n[ \"Harry Trump\", \"Fred Barney\", \"Helen Rigby\", \"Bill Abel\", \"Chris Hand\", \"\" ]\n</pre> <h3 id=\"Returning_a_limited_number_of_splits\">Returning a limited number of splits</h3> <p>In the following example, <code>split()</code> looks for spaces in a string and returns the first 3 splits that it finds.</p> <pre data-language=\"js\">var myString = 'Hello World. How are you doing?';\nvar splits = myString.split(' ', 3);\n\nconsole.log(splits);\n</pre> <p>This script displays the following:</p> <pre>[\"Hello\", \"World.\", \"How\"]\n</pre> <h3 id=\"Splitting_with_a_RegExp_to_include_parts_of_the_separator_in_the_result\">Splitting with a <code>RegExp</code> to include parts of the separator in the result</h3> <p>If <code>separator</code> is a regular expression that contains capturing parentheses <code>(</code><code>)</code>, matched results are included in the array.</p> <pre data-language=\"js\">var myString = 'Hello 1 word. Sentence number 2.';\nvar splits = myString.split(/(\\d)/);\n\nconsole.log(splits);\n</pre> <p>This script displays the following:</p> <pre>[ \"Hello \", \"1\", \" word. Sentence number \", \"2\", \".\" ]\n</pre> <h3 id=\"Splitting_with_an_array_as_separator\">Splitting with an array as separator</h3> <pre data-language=\"js\">var myString = 'this|is|a|Test';\nvar splits = myString.split(['|']);\n\nconsole.log(splits); //[\"this\", \"is\", \"a\", \"Test\"]\n\nvar myString = 'ca,bc,a,bca,bca,bc';\n\nvar splits = myString.split(['a','b']); \n// <em>myString.split(['a','b'])</em> is same as <em>myString.split(String(['a','b']))</em> \n\nconsole.log(splits);  //[\"c\", \"c,\", \"c\", \"c\", \"c\"]\n</pre> <h3 id=\"Reversing_a_String_using_split()\">Reversing a String using <code>split()</code>\n</h3> <div class=\"warning\"> <p>This is not a robust way to reverse a string:</p> <pre data-language=\"js\">var str = 'asdfghjkl';\nvar strReverse = str.split('').reverse().join(''); // 'lkjhgfdsa'\n// split() returns an array on which reverse() and join() can be applied\n</pre> <p>It doesn't work if the string contains grapheme clusters, even when using a unicode aware split (use for example <a href=\"https://github.com/mathiasbynens/esrever\">esrever</a> instead).</p> <pre data-language=\"js\">var str = 'résumé';\nvar strReverse = str.split(/(?:)/u).reverse().join('');\n// =&gt; \"́emuśer\"\n</pre> <p><strong>Bonus:</strong> use <a href=\"../../operators/comparison_operators#Identity_strict_equality_(===)\"><code>===</code></a> operator to test if the original string was palindrome.</p> </div> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/publications/files/ECMA-ST-ARCH/ECMA-262,%203rd%20edition,%20December%201999.pdf\" hreflang=\"en\">ECMAScript 3rd Edition (ECMA-262)</a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition. Implemented in JavaScript 1.1.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/5.1/#sec-15.5.4.14\" hreflang=\"en\">ECMAScript 5.1 (ECMA-262)<br><small>The definition of 'String.prototype.split' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-string.prototype.split\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'String.prototype.split' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-string.prototype.split\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'String.prototype.split' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"charat\"><code>String.prototype.charAt()</code></a></li> <li><a href=\"indexof\"><code>String.prototype.indexOf()</code></a></li> <li><a href=\"lastindexof\"><code>String.prototype.lastIndexOf()</code></a></li> <li><a href=\"../array/join\"><code>Array.prototype.join()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/split$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/split\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/split</a>\n  </p>\n</div>\n","global_objects/date/now":"<h1>Date.now</h1> <p>The <code>Date.now()</code> method returns the number of milliseconds elapsed since January 1, 1970 00:00:00 UTC.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/date-now.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe> <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\">var timeInMs = Date.now();</pre> <h3 id=\"Return_value\">Return value</h3> <p>A <a href=\"../number\"><code>Number</code></a> representing the milliseconds elapsed since the UNIX epoch.</p> <h2 id=\"Description\">Description</h2> <p>Because <code>now()</code> is a static method of <a href=\"../date\"><code>Date</code></a>, you always use it as <code>Date.now()</code>.</p> <h2 id=\"Reduced_time_precision\">Reduced time precision</h2> <p>To offer protection against timing attacks and fingerprinting, the precision of <code>Date.now()</code> might get rounded depending on browser settings.<br> In Firefox, the <code>privacy.reduceTimerPrecision</code> preference is enabled by default and defaults to 20us in Firefox 59; in 60 it will be 2ms.</p> <pre data-language=\"js\">// reduced time precision (2ms) in Firefox 60\nDate.now()\n// 1519211809934\n// 1519211810362\n// 1519211811670\n// ...\n\n\n// reduced time precision with `privacy.resistFingerprinting` enabled\nDate.now();\n// 1519129853500\n// 1519129858900\n// 1519129864400\n// ...\n</pre> <p>In Firefox, you can also enable <code>privacy.resistFingerprinting</code>, the precision will be 100ms or the value of <code>privacy.resistFingerprinting.reduceTimerPrecision.microseconds</code>, whichever is larger.</p> <h2 id=\"Polyfill\">Polyfill</h2> <p>This method was standardized in ECMA-262 5<sup>th</sup> edition. Engines which have not been updated to support this method can work around the absence of this method using the following shim:</p> <pre data-language=\"js\">if (!Date.now) {\n  Date.now = function now() {\n    return new Date().getTime();\n  };\n}\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/5.1/#sec-15.9.4.4\" hreflang=\"en\">ECMAScript 5.1 (ECMA-262)<br><small>The definition of 'Date.now' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition. Implemented in JavaScript 1.5.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-date.now\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Date.now' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-date.now\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Date.now' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 5</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 3</td>\n<td class=\"bc-supports-yes\"> 9</td>\n<td class=\"bc-supports-yes\"> 10.5</td>\n<td class=\"bc-supports-yes\"> 4</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li>\n<a href=\"https://developer.mozilla.org/en-US/docs/Web/API/Performance/now\"><code>Performance.now()</code></a> — provides timestamps with sub-millisecond resolution for use in measuring web page performance</li> <li>\n<a href=\"https://developer.mozilla.org/en-US/docs/Web/API/Console/time\"><code>console.time()</code></a> / <a href=\"https://developer.mozilla.org/en-US/docs/Web/API/Console/timeEnd\"><code>console.timeEnd()</code></a>\n</li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/now$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/now\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/now</a>\n  </p>\n</div>\n","global_objects/date/getday":"<h1>date.getDay</h1> <p>The <code>getDay()</code> method returns the day of the week for the specified date according to local time, where 0 represents Sunday. For the day of the month see <a href=\"getdate\">getDate()</a>.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/date-getday.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\"><var>dateObj</var>.getDay()</pre> <h3 id=\"Return_value\">Return value</h3> <p>An integer number corresponding to the day of the week for the given date, according to local time: 0 for Sunday, 1 for Monday, 2 for Tuesday, and so on.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Using_getDay()\">Using <code>getDay()</code>\n</h3> <p>The second statement below assigns the value 1 to <code>weekday</code>, based on the value of the <a href=\"../date\"><code>Date</code></a> object <code>Xmas95</code>. December 25, 1995, is a Monday.</p> <pre data-language=\"js\">var Xmas95 = new Date('December 25, 1995 23:15:30');\nvar weekday = Xmas95.getDay();\n\nconsole.log(weekday); // 1\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-date.prototype.getday\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Date.prototype.getDay' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-date.prototype.getday\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Date.prototype.getDay' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/5.1/#sec-15.9.5.16\" hreflang=\"en\">ECMAScript 5.1 (ECMA-262)<br><small>The definition of 'Date.prototype.getDay' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/publications/files/ECMA-ST-ARCH/ECMA-262,%201st%20edition,%20June%201997.pdf\" hreflang=\"en\">ECMAScript 1st Edition (ECMA-262)</a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition. Implemented in JavaScript 1.0.</td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"getutcdate\"><code>Date.prototype.getUTCDate()</code></a></li> <li><a href=\"getutcday\"><code>Date.prototype.getUTCDay()</code></a></li> <li><a href=\"setdate\"><code>Date.prototype.setDate()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getDay$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getDay\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getDay</a>\n  </p>\n</div>\n","global_objects/date/getdate":"<h1>date.getDate</h1> <p>The <code>getDate()</code> method returns the day of the month for the specified date according to local time.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/date-getdate.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\"><var>dateObj</var>.getDate()</pre> <h3 id=\"Return_value\">Return value</h3> <p>An integer number, between 1 and 31, representing the day of the month for the given date according to local time.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Using_getDate()\">Using getDate()</h3> <p>The second statement below assigns the value 25 to the variable <code>day</code>, based on the value of the <a href=\"../date\"><code>Date</code></a> object <code>Xmas95</code>.</p> <pre data-language=\"js\">var Xmas95 = new Date('December 25, 1995 23:15:30');\nvar day = Xmas95.getDate();\n\nconsole.log(day); // 25\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-date.prototype.getdate\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Date.prototype.getDate' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-date.prototype.getdate\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Date.prototype.getDate' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/5.1/#sec-15.9.5.14\" hreflang=\"en\">ECMAScript 5.1 (ECMA-262)<br><small>The definition of 'Date.prototype.getDate' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/publications/files/ECMA-ST-ARCH/ECMA-262,%201st%20edition,%20June%201997.pdf\" hreflang=\"en\">ECMAScript 1st Edition (ECMA-262)</a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition. Implemented in JavaScript 1.1.</td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"getutcdate\"><code>Date.prototype.getUTCDate()</code></a></li> <li><a href=\"getutcday\"><code>Date.prototype.getUTCDay()</code></a></li> <li><a href=\"setdate\"><code>Date.prototype.setDate()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getDate$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getDate\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getDate</a>\n  </p>\n</div>\n","global_objects/date/getfullyear":"<h1>date.getFullYear</h1> <p>The <code>getFullYear()</code> method returns the year of the specified date according to local time.</p> <p>Use this method instead of the <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getYear\"><code>getYear()</code></a> method.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/date-getfullyear.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\"><var>dateObj</var>.getFullYear()</pre> <h3 id=\"Return_value\">Return value</h3> <p>A number corresponding to the year of the given date, according to local time.</p> <h2 id=\"Description\">Description</h2> <p>The value returned by <code>getFullYear()</code> is an absolute number. For dates between the years 1000 and 9999, <code>getFullYear()</code> returns a four-digit number, for example, 1995. Use this function to make sure a year is compliant with years after 2000.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Using_getFullYear()\">Using <code>getFullYear()</code>\n</h3> <p>The following example assigns the four-digit value of the current year to the variable <code>year</code>.</p> <pre data-language=\"js\">var today = new Date();\nvar year = today.getFullYear();\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/publications/files/ECMA-ST-ARCH/ECMA-262,%201st%20edition,%20June%201997.pdf\" hreflang=\"en\">ECMAScript 1st Edition (ECMA-262)</a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition. Implemented in JavaScript 1.3.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/5.1/#sec-15.9.5.10\" hreflang=\"en\">ECMAScript 5.1 (ECMA-262)<br><small>The definition of 'Date.prototype.getFullYear' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-date.prototype.getfullyear\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Date.prototype.getFullYear' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-date.prototype.getfullyear\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Date.prototype.getFullYear' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"getutcfullyear\"><code>Date.prototype.getUTCFullYear()</code></a></li> <li><a href=\"setfullyear\"><code>Date.prototype.setFullYear()</code></a></li> <li><a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getYear\"><code>Date.prototype.getYear()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getFullYear$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getFullYear\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getFullYear</a>\n  </p>\n</div>\n","global_objects/date/getminutes":"<h1>date.getMinutes</h1> <p>The <code>getMinutes()</code> method returns the minutes in the specified date according to local time.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/date-getminutes.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe> <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\"><var>dateObj</var>.getMinutes()</pre> <h3 id=\"Return_value\">Return value</h3> <p>An integer number, between 0 and 59, representing the minutes in the given date according to local time.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Using_getMinutes()\">Using <code>getMinutes()</code>\n</h3> <p>The second statement below assigns the value 15 to the variable <code>minutes</code>, based on the value of the <a href=\"../date\"><code>Date</code></a> object <code>Xmas95</code>.</p> <pre data-language=\"js\">var Xmas95 = new Date('December 25, 1995 23:15:30');\nvar minutes = Xmas95.getMinutes();\n\nconsole.log(minutes); // 15\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/publications/files/ECMA-ST-ARCH/ECMA-262,%201st%20edition,%20June%201997.pdf\" hreflang=\"en\">ECMAScript 1st Edition (ECMA-262)</a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition. Implemented in JavaScript 1.0.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/5.1/#sec-15.9.5.20\" hreflang=\"en\">ECMAScript 5.1 (ECMA-262)<br><small>The definition of 'Date.prototype.getMinutes' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-date.prototype.getminutes\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Date.prototype.getMinutes' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-date.prototype.getminutes\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Date.prototype.getMinutes' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"getutcminutes\"><code>Date.prototype.getUTCMinutes()</code></a></li> <li><a href=\"setminutes\"><code>Date.prototype.setMinutes()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getMinutes$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getMinutes\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getMinutes</a>\n  </p>\n</div>\n","global_objects/date/gettimezoneoffset":"<h1>date.getTimezoneOffset</h1> <p>The <code>getTimezoneOffset()</code> method returns the time zone difference, in minutes, from current locale (host system settings) to UTC.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/date-gettimezoneoffset.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\"><var>dateObj</var>.getTimezoneOffset()</pre> <h3 id=\"Return_value\">Return value</h3> <p>A number representing the time-zone offset, in minutes, from the date based on current host system settings to UTC.</p> <h2 id=\"Description\">Description</h2> <p>The time-zone offset is the difference, in minutes, from local time to UTC. Note that this means that the offset is positive if the local timezone is behind UTC and negative if it is ahead. For example, for time zone UTC+10:00 (Australian Eastern Standard Time, Vladivostok Time, Chamorro Standard Time), -600 will be returned.</p> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <td>Current Locale</td> <td>UTC-8</td> <td>UTC</td> <td>UTC+3</td> </tr> <tr> <td>Return Value</td> <td>480</td> <td>0</td> <td>-180</td> </tr> </tbody> </table></div> <p>The time zone offset returned is the one that applies for the Date that it's called on. Where the host system is configured for daylight saving, the offset will change depending on the date and time that the Date represents and that daylight saving applies.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Using_getTimezoneOffset()\">Using <code>getTimezoneOffset()</code>\n</h3> <pre data-language=\"js\">// Get current timezone offset for host device\nvar x = new Date();\nvar currentTimeZoneOffsetInHours = x.getTimezoneOffset() / 60;\n// 1\n\n// Get timezone offset for International Labour Day (May 1) in 2016\n// Be careful, the Date() constructor uses 0-indexed month so May is\n// represented with 4 (and not 5)\nvar labourDay = new Date(2016, 4, 1)\nvar labourDayOffset = labourDay.getTimezoneOffset() / 60;\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/publications/files/ECMA-ST-ARCH/ECMA-262,%201st%20edition,%20June%201997.pdf\" hreflang=\"en\">ECMAScript 1st Edition (ECMA-262)</a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition. Implemented in JavaScript 1.0.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/5.1/#sec-15.9.5.26\" hreflang=\"en\">ECMAScript 5.1 (ECMA-262)<br><small>The definition of 'Date.prototype.getTimezoneOffset' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-date.prototype.gettimezoneoffset\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Date.prototype.getTimezoneOffset' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-date.prototype.gettimezoneoffset\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Date.prototype.getTimezoneOffset' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> 5</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getTimezoneOffset$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getTimezoneOffset\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getTimezoneOffset</a>\n  </p>\n</div>\n","global_objects/date/parse":"<h1>Date.parse</h1> <p>The <code>Date.parse()</code> method parses a string representation of a date, and returns the number of milliseconds since January 1, 1970, 00:00:00 UTC or <code>NaN</code> if the string is unrecognized or, in some cases, contains illegal date values (e.g. 2015-02-31).</p> <p>It is not recommended to use <code>Date.parse</code> as until ES5, parsing of strings was entirely implementation dependent. There are still many differences in how different hosts parse date strings, therefore date strings should be manually parsed (a library can help if many different formats are to be accommodated).</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/date-parse.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <p>Direct call:</p> <pre class=\"syntaxbox\">Date.parse(<var>dateString</var>)</pre> <p>Implicit call:</p> <pre class=\"syntaxbox\">new Date(<var>dateString</var>)</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><code>dateString</code></dt> <dd>A string representing an <a href=\"http://tools.ietf.org/html/rfc2822#section-3.3\">RFC2822</a> or (a variant of) ISO 8601 date (other formats may be used, but results may be unexpected).</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p>A number representing the milliseconds elapsed since January 1, 1970, 00:00:00 UTC and the date obtained by parsing the given string representation of a date. If the argument doesn't represent a valid date, <a href=\"../nan\"><code>NaN</code></a> is returned.</p> <h2 id=\"Description\">Description</h2> <p>The <code>parse()</code> method takes a date string (such as <code>\"Dec 25, 1995\"</code>) and returns the number of milliseconds since January 1, 1970, 00:00:00 UTC. This function is useful for setting date values based on string values, for example in conjunction with the <a href=\"settime\"><code>setTime()</code></a> method and the <a href=\"../date\"><code>Date</code></a> object.</p> <p>Given a string representing a time, <code>parse()</code> returns the time value. It accepts the RFC2822 / IETF date syntax (<a href=\"http://tools.ietf.org/html/rfc2822#section-3.3\">RFC2822 Section 3.3</a>), e.g. <code>\"Mon, 25 Dec 1995 13:30:00 GMT\"</code>. It understands the continental US time zone abbreviations, but for general use, use a time zone offset, for example, <code>\"Mon, 25 Dec 1995 13:30:00 +0430\"</code> (4 hours, 30 minutes east of the Greenwich meridian).</p> <p>GMT and UTC are considered equivalent. The local time zone is used to interpret arguments in <a href=\"http://tools.ietf.org/html/rfc2822#section-3.3\">RFC2822 Section 3.3</a> format that do not contain time zone information.</p> <p>Because of the variances in parsing of date strings, it is recommended to always manually parse strings as results are inconsistent, especially across different ECMAScript implementations where strings like <code>\"2015-10-12 12:00:00\"</code> may be parsed to as <code>NaN</code>, UTC or local timezone.</p> <h3 id=\"ECMAScript_5_ISO-8601_format_support\">ECMAScript 5 ISO-8601 format support</h3> <p>The date time string may be in a simplified <a href=\"http://www.w3.org/TR/NOTE-datetime\">ISO 8601</a> format. For example, <code>\"2011-10-10\"</code> (just date) or <code>\"2011-10-10T14:48:00\"</code> (date and time) can be passed and parsed. Where the string is ISO 8601 date only, the UTC time zone is used to interpret arguments. If the string is date and time in <a href=\"http://www.w3.org/TR/NOTE-datetime\">ISO 8601</a> format, it will be treated as local.</p> <p>While time zone specifiers are used during date string parsing to interpret the argument, the value returned is always the number of milliseconds between January 1, 1970 00:00:00 UTC and the point in time represented by the argument or <code>NaN</code>.</p> <p>Because <code>parse()</code> is a static method of <a href=\"../date\"><code>Date</code></a>, it is called as <code>Date.parse()</code> rather than as a method of a <a href=\"../date\"><code>Date</code></a> instance.</p> <h3 id=\"Differences_in_assumed_time_zone\">Differences in assumed time zone</h3> <p>Given a date string of <code>\"March 7, 2014\"</code>, <code>parse()</code> assumes a local time zone, but given an ISO format such as <code>\"2014-03-07\"</code> it will assume a time zone of UTC (ES5 and ECMAScript 2015). Therefore <a href=\"../date\"><code>Date</code></a> objects produced using those strings may represent different moments in time depending on the version of ECMAScript supported unless the system is set with a local time zone of UTC. This means that two date strings that appear equivalent may result in two different values depending on the format of the string that is being converted.</p> <h3 id=\"Fall-back_to_implementation-specific_date_formats\">Fall-back to implementation-specific date formats</h3> <p>The ECMAScript specification states: If the String does not conform to the standard format the function may fall back to any implementation–specific heuristics or implementation–specific parsing algorithm. Unrecognizable strings or dates containing illegal element values in ISO formatted strings shall cause <code>Date.parse()</code> to return <a href=\"../nan\"><code>NaN</code></a>.</p> <p>However, invalid values in date strings not recognized as simplified ISO format as defined by ECMA-262 may or may not result in <a href=\"../nan\"><code>NaN</code></a>, depending on the browser and values provided, e.g.:</p> <pre data-language=\"js\">// Non-ISO string with invalid date values\nnew Date('23/25/2014');\n</pre> <p>will be treated as a local date of 25 November, 2015 in Firefox 30 and an invalid date in Safari 7. However, if the string is recognized as an ISO format string and it contains invalid values, it will return <a href=\"../nan\"><code>NaN</code></a> in all browsers compliant with ES5 and later:</p> <pre data-language=\"js\">// ISO string with invalid values\nnew Date('2014-25-23').toISOString();\n// returns \"RangeError: invalid date\" in all es5 compliant browsers\n</pre> <p>SpiderMonkey's implementation-specific heuristic can be found in <a href=\"http://mxr.mozilla.org/mozilla-central/source/js/src/jsdate.cpp?rev=64553c483cd1#889\"><code>jsdate.cpp</code></a>. The string <code>\"10 06 2014\"</code> is an example of a non–conforming ISO format and thus falls back to a custom routine. See also this <a href=\"https://bugzilla.mozilla.org/show_bug.cgi?id=1023155#c6\">rough outline</a> on how the parsing works.</p> <pre data-language=\"js\">new Date('10 06 2014');\n</pre> <p>will be treated as a local date of 6 October, 2014 and not 10 June, 2014. Other examples:</p> <pre data-language=\"js\">new Date('foo-bar 2014').toString();\n// returns: \"Invalid Date\"\n\nDate.parse('foo-bar 2014');\n// returns: NaN\n</pre> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Using_Date.parse()\">Using <code>Date.parse()</code>\n</h3> <p>If <code>IPOdate</code> is an existing <a href=\"../date\"><code>Date</code></a> object, it can be set to August 9, 1995 (local time) as follows:</p> <pre data-language=\"js\">IPOdate.setTime(Date.parse('Aug 9, 1995'));</pre> <p>Some other examples of parsing non–standard date strings:</p> <pre data-language=\"js\">Date.parse('Aug 9, 1995');</pre> <p>Returns <code>807937200000</code> in time zone GMT-0300, and other values in other time zones, since the string does not specify a time zone and is not ISO format, therefore the time zone defaults to local.</p> <pre data-language=\"js\">Date.parse('Wed, 09 Aug 1995 00:00:00 GMT');</pre> <p>Returns <code>807926400000</code> no matter the local time zone as GMT (UTC) is provided.</p> <pre data-language=\"js\">Date.parse('Wed, 09 Aug 1995 00:00:00');</pre> <p>Returns <code>807937200000</code> in time zone GMT-0300, and other values in other time zones, since there is no time zone specifier in the argument and it is not ISO format, so is treated as local.</p> <pre data-language=\"js\">Date.parse('Thu, 01 Jan 1970 00:00:00 GMT');</pre> <p>Returns <code>0</code> no matter the local time zone as a time zone GMT (UTC) is provided.</p> <pre data-language=\"js\">Date.parse('Thu, 01 Jan 1970 00:00:00');</pre> <p>Returns <code>14400000</code> in time zone GMT-0400, and other values in other time zones, since no time zone is provided and the string is not in ISO format, therefore the local time zone is used.</p> <pre data-language=\"js\">Date.parse('Thu, 01 Jan 1970 00:00:00 GMT-0400');</pre> <p>Returns <code>14400000</code> no matter the local time zone as a time zone GMT (UTC) is provided.</p> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/publications/files/ECMA-ST-ARCH/ECMA-262,%201st%20edition,%20June%201997.pdf\" hreflang=\"en\">ECMAScript 1st Edition (ECMA-262)</a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition. Implemented in JavaScript 1.0.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/5.1/#sec-15.9.4.2\" hreflang=\"en\">ECMAScript 5.1 (ECMA-262)<br><small>The definition of 'Date.parse' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Simplified ISO 8601 format added.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-date.parse\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Date.parse' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-date.parse\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Date.parse' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">ISO 8601 format</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> 9</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n</tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">ISO 8601 format</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n</tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">ISO 8601 format</th>\n<td> ? </td>\n</tr>\n</tbody>\n</table>\n</div> <h2 id=\"Compatibility_notes\">Compatibility notes</h2> <ul> <li>Firefox 49 (Firefox 49 / Thunderbird 49 / SeaMonkey 2.46) changed the parsing of 2-digit years to be aligned with the Google Chrome browser instead of Internet Explorer. Now, 2-digit years that are less than <code>50</code> are parsed as 21st century years. For example, <code>04/16/17</code>, previously parsed as April 16, 1917, will be April 16, 2017 now. To avoid any interoperability issues or ambiguous years, it is recommended to use the ISO 8601 format like \"2017-04-16\" (<a href=\"https://bugzilla.mozilla.org/show_bug.cgi?id=1265136\">bug 1265136</a>).</li> </ul> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"utc\"><code>Date.UTC()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/parse$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/parse\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/parse</a>\n  </p>\n</div>\n","global_objects/date/getmonth":"<h1>date.getMonth</h1> <p>The <code>getMonth()</code> method returns the month in the specified date according to local time, as a zero-based value (where zero indicates the first month of the year).</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/date-getmonth.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\"><var>dateObj</var>.getMonth()</pre> <h3 id=\"Return_value\">Return value</h3> <p>An integer number, between 0 and 11, representing the month in the given date according to local time. 0 corresponds to January, 1 to February, and so on.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Using_getMonth()\">Using <code>getMonth()</code>\n</h3> <p>The second statement below assigns the value 11 to the variable <code>month</code>, based on the value of the <a href=\"../date\"><code>Date</code></a> object <code>Xmas95</code>.</p> <pre data-language=\"js\">var Xmas95 = new Date('December 25, 1995 23:15:30');\nvar month = Xmas95.getMonth();\n\nconsole.log(month); // 11\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/publications/files/ECMA-ST-ARCH/ECMA-262,%201st%20edition,%20June%201997.pdf\" hreflang=\"en\">ECMAScript 1st Edition (ECMA-262)</a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition. Implemented in JavaScript 1.0.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/5.1/#sec-15.9.5.12\" hreflang=\"en\">ECMAScript 5.1 (ECMA-262)<br><small>The definition of 'Date.prototype.getMonth' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-date.prototype.getmonth\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Date.prototype.getMonth' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-date.prototype.getmonth\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Date.prototype.getMonth' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div> <h2 name=\"See_also\" id=\"See_also\">See also</h2> <ul> <li><a href=\"getutcmonth\"><code>Date.prototype.getUTCMonth()</code></a></li> <li><a href=\"setmonth\"><code>Date.prototype.setMonth()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getMonth$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getMonth\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getMonth</a>\n  </p>\n</div>\n","global_objects/date/utc":"<h1>Date.UTC</h1> <p>The <code>Date.UTC()</code> method accepts the same parameters as the <a href=\"../date\"><code>Date</code></a> constructor, but treats them as UTC. It returns the number of milliseconds since January 1, 1970, 00:00:00 UTC.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/date-utc.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\">Date.UTC(<var>year</var>, <var>month</var>[, <var>day</var>[, <var>hour</var>[, <var>minute</var>[, <var>second</var>[, <var>millisecond</var>]]]]])</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><code>year</code></dt> <dd>A full year.</dd> <dt><code>month</code></dt> <dd>An integer between 0 and 11 representing the month.</dd> <dt><code>day</code></dt> <dd>Optional. An integer between 1 and 31 representing the day of the month. If omitted, defaults to 1.</dd> <dt><code>hour</code></dt> <dd>Optional. An integer between 0 and 23 representing the hours. If omitted, defaults to 0.</dd> <dt><code>minute</code></dt> <dd>Optional. An integer between 0 and 59 representing the minutes. If omitted, defaults to 0.</dd> <dt><code>second</code></dt> <dd>Optional. An integer between 0 and 59 representing the seconds. If omitted, defaults to 0.</dd> <dt><code>millisecond</code></dt> <dd>Optional. An integer between 0 and 999 representing the milliseconds. If omitted, defaults to 0.</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p>A number representing the number of milliseconds for the given date since January 1, 1970, 00:00:00, UTC.</p> <h2 id=\"Description\">Description</h2> <p><code>UTC()</code> takes comma-delimited date and time parameters and returns the number of milliseconds between January 1, 1970, 00:00:00, universal time and the specified date and time.</p> <p>Years between 0 and 99 are converted to a year in the 20th century <code>(1900 + year)</code>; for example, 95 is converted to the year 1995.</p> <p>The <code>UTC()</code> method differs from the <a href=\"../date\"><code>Date</code></a> constructor in two ways.</p> <ul> <li>\n<code>Date.UTC()</code> uses universal time instead of the local time.</li> <li>\n<code>Date.UTC()</code> returns a time value as a number instead of creating a <a href=\"../date\"><code>Date</code></a> object.</li> </ul> <p>If a parameter is outside of the expected range, the <code>UTC()</code> method updates the other parameters to accommodate the value. For example, if 15 is used for month, the year will be incremented by 1 <code>(year + 1)</code> and 3 will be used for the month.</p> <p><code>UTC()</code> is a static method of <a href=\"../date\"><code>Date</code></a>, so it's called as <code>Date.UTC()</code> rather than as a method of a <a href=\"../date\"><code>Date</code></a> instance.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Using_Date.UTC()\">Using <code>Date.UTC()</code>\n</h3> <p>The following statement creates a <a href=\"../date\"><code>Date</code></a> object with the arguments treated as UTC instead of local:</p> <pre data-language=\"js\">var utcDate = new Date(Date.UTC(2018, 11, 1, 0, 0, 0));\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-date.utc\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Date.UTC' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-date.utc\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Date.UTC' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/5.1/#sec-15.9.4.3\" hreflang=\"en\">ECMAScript 5.1 (ECMA-262)<br><small>The definition of 'Date.UTC' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/publications/files/ECMA-ST-ARCH/ECMA-262,%201st%20edition,%20June%201997.pdf\" hreflang=\"en\">ECMAScript 1st Edition (ECMA-262)</a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition. Implemented in JavaScript 1.0.</td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"Compatibility_notes\">Compatibility notes</h2> <h3 id=\"Date.UTC_with_fewer_than_two_arguments\">\n<code>Date.UTC</code> with fewer than two arguments</h3> <p>When providing less than two arguments to <code>Date.UTC</code>, ECMAScript 2017 requires that <a href=\"../nan\"><code>NaN</code></a> is returned. Engines that weren't supporting this behavior have been updated (see <a href=\"https://bugzilla.mozilla.org/show_bug.cgi?id=1050755\">bug 1050755</a>, <a href=\"https://github.com/tc39/ecma262/pull/642\">ecma-262 #642</a>).</p> <pre data-language=\"js\">Date.UTC();\nDate.UTC(1);\n\n// Safari: NaN \n// Chrome/Opera/V8: NaN\n\n// Firefox &lt;54: non-NaN\n// Firefox 54+: NaN\n\n// IE: non-NaN\n// Edge: NaN\n</pre> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"parse\"><code>Date.parse()</code></a></li> <li><a href=\"../date\"><code>Date</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/UTC$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/UTC\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/UTC</a>\n  </p>\n</div>\n","global_objects/date/gethours":"<h1>date.getHours</h1> <p>The <code>getHours()</code> method returns the hour for the specified date, according to local time.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/date-gethours.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\"><var>dateObj</var>.getHours()</pre> <h3 id=\"Return_value\">Return value</h3> <p>An integer number, between 0 and 23, representing the hour for the given date according to local time.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Using_getHours()\">Using <code>getHours()</code>\n</h3> <p>The second statement below assigns the value 23 to the variable <code>hours</code>, based on the value of the <a href=\"../date\"><code>Date</code></a> object <code>Xmas95</code>.</p> <pre data-language=\"js\">var Xmas95 = new Date('December 25, 1995 23:15:30');\nvar hours = Xmas95.getHours();\n\nconsole.log(hours); // 23\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/publications/files/ECMA-ST-ARCH/ECMA-262,%201st%20edition,%20June%201997.pdf\" hreflang=\"en\">ECMAScript 1st Edition (ECMA-262)</a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition. Implemented in JavaScript 1.0.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/5.1/#sec-15.9.5.18\" hreflang=\"en\">ECMAScript 5.1 (ECMA-262)<br><small>The definition of 'Date.prototype.getHours' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-date.prototype.gethours\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Date.prototype.getHours' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-date.prototype.gethours\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Date.prototype.getHours' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"getutchours\"><code>Date.prototype.getUTCHours()</code></a></li> <li><a href=\"sethours\"><code>Date.prototype.setHours()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getHours$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getHours\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getHours</a>\n  </p>\n</div>\n","global_objects/date/getmilliseconds":"<h1>date.getMilliseconds</h1> <p>The <code>getMilliseconds()</code> method returns the milliseconds in the specified date according to local time.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/date-getmilliseconds.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\"><var>dateObj</var>.getMilliseconds()</pre> <h3 id=\"Return_value\">Return value</h3> <p>A number, between 0 and 999, representing the milliseconds for the given date according to local time.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Using_getMilliseconds()\">Using <code>getMilliseconds()</code>\n</h3> <p>The following example assigns the milliseconds portion of the current time to the variable <code>milliseconds</code>:</p> <pre data-language=\"js\">var today = new Date();\nvar milliseconds = today.getMilliseconds();\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/publications/files/ECMA-ST-ARCH/ECMA-262,%201st%20edition,%20June%201997.pdf\" hreflang=\"en\">ECMAScript 1st Edition (ECMA-262)</a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition. Implemented in JavaScript 1.3.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/5.1/#sec-15.9.5.24\" hreflang=\"en\">ECMAScript 5.1 (ECMA-262)<br><small>The definition of 'Date.prototype.getMilliseconds' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-date.prototype.getmilliseconds\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Date.prototype.getMilliseconds' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-date.prototype.getmilliseconds\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Date.prototype.getMilliseconds' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"getutcmilliseconds\"><code>Date.prototype.getUTCMilliseconds()</code></a></li> <li><a href=\"setmilliseconds\"><code>Date.prototype.setMilliseconds()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getMilliseconds$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getMilliseconds\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getMilliseconds</a>\n  </p>\n</div>\n","global_objects/date/getutcday":"<h1>date.getUTCDay</h1> <p>The <code>getUTCDay()</code> method returns the day of the week in the specified date according to universal time, where 0 represents Sunday.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/date-getutcday.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\"><var>dateObj</var>.getUTCDay()</pre> <h3 id=\"Return_value\">Return value</h3> <p>An integer number corresponding to the day of the week for the given date, according to universal time: 0 for Sunday, 1 for Monday, 2 for Tuesday, and so on.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Using_getUTCDay()\">Using <code>getUTCDay()</code>\n</h3> <p>The following example assigns the weekday portion of the current date to the variable <code>weekday</code>.</p> <pre data-language=\"js\">var today = new Date();\nvar weekday = today.getUTCDay();\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/publications/files/ECMA-ST-ARCH/ECMA-262,%201st%20edition,%20June%201997.pdf\" hreflang=\"en\">ECMAScript 1st Edition (ECMA-262)</a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition. Implemented in JavaScript 1.3.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/5.1/#sec-15.9.5.17\" hreflang=\"en\">ECMAScript 5.1 (ECMA-262)<br><small>The definition of 'Date.prototype.getUTCDay' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-date.prototype.getutcday\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Date.prototype.getUTCDay' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-date.prototype.getutcday\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Date.prototype.getUTCDay' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"getutcdate\"><code>Date.prototype.getUTCDate()</code></a></li> <li><a href=\"getday\"><code>Date.prototype.getDay()</code></a></li> <li><a href=\"setutcdate\"><code>Date.prototype.setUTCDate()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getUTCDay$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getUTCDay\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getUTCDay</a>\n  </p>\n</div>\n","global_objects/date/getutcdate":"<h1>date.getUTCDate</h1> <p>The <code>getUTCDate()</code> method returns the day (date) of the month in the specified date according to universal time.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/date-getutcdate.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe> <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\"><var>dateObj</var>.getUTCDate()</pre> <h3 id=\"Return_value\">Return value</h3> <p>An integer number, between 1 and 31, representing the day of the month in the given date according to universal time.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Using_getUTCDate()\">Using <code>getUTCDate()</code>\n</h3> <p>The following example assigns the day portion of the current date to the variable <code>day</code>.</p> <pre data-language=\"js\">var today = new Date();\nvar day = today.getUTCDate();\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/publications/files/ECMA-ST-ARCH/ECMA-262,%201st%20edition,%20June%201997.pdf\" hreflang=\"en\">ECMAScript 1st Edition (ECMA-262)</a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition. Implemented in JavaScript 1.3.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/5.1/#sec-15.9.5.15\" hreflang=\"en\">ECMAScript 5.1 (ECMA-262)<br><small>The definition of 'Date.prototype.getUTCDate' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-date.prototype.getutcdate\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Date.prototype.getUTCDate' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-date.prototype.getutcdate\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Date.prototype.getUTCDate' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"getdate\"><code>Date.prototype.getDate()</code></a></li> <li><a href=\"getutcday\"><code>Date.prototype.getUTCDay()</code></a></li> <li><a href=\"setutcdate\"><code>Date.prototype.setUTCDate()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getUTCDate$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getUTCDate\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getUTCDate</a>\n  </p>\n</div>\n","global_objects/date/getutchours":"<h1>date.getUTCHours</h1> <p>The <code>getUTCHours()</code> method returns the hours in the specified date according to universal time.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/date-getutchours.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\"><var>dateObj</var>.getUTCHours()</pre> <h3 id=\"Return_value\">Return value</h3> <p>An integer number, between 0 and 23, representing the hours in the given date according to universal time.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Using_getUTCHours()\">Using <code>getUTCHours()</code>\n</h3> <p>The following example assigns the hours portion of the current time to the variable <code>hours</code>.</p> <pre data-language=\"js\">var today = new Date();\nvar hours = today.getUTCHours();\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/publications/files/ECMA-ST-ARCH/ECMA-262,%201st%20edition,%20June%201997.pdf\" hreflang=\"en\">ECMAScript 1st Edition (ECMA-262)</a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition. Implemented in JavaScript 1.3.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/5.1/#sec-15.9.5.19\" hreflang=\"en\">ECMAScript 5.1 (ECMA-262)<br><small>The definition of 'Date.prototype.getUTCHours' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-date.prototype.getutchours\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Date.prototype.getUTCHours' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-date.prototype.getutchours\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Date.prototype.getUTCHours' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"gethours\"><code>Date.prototype.getHours()</code></a></li> <li><a href=\"setutchours\"><code>Date.prototype.setUTCHours()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getUTCHours$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getUTCHours\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getUTCHours</a>\n  </p>\n</div>\n","global_objects/date/getutcminutes":"<h1>date.getUTCMinutes</h1> <p>The <code>getUTCMinutes()</code> method returns the minutes in the specified date according to universal time.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/date-getutcminutes.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe> <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\"><var>dateObj</var>.getUTCMinutes()</pre> <h3 id=\"Return_value\">Return value</h3> <p>An integer number, between 0 and 59, representing the minutes in the given date according to universal time.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Using_getUTCMinutes()\">Using <code>getUTCMinutes()</code>\n</h3> <p>The following example assigns the minutes portion of the current time to the variable <code>minutes</code>.</p> <pre data-language=\"js\">var today = new Date();\nvar minutes = today.getUTCMinutes();\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/publications/files/ECMA-ST-ARCH/ECMA-262,%201st%20edition,%20June%201997.pdf\" hreflang=\"en\">ECMAScript 1st Edition (ECMA-262)</a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition. Implemented in JavaScript 1.3.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/5.1/#sec-15.9.5.21\" hreflang=\"en\">ECMAScript 5.1 (ECMA-262)<br><small>The definition of 'Date.prototype.getUTCMinutes' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-date.prototype.getutcminutes\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Date.prototype.getUTCMinutes' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-date.prototype.getutcminutes\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Date.prototype.getUTCMinutes' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"getminutes\"><code>Date.prototype.getMinutes()</code></a></li> <li><a href=\"setutcminutes\"><code>Date.prototype.setUTCMinutes()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getUTCMinutes$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getUTCMinutes\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getUTCMinutes</a>\n  </p>\n</div>\n","global_objects/date/getseconds":"<h1>date.getSeconds</h1> <p>The <code>getSeconds()</code> method returns the seconds in the specified date according to local time.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/date-getseconds.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\"><var>dateObj</var>.getSeconds()</pre> <h3 id=\"Return_value\">Return value</h3> <p>An integer number, between 0 and 59, representing the seconds in the given date according to local time.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Using_getSeconds()\">Using <code>getSeconds()</code>\n</h3> <p>The second statement below assigns the value 30 to the variable <code>seconds</code>, based on the value of the <a href=\"../date\"><code>Date</code></a> object <code>Xmas95</code>.</p> <pre data-language=\"js\">var Xmas95 = new Date('December 25, 1995 23:15:30');\nvar seconds = Xmas95.getSeconds();\n\nconsole.log(seconds); // 30\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/publications/files/ECMA-ST-ARCH/ECMA-262,%201st%20edition,%20June%201997.pdf\" hreflang=\"en\">ECMAScript 1st Edition (ECMA-262)</a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition. Implemented in JavaScript 1.0.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/5.1/#sec-15.9.5.22\" hreflang=\"en\">ECMAScript 5.1 (ECMA-262)<br><small>The definition of 'Date.prototype.getSeconds' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-date.prototype.getseconds\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Date.prototype.getSeconds' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-date.prototype.getseconds\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Date.prototype.getSeconds' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"getutcseconds\"><code>Date.prototype.getUTCSeconds()</code></a></li> <li><a href=\"setseconds\"><code>Date.prototype.setSeconds()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getSeconds$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getSeconds\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getSeconds</a>\n  </p>\n</div>\n","global_objects/date/gettime":"<h1>date.getTime</h1> <p>The <code>getTime()</code> method returns the numeric value corresponding to the time for the specified date according to universal time.</p> <p><em>getTime() always uses UTC for time representation. For example, a client browser in one timezone, getTime() will be the same as a client browser in any other timezone.</em></p> <p>You can use this method to help assign a date and time to another <a href=\"../date\"><code>Date</code></a> object. This method is functionally equivalent to the <a href=\"valueof\"><code>valueOf()</code></a> method.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/date-gettime.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\"><var>dateObj</var>.getTime()</pre> <h3 id=\"Return_value\">Return value</h3> <p>A number representing the milliseconds elapsed between 1 January 1970 00:00:00 UTC and the given date.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Using_getTime()_for_copying_dates\">Using <code>getTime()</code> for copying dates</h3> <p>Constructing a date object with the identical time value.</p> <pre data-language=\"js\">// Since month is zero based, birthday will be January 10, 1995\nvar birthday = new Date(1994, 12, 10);\nvar copy = new Date();\ncopy.setTime(birthday.getTime());\n</pre> <h3 id=\"Measuring_execution_time\">Measuring execution time</h3> <p>Subtracting two subsequent <code>getTime()</code> calls on newly generated <a href=\"../date\"><code>Date</code></a> objects, give the time span between these two calls. This can be used to calculate the executing time of some operations. See also <a href=\"now\"><code>Date.now()</code></a> to prevent instantiating unnecessary <a href=\"../date\"><code>Date</code></a> objects.</p> <pre data-language=\"js\">var end, start;\n\nstart = new Date();\nfor (var i = 0; i &lt; 1000; i++) {\n  Math.sqrt(i);\n}\nend = new Date();\n\nconsole.log('Operation took ' + (end.getTime() - start.getTime()) + ' msec');\n</pre> <h2 id=\"Reduced_time_precision\">Reduced time precision</h2> <p>To offer protection against timing attacks and fingerprinting, the precision of <code>new Date().getTime()</code> might get rounded depending on browser settings.<br> In Firefox, the <code>privacy.reduceTimerPrecision</code> preference is enabled by default and defaults to 20us in Firefox 59; in 60 it will be 2ms.</p> <pre data-language=\"js\">// reduced time precision (2ms) in Firefox 60\nnew Date().getTime();\n// 1519211809934\n// 1519211810362\n// 1519211811670\n// ...\n\n\n// reduced time precision with `privacy.resistFingerprinting` enabled\nnew Date().getTime();\n// 1519129853500\n// 1519129858900\n// 1519129864400\n// ...\n</pre> <p>In Firefox, you can also enabled <code>privacy.resistFingerprinting</code>, the precision will be 100ms or the value of <code>privacy.resistFingerprinting.reduceTimerPrecision.microseconds</code>, whichever is larger.</p> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/publications/files/ECMA-ST-ARCH/ECMA-262,%201st%20edition,%20June%201997.pdf\" hreflang=\"en\">ECMAScript 1st Edition (ECMA-262)</a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition. Implemented in JavaScript 1.0.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/5.1/#sec-15.9.5.9\" hreflang=\"en\">ECMAScript 5.1 (ECMA-262)<br><small>The definition of 'Date.prototype.getTime' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-date.prototype.gettime\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Date.prototype.getTime' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-date.prototype.gettime\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Date.prototype.getTime' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"settime\"><code>Date.prototype.setTime()</code></a></li> <li><a href=\"valueof\"><code>Date.prototype.valueOf()</code></a></li> <li><a href=\"now\"><code>Date.now()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getTime$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getTime\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getTime</a>\n  </p>\n</div>\n","global_objects/date/getutcmonth":"<h1>date.getUTCMonth</h1> <p>The <code>getUTCMonth()</code> returns the month of the specified date according to universal time, as a zero-based value (where zero indicates the first month of the year).</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/date-getutcmonth.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\"><var>dateObj</var>.getUTCMonth()</pre> <h3 id=\"Return_value\">Return value</h3> <p>An integer number, between 0 and 11, corresponding to the month of the given date according to universal time. 0 for January, 1 for February, 2 for March, and so on.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Using_getUTCMonth()\">Using <code>getUTCMonth()</code>\n</h3> <p>The following example assigns the month portion of the current date to the variable <code>month</code>.</p> <pre data-language=\"js\">var today = new Date();\nvar month = today.getUTCMonth();\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/publications/files/ECMA-ST-ARCH/ECMA-262,%201st%20edition,%20June%201997.pdf\" hreflang=\"en\">ECMAScript 1st Edition (ECMA-262)</a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition. Implemented in JavaScript 1.3.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/5.1/#sec-15.9.5.13\" hreflang=\"en\">ECMAScript 5.1 (ECMA-262)<br><small>The definition of 'Date.prototype.getUTCMonth' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-date.prototype.getutcmonth\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Date.prototype.getUTCMonth' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-date.prototype.getutcmonth\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Date.prototype.getUTCMonth' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"getmonth\"><code>Date.prototype.getMonth()</code></a></li> <li><a href=\"setutcmonth\"><code>Date.prototype.setUTCMonth()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getUTCMonth$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getUTCMonth\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getUTCMonth</a>\n  </p>\n</div>\n","global_objects/date/getutcmilliseconds":"<h1>date.getUTCMilliseconds</h1> <p>The <code>getUTCMilliseconds()</code> method returns the milliseconds in the specified date according to universal time.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/date-getutcmilliseconds.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe> <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\"><var>dateObj</var>.getUTCMilliseconds()</pre> <h3 id=\"Return_value\">Return value</h3> <p>An integer number, between 0 and 999, representing the milliseconds in the given date according to universal time.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Using_getUTCMilliseconds()\">Using <code>getUTCMilliseconds()</code>\n</h3> <p>The following example assigns the milliseconds portion of the current time to the variable <code>milliseconds</code>.</p> <pre data-language=\"js\">var today = new Date();\nvar milliseconds = today.getUTCMilliseconds();\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/publications/files/ECMA-ST-ARCH/ECMA-262,%201st%20edition,%20June%201997.pdf\" hreflang=\"en\">ECMAScript 1st Edition (ECMA-262)</a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition. Implemented in JavaScript 1.3.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/5.1/#sec-15.9.5.25\" hreflang=\"en\">ECMAScript 5.1 (ECMA-262)<br><small>The definition of 'Date.prototype.getUTCMilliseconds' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-date.prototype.getutcmilliseconds\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Date.prototype.getUTCMilliseconds' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-date.prototype.getutcmilliseconds\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Date.prototype.getUTCMilliseconds' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"getmilliseconds\"><code>Date.prototype.getMilliseconds()</code></a></li> <li><a href=\"setutcmilliseconds\"><code>Date.prototype.setUTCMilliseconds()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getUTCMilliseconds$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getUTCMilliseconds\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getUTCMilliseconds</a>\n  </p>\n</div>\n","global_objects/date/getutcfullyear":"<h1>date.getUTCFullYear</h1> <p>The <code>getUTCFullYear()</code> method returns the year in the specified date according to universal time.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/date-getutcfullyear.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\"><var>dateObj</var>.getUTCFullYear()</pre> <h3 id=\"Return_value\">Return value</h3> <p>A number representing the year in the given date according to universal time.</p> <h2 id=\"Description\">Description</h2> <p>The value returned by <code>getUTCFullYear()</code> is an absolute number that is compliant with year-2000, for example, 1995.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Using_getUTCFullYear()\">Using <code>getUTCFullYear()</code>\n</h3> <p>The following example assigns the four-digit value of the current year to the variable <code>year</code>.</p> <pre data-language=\"js\">var today = new Date();\nvar year = today.getUTCFullYear();\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/publications/files/ECMA-ST-ARCH/ECMA-262,%201st%20edition,%20June%201997.pdf\" hreflang=\"en\">ECMAScript 1st Edition (ECMA-262)</a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition. Implemented in JavaScript 1.3.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/5.1/#sec-15.9.5.11\" hreflang=\"en\">ECMAScript 5.1 (ECMA-262)<br><small>The definition of 'Date.prototype.getUTCFullYear' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-date.prototype.getutcfullyear\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Date.prototype.getUTCFullYear' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-date.prototype.getutcfullyear\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Date.prototype.getUTCFullYear' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"getfullyear\"><code>Date.prototype.getFullYear()</code></a></li> <li><a href=\"setfullyear\"><code>Date.prototype.setFullYear()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getUTCFullYear$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getUTCFullYear\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getUTCFullYear</a>\n  </p>\n</div>\n","global_objects/date/setdate":"<h1>date.setDate</h1> <p>The <code>setDate()</code> method sets the day of the <a href=\"../date\"><code>Date</code></a> object relative to the beginning of the currently set month.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/date-setdate.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\"><var>dateObj</var>.setDate(<var>dayValue</var>)</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><code>dayValue</code></dt> <dd>An integer representing the day of the month.</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p>The number of milliseconds between 1 January 1970 00:00:00 UTC and the given date (the <a href=\"../date\"><code>Date</code></a> object is also changed in place).</p> <h2 id=\"Description\">Description</h2> <p>If the <code>dayValue</code> is outside of the range of date values for the month, <code>setDate()</code> will update the <a href=\"../date\"><code>Date</code></a> object accordingly. For example, if 0 is provided for <code>dayValue</code>, the date will be set to the last day of the previous month.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Using_setDate()\">Using <code>setDate()</code>\n</h3> <pre data-language=\"js\">var theBigDay = new Date(1962, 6, 7); // 1962-07-07\ntheBigDay.setDate(24);  // 1962-07-24\ntheBigDay.setDate(32);  // 1962-08-01\ntheBigDay.setDate(22);  // 1962-08-22\ntheBigDay.setDate(0); // 1962-07-31\ntheBigDay.setDate(98); // 1962-10-06\ntheBigDay.setDate(-50); // 1962-08-11\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/publications/files/ECMA-ST-ARCH/ECMA-262,%201st%20edition,%20June%201997.pdf\" hreflang=\"en\">ECMAScript 1st Edition (ECMA-262)</a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition. Implemented in JavaScript 1.0.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/5.1/#sec-15.9.5.36\" hreflang=\"en\">ECMAScript 5.1 (ECMA-262)<br><small>The definition of 'Date.prototype.setDate' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-date.prototype.setdate\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Date.prototype.setDate' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-date.prototype.setdate\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Date.prototype.setDate' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"getdate\"><code>Date.prototype.getDate()</code></a></li> <li><a href=\"setutcdate\"><code>Date.prototype.setUTCDate()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setDate$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setDate\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setDate</a>\n  </p>\n</div>\n","global_objects/date/sethours":"<h1>date.setHours</h1> <p>The <code>setHours()</code> method sets the hours for a specified date according to local time, and returns the number of milliseconds since January 1, 1970 00:00:00 UTC until the time represented by the updated <a href=\"../date\"><code>Date</code></a> instance.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/date-sethours.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\"><var>dateObj</var>.setHours(<var>hoursValue</var>[, <var>minutesValue</var>[, <var>secondsValue</var>[, <var>msValue</var>]]])</pre> <h3 id=\"Versions_prior_to_JavaScript_1.3\">Versions prior to JavaScript 1.3</h3> <pre class=\"syntaxbox\"><var>dateObj</var>.setHours(<var>hoursValue</var>)</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><code>hoursValue</code></dt> <dd>Ideally, an integer between 0 and 23, representing the hour. If a value greater than 23 is provided, the datetime will be incremented by the extra hours.</dd> <dt><code>minutesValue</code></dt> <dd>Optional. Ideally, an integer between 0 and 59, representing the minutes. If a value greater than 59 is provided, the datetime will be incremented by the extra minutes.</dd> <dt><code>secondsValue</code></dt> <dd>Optional. Ideally, an integer between 0 and 59, representing the seconds. If a value greater than 59 is provided, the datetime will be incremented by the extra seconds. If you specify the <code>secondsValue</code> parameter, you must also specify the <code>minutesValue</code>.</dd> <dt><code>msValue</code></dt> <dd>Optional. Ideally, a number between 0 and 999, representing the milliseconds. If a value greater than 999 is provided, the datetime will be incremented by the extra milliseconds. If you specify the <code>msValue</code> parameter, you must also specify the <code>minutesValue</code> and <code>secondsValue</code>.</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p>The number of milliseconds between January 1, 1970 00:00:00 UTC and the updated date.</p> <h2 id=\"Description\">Description</h2> <p>If you do not specify the <code>minutesValue</code>, <code>secondsValue</code>, and <code>msValue</code> parameters, the values returned from the <a href=\"getminutes\"><code>getMinutes()</code></a>, <a href=\"getseconds\"><code>getSeconds()</code></a>, and <a href=\"getmilliseconds\"><code>getMilliseconds()</code></a> methods are used.</p> <p>If a parameter you specify is outside of the expected range, <code>setHours()</code> attempts to update the date information in the <a href=\"../date\"><code>Date</code></a> object accordingly. For example, if you use 100 for <code>secondsValue</code>, the minutes will be incremented by 1 (<code>minutesValue + 1</code>), and 40 will be used for seconds.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Using_setHours()\">Using <code>setHours()</code>\n</h3> <pre data-language=\"js\">var theBigDay = new Date();\ntheBigDay.setHours(7);\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/publications/files/ECMA-ST-ARCH/ECMA-262,%201st%20edition,%20June%201997.pdf\" hreflang=\"en\">ECMAScript 1st Edition (ECMA-262)</a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition. Implemented in JavaScript 1.0.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/5.1/#sec-15.9.5.34\" hreflang=\"en\">ECMAScript 5.1 (ECMA-262)<br><small>The definition of 'Date.prototype.setHours' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-date.prototype.sethours\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Date.prototype.setHours' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-date.prototype.sethours\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Date.prototype.setHours' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"gethours\"><code>Date.prototype.getHours()</code></a></li> <li><a href=\"setutchours\"><code>Date.prototype.setUTCHours()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setHours$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setHours\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setHours</a>\n  </p>\n</div>\n","global_objects/date/setmilliseconds":"<h1>date.setMilliseconds</h1> <p>The <code>setMilliseconds()</code> method sets the milliseconds for a specified date according to local time.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/date-setmilliseconds.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\"><var>dateObj</var>.setMilliseconds(<var>millisecondsValue</var>)</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><code>millisecondsValue</code></dt> <dd>A number between 0 and 999, representing the milliseconds.</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p>The number of milliseconds between 1 January 1970 00:00:00 UTC and the updated date.</p> <h2 id=\"Description\">Description</h2> <p>If you specify a number outside the expected range, the date information in the <a href=\"../date\"><code>Date</code></a> object is updated accordingly. For example, if you specify 1005, the number of seconds is incremented by 1, and 5 is used for the milliseconds.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Using_setMilliseconds()\">Using <code>setMilliseconds()</code>\n</h3> <pre data-language=\"js\">var theBigDay = new Date();\ntheBigDay.setMilliseconds(100);\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/publications/files/ECMA-ST-ARCH/ECMA-262,%201st%20edition,%20June%201997.pdf\" hreflang=\"en\">ECMAScript 1st Edition (ECMA-262)</a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition. Implemented in JavaScript 1.3.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/5.1/#sec-15.9.5.28\" hreflang=\"en\">ECMAScript 5.1 (ECMA-262)<br><small>The definition of 'Date.prototype.setMilliseconds' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-date.prototype.setmilliseconds\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Date.prototype.setMilliseconds' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-date.prototype.setmilliseconds\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Date.prototype.setMilliseconds' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"getmilliseconds\"><code>Date.prototype.getMilliseconds()</code></a></li> <li><a href=\"setutcmilliseconds\"><code>Date.prototype.setUTCMilliseconds()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setMilliseconds$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setMilliseconds\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setMilliseconds</a>\n  </p>\n</div>\n","global_objects/date/setmonth":"<h1>date.setMonth</h1> <p>The <code>setMonth()</code> method sets the month for a specified date according to the currently set year.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/date-setmonth.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe> <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\"><var>dateObj</var>.setMonth(<var>monthValue</var>[, <var>dayValue</var>])</pre> <h3 id=\"Versions_prior_to_JavaScript_1.3\">Versions prior to JavaScript 1.3</h3> <pre class=\"syntaxbox\"><var>dateObj</var>.setMonth(<var>monthValue</var>)</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><code>monthValue</code></dt> <dd>An integer between 0 and 11, representing the months January through December.</dd> <dt><code>dayValue</code></dt> <dd>Optional. An integer from 1 to 31, representing the day of the month.</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p>The number of milliseconds between 1 January 1970 00:00:00 UTC and the updated date.</p> <h2 id=\"Description\">Description</h2> <p>If you do not specify the <code>dayValue</code> parameter, the value returned from the <a href=\"getdate\"><code>getDate()</code></a> method is used.</p> <p>If a parameter you specify is outside of the expected range, <code>setMonth()</code> attempts to update the date information in the <a href=\"../date\"><code>Date</code></a> object accordingly. For example, if you use 15 for <code>monthValue</code>, the year will be incremented by 1, and 3 will be used for month.</p> <p>The current day of month will have an impact on the behaviour of this method. Conceptually it will add the number of days given by the current day of the month to the 1st day of the new month specified as the parameter, to return the new date. For example, if the current value is 31st August 2016, calling setMonth with a value of 1 will return 2nd March 2016. This is because in 2016 February had 29 days.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Using_setMonth()\">Using <code>setMonth()</code>\n</h3> <pre data-language=\"js\">var theBigDay = new Date();\ntheBigDay.setMonth(6);\n\n//Watch out for end of month transitions\nvar endOfMonth = new Date(2016, 7, 31);\nendOfMonth.setMonth(1);\nconsole.log(endOfMonth); //Wed Mar 02 2016 00:00:00\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/publications/files/ECMA-ST-ARCH/ECMA-262,%201st%20edition,%20June%201997.pdf\" hreflang=\"en\">ECMAScript 1st Edition (ECMA-262)</a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition. Implemented in JavaScript 1.0.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/5.1/#sec-15.9.5.38\" hreflang=\"en\">ECMAScript 5.1 (ECMA-262)<br><small>The definition of 'Date.prototype.setMonth' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-date.prototype.setmonth\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Date.prototype.setMonth' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-date.prototype.setmonth\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Date.prototype.setMonth' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"getmonth\"><code>Date.prototype.getMonth()</code></a></li> <li><a href=\"setutcmonth\"><code>Date.prototype.setUTCMonth()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setMonth$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setMonth\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setMonth</a>\n  </p>\n</div>\n","global_objects/date/setfullyear":"<h1>date.setFullYear</h1> <p>The <code>setFullYear()</code> method sets the full year for a specified date according to local time. Returns new timestamp.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/date-setfullyear.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\"><var>dateObj</var>.setFullYear(<var>yearValue</var>[, <var>monthValue</var>[, <var>dateValue</var>]])</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><code>yearValue</code></dt> <dd>An integer specifying the numeric value of the year, for example, 1995.</dd> <dt><code>monthValue</code></dt> <dd>Optional. An integer between 0 and 11 representing the months January through December.</dd> <dt><code>dateValue</code></dt> <dd>Optional. An integer between 1 and 31 representing the day of the month. If you specify the <code>dateValue</code> parameter, you must also specify the <code>monthValue</code>.</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p>The number of milliseconds between 1 January 1970 00:00:00 UTC and the updated date.</p> <h2 id=\"Description\">Description</h2> <p>If you do not specify the <code>monthValue</code> and <code>dateValue</code> parameters, the values returned from the <a href=\"getmonth\"><code>getMonth()</code></a> and <a href=\"getdate\"><code>getDate()</code></a> methods are used.</p> <p>If a parameter you specify is outside of the expected range, <code>setFullYear()</code> attempts to update the other parameters and the date information in the <a href=\"../date\"><code>Date</code></a> object accordingly. For example, if you specify 15 for <code>monthValue</code>, the year is incremented by 1 (<code>yearValue + 1</code>), and 3 is used for the month.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Using_setFullYear()\">Using <code>setFullYear()</code>\n</h3> <pre data-language=\"js\">var theBigDay = new Date();\ntheBigDay.setFullYear(1997);\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/publications/files/ECMA-ST-ARCH/ECMA-262,%201st%20edition,%20June%201997.pdf\" hreflang=\"en\">ECMAScript 1st Edition (ECMA-262)</a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition. Implemented in JavaScript 1.3.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/5.1/#sec-15.9.5.40\" hreflang=\"en\">ECMAScript 5.1 (ECMA-262)<br><small>The definition of 'Date.prototype.setFullYear' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-date.prototype.setfullyear\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Date.prototype.setFullYear' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-date.prototype.setfullyear\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Date.prototype.setFullYear' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"getutcfullyear\"><code>Date.prototype.getUTCFullYear()</code></a></li> <li><a href=\"setutcfullyear\"><code>Date.prototype.setUTCFullYear()</code></a></li> <li><a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setYear\"><code>Date.prototype.setYear()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setFullYear$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setFullYear\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setFullYear</a>\n  </p>\n</div>\n","global_objects/date/setutchours":"<h1>date.setUTCHours</h1> <p>The <code>setUTCHours()</code> method sets the hour for a specified date according to universal time, and returns the number of milliseconds since January 1, 1970 00:00:00 UTC until the time represented by the updated <a href=\"../date\"><code>Date</code></a> instance.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/date-setutchours.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\"><var>dateObj</var>.setUTCHours(<var>hoursValue</var>[, <var>minutesValue</var>[, <var>secondsValue</var>[, <var>msValue</var>]]])</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><code>hoursValue</code></dt> <dd>An integer between 0 and 23, representing the hour.</dd> <dt><code>minutesValue</code></dt> <dd>Optional. An integer between 0 and 59, representing the minutes.</dd> <dt><code>secondsValue</code></dt> <dd>Optional. An integer between 0 and 59, representing the seconds. If you specify the <code>secondsValue</code> parameter, you must also specify the <code>minutesValue</code>.</dd> <dt><code>msValue</code></dt> <dd>Optional. A number between 0 and 999, representing the milliseconds. If you specify the <code>msValue</code> parameter, you must also specify the <code>minutesValue</code> and <code>secondsValue</code>.</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p>The number of milliseconds between January 1, 1970 00:00:00 UTC and the updated date.</p> <h2 id=\"Description\">Description</h2> <p>If you do not specify the <code>minutesValue</code>, <code>secondsValue</code>, and <code>msValue</code> parameters, the values returned from the <a href=\"getutcminutes\"><code>getUTCMinutes()</code></a>, <a href=\"getutcseconds\"><code>getUTCSeconds()</code></a>, and <a href=\"getutcmilliseconds\"><code>getUTCMilliseconds()</code></a> methods are used.</p> <p>If a parameter you specify is outside of the expected range, <code>setUTCHours()</code> attempts to update the date information in the <a href=\"../date\"><code>Date</code></a> object accordingly. For example, if you use 100 for <code>secondsValue</code>, the minutes will be incremented by 1 (<code>minutesValue + 1</code>), and 40 will be used for seconds.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Using_setUTCHours()\">Using <code>setUTCHours()</code>\n</h3> <pre data-language=\"js\">var theBigDay = new Date();\ntheBigDay.setUTCHours(8);\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/publications/files/ECMA-ST-ARCH/ECMA-262,%201st%20edition,%20June%201997.pdf\" hreflang=\"en\">ECMAScript 1st Edition (ECMA-262)</a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition. Implemented in JavaScript 1.3.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/5.1/#sec-15.9.5.35\" hreflang=\"en\">ECMAScript 5.1 (ECMA-262)<br><small>The definition of 'Date.prototype.setUTCHours' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-date.prototype.setutchours\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Date.prototype.setUTCHours' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-date.prototype.setutchours\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Date.prototype.setUTCHours' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"getutchours\"><code>Date.prototype.getUTCHours()</code></a></li> <li><a href=\"sethours\"><code>Date.prototype.setHours()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setUTCHours$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setUTCHours\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setUTCHours</a>\n  </p>\n</div>\n","global_objects/date/prototype":"<h1>Date.prototype</h1> <p>The <code>Date.prototype</code> property represents the prototype for the <a href=\"../date\"><code>Date</code></a> constructor.</p> <div class=\"_table\"><table class=\"standard-table\"> <thead> <tr> <th colspan=\"2\" class=\"header\">Property attributes of <code>Date.prototype</code>\n</th> </tr> </thead> <tbody> <tr> <td>Writable</td> <td>no</td> </tr> <tr> <td>Enumerable</td> <td>no</td> </tr> <tr> <td>Configurable</td> <td>yes</td> </tr> </tbody> </table></div> <h2 id=\"Description\">Description</h2> <p>JavaScript <a href=\"../date\"><code>Date</code></a> instances inherit from <code>Date.prototype</code>. You can modify the constructor's prototype object to affect properties and methods inherited by JavaScript <a href=\"../date\"><code>Date</code></a> instances.</p> <p>For compatibility with millennium calculations (in other words, to take into account the year 2000), you should always specify the year in full; for example, use 1998, not 98. To assist you in specifying the complete year, JavaScript includes the methods <a href=\"getfullyear\"><code>getFullYear()</code></a>, <a href=\"setfullyear\"><code>setFullYear()</code></a>, <a href=\"getutcfullyear\"><code>getUTCFullYear()</code></a> and <a href=\"setutcfullyear\"><code>setUTCFullYear()</code></a>.</p> <p>Starting with ECMAScript 6, the <code>Date.prototype</code> object is itself an ordinary object. It is not a <a href=\"../date\"><code>Date</code></a> instance.</p> <h2 id=\"Properties\">Properties</h2> <dl> <dt><code>Date.prototype.constructor</code></dt> <dd>Returns the function that created an instance. This is the <a href=\"../date\"><code>Date</code></a> constructor by default.</dd> </dl> <h2 id=\"Methods\">Methods</h2> <h3 id=\"Getter\">Getter</h3> <dl> <dt><a href=\"getdate\"><code>Date.prototype.getDate()</code></a></dt> <dd>Returns the day of the month (1-31) for the specified date according to local time.</dd> <dt><a href=\"getday\"><code>Date.prototype.getDay()</code></a></dt> <dd>Returns the day of the week (0-6) for the specified date according to local time.</dd> <dt><a href=\"getfullyear\"><code>Date.prototype.getFullYear()</code></a></dt> <dd>Returns the year (4 digits for 4-digit years) of the specified date according to local time.</dd> <dt><a href=\"gethours\"><code>Date.prototype.getHours()</code></a></dt> <dd>Returns the hour (0-23) in the specified date according to local time.</dd> <dt><a href=\"getmilliseconds\"><code>Date.prototype.getMilliseconds()</code></a></dt> <dd>Returns the milliseconds (0-999) in the specified date according to local time.</dd> <dt><a href=\"getminutes\"><code>Date.prototype.getMinutes()</code></a></dt> <dd>Returns the minutes (0-59) in the specified date according to local time.</dd> <dt><a href=\"getmonth\"><code>Date.prototype.getMonth()</code></a></dt> <dd>Returns the month (0-11) in the specified date according to local time.</dd> <dt><a href=\"getseconds\"><code>Date.prototype.getSeconds()</code></a></dt> <dd>Returns the seconds (0-59) in the specified date according to local time.</dd> <dt><a href=\"gettime\"><code>Date.prototype.getTime()</code></a></dt> <dd>Returns the numeric value of the specified date as the number of milliseconds since January 1, 1970, 00:00:00 UTC (negative for prior times).</dd> <dt><a href=\"gettimezoneoffset\"><code>Date.prototype.getTimezoneOffset()</code></a></dt> <dd>Returns the time-zone offset in minutes for the current locale.</dd> <dt><a href=\"getutcdate\"><code>Date.prototype.getUTCDate()</code></a></dt> <dd>Returns the day (date) of the month (1-31) in the specified date according to universal time.</dd> <dt><a href=\"getutcday\"><code>Date.prototype.getUTCDay()</code></a></dt> <dd>Returns the day of the week (0-6) in the specified date according to universal time.</dd> <dt><a href=\"getutcfullyear\"><code>Date.prototype.getUTCFullYear()</code></a></dt> <dd>Returns the year (4 digits for 4-digit years) in the specified date according to universal time.</dd> <dt><a href=\"getutchours\"><code>Date.prototype.getUTCHours()</code></a></dt> <dd>Returns the hours (0-23) in the specified date according to universal time.</dd> <dt><a href=\"getutcmilliseconds\"><code>Date.prototype.getUTCMilliseconds()</code></a></dt> <dd>Returns the milliseconds (0-999) in the specified date according to universal time.</dd> <dt><a href=\"getutcminutes\"><code>Date.prototype.getUTCMinutes()</code></a></dt> <dd>Returns the minutes (0-59) in the specified date according to universal time.</dd> <dt><a href=\"getutcmonth\"><code>Date.prototype.getUTCMonth()</code></a></dt> <dd>Returns the month (0-11) in the specified date according to universal time.</dd> <dt><a href=\"getutcseconds\"><code>Date.prototype.getUTCSeconds()</code></a></dt> <dd>Returns the seconds (0-59) in the specified date according to universal time.</dd> <dt>\n<a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getYear\"><code>Date.prototype.getYear()</code></a> \n</dt> <dd>Returns the year (usually 2-3 digits) in the specified date according to local time. Use <a href=\"getfullyear\"><code>getFullYear()</code></a> instead.</dd> </dl> <h3 id=\"Setter\">Setter</h3> <dl> <dt><a href=\"setdate\"><code>Date.prototype.setDate()</code></a></dt> <dd>Sets the day of the month for a specified date according to local time.</dd> <dt><a href=\"setfullyear\"><code>Date.prototype.setFullYear()</code></a></dt> <dd>Sets the full year (e.g. 4 digits for 4-digit years) for a specified date according to local time.</dd> <dt><a href=\"sethours\"><code>Date.prototype.setHours()</code></a></dt> <dd>Sets the hours for a specified date according to local time.</dd> <dt><a href=\"setmilliseconds\"><code>Date.prototype.setMilliseconds()</code></a></dt> <dd>Sets the milliseconds for a specified date according to local time.</dd> <dt><a href=\"setminutes\"><code>Date.prototype.setMinutes()</code></a></dt> <dd>Sets the minutes for a specified date according to local time.</dd> <dt><a href=\"setmonth\"><code>Date.prototype.setMonth()</code></a></dt> <dd>Sets the month for a specified date according to local time.</dd> <dt><a href=\"setseconds\"><code>Date.prototype.setSeconds()</code></a></dt> <dd>Sets the seconds for a specified date according to local time.</dd> <dt><a href=\"settime\"><code>Date.prototype.setTime()</code></a></dt> <dd>Sets the <a href=\"../date\"><code>Date</code></a> object to the time represented by a number of milliseconds since January 1, 1970, 00:00:00 UTC, allowing for negative numbers for times prior.</dd> <dt><a href=\"setutcdate\"><code>Date.prototype.setUTCDate()</code></a></dt> <dd>Sets the day of the month for a specified date according to universal time.</dd> <dt><a href=\"setutcfullyear\"><code>Date.prototype.setUTCFullYear()</code></a></dt> <dd>Sets the full year (e.g. 4 digits for 4-digit years) for a specified date according to universal time.</dd> <dt><a href=\"setutchours\"><code>Date.prototype.setUTCHours()</code></a></dt> <dd>Sets the hour for a specified date according to universal time.</dd> <dt><a href=\"setutcmilliseconds\"><code>Date.prototype.setUTCMilliseconds()</code></a></dt> <dd>Sets the milliseconds for a specified date according to universal time.</dd> <dt><a href=\"setutcminutes\"><code>Date.prototype.setUTCMinutes()</code></a></dt> <dd>Sets the minutes for a specified date according to universal time.</dd> <dt><a href=\"setutcmonth\"><code>Date.prototype.setUTCMonth()</code></a></dt> <dd>Sets the month for a specified date according to universal time.</dd> <dt><a href=\"setutcseconds\"><code>Date.prototype.setUTCSeconds()</code></a></dt> <dd>Sets the seconds for a specified date according to universal time.</dd> <dt>\n<a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setYear\"><code>Date.prototype.setYear()</code></a> \n</dt> <dd>Sets the year (usually 2-3 digits) for a specified date according to local time. Use <a href=\"setfullyear\"><code>setFullYear()</code></a> instead.</dd> </dl> <h3 id=\"Conversion_getter\">Conversion getter</h3> <dl> <dt><a href=\"todatestring\"><code>Date.prototype.toDateString()</code></a></dt> <dd>Returns the \"date\" portion of the <a href=\"../date\"><code>Date</code></a> as a human-readable string like 'Thu Apr 12 2018'</dd> <dt><a href=\"toisostring\"><code>Date.prototype.toISOString()</code></a></dt> <dd>Converts a date to a string following the ISO 8601 Extended Format.</dd> <dt><a href=\"tojson\"><code>Date.prototype.toJSON()</code></a></dt> <dd>Returns a string representing the <a href=\"../date\"><code>Date</code></a> using <a href=\"toisostring\"><code>toISOString()</code></a>. Intended for use by <a href=\"../json/stringify\"><code>JSON.stringify()</code></a>.</dd> <dt>\n<a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toGMTString\"><code>Date.prototype.toGMTString()</code></a> \n</dt> <dd>Returns a string representing the <a href=\"../date\"><code>Date</code></a> based on the GMT (UT) time zone. Use <a href=\"toutcstring\"><code>toUTCString()</code></a> instead.</dd> <dt><a href=\"tolocaledatestring\"><code>Date.prototype.toLocaleDateString()</code></a></dt> <dd>Returns a string with a locality sensitive representation of the date portion of this date based on system settings.</dd> <dt>\n<a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toLocaleFormat\"><code>Date.prototype.toLocaleFormat()</code></a> \n</dt> <dd>Converts a date to a string, using a format string.</dd> <dt><a href=\"tolocalestring\"><code>Date.prototype.toLocaleString()</code></a></dt> <dd>Returns a string with a locality sensitive representation of this date. Overrides the <a href=\"../object/tolocalestring\"><code>Object.prototype.toLocaleString()</code></a> method.</dd> <dt><a href=\"tolocaletimestring\"><code>Date.prototype.toLocaleTimeString()</code></a></dt> <dd>Returns a string with a locality sensitive representation of the time portion of this date based on system settings.</dd> <dt>\n<a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toSource\"><code>Date.prototype.toSource()</code></a> \n</dt> <dd>Returns a string representing the source for an equivalent <a href=\"../date\"><code>Date</code></a> object; you can use this value to create a new object. Overrides the <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/toSource\"><code>Object.prototype.toSource()</code></a> method.</dd> <dt><a href=\"tostring\"><code>Date.prototype.toString()</code></a></dt> <dd>Returns a string representing the specified <a href=\"../date\"><code>Date</code></a> object. Overrides the <a href=\"../object/tostring\"><code>Object.prototype.toString()</code></a> method.</dd> <dt><a href=\"totimestring\"><code>Date.prototype.toTimeString()</code></a></dt> <dd>Returns the \"time\" portion of the <a href=\"../date\"><code>Date</code></a> as a human-readable string.</dd> <dt><a href=\"toutcstring\"><code>Date.prototype.toUTCString()</code></a></dt> <dd>Converts a date to a string using the UTC timezone.</dd> <dt><a href=\"valueof\"><code>Date.prototype.valueOf()</code></a></dt> <dd>Returns the primitive value of a <a href=\"../date\"><code>Date</code></a> object. Overrides the <a href=\"../object/valueof\"><code>Object.prototype.valueOf()</code></a> method.</dd> </dl> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/publications/files/ECMA-ST-ARCH/ECMA-262,%201st%20edition,%20June%201997.pdf\" hreflang=\"en\">ECMAScript 1st Edition (ECMA-262)</a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition. Implemented in JavaScript 1.1.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/5.1/#sec-15.9.5\" hreflang=\"en\">ECMAScript 5.1 (ECMA-262)<br><small>The definition of 'Date.prototype' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-properties-of-the-date-prototype-object\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Date.prototype' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-properties-of-the-date-prototype-object\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Date.prototype' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">Ordinary object (ES2015)</th>\n<td> ? </td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 41</td>\n<td> ? </td>\n<td> ? </td>\n<td> ? </td>\n</tr>\n</tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">Ordinary object (ES2015)</th>\n<td> ? </td>\n<td> ? </td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 41</td>\n<td> ? </td>\n<td> ? </td>\n<td> ? </td>\n</tr>\n</tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\">Ordinary object (ES2015)</th>\n<td> ? </td>\n</tr>\n</tbody>\n</table>\n</div><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/prototype$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/prototype\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/prototype</a>\n  </p>\n</div>\n","global_objects/date/setminutes":"<h1>date.setMinutes</h1> <p>The <code>setMinutes()</code> method sets the minutes for a specified date according to local time.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/date-setminutes.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\"><var>dateObj</var>.setMinutes(<var>minutesValue</var>[, <var>secondsValue</var>[, <var>msValue</var>]])</pre> <h3 id=\"Versions_prior_to_JavaScript_1.3\">Versions prior to JavaScript 1.3</h3> <pre class=\"syntaxbox\"><var>dateObj</var>.setMinutes(<var>minutesValue</var>)</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><code>minutesValue</code></dt> <dd>An integer between 0 and 59, representing the minutes.</dd> <dt><code>secondsValue</code></dt> <dd>Optional. An integer between 0 and 59, representing the seconds. If you specify the <code>secondsValue</code> parameter, you must also specify the <code>minutesValue</code>.</dd> <dt><code>msValue</code></dt> <dd>Optional. A number between 0 and 999, representing the milliseconds. If you specify the <code>msValue</code> parameter, you must also specify the <code>minutesValue</code> and <code>secondsValue</code>.</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p>The number of milliseconds between 1 January 1970 00:00:00 UTC and the updated date.</p> <h2 id=\"Description\">Description</h2> <p>If you do not specify the <code>secondsValue</code> and <code>msValue</code> parameters, the values returned from <a href=\"getseconds\"><code>getSeconds()</code></a> and <a href=\"getmilliseconds\"><code>getMilliseconds()</code></a> methods are used.</p> <p>If a parameter you specify is outside of the expected range, <code>setMinutes()</code> attempts to update the date information in the <a href=\"../date\"><code>Date</code></a> object accordingly. For example, if you use 100 for <code>secondsValue</code>, the minutes will be incremented by 1 (<code>minutesValue + 1</code>), and 40 will be used for seconds.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Using_setMinutes()\">Using <code>setMinutes()</code>\n</h3> <pre data-language=\"js\">var theBigDay = new Date();\ntheBigDay.setMinutes(45);\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/publications/files/ECMA-ST-ARCH/ECMA-262,%201st%20edition,%20June%201997.pdf\" hreflang=\"en\">ECMAScript 1st Edition (ECMA-262)</a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition. Implemented in JavaScript 1.0.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/5.1/#sec-15.9.5.32\" hreflang=\"en\">ECMAScript 5.1 (ECMA-262)<br><small>The definition of 'Date.prototype.setMinutes' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-date.prototype.setminutes\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Date.prototype.setMinutes' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-date.prototype.setminutes\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Date.prototype.setMinutes' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"getminutes\"><code>Date.prototype.getMinutes()</code></a></li> <li><a href=\"setutcminutes\"><code>Date.prototype.setUTCMinutes()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setMinutes$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setMinutes\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setMinutes</a>\n  </p>\n</div>\n","global_objects/date/setseconds":"<h1>date.setSeconds</h1> <p>The <code>setSeconds()</code> method sets the seconds for a specified date according to local time.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/date-setseconds.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\"><var>dateObj</var>.setSeconds(<var>secondsValue</var>[, <var>msValue</var>])</pre> <h3 id=\"Versions_prior_to_JavaScript_1.3\">Versions prior to JavaScript 1.3</h3> <pre class=\"syntaxbox\"><var>dateObj</var>.setSeconds(<var>secondsValue</var>)</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><code>secondsValue</code></dt> <dd>An integer between 0 and 59, representing the seconds.</dd> <dt><code>msValue</code></dt> <dd>Optional. A number between 0 and 999, representing the milliseconds.</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p>The number of milliseconds between 1 January 1970 00:00:00 UTC and the updated date.</p> <h2 id=\"Description\">Description</h2> <p>If you do not specify the <code>msValue</code> parameter, the value returned from the <a href=\"getmilliseconds\"><code>getMilliseconds()</code></a> method is used.</p> <p>If a parameter you specify is outside of the expected range, <code>setSeconds()</code> attempts to update the date information in the <a href=\"../date\"><code>Date</code></a> object accordingly. For example, if you use 100 for <code>secondsValue</code>, the minutes stored in the <a href=\"../date\"><code>Date</code></a> object will be incremented by 1, and 40 will be used for seconds.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Using_setSeconds()\">Using <code>setSeconds()</code>\n</h3> <pre data-language=\"js\">var theBigDay = new Date();\ntheBigDay.setSeconds(30);\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/publications/files/ECMA-ST-ARCH/ECMA-262,%201st%20edition,%20June%201997.pdf\" hreflang=\"en\">ECMAScript 1st Edition (ECMA-262)</a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition. Implemented in JavaScript 1.0.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/5.1/#sec-15.9.5.30\" hreflang=\"en\">ECMAScript 5.1 (ECMA-262)<br><small>The definition of 'Date.prototype.setSeconds' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-date.prototype.setseconds\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Date.prototype.setSeconds' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-date.prototype.setseconds\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Date.prototype.setSeconds' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"getseconds\"><code>Date.prototype.getSeconds()</code></a></li> <li><a href=\"setutcseconds\"><code>Date.prototype.setUTCSeconds()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setSeconds$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setSeconds\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setSeconds</a>\n  </p>\n</div>\n","global_objects/date/settime":"<h1>date.setTime</h1> <p>The <code>setTime()</code> method sets the <a href=\"../date\"><code>Date</code></a> object to the time represented by a number of milliseconds since January 1, 1970, 00:00:00 UTC.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/date-settime.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\"><var>dateObj</var>.setTime(<var>timeValue</var>)</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><code>timeValue</code></dt> <dd>An integer representing the number of milliseconds since 1 January 1970, 00:00:00 UTC.</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p>The number of milliseconds between 1 January 1970 00:00:00 UTC and the updated date (effectively, the value of the argument).</p> <h2 id=\"Description\">Description</h2> <p>Use the <code>setTime()</code> method to help assign a date and time to another <a href=\"../date\"><code>Date</code></a> object.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Using_setTime()\">Using <code>setTime()</code>\n</h3> <pre data-language=\"js\">var theBigDay = new Date('July 1, 1999');\nvar sameAsBigDay = new Date();\nsameAsBigDay.setTime(theBigDay.getTime());\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/publications/files/ECMA-ST-ARCH/ECMA-262,%201st%20edition,%20June%201997.pdf\" hreflang=\"en\">ECMAScript 1st Edition (ECMA-262)</a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition. Implemented in JavaScript 1.0.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/5.1/#sec-15.9.5.27\" hreflang=\"en\">ECMAScript 5.1 (ECMA-262)<br><small>The definition of 'Date.prototype.setTime' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-date.prototype.settime\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Date.prototype.setTime' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-date.prototype.settime\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Date.prototype.setTime' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"gettime\"><code>Date.prototype.getTime()</code></a></li> <li><a href=\"setutchours\"><code>Date.prototype.setUTCHours()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setTime$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setTime\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setTime</a>\n  </p>\n</div>\n","global_objects/date/setutcfullyear":"<h1>date.setUTCFullYear</h1> <p>The <code>setUTCFullYear()</code> method sets the full year for a specified date according to universal time.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/date-setutcfullyear.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\"><var>dateObj</var>.setUTCFullYear(<var>yearValue</var>[, <var>monthValue</var>[, <var>dayValue</var>]])</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><code>yearValue</code></dt> <dd>An integer specifying the numeric value of the year, for example, 1995.</dd> <dt><code>monthValue</code></dt> <dd>Optional. An integer between 0 and 11 representing the months January through December.</dd> <dt><code>dayValue</code></dt> <dd>Optional. An integer between 1 and 31 representing the day of the month. If you specify the <code>dayValue</code> parameter, you must also specify the <code>monthValue</code>.</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p>The number of milliseconds between 1 January 1970 00:00:00 UTC and the updated date.</p> <h2 id=\"Description\">Description</h2> <p>If you do not specify the <code>monthValue</code> and <code>dayValue</code> parameters, the values returned from the <a href=\"getutcmonth\"><code>getUTCMonth()</code></a> and <a href=\"getutcdate\"><code>getUTCDate()</code></a> methods are used.</p> <p>If a parameter you specify is outside of the expected range, <code>setUTCFullYear()</code> attempts to update the other parameters and the date information in the <a href=\"../date\"><code>Date</code></a> object accordingly. For example, if you specify 15 for <code>monthValue</code>, the year is incremented by 1 (<code>yearValue + 1</code>), and 3 is used for the month.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Using_setUTCFullYear()\">Using <code>setUTCFullYear()</code>\n</h3> <pre data-language=\"js\">var theBigDay = new Date();\ntheBigDay.setUTCFullYear(1997);\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/publications/files/ECMA-ST-ARCH/ECMA-262,%201st%20edition,%20June%201997.pdf\" hreflang=\"en\">ECMAScript 1st Edition (ECMA-262)</a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition. Implemented in JavaScript 1.3.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/5.1/#sec-15.9.5.41\" hreflang=\"en\">ECMAScript 5.1 (ECMA-262)<br><small>The definition of 'Date.prototype.setUTCFullYear' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-date.prototype.setutcfullyear\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Date.prototype.setUTCFullYear' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-date.prototype.setutcfullyear\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Date.prototype.setUTCFullYear' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"getutcfullyear\"><code>Date.prototype.getUTCFullYear()</code></a></li> <li><a href=\"setfullyear\"><code>Date.prototype.setFullYear()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setUTCFullYear$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setUTCFullYear\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setUTCFullYear</a>\n  </p>\n</div>\n","global_objects/date/setutcmilliseconds":"<h1>date.setUTCMilliseconds</h1> <p>The <code>setUTCMilliseconds()</code> method sets the milliseconds for a specified date according to universal time.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/date-setutcmilliseconds.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\"><var>dateObj</var>.setUTCMilliseconds(<var>millisecondsValue</var>)</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><code>millisecondsValue</code></dt> <dd>A number between 0 and 999, representing the milliseconds.</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p>The number of milliseconds between 1 January 1970 00:00:00 UTC and the updated date.</p> <h2 id=\"Description\">Description</h2> <p>If a parameter you specify is outside of the expected range, <code>setUTCMilliseconds()</code> attempts to update the date information in the <a href=\"../date\"><code>Date</code></a> object accordingly. For example, if you use 1100 for <code>millisecondsValue</code>, the seconds stored in the <a href=\"../date\"><code>Date</code></a> object will be incremented by 1, and 100 will be used for milliseconds.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Using_setUTCMilliseconds()\">Using <code>setUTCMilliseconds()</code>\n</h3> <pre data-language=\"js\">var theBigDay = new Date();\ntheBigDay.setUTCMilliseconds(500);\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/publications/files/ECMA-ST-ARCH/ECMA-262,%201st%20edition,%20June%201997.pdf\" hreflang=\"en\">ECMAScript 1st Edition (ECMA-262)</a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition. Implemented in JavaScript 1.3.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/5.1/#sec-15.9.5.29\" hreflang=\"en\">ECMAScript 5.1 (ECMA-262)<br><small>The definition of 'Date.prototype.setUTCMilliseconds' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-date.prototype.setutcmilliseconds\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Date.prototype.setUTCMilliseconds' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-date.prototype.setutcmilliseconds\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Date.prototype.setUTCMilliseconds' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"getutcmilliseconds\"><code>Date.prototype.getUTCMilliseconds()</code></a></li> <li><a href=\"setmilliseconds\"><code>Date.prototype.setMilliseconds()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setUTCMilliseconds$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setUTCMilliseconds\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setUTCMilliseconds</a>\n  </p>\n</div>\n","global_objects/date/getutcseconds":"<h1>date.getUTCSeconds</h1> <p>The <code>getUTCSeconds()</code> method returns the seconds in the specified date according to universal time.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/date-getutcseconds.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe> <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\"><var>dateObj</var>.getUTCSeconds()</pre> <h3 id=\"Return_value\">Return value</h3> <p>An integer number, between 0 and 59, representing the seconds in the given date according to universal time.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Using_getUTCSeconds()\">Using <code>getUTCSeconds()</code>\n</h3> <p>The following example assigns the seconds portion of the current time to the variable <code>seconds</code>.</p> <pre data-language=\"js\">var today = new Date();\nvar seconds = today.getUTCSeconds();\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/publications/files/ECMA-ST-ARCH/ECMA-262,%201st%20edition,%20June%201997.pdf\" hreflang=\"en\">ECMAScript 1st Edition (ECMA-262)</a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition. Implemented in JavaScript 1.3.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/5.1/#sec-15.9.5.23\" hreflang=\"en\">ECMAScript 5.1 (ECMA-262)<br><small>The definition of 'Date.prototype.getUTCSeconds' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-date.prototype.getutcseconds\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Date.prototype.getUTCSeconds' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-date.prototype.getutcseconds\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Date.prototype.getUTCSeconds' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"getseconds\"><code>Date.prototype.getSeconds()</code></a></li> <li><a href=\"setutcseconds\"><code>Date.prototype.setUTCSeconds()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getUTCSeconds$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getUTCSeconds\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getUTCSeconds</a>\n  </p>\n</div>\n","global_objects/date/setutcseconds":"<h1>date.setUTCSeconds</h1> <p>The <code>setUTCSeconds()</code> method sets the seconds for a specified date according to universal time.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/date-setutcseconds.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\"><var>dateObj</var>.setUTCSeconds(<var>secondsValue</var>[, <var>msValue</var>])</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><code>secondsValue</code></dt> <dd>An integer between 0 and 59, representing the seconds.</dd> <dt><code>msValue</code></dt> <dd>Optional. A number between 0 and 999, representing the milliseconds.</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p>The number of milliseconds between 1 January 1970 00:00:00 UTC and the updated date.</p> <h2 id=\"Description\">Description</h2> <p>If you do not specify the <code>msValue</code> parameter, the value returned from the <a href=\"getutcmilliseconds\"><code>getUTCMilliseconds()</code></a> method is used.</p> <p>If a parameter you specify is outside of the expected range, <code>setUTCSeconds()</code> attempts to update the date information in the <a href=\"../date\"><code>Date</code></a> object accordingly. For example, if you use 100 for <code>secondsValue</code>, the minutes stored in the <a href=\"../date\"><code>Date</code></a> object will be incremented by 1, and 40 will be used for seconds.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Using_setUTCSeconds()\">Using <code>setUTCSeconds()</code>\n</h3> <pre data-language=\"js\">var theBigDay = new Date();\ntheBigDay.setUTCSeconds(20);\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/publications/files/ECMA-ST-ARCH/ECMA-262,%201st%20edition,%20June%201997.pdf\" hreflang=\"en\">ECMAScript 1st Edition (ECMA-262)</a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition. Implemented in JavaScript 1.3.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/5.1/#sec-15.9.5.31\" hreflang=\"en\">ECMAScript 5.1 (ECMA-262)<br><small>The definition of 'Date.prototype.setUTCSeconds' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-date.prototype.setutcseconds\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Date.prototype.setUTCSeconds' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-date.prototype.setutcseconds\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Date.prototype.setUTCSeconds' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"getutcseconds\"><code>Date.prototype.getUTCSeconds()</code></a></li> <li><a href=\"setseconds\"><code>Date.prototype.setSeconds()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setUTCSeconds$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setUTCSeconds\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setUTCSeconds</a>\n  </p>\n</div>\n","global_objects/date/setutcmonth":"<h1>date.setUTCMonth</h1> <p>The <code>setUTCMonth()</code> method sets the month for a specified date according to universal time.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/date-setutcmonth.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\"><var>dateObj</var>.setUTCMonth(<var>monthValue</var>[, <var>dayValue</var>])</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><code>monthValue</code></dt> <dd>An integer between 0 and 11, representing the months January through December.</dd> <dt><code>dayValue</code></dt> <dd>Optional. An integer from 1 to 31, representing the day of the month.</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p>The number of milliseconds between 1 January 1970 00:00:00 UTC and the updated date.</p> <h2 id=\"Description\">Description</h2> <p>If you do not specify the <code>dayValue</code> parameter, the value returned from the <a href=\"getutcdate\"><code>getUTCDate()</code></a> method is used.</p> <p>If a parameter you specify is outside of the expected range, <code>setUTCMonth()</code> attempts to update the date information in the <a href=\"../date\"><code>Date</code></a> object accordingly. For example, if you use 15 for <code>monthValue</code>, the year will be incremented by 1, and 3 will be used for month.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Using_setUTCMonth()\">Using <code>setUTCMonth()</code>\n</h3> <pre data-language=\"js\">var theBigDay = new Date();\ntheBigDay.setUTCMonth(11);\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/publications/files/ECMA-ST-ARCH/ECMA-262,%201st%20edition,%20June%201997.pdf\" hreflang=\"en\">ECMAScript 1st Edition (ECMA-262)</a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition. Implemented in JavaScript 1.3.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/5.1/#sec-15.9.5.39\" hreflang=\"en\">ECMAScript 5.1 (ECMA-262)<br><small>The definition of 'Date.prototype.setUTCMonth' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-date.prototype.setutcmonth\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Date.prototype.setUTCMonth' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-date.prototype.setutcmonth\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Date.prototype.setUTCMonth' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"getutcmonth\"><code>Date.prototype.getUTCMonth()</code></a></li> <li><a href=\"setmonth\"><code>Date.prototype.setMonth()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setUTCMonth$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setUTCMonth\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setUTCMonth</a>\n  </p>\n</div>\n","global_objects/date/setutcdate":"<h1>date.setUTCDate</h1> <p>The <code>setUTCDate()</code> method sets the day of the month for a specified date according to universal time.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/date-setutcdate.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\"><var>dateObj</var>.setUTCDate(<var>dayValue</var>)</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><code>dayValue</code></dt> <dd>An integer from 1 to 31, representing the day of the month.</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p>The number of milliseconds between 1 January 1970 00:00:00 UTC and the updated date.</p> <h2 id=\"Description\">Description</h2> <p>If a parameter you specify is outside of the expected range, <code>setUTCDate()</code> attempts to update the date information in the <a href=\"../date\"><code>Date</code></a> object accordingly. For example, if you use 40 for <code>dayValue</code>, and the month stored in the <a href=\"../date\"><code>Date</code></a> object is June, the day will be changed to 10 and the month will be incremented to July.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Using_setUTCDate()\">Using <code>setUTCDate()</code>\n</h3> <pre data-language=\"js\">var theBigDay = new Date();\ntheBigDay.setUTCDate(20);\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/publications/files/ECMA-ST-ARCH/ECMA-262,%201st%20edition,%20June%201997.pdf\" hreflang=\"en\">ECMAScript 1st Edition (ECMA-262)</a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition. Implemented in JavaScript 1.3.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/5.1/#sec-15.9.5.37\" hreflang=\"en\">ECMAScript 5.1 (ECMA-262)<br><small>The definition of 'Date.prototype.setUTCDate' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-date.prototype.setutcdate\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Date.prototype.setUTCDate' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-date.prototype.setutcdate\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Date.prototype.setUTCDate' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"getutcdate\"><code>Date.prototype.getUTCDate()</code></a></li> <li><a href=\"setdate\"><code>Date.prototype.setDate()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setUTCDate$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setUTCDate\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setUTCDate</a>\n  </p>\n</div>\n","global_objects/date/todatestring":"<h1>date.toDateString</h1> <p>The <code>toDateString()</code> method returns the date portion of a <a href=\"../date\"><code>Date</code></a> object in human readable form in American English.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/date-todatestring.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\"><var>dateObj</var>.toDateString()</pre> <h3 id=\"Return_value\">Return value</h3> <p>A string representing the date portion of the given <a href=\"../date\"><code>Date</code></a> object in human readable form in American English.</p> <h2 id=\"Description\">Description</h2> <p><a href=\"../date\"><code>Date</code></a> instances refer to a specific point in time. Calling <a href=\"tostring\"><code>toString()</code></a> will return the date formatted in a human readable form in American English. In <a href=\"https://developer.mozilla.org/en-US/docs/SpiderMonkey\">SpiderMonkey</a>, this consists of the date portion (day, month, and year) followed by the time portion (hours, minutes, seconds, and time zone). Sometimes it is desirable to obtain a string of the time portion; such a thing can be accomplished with the <code>toTimeString()</code> method.</p> <p>The <code>toDateString()</code> method is especially useful because compliant engines implementing <a href=\"https://developer.mozilla.org/en-US/docs/ECMAScript\">ECMA-262</a> may differ in the string obtained from <a href=\"tostring\"><code>toString()</code></a> for <a href=\"../date\"><code>Date</code></a> objects, as the format is implementation-dependent and simple string slicing approaches may not produce consistent results across multiple engines.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"A_basic_usage_of_toDateString()\">A basic usage of <code>toDateString()</code>\n</h3> <pre data-language=\"js\">var d = new Date(1993, 5, 28, 14, 39, 7);\n\nconsole.log(d.toString());     // logs Wed Jun 28 1993 14:39:07 GMT-0600 (PDT)\nconsole.log(d.toDateString()); // logs Wed Jun 28 1993\n</pre> <div class=\"note\"> <p><strong>Note:</strong> Month are 0-indexed when used as an argument of <a href=\"../date\"><code>Date</code></a> (thus 0 corresponds to January and 11 to December).</p> </div> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/publications/files/ECMA-ST-ARCH/ECMA-262,%203rd%20edition,%20December%201999.pdf\" hreflang=\"en\">ECMAScript 3rd Edition (ECMA-262)</a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/5.1/#sec-15.9.5.3\" hreflang=\"en\">ECMAScript 5.1 (ECMA-262)<br><small>The definition of 'Date.prototype.toDateString' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-date.prototype.todatestring\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Date.prototype.toDateString' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-date.prototype.todatestring\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Date.prototype.toDateString' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"tolocaledatestring\"><code>Date.prototype.toLocaleDateString()</code></a></li> <li><a href=\"totimestring\"><code>Date.prototype.toTimeString()</code></a></li> <li><a href=\"tostring\"><code>Date.prototype.toString()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toDateString$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toDateString\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toDateString</a>\n  </p>\n</div>\n","global_objects/date/tostring":"<h1>date.toString</h1> <p>The <code>toString()</code> method returns a string representing the specified <a href=\"../date\"><code>Date</code></a> object.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/date-tostring.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\"><var>dateObj</var>.toString()</pre> <h3 id=\"Return_value\">Return value</h3> <p>A string representing the given date.</p> <h2 id=\"Description\">Description</h2> <p><a href=\"../date\"><code>Date</code></a> instances inherit their <code>toString()</code> method from <a href=\"prototype\"><code>Date.prototype</code></a>, not <a href=\"../object/prototype\"><code>Object.prototype</code></a>. <code>Date.prototype.toString()</code> returns a string representation of the Date in the format specified in ECMA-262 which can be summarised as:</p> <ul> <li>Week day: 3 letter English week day name, e.g. \"Sat\"</li> <li>space</li> <li>Month name: 3 letter English month name, e.g. \"Sep\"</li> <li>space</li> <li>Date: 2 digit day in month, e.g. \"01\"</li> <li>space</li> <li>Year: 4 digit year, e.g. \"2018\"</li> <li>space</li> <li>Hour: 2 digit hour of day, e.g. \"14\"</li> <li>colon</li> <li>Minute: 2 digit minute of hour, e.g. \"53\"</li> <li>colon</li> <li>Second: 2 digit second of minute, e.g. \"26\"</li> <li>space</li> <li>The string \"GMT\"</li> <li>Timezone offset sign, either: <ul> <li>\"+\" for positive offsets (0 or greater)</li> <li>\"-\" for negative offsets (less than zero)</li> </ul> </li> <li>Two digit hour offset, e.g. \"14\"</li> <li>Two digit minute offset, e.g. \"00\"</li> <li>Optionally, a timezone name consisting of: <ul> <li>space</li> <li>Left bracket, i.e. \"(\"</li> <li>An implementation dependent string representation of the timezone, which might be an abbreviation or full name (there is no standard for names or abbreviations of timezones), e.g. \"Line Islands Time\" or \"LINT\"</li> <li>Right bracket, i.e. \")\"</li> </ul> </li> </ul> <p>E.g. \"Sat Sep 01 2018 14:53:26 GMT+1400 (LINT)\"</p> <p>Until ECMAScript 2018 (edition 9), the format of the string returned by <code>Date.prototype.toString</code> was implementation dependent. Therefore it should not be relied upon to be in the specified format.</p> <p>The <code>toString()</code> method is automatically called when a date is to be represented as a text value, e.g. <code>console.log(new Date())</code>, or when a date is used in a string concatenation, such as <code>var today = 'Today is ' + new Date()</code>.</p> <p><code>toString()</code> is a generic method, it does not require that its <code>this</code> is a <a href=\"../date\"><code>Date</code></a> instance. However, it must have an internal <code>[[TimeValue]]</code> property that can't be constructed using native javascript, so it's effectively limited to use with <a href=\"../date\"><code>Date</code></a> instances. If called on a non–Date instance, a <a href=\"../typeerror\"><code>TypeError</code></a> is thrown.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Using_toString()\">Using <code>toString()</code>\n</h3> <p>The following assigns the <code>toString()</code> value of a <a href=\"../date\"><code>Date</code></a> object to <code>myVar</code>:</p> <pre data-language=\"js\">var x = new Date();\nvar myVar = x.toString(); // assigns a string value to myVar in the same format as:\n                          // Mon Sep 08 1998 14:36:22 GMT-0700 (PDT)\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/publications/files/ECMA-ST-ARCH/ECMA-262,%201st%20edition,%20June%201997.pdf\" hreflang=\"en\">ECMAScript 1st Edition (ECMA-262)</a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition. Implemented in JavaScript 1.0.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/5.1/#sec-15.9.5.2\" hreflang=\"en\">ECMAScript 5.1 (ECMA-262)<br><small>The definition of 'Date.prototype.toLocaleTimeString' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-date.prototype.tostring\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Date.prototype.toString' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a hreflang=\"en\">Unknown<br><small>The definition of 'Date.prototype.toString' in that specification.</small></a></td> <td><span class=\"spec-\">Unknown</span></td> <td>Format of Date.prototype.toString is standardised.</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-date.prototype.tostring\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Date.prototype.toString' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"../object/tostring\"><code>Object.prototype.toString()</code></a></li> <li><a href=\"todatestring\"><code>Date.prototype.toDateString()</code></a></li> <li><a href=\"tolocalestring\"><code>Date.prototype.toLocaleString()</code></a></li> <li><a href=\"totimestring\"><code>Date.prototype.toTimeString()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toString$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toString\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toString</a>\n  </p>\n</div>\n","global_objects/date/setutcminutes":"<h1>date.setUTCMinutes</h1> <p>The <code>setUTCMinutes()</code> method sets the minutes for a specified date according to universal time.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/date-setutcminutes.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\"><var>dateObj</var>.setUTCMinutes(<var>minutesValue</var>[, <var>secondsValue</var>[, <var>msValue</var>]])</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><code>minutesValue</code></dt> <dd>An integer between 0 and 59, representing the minutes.</dd> <dt><code>secondsValue</code></dt> <dd>Optional. An integer between 0 and 59, representing the seconds. If you specify the <code>secondsValue</code> parameter, you must also specify the <code>minutesValue</code>.</dd> <dt><code>msValue</code></dt> <dd>Optional. A number between 0 and 999, representing the milliseconds. If you specify the <code>msValue</code> parameter, you must also specify the <code>minutesValue</code> and <code>secondsValue</code>.</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p>The number of milliseconds between 1 January 1970 00:00:00 UTC and the updated date.</p> <h2 id=\"Description\">Description</h2> <p>If you do not specify the <code>secondsValue</code> and <code>msValue</code> parameters, the values returned from <a href=\"getutcseconds\"><code>getUTCSeconds()</code></a> and <a href=\"getutcmilliseconds\"><code>getUTCMilliseconds()</code></a> methods are used.</p> <p>If a parameter you specify is outside of the expected range, <code>setUTCMinutes()</code> attempts to update the date information in the <a href=\"../date\"><code>Date</code></a> object accordingly. For example, if you use 100 for <code>secondsValue</code>, the minutes will be incremented by 1 (<code>minutesValue + 1</code>), and 40 will be used for seconds.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Using_setUTCMinutes()\">Using <code>setUTCMinutes()</code>\n</h3> <pre data-language=\"js\">var theBigDay = new Date();\ntheBigDay.setUTCMinutes(43);\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/publications/files/ECMA-ST-ARCH/ECMA-262,%201st%20edition,%20June%201997.pdf\" hreflang=\"en\">ECMAScript 1st Edition (ECMA-262)</a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition. Implemented in JavaScript 1.3.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/5.1/#sec-15.9.5.33\" hreflang=\"en\">ECMAScript 5.1 (ECMA-262)<br><small>The definition of 'Date.prototype.setUTCMinutes' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-date.prototype.setutcminutes\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Date.prototype.setUTCMinutes' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-date.prototype.setutcminutes\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Date.prototype.setUTCMinutes' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"getutcminutes\"><code>Date.prototype.getUTCMinutes()</code></a></li> <li><a href=\"setminutes\"><code>Date.prototype.setMinutes()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setUTCMinutes$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setUTCMinutes\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setUTCMinutes</a>\n  </p>\n</div>\n","global_objects/math/e":"<h1>Math.E</h1> <p>The <code>Math.E</code> property represents the base of natural logarithms, e, approximately 2.718.</p> <p><math display=\"block\"><semantics><mrow><mstyle mathvariant=\"monospace\"><mi>Math.E</mi></mstyle><mo>=</mo><mi>e</mi><mo>≈</mo><mn>2.718</mn></mrow><annotation encoding=\"TeX\">\\mathtt{\\mi{Math.E}} = e \\approx 2.718</annotation></semantics></math></p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/math-e.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <div class=\"_table\"><table class=\"standard-table\"> <thead> <tr> <th colspan=\"2\" class=\"header\">Property attributes of <code>Math.E</code>\n</th> </tr> </thead> <tbody> <tr> <td>Writable</td> <td>no</td> </tr> <tr> <td>Enumerable</td> <td>no</td> </tr> <tr> <td>Configurable</td> <td>no</td> </tr> </tbody> </table></div> <h2 id=\"Description\">Description</h2> <p>Because <code>E</code> is a static property of <code>Math</code>, you always use it as <code>Math.E</code>, rather than as a property of a <code>Math</code> object you created (<code>Math</code> is not a constructor).</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Using_Math.E\">Using <code>Math.E</code>\n</h3> <p>The following function returns e:</p> <pre data-language=\"js\">function getNapier() {\n  return Math.E;\n}\n\ngetNapier(); // 2.718281828459045\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/publications/files/ECMA-ST-ARCH/ECMA-262,%201st%20edition,%20June%201997.pdf\" hreflang=\"en\">ECMAScript 1st Edition (ECMA-262)</a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition. Implemented in JavaScript 1.0.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/5.1/#sec-15.8.1.1\" hreflang=\"en\">ECMAScript 5.1 (ECMA-262)<br><small>The definition of 'Math.E' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-math.e\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Math.E' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-math.e\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Math.E' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"exp\"><code>Math.exp()</code></a></li> <li><a href=\"log\"><code>Math.log()</code></a></li> <li><a href=\"log1p\"><code>Math.log1p()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/E$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/E\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/E</a>\n  </p>\n</div>\n","global_objects/math/ln10":"<h1>Math.LN10</h1> <p>The <code>Math.LN10</code> property represents the natural logarithm of 10, approximately 2.302:</p> <p><math display=\"block\"><semantics><mrow><mstyle mathvariant=\"monospace\"><mi>Math.LN10</mi></mstyle><mo>=</mo><mo rspace=\"0em\" lspace=\"0em\">ln</mo><mo stretchy=\"false\">(</mo><mn>10</mn><mo stretchy=\"false\">)</mo><mo>≈</mo><mn>2.302</mn></mrow><annotation encoding=\"TeX\">\\mathtt{\\mi{Math.LN10}} = \\ln(10) \\approx 2.302</annotation></semantics></math></p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/math-ln10.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <div class=\"_table\"><table class=\"standard-table\"> <thead> <tr> <th colspan=\"2\" class=\"header\">Property attributes of <code>Math.LN10</code>\n</th> </tr> </thead> <tbody> <tr> <td>Writable</td> <td>no</td> </tr> <tr> <td>Enumerable</td> <td>no</td> </tr> <tr> <td>Configurable</td> <td>no</td> </tr> </tbody> </table></div> <h2 id=\"Description\">Description</h2> <p>Because <code>LN10</code> is a static property of <code>Math</code>, you always use it as <code>Math.LN10</code>, rather than as a property of a <code>Math</code> object you created (<code>Math</code> is not a constructor).</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Using_Math.LN10\">Using <code>Math.LN10</code>\n</h3> <p>The following function returns the natural log of 10:</p> <pre data-language=\"js\">function getNatLog10() {\n  return Math.LN10;\n}\n\ngetNatLog10(); // 2.302585092994046\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/publications/files/ECMA-ST-ARCH/ECMA-262,%201st%20edition,%20June%201997.pdf\" hreflang=\"en\">ECMAScript 1st Edition (ECMA-262)</a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition. Implemented in JavaScript 1.0.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/5.1/#sec-15.8.1.2\" hreflang=\"en\">ECMAScript 5.1 (ECMA-262)<br><small>The definition of 'Math.LN10' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-math.ln10\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Math.LN10' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-math.ln10\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Math.LN10' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"exp\"><code>Math.exp()</code></a></li> <li><a href=\"log\"><code>Math.log()</code></a></li> <li><a href=\"log10\"><code>Math.log10()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/LN10$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/LN10\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/LN10</a>\n  </p>\n</div>\n","global_objects/date/totimestring":"<h1>date.toTimeString</h1> <p>The <code>toTimeString()</code> method returns the time portion of a <a href=\"../date\"><code>Date</code></a> object in human readable form in American English.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/date-totimestring.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\"><var>dateObj</var>.toTimeString()</pre> <h3 id=\"Return_value\">Return value</h3> <p>A string representing the time portion of the given date in human readable form in American English.</p> <h2 id=\"Description\">Description</h2> <p><a href=\"../date\"><code>Date</code></a> instances refer to a specific point in time. Calling <a href=\"tostring\"><code>toString()</code></a> will return the date formatted in a human readable form in American English. In <a href=\"https://developer.mozilla.org/en-US/docs/SpiderMonkey\">SpiderMonkey</a>, this consists of the date portion (day, month, and year) followed by the time portion (hours, minutes, seconds, and time zone). Sometimes it is desirable to obtain a string of the time portion; such a thing can be accomplished with the <code>toTimeString()</code> method.</p> <p>The <code>toTimeString()</code> method is especially useful because compliant engines implementing <a href=\"https://developer.mozilla.org/en-US/docs/ECMAScript\">ECMA-262</a> may differ in the string obtained from <a href=\"tostring\"><code>toString()</code></a> for <a href=\"../date\"><code>Date</code></a> objects, as the format is implementation-dependent; simple string slicing approaches may not produce consistent results across multiple engines.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"A_basic_usage_of_toTimeString()\">A basic usage of <code>toTimeString()</code>\n</h3> <pre data-language=\"js\">var d = new Date(1993, 6, 28, 14, 39, 7);\n\nconsole.log(d.toString());     // Wed Jul 28 1993 14:39:07 GMT-0600 (PDT)\nconsole.log(d.toTimeString()); // 14:39:07 GMT-0600 (PDT)\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/publications/files/ECMA-ST-ARCH/ECMA-262,%203rd%20edition,%20December%201999.pdf\" hreflang=\"en\">ECMAScript 3rd Edition (ECMA-262)</a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/5.1/#sec-15.9.5.4\" hreflang=\"en\">ECMAScript 5.1 (ECMA-262)<br><small>The definition of 'Date.prototype.toTimeString' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-date.prototype.totimestring\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Date.prototype.toTimeString' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-date.prototype.totimestring\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Date.prototype.toTimeString' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"tolocaletimestring\"><code>Date.prototype.toLocaleTimeString()</code></a></li> <li><a href=\"todatestring\"><code>Date.prototype.toDateString()</code></a></li> <li><a href=\"tostring\"><code>Date.prototype.toString()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toTimeString$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toTimeString\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toTimeString</a>\n  </p>\n</div>\n","global_objects/date/toisostring":"<h1>date.toISOString</h1> <p>The <code>toISOString()</code> method returns a string in <em>simplified</em> extended ISO format (<a href=\"http://en.wikipedia.org/wiki/ISO_8601\">ISO 8601</a>), which is always 24 or 27 characters long (<code>YYYY-MM-DDTHH:mm:ss.sssZ</code> or <code>±YYYYYY-MM-DDTHH:mm:ss.sssZ</code>, respectively). The timezone is always zero UTC offset, as denoted by the suffix \"<code>Z</code>\".</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/date-toisostring.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\"><var>dateObj</var>.toISOString()</pre> <h3 id=\"Return_value\">Return value</h3> <p>A string representing the given date in the <a href=\"http://en.wikipedia.org/wiki/ISO_8601\">ISO 8601</a> format according to universal time.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Using_toISOString()\">Using <code>toISOString()</code>\n</h3> <pre data-language=\"js\">var today = new Date('05 October 2011 14:48 UTC');\n\nconsole.log(today.toISOString()); // Returns 2011-10-05T14:48:00.000Z\n</pre> <p>The above example uses parsing of a non–standard string value that may not be correctly parsed in non–Mozilla browsers.</p> <h2 id=\"Polyfill\">Polyfill</h2> <p>This method was standardized in ECMA-262 5th edition. Engines which have not been updated to support this method can work around the absence of this method using the following shim:</p> <pre data-language=\"js\">if (!Date.prototype.toISOString) {\n  (function() {\n\n    function pad(number) {\n      if (number &lt; 10) {\n        return '0' + number;\n      }\n      return number;\n    }\n\n    Date.prototype.toISOString = function() {\n      return this.getUTCFullYear() +\n        '-' + pad(this.getUTCMonth() + 1) +\n        '-' + pad(this.getUTCDate()) +\n        'T' + pad(this.getUTCHours()) +\n        ':' + pad(this.getUTCMinutes()) +\n        ':' + pad(this.getUTCSeconds()) +\n        '.' + (this.getUTCMilliseconds() / 1000).toFixed(3).slice(2, 5) +\n        'Z';\n    };\n\n  }());\n}\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/5.1/#sec-15.9.5.43\" hreflang=\"en\">ECMAScript 5.1 (ECMA-262)<br><small>The definition of 'Date.prototype.toISOString' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition. Implemented in JavaScript 1.8.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-date.prototype.toisostring\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Date.prototype.toISOString' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-date.prototype.toisostring\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Date.prototype.toISOString' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> 9</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"tolocaledatestring\"><code>Date.prototype.toLocaleDateString()</code></a></li> <li><a href=\"totimestring\"><code>Date.prototype.toTimeString()</code></a></li> <li><a href=\"toutcstring\"><code>Date.prototype.toUTCString()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toISOString$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toISOString\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toISOString</a>\n  </p>\n</div>\n","global_objects/math/floor":"<h1>Math.floor</h1> <p>The <code>Math.floor()</code> function returns the largest integer less than or equal to a given number.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/math-floor.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\">Math.floor(<var>x</var>)</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><code>x</code></dt> <dd>A number.</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p>A number representing the largest integer less than or equal to the specified number.</p> <h2 id=\"Description\">Description</h2> <p>Because <code>floor()</code> is a static method of <code>Math</code>, you always use it as <code>Math.floor()</code>, rather than as a method of a <code>Math</code> object you created (<code>Math</code> is not a constructor).</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Using_Math.floor()\">Using <code>Math.floor()</code>\n</h3> <pre data-language=\"js\">Math.floor( 45.95); //  45\nMath.floor( 45.05); //  45\nMath.floor(  4   ); //   4\nMath.floor(-45.05); // -46 \nMath.floor(-45.95); // -46\n</pre> <h3 id=\"Decimal_adjustment\">Decimal adjustment</h3> <pre data-language=\"js\">// Closure\n(function() {\n  /**\n   * Decimal adjustment of a number.\n   *\n   * @param {String}  type  The type of adjustment.\n   * @param {Number}  value The number.\n   * @param {Integer} exp   The exponent (the 10 logarithm of the adjustment base).\n   * @returns {Number} The adjusted value.\n   */\n  function decimalAdjust(type, value, exp) {\n    // If the exp is undefined or zero...\n    if (typeof exp === 'undefined' || +exp === 0) {\n      return Math[type](value);\n    }\n    value = +value;\n    exp = +exp;\n    // If the value is not a number or the exp is not an integer...\n    if (isNaN(value) || !(typeof exp === 'number' &amp;&amp; exp % 1 === 0)) {\n      return NaN;\n    }\n    // Shift\n    value = value.toString().split('e');\n    value = Math[type](+(value[0] + 'e' + (value[1] ? (+value[1] - exp) : -exp)));\n    // Shift back\n    value = value.toString().split('e');\n    return +(value[0] + 'e' + (value[1] ? (+value[1] + exp) : exp));\n  }\n\n  // Decimal round\n  if (!Math.round10) {\n    Math.round10 = function(value, exp) {\n      return decimalAdjust('round', value, exp);\n    };\n  }\n  // Decimal floor\n  if (!Math.floor10) {\n    Math.floor10 = function(value, exp) {\n      return decimalAdjust('floor', value, exp);\n    };\n  }\n  // Decimal ceil\n  if (!Math.ceil10) {\n    Math.ceil10 = function(value, exp) {\n      return decimalAdjust('ceil', value, exp);\n    };\n  }\n})();\n\n// Round\nMath.round10(55.55, -1);   // 55.6\nMath.round10(55.549, -1);  // 55.5\nMath.round10(55, 1);       // 60\nMath.round10(54.9, 1);     // 50\nMath.round10(-55.55, -1);  // -55.5\nMath.round10(-55.551, -1); // -55.6\nMath.round10(-55, 1);      // -50\nMath.round10(-55.1, 1);    // -60\n// Floor\nMath.floor10(55.59, -1);   // 55.5\nMath.floor10(59, 1);       // 50\nMath.floor10(-55.51, -1);  // -55.6\nMath.floor10(-51, 1);      // -60\n// Ceil\nMath.ceil10(55.51, -1);    // 55.6\nMath.ceil10(51, 1);        // 60\nMath.ceil10(-55.59, -1);   // -55.5\nMath.ceil10(-59, 1);       // -50\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/publications/files/ECMA-ST-ARCH/ECMA-262,%201st%20edition,%20June%201997.pdf\" hreflang=\"en\">ECMAScript 1st Edition (ECMA-262)</a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition. Implemented in JavaScript 1.0.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/5.1/#sec-15.8.2.9\" hreflang=\"en\">ECMAScript 5.1 (ECMA-262)<br><small>The definition of 'Math.floor' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-math.floor\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Math.floor' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-math.floor\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Math.floor' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"abs\"><code>Math.abs()</code></a></li> <li><a href=\"ceil\"><code>Math.ceil()</code></a></li> <li><a href=\"round\"><code>Math.round()</code></a></li> <li><a href=\"sign\"><code>Math.sign()</code></a></li> <li><a href=\"trunc\"><code>Math.trunc()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/floor$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/floor\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/floor</a>\n  </p>\n</div>\n","global_objects/date/toutcstring":"<h1>date.toUTCString</h1> <p>The <code>toUTCString()</code> method converts a date to a string, using the UTC time zone.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/date-toutcstring.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\"><var>dateObj</var>.toUTCString()</pre> <h3 id=\"Return_value\">Return value</h3> <p>A string representing the given date using the UTC time zone.</p> <h2 id=\"Description\">Description</h2> <p>The value returned by <code>toUTCString()</code> is a string in the same format as <a href=\"tostring\"><code>Date.prototype.toString()</code></a> but with a zero timezone offset (<abbr title=\"Coordinated Universal Time\">UTC)</abbr>.</p> <p>Prior to ECMAScript 2018, the format of the return value varied according to the platform. The most common return value was an RFC-1123 formatted date stamp, which is a slightly updated version of RFC-822 date stamps.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Using_toUTCString()\">Using <code>toUTCString()</code>\n</h3> <pre data-language=\"js\">var today = new Date('Wed, 14 Jun 2017 00:00:00 PDT');\nvar UTCstring = today.toUTCString(); // Wed, 14 Jun 2017 07:00:00 GMT\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/publications/files/ECMA-ST-ARCH/ECMA-262,%201st%20edition,%20June%201997.pdf\" hreflang=\"en\">ECMAScript 1st Edition (ECMA-262)</a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition. Implemented in JavaScript 1.3. Format is implementation dependent.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/5.1/#sec-15.9.5.42\" hreflang=\"en\">ECMAScript 5.1 (ECMA-262)<br><small>The definition of 'Date.prototype.toUTCString' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-date.prototype.toutcstring\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Date.prototype.toUTCString' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/9.0/#sec-date.prototype.toutcstring\" hreflang=\"en\">ECMAScript 2018 (ECMA-262)<br><small>The definition of 'Date.prototype.toUTCString' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>First standardisation of the format.</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-date.prototype.toutcstring\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Date.prototype.toUTCString' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"tolocalestring\"><code>Date.prototype.toLocaleString()</code></a></li> <li><a href=\"todatestring\"><code>Date.prototype.toDateString()</code></a></li> <li><a href=\"toisostring\"><code>Date.prototype.toISOString()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toUTCString$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toUTCString\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toUTCString</a>\n  </p>\n</div>\n","global_objects/date/valueof":"<h1>date.valueOf</h1> <p>The <code>valueOf()</code> method returns the primitive value of a <a href=\"../date\"><code>Date</code></a> object.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/date-valueof.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe> <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\"><var>dateObj</var>.valueOf()</pre> <h3 id=\"Return_value\">Return value</h3> <p>The number of milliseconds between 1 January 1970 00:00:00 UTC and the given date.</p> <h2 id=\"Description\">Description</h2> <p>The <code>valueOf()</code> method returns the primitive value of a <a href=\"../date\"><code>Date</code></a> object as a number data type, the number of milliseconds since midnight 01 January, 1970 UTC.</p> <p>This method is functionally equivalent to the <a href=\"gettime\"><code>Date.prototype.getTime()</code></a> method.</p> <p>This method is usually called internally by JavaScript and not explicitly in code.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Using_valueOf()\">Using <code>valueOf()</code>\n</h3> <pre data-language=\"js\">var x = new Date(56, 6, 17);\nvar myVar = x.valueOf();      // assigns -424713600000 to myVar\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/publications/files/ECMA-ST-ARCH/ECMA-262,%201st%20edition,%20June%201997.pdf\" hreflang=\"en\">ECMAScript 1st Edition (ECMA-262)</a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition. Implemented in JavaScript 1.1.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/5.1/#sec-15.9.5.8\" hreflang=\"en\">ECMAScript 5.1 (ECMA-262)<br><small>The definition of 'Date.prototype.valueOf' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-date.prototype.valueof\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Date.prototype.valueOf' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-date.prototype.valueof\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Date.prototype.valueOf' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"../object/valueof\"><code>Object.prototype.valueOf()</code></a></li> <li><a href=\"gettime\"><code>Date.prototype.getTime()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/valueOf$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/valueOf\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/valueOf</a>\n  </p>\n</div>\n","global_objects/date/@@toprimitive":"<h1>date.@@toPrimitive</h1> <p>The <code><strong>[@@toPrimitive]()</strong></code> method converts a <code>Date</code> object to a primitive value.</p> <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\"><var>Date()[Symbol.toPrimitive](hint);\n</var></pre> <h3 id=\"Return_value\">Return value</h3> <p>The primitive value of the given <a href=\"../date\"><code>Date</code></a> object. Depending on the argument, the method can return either a string or a number.</p> <h2 id=\"Description\">Description</h2> <p>The <code>[@@toPrimitive]()</code> method of the <a href=\"../date\"><code>Date</code></a> object returns a primitive value, that is either of type number or of type string.</p> <p>If <code>hint</code> is <code>\"string\"</code> or <code>\"default\"</code>, <code>[@@toPrimitive]()</code> tries to call the <a href=\"../object/tostring\"><code>toString</code></a> method. If the <code>toString</code> property does not exist, it tries to call the <a href=\"../object/valueof\"><code>valueOf</code></a> method and if the <code>valueOf</code> does not exist either, <code>[@@toPrimitive]()</code> throws a <a href=\"../typeerror\"><code>TypeError</code></a>.</p> <p>If <code>hint</code> is <code>\"number\"</code>, <code>[@@toPrimitive]()</code> first tries to call <code>valueOf</code>, and if that fails, it calls <code>toString</code>.</p> <p>JavaScript calls the <code>[@@toPrimitive]()</code> method to convert an object to a primitive value. You rarely need to invoke the <code>[@@toPrimitive]()</code> method yourself; JavaScript automatically invokes it when encountering an object where a primitive value is expected.</p> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-date.prototype-@@toprimitive\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Date.prototype.@@toPrimitive' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-date.prototype-@@toprimitive\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Date.prototype.@@toPrimitive' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td> ? </td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 44</td>\n<td> ? </td>\n<td> ? </td>\n<td> ? </td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td> ? </td>\n<td> ? </td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 44</td>\n<td> ? </td>\n<td> ? </td>\n<td> ? </td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 6.0.0</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"../symbol/toprimitive\"><code>Symbol.toPrimitive</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/@@toPrimitive$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/@@toPrimitive\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/@@toPrimitive</a>\n  </p>\n</div>\n","global_objects/math/round":"<h1>Math.round</h1> <p>The <code>Math.round()</code> function returns the value of a number rounded to the nearest integer.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/math-round.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\">Math.round(<var>x</var>)</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><code>x</code></dt> <dd>A number.</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p>The value of the given number rounded to the nearest integer.</p> <h2 id=\"Description\">Description</h2> <p>If the fractional portion of the argument is greater than 0.5, the argument is rounded to the integer with the next higher absolute value. If it is less than 0.5, the argument is rounded to the integer with the lower absolute value. If the fractional portion is exactly 0.5, the argument is rounded to the next integer in the direction of +∞. <strong>Note that this differs from many languages' <code>round()</code> functions, which often round this case to the next integer <em>away from zero</em></strong>, instead giving a different result in the case of negative numbers with a fractional part of exactly 0.5.</p> <p>Because <code>round()</code> is a static method of <code>Math</code>, you always use it as <code>Math.round()</code>, rather than as a method of a <code>Math</code> object you created (<code>Math</code> has no constructor).</p> <h2 id=\"Examples\">Examples</h2> <pre data-language=\"js\">Math.round( 20.49); //  20\nMath.round( 20.5 ); //  21\nMath.round( 42   ); //  42\nMath.round(-20.5 ); // -20\nMath.round(-20.51); // -21\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/publications/files/ECMA-ST-ARCH/ECMA-262,%201st%20edition,%20June%201997.pdf\" hreflang=\"en\">ECMAScript 1st Edition (ECMA-262)</a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition. Implemented in JavaScript 1.0.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/5.1/#sec-15.8.2.15\" hreflang=\"en\">ECMAScript 5.1 (ECMA-262)<br><small>The definition of 'Math.round' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-math.round\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Math.round' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-math.round\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Math.round' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"../number/toprecision\"><code>Number.toPrecision()</code></a></li> <li><a href=\"../number/tofixed\"><code>Number.toFixed()</code></a></li> <li><a href=\"abs\"><code>Math.abs()</code></a></li> <li><a href=\"ceil\"><code>Math.ceil()</code></a></li> <li><a href=\"floor\"><code>Math.floor()</code></a></li> <li><a href=\"sign\"><code>Math.sign()</code></a></li> <li><a href=\"trunc\"><code>Math.trunc()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/round$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/round\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/round</a>\n  </p>\n</div>\n","global_objects/math/log2e":"<h1>Math.LOG2E</h1> <p>The <code>Math.LOG2E</code> property represents the base 2 logarithm of e, approximately 1.442:</p> <p><math display=\"block\"><semantics><mrow><mstyle mathvariant=\"monospace\"><mi>Math.LOG2E</mi></mstyle><mo>=</mo><msub><mo rspace=\"0em\" lspace=\"0em\">log</mo><mn>2</mn></msub><mo stretchy=\"false\">(</mo><mi>e</mi><mo stretchy=\"false\">)</mo><mo>≈</mo><mn>1.442</mn></mrow><annotation encoding=\"TeX\">\\mathtt{\\mi{Math.LOG2E}} = \\log_2(e) \\approx 1.442</annotation></semantics></math></p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/math-log2e.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <div class=\"_table\"><table class=\"standard-table\"> <thead> <tr> <th colspan=\"2\" class=\"header\">Property attributes of <code>Math.LOG2E</code>\n</th> </tr> </thead> <tbody> <tr> <td>Writable</td> <td>no</td> </tr> <tr> <td>Enumerable</td> <td>no</td> </tr> <tr> <td>Configurable</td> <td>no</td> </tr> </tbody> </table></div> <h2 id=\"Description\">Description</h2> <p>Because <code>LOG2E</code> is a static property of <code>Math</code>, you always use it as <code>Math.LOG2E</code>, rather than as a property of a <code>Math</code> object you created (<code>Math</code> is not a constructor).</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Using_Math.LOG2E\">Using <code>Math.LOG2E</code>\n</h3> <p>The following function returns the base 2 logarithm of e:</p> <pre data-language=\"js\">function getLog2e() {\n  return Math.LOG2E;\n}\n\ngetLog2e(); // 1.4426950408889634\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/publications/files/ECMA-ST-ARCH/ECMA-262,%201st%20edition,%20June%201997.pdf\" hreflang=\"en\">ECMAScript 1st Edition (ECMA-262)</a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition. Implemented in JavaScript 1.0.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/5.1/#sec-15.8.1.4\" hreflang=\"en\">ECMAScript 5.1 (ECMA-262)<br><small>The definition of 'Math.LOG2E' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-math.log2e\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Math.LOG2E' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-math.log2e\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Math.LOG2E' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"exp\"><code>Math.exp()</code></a></li> <li><a href=\"log\"><code>Math.log()</code></a></li> <li><a href=\"log2\"><code>Math.log2()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/LOG2E$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/LOG2E\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/LOG2E</a>\n  </p>\n</div>\n","global_objects/math/ln2":"<h1>Math.LN2</h1> <p>The <code>Math.LN2</code> property represents the natural logarithm of 2, approximately 0.693:</p> <p><math display=\"block\"><semantics><mrow><mstyle mathvariant=\"monospace\"><mi>Math.LN2</mi></mstyle><mo>=</mo><mo rspace=\"0em\" lspace=\"0em\">ln</mo><mo stretchy=\"false\">(</mo><mn>2</mn><mo stretchy=\"false\">)</mo><mo>≈</mo><mn>0.693</mn></mrow><annotation encoding=\"TeX\">\\mathtt{\\mi{Math.LN2}} = \\ln(2) \\approx 0.693</annotation></semantics></math></p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/math-ln2.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <div class=\"_table\"><table class=\"standard-table\"> <thead> <tr> <th colspan=\"2\" class=\"header\">Property attributes of <code>Math.LN2</code>\n</th> </tr> </thead> <tbody> <tr> <td>Writable</td> <td>no</td> </tr> <tr> <td>Enumerable</td> <td>no</td> </tr> <tr> <td>Configurable</td> <td>no</td> </tr> </tbody> </table></div> <h2 id=\"Description\">Description</h2> <p>Because <code>LN2</code> is a static property of <code>Math</code>, you always use it as <code>Math.LN2</code>, rather than as a property of a <code>Math</code> object you created (<code>Math</code> is not a constructor).</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Using_Math.LN2\">Using <code>Math.LN2</code>\n</h3> <p>The following function returns the natural log of 2:</p> <pre data-language=\"js\">function getNatLog2() {\n  return Math.LN2;\n}\n\ngetNatLog2(); // 0.6931471805599453\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/publications/files/ECMA-ST-ARCH/ECMA-262,%201st%20edition,%20June%201997.pdf\" hreflang=\"en\">ECMAScript 1st Edition (ECMA-262)</a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition. Implemented in JavaScript 1.0.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/5.1/#sec-15.8.1.3\" hreflang=\"en\">ECMAScript 5.1 (ECMA-262)<br><small>The definition of 'Math.LN2' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-math.ln2\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Math.LN2' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-math.ln2\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Math.LN2' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"exp\"><code>Math.exp()</code></a></li> <li><a href=\"log\"><code>Math.log()</code></a></li> <li><a href=\"log2\"><code>Math.log2()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/LN2$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/LN2\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/LN2</a>\n  </p>\n</div>\n","global_objects/math/log10e":"<h1>Math.LOG10E</h1> <p>The <code>Math.LOG10E</code> property represents the base 10 logarithm of e, approximately 0.434:</p> <p><math display=\"block\"><semantics><mrow><mstyle mathvariant=\"monospace\"><mi>Math.LOG10E</mi></mstyle><mo>=</mo><msub><mo rspace=\"0em\" lspace=\"0em\">log</mo><mn>10</mn></msub><mo stretchy=\"false\">(</mo><mi>e</mi><mo stretchy=\"false\">)</mo><mo>≈</mo><mn>0.434</mn></mrow><annotation encoding=\"TeX\">\\mathtt{\\mi{Math.LOG10E}} = \\log_10(e) \\approx 0.434</annotation></semantics></math></p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/math-log10e.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <div class=\"_table\"><table class=\"standard-table\"> <thead> <tr> <th colspan=\"2\" class=\"header\">Property attributes of <code>Math.LOG10E</code>\n</th> </tr> </thead> <tbody> <tr> <td>Writable</td> <td>no</td> </tr> <tr> <td>Enumerable</td> <td>no</td> </tr> <tr> <td>Configurable</td> <td>no</td> </tr> </tbody> </table></div> <h2 id=\"Description\">Description</h2> <p>Because <code>LOG10E</code> is a static property of <code>Math</code>, you always use it as <code>Math.LOG10E</code>, rather than as a property of a <code>Math</code> object you created (<code>Math</code> is not a constructor).</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Using_Math.LOG10E\">Using <code>Math.LOG10E</code>\n</h3> <p>The following function returns the base 10 logarithm of e:</p> <pre data-language=\"js\">function getLog10e() {\n  return Math.LOG10E;\n}\n\ngetLog10e(); // 0.4342944819032518\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/publications/files/ECMA-ST-ARCH/ECMA-262,%201st%20edition,%20June%201997.pdf\" hreflang=\"en\">ECMAScript 1st Edition (ECMA-262)</a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition. Implemented in JavaScript 1.0.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/5.1/#sec-15.8.1.5\" hreflang=\"en\">ECMAScript 5.1 (ECMA-262)<br><small>The definition of 'Math.LOG10E' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-math.log10e\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Math.LOG10E' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-math.log10e\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Math.LOG10E' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"exp\"><code>Math.exp()</code></a></li> <li><a href=\"log\"><code>Math.log()</code></a></li> <li><a href=\"log10\"><code>Math.log10()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/LOG10E$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/LOG10E\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/LOG10E</a>\n  </p>\n</div>\n","global_objects/math/pi":"<h1>Math.PI</h1> <p>The <code>Math.PI</code> property represents the ratio of the circumference of a circle to its diameter, approximately 3.14159:</p> <p><math display=\"block\"><semantics><mrow><mstyle mathvariant=\"monospace\"><mi>Math.PI</mi></mstyle><mo>=</mo><mi>π</mi><mo>≈</mo><mn>3.14159</mn></mrow><annotation encoding=\"TeX\">\\mathtt{\\mi{Math.PI}} = \\pi \\approx 3.14159</annotation></semantics></math></p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/math-pi.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <div class=\"_table\"><table class=\"standard-table\"> <thead> <tr> <th colspan=\"2\" class=\"header\">Property attributes of <code>Math.PI</code>\n</th> </tr> </thead> <tbody> <tr> <td>Writable</td> <td>no</td> </tr> <tr> <td>Enumerable</td> <td>no</td> </tr> <tr> <td>Configurable</td> <td>no</td> </tr> </tbody> </table></div> <h2 id=\"Description\">Description</h2> <p>Because <code>PI</code> is a static property of <code>Math</code>, you always use it as <code>Math.PI</code>, rather than as a property of a <code>Math</code> object you created (<code>Math</code> is not a constructor).</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Using_Math.PI\">Using <code>Math.PI</code>\n</h3> <p>The following function uses <code>Math.PI</code> to calculate the circumference of a circle with a passed radius.</p> <pre data-language=\"js\">function calculateCircumference(radius) {\n  return Math.PI * (radius + radius);\n}\n\ncalculateCircumference(1);  // 6.283185307179586\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/publications/files/ECMA-ST-ARCH/ECMA-262,%201st%20edition,%20June%201997.pdf\" hreflang=\"en\">ECMAScript 1st Edition (ECMA-262)</a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition. Implemented in JavaScript 1.0.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/5.1/#sec-15.8.1.6\" hreflang=\"en\">ECMAScript 5.1 (ECMA-262)<br><small>The definition of 'Math.PI' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-math.pi\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Math.PI' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-math.pi\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Math.PI' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"../math\"><code>Math</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/PI$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/PI\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/PI</a>\n  </p>\n</div>\n","global_objects/math/sqrt1_2":"<h1>Math.SQRT1_2</h1> <p>The <code>Math.SQRT1_2</code> property represents the square root of 1/2 which is approximately 0.707:</p> <p><math display=\"block\"><semantics><mrow><mstyle mathvariant=\"monospace\"><mi>Math.SQRT1_2</mi></mstyle><mo>=</mo><msqrt><mfrac><mn>1</mn><mn>2</mn></mfrac></msqrt><mo>=</mo><mfrac><mn>1</mn><msqrt><mn>2</mn></msqrt></mfrac><mo>≈</mo><mn>0.707</mn></mrow><annotation encoding=\"TeX\">\\mathtt{\\mi{Math.SQRT1_2}} = \\sqrt{\\frac{1}{2}} = \\frac{1}{\\sqrt{2}} \\approx 0.707</annotation></semantics></math></p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/math-sqrt1_2.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <div class=\"_table\"><table class=\"standard-table\"> <thead> <tr> <th colspan=\"2\" class=\"header\">Property attributes of <code>Math.SQRT1_2</code>\n</th> </tr> </thead> <tbody> <tr> <td>Writable</td> <td>no</td> </tr> <tr> <td>Enumerable</td> <td>no</td> </tr> <tr> <td>Configurable</td> <td>no</td> </tr> </tbody> </table></div> <h2 id=\"Description\">Description</h2> <p>Because <code>SQRT1_2</code> is a static property of <code>Math</code>, you always use it as <code>Math.SQRT1_2</code>, rather than as a property of a <code>Math</code> object you created (<code>Math</code> is not a constructor).</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Using_Math.SQRT1_2\">Using <code>Math.SQRT1_2</code>\n</h3> <p>The following function returns 1 over the square root of 2:</p> <pre data-language=\"js\">function getRoot1_2() {\n  return Math.SQRT1_2;\n}\n\ngetRoot1_2(); // 0.7071067811865476\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/publications/files/ECMA-ST-ARCH/ECMA-262,%201st%20edition,%20June%201997.pdf\" hreflang=\"en\">ECMAScript 1st Edition (ECMA-262)</a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition. Implemented in JavaScript 1.0.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/5.1/#sec-15.8.1.7\" hreflang=\"en\">ECMAScript 5.1 (ECMA-262)<br><small>The definition of 'Math.SQRT1_2' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-math.sqrt1_2\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Math.SQRT1_2' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-math.sqrt1_2\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Math.SQRT1_2' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"pow\"><code>Math.pow()</code></a></li> <li><a href=\"sqrt\"><code>Math.sqrt()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/SQRT1_2$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/SQRT1_2\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/SQRT1_2</a>\n  </p>\n</div>\n","global_objects/math/sqrt2":"<h1>Math.SQRT2</h1> <p>The <code>Math.SQRT2</code> property represents the square root of 2, approximately 1.414:</p> <p><math display=\"block\"><semantics><mrow><mstyle mathvariant=\"monospace\"><mi>Math.SQRT2</mi></mstyle><mo>=</mo><msqrt><mn>2</mn></msqrt><mo>≈</mo><mn>1.414</mn></mrow><annotation encoding=\"TeX\">\\mathtt{\\mi{Math.SQRT2}} = \\sqrt{2} \\approx 1.414</annotation></semantics></math></p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/math-sqrt2.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <div class=\"_table\"><table class=\"standard-table\"> <thead> <tr> <th colspan=\"2\" class=\"header\">Property attributes of <code>Math.SQRT2</code>\n</th> </tr> </thead> <tbody> <tr> <td>Writable</td> <td>no</td> </tr> <tr> <td>Enumerable</td> <td>no</td> </tr> <tr> <td>Configurable</td> <td>no</td> </tr> </tbody> </table></div> <h2 id=\"Description\">Description</h2> <p>Because <code>SQRT2</code> is a static property of <code>Math</code>, you always use it as <code>Math.SQRT2</code>, rather than as a property of a <code>Math</code> object you created (<code>Math</code> is not a constructor).</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Using_Math.SQRT2\">Using <code>Math.SQRT2</code>\n</h3> <p>The following function returns the square root of 2:</p> <pre data-language=\"js\">function getRoot2() {\n  return Math.SQRT2;\n}\n\ngetRoot2(); // 1.4142135623730951\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/publications/files/ECMA-ST-ARCH/ECMA-262,%201st%20edition,%20June%201997.pdf\" hreflang=\"en\">ECMAScript 1st Edition (ECMA-262)</a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition. Implemented in JavaScript 1.0.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/5.1/#sec-15.8.1.8\" hreflang=\"en\">ECMAScript 5.1 (ECMA-262)<br><small>The definition of 'Math.SQRT2' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-math.sqrt2\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Math.SQRT2' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-math.sqrt2\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Math.SQRT2' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"pow\"><code>Math.pow()</code></a></li> <li><a href=\"sqrt\"><code>Math.sqrt()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/SQRT2$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/SQRT2\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/SQRT2</a>\n  </p>\n</div>\n","global_objects/math/acos":"<h1>Math.acos</h1> <p>The <code>Math.acos()</code> function returns the arccosine (in radians) of a number, that is</p> <p><math display=\"block\"><semantics><mrow><mo>∀</mo><mi>x</mi><mo>∊</mo><mo stretchy=\"false\">[</mo><mrow><mo>-</mo><mn>1</mn></mrow><mo>;</mo><mn>1</mn><mo stretchy=\"false\">]</mo><mo>,</mo><mspace width=\"thickmathspace\"></mspace><mstyle mathvariant=\"monospace\"><mrow><mo rspace=\"thinmathspace\" lspace=\"0em\">Math.acos</mo><mo stretchy=\"false\">(</mo><mi>x</mi><mo stretchy=\"false\">)</mo></mrow></mstyle><mo>=</mo><mo rspace=\"0em\" lspace=\"0em\">arccos</mo><mo stretchy=\"false\">(</mo><mi>x</mi><mo stretchy=\"false\">)</mo><mo>=</mo><mtext> the unique </mtext><mspace width=\"thickmathspace\"></mspace><mi>y</mi><mo>∊</mo><mo stretchy=\"false\">[</mo><mn>0</mn><mo>;</mo><mi>π</mi><mo stretchy=\"false\">]</mo><mspace width=\"thinmathspace\"></mspace><mtext>such that</mtext><mspace width=\"thickmathspace\"></mspace><mo rspace=\"0em\" lspace=\"0em\">cos</mo><mo stretchy=\"false\">(</mo><mi>y</mi><mo stretchy=\"false\">)</mo><mo>=</mo><mi>x</mi></mrow><annotation encoding=\"TeX\">\\forall x \\in [{-1};1],\\;\\mathtt{\\operatorname{Math.acos}(x)} = \\arccos(x) = \\text{ the unique } \\; y \\in [0; \\pi] \\, \\text{such that} \\; \\cos(y) = x</annotation></semantics></math></p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/math-acos.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\">Math.acos(<var>x</var>)</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><code>x</code></dt> <dd>A number.</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p>The arccosine (in radians) of the given number if it's between <strong>-1</strong> and <strong>1</strong>; otherwise, <a href=\"../nan\"><code>NaN</code></a>.</p> <h2 id=\"Description\">Description</h2> <p>The <code>Math.acos()</code> method returns a numeric value between 0 and π radians for <code>x</code> between -1 and 1. If the value of <code>x</code> is outside this range, it returns <a href=\"../nan\"><code>NaN</code></a>.</p> <p>Because <code>acos()</code> is a static method of <code>Math</code>, you always use it as <code>Math.acos()</code>, rather than as a method of a <code>Math</code> object you created (<code>Math</code> is not a constructor).</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Using_Math.acos()\">Using <code>Math.acos()</code>\n</h3> <pre data-language=\"js\">Math.acos(-2);  // NaN\nMath.acos(-1);  // 3.141592653589793\nMath.acos(0);   // 1.5707963267948966\nMath.acos(0.5); // 1.0471975511965979\nMath.acos(1);   // 0\nMath.acos(2);   // NaN\n</pre> <p>For values less than -1 or greater than 1, <code>Math.acos()</code> returns <a href=\"../nan\"><code>NaN</code></a>.</p> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/publications/files/ECMA-ST-ARCH/ECMA-262,%201st%20edition,%20June%201997.pdf\" hreflang=\"en\">ECMAScript 1st Edition (ECMA-262)</a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition. Implemented in JavaScript 1.0.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/5.1/#sec-15.8.2.2\" hreflang=\"en\">ECMAScript 5.1 (ECMA-262)<br><small>The definition of 'Math.acos' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-math.acos\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Math.acos' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-math.acos\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Math.acos' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"asin\"><code>Math.asin()</code></a></li> <li><a href=\"atan\"><code>Math.atan()</code></a></li> <li><a href=\"atan2\"><code>Math.atan2()</code></a></li> <li><a href=\"cos\"><code>Math.cos()</code></a></li> <li><a href=\"sin\"><code>Math.sin()</code></a></li> <li><a href=\"tan\"><code>Math.tan()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/acos$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/acos\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/acos</a>\n  </p>\n</div>\n","global_objects/math/acosh":"<h1>Math.acosh</h1> <p>The <code>Math.acosh()</code> function returns the hyperbolic arc-cosine of a number, that is</p> <p><math display=\"block\"><semantics><mrow><mo>∀</mo><mi>x</mi><mo>≥</mo><mn>1</mn><mo>,</mo><mstyle mathvariant=\"monospace\"><mrow><mo rspace=\"thinmathspace\" lspace=\"0em\">Math.acosh</mo><mo stretchy=\"false\">(</mo><mi>x</mi><mo stretchy=\"false\">)</mo></mrow></mstyle><mo>=</mo><mo rspace=\"thinmathspace\" lspace=\"0em\">arcosh</mo><mo stretchy=\"false\">(</mo><mi>x</mi><mo stretchy=\"false\">)</mo><mo>=</mo><mtext> the unique </mtext><mspace width=\"thickmathspace\"></mspace><mi>y</mi><mo>≥</mo><mn>0</mn><mspace width=\"thickmathspace\"></mspace><mtext>such that</mtext><mspace width=\"thickmathspace\"></mspace><mo rspace=\"0em\" lspace=\"0em\">cosh</mo><mo stretchy=\"false\">(</mo><mi>y</mi><mo stretchy=\"false\">)</mo><mo>=</mo><mi>x</mi></mrow><annotation encoding=\"TeX\">\\forall x \\geq 1, \\mathtt{\\operatorname{Math.acosh}(x)} = \\operatorname{arcosh}(x) = \\text{ the unique } \\; y \\geq 0 \\; \\text{such that} \\; \\cosh(y) = x</annotation></semantics></math></p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/math-acosh.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\">Math.acosh(<var>x</var>)</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><var>x</var></dt> <dd>A number.</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p>The hyperbolic arc-cosine of the given number. If the number is less than <strong>1</strong>, <a href=\"../nan\"><code>NaN</code></a>.</p> <h2 id=\"Description\">Description</h2> <p>Because <code>acosh()</code> is a static method of <code>Math</code>, you always use it as <code>Math.acosh()</code>, rather than as a method of a <code>Math</code> object you created (<code>Math</code> is no constructor).</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Using_Math.acosh()\">Using <code>Math.acosh()</code>\n</h3> <pre data-language=\"js\">Math.acosh(-1);  // NaN\nMath.acosh(0);   // NaN\nMath.acosh(0.5); // NaN\nMath.acosh(1);   // 0\nMath.acosh(2);   // 1.3169578969248166\n</pre> <p>For values less than 1 <code>Math.acosh()</code> returns <a href=\"../nan\"><code>NaN</code></a>.</p> <h2 id=\"Polyfill\">Polyfill</h2> <p>For all <math><semantics><mrow><mi>x</mi><mo>≥</mo><mn>1</mn></mrow><annotation encoding=\"TeX\">x \\geq 1</annotation></semantics></math>, we have <math><semantics><mrow><mo rspace=\"thinmathspace\" lspace=\"0em\">arcosh</mo><mo stretchy=\"false\">(</mo><mi>x</mi><mo stretchy=\"false\">)</mo><mo>=</mo><mo rspace=\"0em\" lspace=\"0em\">ln</mo><mrow><mo>(</mo><mrow><mi>x</mi><mo>+</mo><msqrt><mrow><msup><mi>x</mi><mn>2</mn></msup><mo>-</mo><mn>1</mn></mrow></msqrt></mrow><mo>)</mo></mrow></mrow><annotation encoding=\"TeX\">\\operatorname {arcosh} (x) = \\ln \\left(x + \\sqrt{x^{2} - 1} \\right)</annotation></semantics></math> and so this can be emulated with the following function:</p> <pre data-language=\"js\">Math.acosh = Math.acosh || function(x) {\n  return Math.log(x + Math.sqrt(x * x - 1));\n};\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <thead> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> </thead> <tbody> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-math.acosh\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Math.acosh' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-math.acosh\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Math.acosh' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 38</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 25</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 25</td>\n<td class=\"bc-supports-yes\"> 8</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 25</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 8</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 0.12</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"asinh\"><code>Math.asinh()</code></a></li> <li><a href=\"atanh\"><code>Math.atanh()</code></a></li> <li><a href=\"cosh\"><code>Math.cosh()</code></a></li> <li><a href=\"sinh\"><code>Math.sinh()</code></a></li> <li><a href=\"tanh\"><code>Math.tanh()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/acosh$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/acosh\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/acosh</a>\n  </p>\n</div>\n","global_objects/math/abs":"<h1>Math.abs</h1> <p>The <code>Math.abs()</code> function returns the absolute value of a number, that is</p> <p><math display=\"block\"><semantics><mrow><mstyle mathvariant=\"monospace\"><mrow><mo rspace=\"thinmathspace\" lspace=\"0em\">Math.abs</mo><mo stretchy=\"false\">(</mo><mi>x</mi><mo stretchy=\"false\">)</mo></mrow></mstyle><mo>=</mo><mrow><mo stretchy=\"false\">|</mo><mi>x</mi><mo stretchy=\"false\">|</mo></mrow><mo>=</mo><mrow><mo>{</mo><mtable columnalign=\"left left\"><mtr><mtd><mi>x</mi></mtd><mtd><mtext>if</mtext><mspace width=\"1em\"></mspace><mi>x</mi><mo>&gt;</mo><mn>0</mn></mtd></mtr><mtr><mtd><mi>0</mi></mtd><mtd><mtext>if</mtext><mspace width=\"1em\"></mspace><mi>x</mi><mo>=</mo><mn>0</mn></mtd></mtr><mtr><mtd><mo>-</mo><mi>x</mi></mtd><mtd><mtext>if</mtext><mspace width=\"1em\"></mspace><mi>x</mi><mo>&lt;</mo><mn>0</mn></mtd></mtr></mtable></mrow></mrow><annotation encoding=\"TeX\">{\\mathtt{\\operatorname{Math.abs}(z)}} = {|z|} = \\begin{cases} x &amp; \\text{if} \\quad x \\geq 0 \\\\ x &amp; \\text{if} \\quad x &lt; 0 \\end{cases} </annotation></semantics></math></p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/math-abs.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\">Math.abs(<var>x</var>)</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><code>x</code></dt> <dd>A number.</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p>The absolute value of the given number.</p> <h2 id=\"Description\">Description</h2> <p>Because <code>abs()</code> is a static method of <code>Math</code>, you always use it as <code>Math.abs()</code>, rather than as a method of a <code>Math</code> object you created (<code>Math</code> is not a constructor).</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Behavior_of_Math.abs()\">Behavior of <code>Math.abs()</code>\n</h3> <p>Passing an empty object, an array with more than one member, a non-numeric string or <a href=\"../undefined\"><code>undefined</code></a>/empty variable returns <a href=\"../nan\"><code>NaN</code></a>. Passing <a href=\"../null\"><code>null</code></a>, an empty string or an empty array returns 0.</p> <pre dir=\"rtl\" data-language=\"js\">Math.abs('-1');     // 1\nMath.abs(-2);       // 2\nMath.abs(null);     // 0\nMath.abs('');       // 0\nMath.abs([]);       // 0\nMath.abs([2]);      // 2\nMath.abs([1,2]);    // NaN\nMath.abs({});       // NaN\nMath.abs('string'); // NaN\nMath.abs();         // NaN\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/publications/files/ECMA-ST-ARCH/ECMA-262,%201st%20edition,%20June%201997.pdf\" hreflang=\"en\">ECMAScript 1st Edition (ECMA-262)</a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition. Implemented in JavaScript 1.0.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/5.1/#sec-15.8.2.1\" hreflang=\"en\">ECMAScript 5.1 (ECMA-262)<br><small>The definition of 'Math.abs' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-math.abs\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Math.abs' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-math.abs\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Math.abs' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"ceil\"><code>Math.ceil()</code></a></li> <li><a href=\"floor\"><code>Math.floor()</code></a></li> <li><a href=\"round\"><code>Math.round()</code></a></li> <li><a href=\"sign\"><code>Math.sign()</code></a></li> <li><a href=\"trunc\"><code>Math.trunc()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/abs$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/abs\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/abs</a>\n  </p>\n</div>\n","global_objects/math/asinh":"<h1>Math.asinh</h1> <p>The <code>Math.asinh()</code> function returns the hyperbolic arcsine of a number, that is</p> <p><math display=\"block\"><semantics><mrow><mstyle mathvariant=\"monospace\"><mrow><mo rspace=\"thinmathspace\" lspace=\"0em\">Math.asinh</mo><mo stretchy=\"false\">(</mo><mi>x</mi><mo stretchy=\"false\">)</mo></mrow></mstyle><mo>=</mo><mo rspace=\"thinmathspace\" lspace=\"0em\">arsinh</mo><mo stretchy=\"false\">(</mo><mi>x</mi><mo stretchy=\"false\">)</mo><mo>=</mo><mtext> the unique </mtext><mspace width=\"thickmathspace\"></mspace><mi>y</mi><mspace width=\"thickmathspace\"></mspace><mtext>such that</mtext><mspace width=\"thickmathspace\"></mspace><mo rspace=\"0em\" lspace=\"0em\">sinh</mo><mo stretchy=\"false\">(</mo><mi>y</mi><mo stretchy=\"false\">)</mo><mo>=</mo><mi>x</mi></mrow><annotation encoding=\"TeX\">\\mathtt{\\operatorname{Math.asinh}(x)} = \\operatorname{arsinh}(x) = \\text{ the unique } \\; y \\; \\text{such that} \\; \\sinh(y) = x</annotation></semantics></math></p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/math-asinh.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\">Math.asinh(<var>x</var>)</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><var>x</var></dt> <dd>A number.</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p>The hyperbolic arcsine of the given number.</p> <h2 id=\"Description\">Description</h2> <p>Because <code>asinh()</code> is a static method of <code>Math</code>, you always use it as <code>Math.asinh()</code>, rather than as a method of a <code>Math</code> object you created (<code>Math</code> is not a constructor).</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Using_Math.asinh()\">Using <code>Math.asinh()</code>\n</h3> <pre data-language=\"js\">Math.asinh(1);  // 0.881373587019543\nMath.asinh(0);  // 0\n</pre> <h2 id=\"Polyfill\">Polyfill</h2> <p>As a quick and dirty hack the expression <math><semantics><mrow><mo rspace=\"thinmathspace\" lspace=\"0em\">arsinh</mo><mo stretchy=\"false\">(</mo><mi>x</mi><mo stretchy=\"false\">)</mo><mo>=</mo><mo rspace=\"0em\" lspace=\"0em\">ln</mo><mrow><mo>(</mo><mrow><mi>x</mi><mo>+</mo><msqrt><mrow><msup><mi>x</mi><mn>2</mn></msup><mo>+</mo><mn>1</mn></mrow></msqrt></mrow><mo>)</mo></mrow></mrow><annotation encoding=\"TeX\">\\operatorname {arsinh} (x) = \\ln \\left(x + \\sqrt{x^{2} + 1} \\right)</annotation></semantics></math> may be used directly for a coarse emulation by the following function:</p> <pre data-language=\"js\">Math.asinh = Math.asinh || function(x) {\n  if (x === -Infinity) {\n    return x;\n  } else {\n    return Math.log(x + Math.sqrt(x * x + 1));\n  }\n};\n</pre> <p>Been formally correct it suffers from a number of issues related to floating point computations. Accurate result requires special handling of positive/negative, small/large arguments as it done e.g. in <a href=\"https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/ieee754/dbl-64/s_asinh.c\">glibc</a> or <a href=\"http://git.savannah.gnu.org/cgit/gsl.git/tree/sys/invhyp.c\">GNU Scientific Library</a>.</p> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <thead> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> </thead> <tbody> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-math.asinh\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Math.asinh' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-math.asinh\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Math.asinh' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 38</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 25</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 25</td>\n<td class=\"bc-supports-yes\"> 8</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 25</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 8</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 0.12</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"acosh\"><code>Math.acosh()</code></a></li> <li><a href=\"atanh\"><code>Math.atanh()</code></a></li> <li><a href=\"cosh\"><code>Math.cosh()</code></a></li> <li><a href=\"sinh\"><code>Math.sinh()</code></a></li> <li><a href=\"tanh\"><code>Math.tanh()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/asinh$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/asinh\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/asinh</a>\n  </p>\n</div>\n","global_objects/math/cbrt":"<h1>Math.cbrt</h1> <p>The <code>Math.cbrt()</code> function returns the cube root of a number, that is</p> <p><math display=\"block\"><semantics><mrow><mstyle mathvariant=\"monospace\"><mrow><mi>M</mi><mi>a</mi><mi>t</mi><mi>h</mi><mo>.</mo><mi>c</mi><mi>b</mi><mi>r</mi><mi>t</mi><mo stretchy=\"false\">(</mo><mi>x</mi><mo stretchy=\"false\">)</mo></mrow></mstyle><mo>=</mo><mroot><mi>x</mi><mn>3</mn></mroot><mo>=</mo><mtext>the unique</mtext><mspace width=\"thickmathspace\"></mspace><mi>y</mi><mspace width=\"thickmathspace\"></mspace><mtext>such that</mtext><mspace width=\"thickmathspace\"></mspace><msup><mi>y</mi><mn>3</mn></msup><mo>=</mo><mi>x</mi></mrow><annotation encoding=\"TeX\">\\mathtt{Math.cbrt(x)} = \\sqrt[3]{x} = \\text{the unique} \\; y \\; \\text{such that} \\; y^3 = x</annotation></semantics></math></p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/math-cbrt.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\">Math.cbrt(<var>x</var>)</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><var>x</var></dt> <dd>A number.</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p>The cube root of the given number.</p> <h2 id=\"Description\">Description</h2> <p>Because <code>cbrt()</code> is a static method of <code>Math</code>, you always use it as <code>Math.cbrt()</code>, rather than as a method of a <code>Math</code> object you created (<code>Math</code> is not a constructor).</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Using_Math.cbrt()\">Using <code>Math.cbrt()</code>\n</h3> <pre data-language=\"js\">Math.cbrt(NaN); // NaN\nMath.cbrt(-1); // -1\nMath.cbrt(-0); // -0\nMath.cbrt(-Infinity); // -Infinity\nMath.cbrt(0); // 0\nMath.cbrt(1); // 1\nMath.cbrt(Infinity); // Infinity\nMath.cbrt(null); // 0\nMath.cbrt(2);  // 1.2599210498948732\n</pre> <h2 id=\"Polyfill\">Polyfill</h2> <p>For all <math><semantics><mrow><mi>x</mi><mo>≥</mo><mn>0</mn></mrow><annotation encoding=\"TeX\">x \\geq 0</annotation></semantics></math>, have <math><semantics><mrow><mroot><mi>x</mi><mn>3</mn></mroot><mo>=</mo><msup><mi>x</mi><mrow><mn>1</mn><mo>/</mo><mn>3</mn></mrow></msup></mrow><annotation encoding=\"TeX\">\\sqrt[3]{x} = x^{1/3}</annotation></semantics></math> so this can be emulated by the following function:</p> <pre data-language=\"js\">if (!Math.cbrt) {\n  Math.cbrt = (function(pow) {\n    return function cbrt(){\n      // ensure negative numbers remain negative:\n      return x &lt; 0 ? -pow(-x, 1/3) : pow(x, 1/3);\n    };\n  })(Math.pow); // localize Math.pow to increase efficiency\n}\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <thead> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> </thead> <tbody> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-math.cbrt\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Math.cbrt' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-math.cbrt\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Math.cbrt' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 38</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 25</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 25</td>\n<td class=\"bc-supports-yes\"> 8</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 25</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 8</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 0.12</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"pow\"><code>Math.pow()</code></a></li> <li><a href=\"sqrt\"><code>Math.sqrt()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/cbrt$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/cbrt\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/cbrt</a>\n  </p>\n</div>\n","global_objects/math/ceil":"<h1>Math.ceil</h1> <p>The <code>Math.ceil()</code> function returns the smallest integer greater than or equal to a given number.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/math-ceil.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\">Math.ceil(<var>x</var>)</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><code>x</code></dt> <dd>A number.</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p>The smallest integer greater than or equal to the given number.</p> <h2 id=\"Description\">Description</h2> <p>Because <code>ceil()</code> is a static method of <code>Math</code>, you always use it as <code>Math.ceil()</code>, rather than as a method of a <code>Math</code> object you created (<code>Math</code> is not a constructor).</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Using_Math.ceil()\">Using <code>Math.ceil()</code>\n</h3> <p>The following example shows example usage of <code>Math.ceil()</code>.</p> <pre data-language=\"js\">Math.ceil(.95);    // 1\nMath.ceil(4);      // 4\nMath.ceil(7.004);  // 8\nMath.ceil(-0.95);  // -0\nMath.ceil(-4);     // -4\nMath.ceil(-7.004); // -7\n</pre> <h3 id=\"Decimal_adjustment\">Decimal adjustment</h3> <pre data-language=\"js\">// Closure\n(function() {\n  /**\n   * Decimal adjustment of a number.\n   *\n   * @param {String}  type  The type of adjustment.\n   * @param {Number}  value The number.\n   * @param {Integer} exp   The exponent (the 10 logarithm of the adjustment base).\n   * @returns {Number} The adjusted value.\n   */\n  function decimalAdjust(type, value, exp) {\n    // If the exp is undefined or zero...\n    if (typeof exp === 'undefined' || +exp === 0) {\n      return Math[type](value);\n    }\n    value = +value;\n    exp = +exp;\n    // If the value is not a number or the exp is not an integer...\n    if (isNaN(value) || !(typeof exp === 'number' &amp;&amp; exp % 1 === 0)) {\n      return NaN;\n    }\n    // Shift\n    value = value.toString().split('e');\n    value = Math[type](+(value[0] + 'e' + (value[1] ? (+value[1] - exp) : -exp)));\n    // Shift back\n    value = value.toString().split('e');\n    return +(value[0] + 'e' + (value[1] ? (+value[1] + exp) : exp));\n  }\n\n  // Decimal round\n  if (!Math.round10) {\n    Math.round10 = function(value, exp) {\n      return decimalAdjust('round', value, exp);\n    };\n  }\n  // Decimal floor\n  if (!Math.floor10) {\n    Math.floor10 = function(value, exp) {\n      return decimalAdjust('floor', value, exp);\n    };\n  }\n  // Decimal ceil\n  if (!Math.ceil10) {\n    Math.ceil10 = function(value, exp) {\n      return decimalAdjust('ceil', value, exp);\n    };\n  }\n})();\n\n// Round\nMath.round10(55.55, -1);   // 55.6\nMath.round10(55.549, -1);  // 55.5\nMath.round10(55, 1);       // 60\nMath.round10(54.9, 1);     // 50\nMath.round10(-55.55, -1);  // -55.5\nMath.round10(-55.551, -1); // -55.6\nMath.round10(-55, 1);      // -50\nMath.round10(-55.1, 1);    // -60\n// Floor\nMath.floor10(55.59, -1);   // 55.5\nMath.floor10(59, 1);       // 50\nMath.floor10(-55.51, -1);  // -55.6\nMath.floor10(-51, 1);      // -60\n// Ceil\nMath.ceil10(55.51, -1);    // 55.6\nMath.ceil10(51, 1);        // 60\nMath.ceil10(-55.59, -1);   // -55.5\nMath.ceil10(-59, 1);       // -50\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/publications/files/ECMA-ST-ARCH/ECMA-262,%201st%20edition,%20June%201997.pdf\" hreflang=\"en\">ECMAScript 1st Edition (ECMA-262)</a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition. Implemented in JavaScript 1.0.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/5.1/#sec-15.8.2.6\" hreflang=\"en\">ECMAScript 5.1 (ECMA-262)<br><small>The definition of 'Math.ceil' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-math.ceil\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Math.ceil' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-math.ceil\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Math.ceil' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"abs\"><code>Math.abs()</code></a></li> <li><a href=\"floor\"><code>Math.floor()</code></a></li> <li><a href=\"round\"><code>Math.round()</code></a></li> <li><a href=\"sign\"><code>Math.sign()</code></a></li> <li><a href=\"trunc\"><code>Math.trunc()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/ceil$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/ceil\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/ceil</a>\n  </p>\n</div>\n","global_objects/math/atan2":"<h1>Math.atan2</h1> <p>The <code>Math.atan2()</code> function returns the angle in the plane (in radians) between the positive x-axis and the ray from (0,0) to the point (x,y), for <code>Math.atan2(y,x)</code>.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/math-atan2.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\">Math.atan2(<var>y</var>, <var>x</var>)</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><code>y</code></dt> <dd>The y coordinate of the point.</dd> <dt><code>x</code></dt> <dd>The x coordinate of the point</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p>The angle in radians (in <math><semantics><mrow><mo stretchy=\"false\">[</mo><mo>-</mo><mi>π</mi><mo>,</mo><mi>π</mi><mo stretchy=\"false\">]</mo></mrow><annotation encoding=\"TeX\">[-\\pi, \\pi]</annotation></semantics></math>) between the positive x-axis and the ray from (0,0) to the point <math><semantics><annotation encoding=\"TeX\">(x,y).</annotation></semantics></math></p> <h2 id=\"Description\">Description</h2> <p>The <code>Math.atan2()</code> method returns a numeric value between -π and π representing the angle theta of an <code>(x, y)</code> point. This is the counterclockwise angle, measured in radians, between the positive X axis, and the point <code>(x, y)</code>. Note that the arguments to this function pass the y-coordinate first and the x-coordinate second.</p> <p><img src=\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAASwAAAEsCAMAAABOo35HAAAAGXRFWHRTb2Z0d2FyZQB3d3cuaW5rc2NhcGUub3Jnm+48GgAAAAlwSFlzAAAITgAACE4BjDEA7AAAAQtQTFRFR3BM/wAA/wAA/wAA/wAA/wAA/wAAAAAA/wAAhgCaAAD//wAAAAD//wAAAAD/AAD//wAA/wAA/wAA/wAA/wAA/wAA/wAAAAD/AAD//wAA/wAA/wAA/wAAAAD//wAAAAD/AAD/AAD/AAD//wAAAAD//wAA/wAAAAD/AAD/AAD//wAA/wAAAAD//wAA/wAA/wAA/wAA/wAA/wAA/wAA/wAAAAD/AAD/AAD/AAD/AAD//wAA/wAAAAD//wAAAAD/AAD/9QAOAAD//wAAAAD/AAD//wAA/wAAAAD//wAACAAAAAD/AABU4wAcsgBNPQDCdgAAKgAAVwAAAAAA/wAAAAD/fwAAAAB/FADrPwAAMV/VEAAAAFJ0Uk5TAOwO+QUCFYD9Ac0Jvn/3ZTr05c4fG2D83MG8LTQF4CQq5rOoDIdvUxzwJ3aMkK/IWUC1U0x7PqsVSdhpW0dtc0WEmJMzoiOjnMaZv/382+6ZwgWbH64AAAebSURBVHja7d0Jc9o4GAZgGQO1IYC5rwLhykVzNCV3c7VJmrZ75tN29///kpUJEEM5BHhnstL7zrSkLsNknrGkz7YkGHuFefP09IYhwAIWsIAFLGAhwAIWsIAFLGAhwAIWsIAFLGAhwAIWsIAFLGAhwAKWHlgH6UdbvAT39nf6R5x0rPda7r9qixVwbsqhkSOhEm2Il93e370EU8mA+/pIjs5YD02LiFKdoPdgOGU6rEvNlyMxunBdk2mdm+Fl0rUS2Q97DztmtWykox4+81y0zA7lNMbaMftWZBVHmuIGmUbGe6ApGmDo3AhqjFUaWIkcjHRbVdodeacjGuUltTUeDTMvVOLU8v5PjAxztC9Pm+FDK6sx1oEHi0xPO7y0mjvJ1Eg3dkGPVlPnOuvCi0Uv/XnGOA+wHBXdHipL9NY9FjXo/1I3/DdYH7xWSXtwOJo2XZ/7XhclzJ6P7lKa6YyV9fTv1uGLYbNXIQTumxmX7MNggMxpjcX2PFrdyW9JpZ7LBVE3RPXGyrxg7U1+R5k6gybbZnpjxQZtkA6nnDYbyf6YWLQyemPdiBNrX4xylM7ZU94S7pdWgfaF5rdo9ohKIZbZCTDV8h9gBdvVMFMyvmMF+n+AJXGtk3KYsvEZq5wk8xJYcm2wKsbAKLBkYouBMLmDZiiV96K4+sCAJZeu0WbAkol7my8TBJZULVqMhZja8Q9rl6gJLMlqVHTuG8CSyk6SaM8GllSKROcBBiypZPeTZQYs2cHwLQOWVOVeCjMd4gdWNkXVMrAkq1GiVBZYstWo9R7NUCo3ohrtMGDJXT/HLOWrUR87+G6AAUuqw3KYPlkRa4PMDWDJxTFpbJYosKYlnCLaDwJLKiUiI8uAJXdNaFiXDFiSyeQYsGSy07GZZlkaK5qmwwCw5HJPlCwDSyruyoAcmqFU3opq9BMDllw5WlJ5apHfzTDYzjBgySQXZlpmGayulboBllweDKJfPwJLshqlX/7mn21gzc8jkfkb57zRAta82G1RjbYaQityCqz5/fuuILsVWoUtYM0sRp3BT4m80KoBa3pCh1Zs0LFvxjmvrwNramJE1mBqkX28LbRqwJoSd9mlZ/cmV0urfmsRrIzRW3bp0RItsXAKrElxDBpbdnkmtCJT6q2t20i9sPaxomszzBbH50JuijHxZGIt77ZRN2stHbHKE9dPJITHu0nnVZzXE3fH7/K8oSFWOXk48cbMO6GV+PnwCd/udf1XnJ9ph+UuuzycePlzwnn8bvzoaZ4f9X6oFPiJblgzll22ImJIHO+YNjlfH5x527ZmWLEZyy5roitv2OONc0Ak2Gp6YYWKNGPTGOHBr8a7rEj/p3WFOi3JMyvYLs2YWiQ6+fjoVeLacBA8ndj/q4sVdIfBWdOwKqLbioxUnxFeX+vnp7NObaxPcze2WBeV/NEolifXGmEdEJnzZjUcjTXECI8knnOl1ZlVTkqs57VFa1uzte+zAucyyy7tdXGRuKn9aHhgyW0CIkbEestbZw1uTAzLUx2aYdeQ2QTEbtU5vx3+8+OwFL3l8YomWAvshiV84luea8PrQVevzm2HmVh2OCW/sYUtyoVvw381eP20T7ipB5a77FJ+ypronfLDy8BanBfOtmpH8ZFBUmWsBZddivLhy8sFY/y5IlXpicYsrEU3Abnznlps/Us9H49cqzQjYgZWsCqq0UXakN3g/PPINSOzlZprM+vMyu4vuAnIsRgQVX4yNhXLFsNgcNFVTJGx62ldsDrLbGwhCoV6RTss2zGp+rDwp1XqKpVVsljLLru85So9J5TDcqvRpZZd1vI8v6UZ1sXSm4CsqdzFT8YKxawlNwERXXxBu9HQWbKarGwrdP9KAitaulnhA08UbocTsJpkrbCxxSYf3lHWAGtjtWWXrbhCz+vnYTmrLrtsKPQ4Zw5WtLrqJiBXXKFJRnPOrPeGsdqyy3Wu0CSjeX1WxlntE21xfXinA1Y35sM58UWh2Q0zsB4MHza2sBPeW/HKYrnLLn34fqE7Za94vFj3RKYPm/5WRKXVUh0r59cmIBHOj1XHCpd82gTkm6o9vLcZBjv+bAJyPfZETDmsUNu/jS3OOF9TGqtN/n0jWk3V4bCP1R1ddrnicJjn+Za6WD8tu1wtBUXv0vSwfKpGla8delh2xzL9/AqKhqKPWgd9lq9b0n1T9P6fwPrD968JuFX0oYXA+t3y+xvRricvBVYB6y/fN0i+UrSE72H5/W2XCe+85WV/sVeYr09P//zp94d+//Hj+4ofwZ4Q6QBrEaxX2gy/vsbf69Xfz0KABSxgAQtYwEKABSxgAQtYwEKABSxgAQtYwEKABSxgAQtYwEKABSxgAQtYwEKABSxgAQtYwEKABSxgAQtYwEKABSxgAQtYwEKABSxgAQtYwEKABSxgAQtYwEKABSxgAQtYwEKABSxgAQtYwEKABSxgAQtYwEKABSxgAQtYwEKABSxgAQtYwEKABSxgAQtYwEKABSxgAQtYwEKABSxgAQtYwEKABSxgAQtYwEKABSxgAQtYwEKABSxgAQtYwEKABSxgAQtYwEKABSxgAQtYwEKABSxgAQtYwEKABSxgefIvskGVuW9c1cMAAAAASUVORK5CYII=\" alt=\"A simple diagram showing the angle returned by atan2(y, x)\" style=\"height: 300px; width: 300px;\"></p> <p><code>Math.atan2()</code> is passed separate <code>x</code> and <code>y</code> arguments, and <code>Math.atan()</code> is passed the ratio of those two arguments.</p> <p>Because <code>atan2()</code> is a static method of <code>Math</code>, you always use it as <code>Math.atan2()</code>, rather than as a method of a <code>Math</code> object you created (<code>Math</code> is not a constructor).</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Using_Math.atan2()\">Using <code>Math.atan2()</code>\n</h3> <pre data-language=\"js\">Math.atan2(90, 15); // 1.4056476493802699\nMath.atan2(15, 90); // 0.16514867741462683\n\nMath.atan2(±0, -0);               // ±PI.\nMath.atan2(±0, +0);               // ±0.\nMath.atan2(±0, -x);               // ±PI for x &gt; 0.\nMath.atan2(±0, x);                // ±0 for x &gt; 0.\nMath.atan2(-y, ±0);               // -PI/2 for y &gt; 0.\nMath.atan2(y, ±0);                // PI/2 for y &gt; 0.\nMath.atan2(±y, -Infinity);        // ±PI for finite y &gt; 0.\nMath.atan2(±y, +Infinity);        // ±0 for finite y &gt; 0.\nMath.atan2(±Infinity, x);         // ±PI/2 for finite x.\nMath.atan2(±Infinity, -Infinity); // ±3*PI/4.\nMath.atan2(±Infinity, +Infinity); // ±PI/4.\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/publications/files/ECMA-ST-ARCH/ECMA-262,%201st%20edition,%20June%201997.pdf\" hreflang=\"en\">ECMAScript 1st Edition (ECMA-262)</a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition. Implemented in JavaScript 1.0.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/5.1/#sec-15.8.2.5\" hreflang=\"en\">ECMAScript 5.1 (ECMA-262)<br><small>The definition of 'Math.atan2' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-math.atan2\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Math.atan2' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-math.atan2\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Math.atan2' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"acos\"><code>Math.acos()</code></a></li> <li><a href=\"asin\"><code>Math.asin()</code></a></li> <li><a href=\"atan\"><code>Math.atan()</code></a></li> <li><a href=\"cos\"><code>Math.cos()</code></a></li> <li><a href=\"sin\"><code>Math.sin()</code></a></li> <li><a href=\"tan\"><code>Math.tan()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/atan2$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/atan2\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/atan2</a>\n  </p>\n</div>\n","global_objects/math/atanh":"<h1>Math.atanh</h1> <p>The <code>Math.atanh()</code> function returns the hyperbolic arctangent of a number, that is</p> <p><math display=\"block\"><semantics><mrow><mo>∀</mo><mi>x</mi><mo>∊</mo><mrow><mo>(</mo><mrow><mo>-</mo><mn>1</mn><mo>,</mo><mn>1</mn></mrow><mo>)</mo></mrow><mo>,</mo><mstyle mathvariant=\"monospace\"><mrow><mo rspace=\"thinmathspace\" lspace=\"0em\">Math.atanh</mo><mo stretchy=\"false\">(</mo><mi>x</mi><mo stretchy=\"false\">)</mo></mrow></mstyle><mo>=</mo><mo rspace=\"thinmathspace\" lspace=\"0em\">arctanh</mo><mo stretchy=\"false\">(</mo><mi>x</mi><mo stretchy=\"false\">)</mo><mo>=</mo><mtext> the unique </mtext><mspace width=\"thickmathspace\"></mspace><mi>y</mi><mspace width=\"thickmathspace\"></mspace><mtext>such that</mtext><mspace width=\"thickmathspace\"></mspace><mo rspace=\"0em\" lspace=\"0em\">tanh</mo><mo stretchy=\"false\">(</mo><mi>y</mi><mo stretchy=\"false\">)</mo><mo>=</mo><mi>x</mi></mrow><annotation encoding=\"TeX\">\\forall x \\in \\left( -1, 1 \\right), \\mathtt{\\operatorname{Math.atanh}(x)} = \\operatorname{arctanh}(x) = \\text{ the unique } \\; y \\; \\text{such that} \\; \\tanh(y) = x</annotation></semantics></math></p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/math-atanh.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\">Math.atanh(<var>x</var>)</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><var>x</var></dt> <dd>A number.</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p>The hyperbolic arctangent of the given number.</p> <h2 id=\"Description\">Description</h2> <p>Because <code>atanh()</code> is a static method of <code>Math</code>, you always use it as <code>Math.atanh()</code>, rather than as a method of a <code>Math</code> object you created (<code>Math</code> is not a constructor).</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Using_Math.atanh()\">Using <code>Math.atanh()</code>\n</h3> <pre data-language=\"js\">Math.atanh(-2);  // NaN\nMath.atanh(-1);  // -Infinity\nMath.atanh(0);   // 0\nMath.atanh(0.5); // 0.5493061443340548\nMath.atanh(1);   // Infinity\nMath.atanh(2);   // NaN\n</pre> <p>For values greater than 1 or less than -1, <a href=\"../nan\"><code>NaN</code></a> is returned.</p> <h2 id=\"Polyfill\">Polyfill</h2> <p>For <math><semantics><mrow><mrow><mo>|</mo><mi>x</mi><mo>|</mo></mrow><mo>&lt;</mo><mn>1</mn></mrow><annotation encoding=\"TeX\">\\left|x\\right| &lt; 1</annotation></semantics></math>, we have <math><semantics><mrow><mo rspace=\"thinmathspace\" lspace=\"0em\">artanh</mo><mo stretchy=\"false\">(</mo><mi>x</mi><mo stretchy=\"false\">)</mo><mo>=</mo><mfrac><mn>1</mn><mn>2</mn></mfrac><mo rspace=\"0em\" lspace=\"0em\">ln</mo><mrow><mo>(</mo><mfrac><mrow><mn>1</mn><mo>+</mo><mi>x</mi></mrow><mrow><mn>1</mn><mo>-</mo><mi>x</mi></mrow></mfrac><mo>)</mo></mrow></mrow><annotation encoding=\"TeX\">\\operatorname {artanh} (x) = \\frac{1}{2}\\ln \\left( \\frac{1 + x}{1 - x} \\right)</annotation></semantics></math> so this can be emulated by the following function:</p> <pre data-language=\"js\">Math.atanh = Math.atanh || function(x) {\n  return Math.log((1+x)/(1-x)) / 2;\n};\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <thead> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> </thead> <tbody> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-math.atanh\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Math.atanh' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-math.atanh\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Math.atanh' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 38</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 25</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 25</td>\n<td class=\"bc-supports-yes\"> 8</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 25</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 8</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 0.12</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"acosh\"><code>Math.acosh()</code></a></li> <li><a href=\"asinh\"><code>Math.asinh()</code></a></li> <li><a href=\"cosh\"><code>Math.cosh()</code></a></li> <li><a href=\"sinh\"><code>Math.sinh()</code></a></li> <li><a href=\"tanh\"><code>Math.tanh()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/atanh$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/atanh\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/atanh</a>\n  </p>\n</div>\n","global_objects/math/asin":"<h1>Math.asin</h1> <p>The <code>Math.asin()</code> function returns the arcsine (in radians) of a number, that is</p> <p><math display=\"block\"><semantics><mrow><mo>∀</mo><mi>x</mi><mo>∊</mo><mo stretchy=\"false\">[</mo><mrow><mo>-</mo><mn>1</mn></mrow><mo>;</mo><mn>1</mn><mo stretchy=\"false\">]</mo><mo>,</mo><mspace width=\"thickmathspace\"></mspace><mstyle mathvariant=\"monospace\"><mrow><mo rspace=\"thinmathspace\" lspace=\"0em\">Math.asin</mo><mo stretchy=\"false\">(</mo><mi>x</mi><mo stretchy=\"false\">)</mo></mrow></mstyle><mo>=</mo><mo rspace=\"0em\" lspace=\"0em\">arcsin</mo><mo stretchy=\"false\">(</mo><mi>x</mi><mo stretchy=\"false\">)</mo><mo>=</mo><mtext> the unique </mtext><mspace width=\"thickmathspace\"></mspace><mi>y</mi><mo>∊</mo><mrow><mo>[</mo><mrow><mo>-</mo><mfrac><mi>π</mi><mn>2</mn></mfrac><mo>;</mo><mfrac><mi>π</mi><mn>2</mn></mfrac></mrow><mo>]</mo></mrow><mspace width=\"thinmathspace\"></mspace><mtext>such that</mtext><mspace width=\"thickmathspace\"></mspace><mo rspace=\"0em\" lspace=\"0em\">sin</mo><mo stretchy=\"false\">(</mo><mi>y</mi><mo stretchy=\"false\">)</mo><mo>=</mo><mi>x</mi></mrow><annotation encoding=\"TeX\">\\forall x \\in [{-1};1],\\;\\mathtt{\\operatorname{Math.asin}(x)} = \\arcsin(x) = \\text{ the unique } \\; y \\in \\left[-\\frac{\\pi}{2}; \\frac{\\pi}{2}\\right] \\, \\text{such that} \\; \\sin(y) = x</annotation></semantics></math></p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/math-asin.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\">Math.asin(<var>x</var>)</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><code>x</code></dt> <dd>A number.</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p>The arcsine (in radians) of the given number if it's between <strong>-1</strong> and <strong>1</strong>; otherwise, <a href=\"../nan\"><code>NaN</code></a>.</p> <h2 id=\"Description\">Description</h2> <p>The <code>Math.asin()</code> method returns a numeric value between <math><semantics><mrow><mo>-</mo><mfrac><mi>π</mi><mn>2</mn></mfrac></mrow><annotation encoding=\"TeX\">-\\frac{\\pi}{2}</annotation></semantics></math> and <math><semantics><mfrac><mi>π</mi><mn>2</mn></mfrac><annotation encoding=\"TeX\">\\frac{\\pi}{2}</annotation></semantics></math> radians for <code>x</code> between -1 and 1. If the value of <code>x</code> is outside this range, it returns <a href=\"../nan\"><code>NaN</code></a>.</p> <p>Because <code>asin()</code> is a static method of <code>Math</code>, you always use it as <code>Math.asin()</code>, rather than as a method of a <code>Math</code> object you created (<code>Math</code> is not a constructor).</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Using_Math.asin()\">Using <code>Math.asin()</code>\n</h3> <pre data-language=\"js\">Math.asin(-2);  // NaN\nMath.asin(-1);  // -1.5707963267948966 (-pi/2)\nMath.asin(0);   // 0\nMath.asin(0.5); // 0.5235987755982989\nMath.asin(1);   // 1.5707963267948966 (pi/2)\nMath.asin(2);   // NaN\n</pre> <p>For values less than -1 or greater than 1, <code>Math.asin()</code> returns <a href=\"../nan\"><code>NaN</code></a>.</p> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/publications/files/ECMA-ST-ARCH/ECMA-262,%201st%20edition,%20June%201997.pdf\" hreflang=\"en\">ECMAScript 1st Edition (ECMA-262)</a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition. Implemented in JavaScript 1.0.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/5.1/#sec-15.8.2.3\" hreflang=\"en\">ECMAScript 5.1 (ECMA-262)<br><small>The definition of 'Math.asin' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-math.asin\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Math.asin' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-math.asin\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Math.asin' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"acos\"><code>Math.acos()</code></a></li> <li><a href=\"atan\"><code>Math.atan()</code></a></li> <li><a href=\"atan2\"><code>Math.atan2()</code></a></li> <li><a href=\"cos\"><code>Math.cos()</code></a></li> <li><a href=\"sin\"><code>Math.sin()</code></a></li> <li><a href=\"tan\"><code>Math.tan()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/asin$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/asin\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/asin</a>\n  </p>\n</div>\n","global_objects/math/imul":"<h1>Math.imul</h1> <p>The <code>Math.imul()</code> function returns the result of the C-like 32-bit multiplication of the two parameters.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/math-imul.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\">var <em>product</em> = Math.imul(<em>a</em>, <em>b</em>);</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><code>a</code></dt> <dd>First number.</dd> <dt><code>b</code></dt> <dd>Second number.</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p>The result of the C-like 32-bit multiplication of the given arguments.</p> <h2 id=\"Description\">Description</h2> <p><code>Math.imul()</code> allows for 32-bit integer multiplication with C-like semantics. This feature is useful for projects like <a href=\"http://en.wikipedia.org/wiki/Emscripten\">Emscripten</a>. Because <code>imul()</code> is a static method of <code>Math</code>, you always use it as <code>Math.imul()</code>, rather than as a method of a <code>Math</code> object you created (<code>Math</code> is not a constructor). If you use normal JavaScript floating point numbers in imul, you will experience a degrade in performance. This is because of the costly conversion from a floating point to an integer for multiplication, and then converting the multiplied integer back into a floating point. The reason imul exists is because it is faster in only one (so far) circumstance: AsmJS. AsmJS allows for JIST-optimizers to more easily implement internal integers in JavaScript. Multiplying two numbers stored internally as integers (which is only possible with AsmJS) with imul is the only potential circumstance where Math.imul may prove performant in current browsers.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Using_Math.imul()\">Using <code>Math.imul()</code>\n</h3> <pre data-language=\"js\">Math.imul(2, 4);          // 8\nMath.imul(-1, 8);         // -8\nMath.imul(-2, -2);        // 4\nMath.imul(0xffffffff, 5); // -5\nMath.imul(0xfffffffe, 5); // -10\n</pre> <h2 id=\"Polyfill\">Polyfill</h2> <p>This can be emulated with the following function:</p> <pre data-language=\"js\">if (!Math.imul) Math.imul = function(a, b) {\n  var aHi = (a &gt;&gt;&gt; 16) &amp; 0xffff;\n  var aLo = a &amp; 0xffff;\n  var bHi = (b &gt;&gt;&gt; 16) &amp; 0xffff;\n  var bLo = b &amp; 0xffff;\n  // the shift by 0 fixes the sign on the high part\n  // the final |0 converts the unsigned value into a signed value\n  return ((aLo * bLo) + (((aHi * bLo + aLo * bHi) &lt;&lt; 16) &gt;&gt;&gt; 0) | 0);\n};</pre> <p>However, the following function is more performant because it is likely that browsers in which this polyfill would be used do not optimize with an internal integer type in javascript, instead using floating points for all numbers.</p> <pre data-language=\"js\">if (!Math.imul) Math.imul = function(opA, opB) {\n  opB |= 0; // ensure that opB is an integer. opA will automatically be coerced.\n  // floating points give us 53 bits of precision to work with plus 1 sign bit\n  // automatically handled for our convienence:\n  // 1. 0x003fffff /*opA &amp; 0x000fffff*/ * 0x7fffffff /*opB*/ = 0x1fffff7fc00001\n  //    0x1fffff7fc00001 &lt; Number.MAX_SAFE_INTEGER /*0x1fffffffffffff*/\n  var result = (opA &amp; 0x001fffff) * opB;\n  // 2. We can remove an integer coersion from the statement above because:\n  //    0x1fffff7fc00001 + 0xffc00000 = 0x1fffffff800001\n  //    0x1fffffff800001 &lt; Number.MAX_SAFE_INTEGER /*0x1fffffffffffff*/\n  if (opA &amp; 0xffc00000 /*!== 0*/) result += (opA &amp; 0xffc00000) * opB |0;\n  return result |0;\n};</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-math.imul\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Math.imul' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-math.imul\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Math.imul' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 28</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 20</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 16</td>\n<td class=\"bc-supports-yes\"> 7</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 20</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 7</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 0.12</td>\n</tr></tbody>\n</table>\n</div><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/imul$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/imul\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/imul</a>\n  </p>\n</div>\n","global_objects/math/log1p":"<h1>Math.log1p</h1> <p>The <code>Math.log1p()</code> function returns the natural logarithm (base <a href=\"e\"><code>e</code></a>) of 1 + a number, that is</p> <p><math display=\"block\"><semantics><mrow><mo>∀</mo><mi>x</mi><mo>&gt;</mo><mo>-</mo><mn>1</mn><mo>,</mo><mstyle mathvariant=\"monospace\"><mrow><mo rspace=\"thinmathspace\" lspace=\"0em\">Math.log1p</mo><mo stretchy=\"false\">(</mo><mi>x</mi><mo stretchy=\"false\">)</mo></mrow></mstyle><mo>=</mo><mo rspace=\"0em\" lspace=\"0em\">ln</mo><mo stretchy=\"false\">(</mo><mn>1</mn><mo>+</mo><mi>x</mi><mo stretchy=\"false\">)</mo></mrow><annotation encoding=\"TeX\">\\forall x &gt; -1, \\mathtt{\\operatorname{Math.log1p}(x)} = \\ln(1 + x)</annotation></semantics></math></p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/math-log1p.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\">Math.log1p(<var>x</var>)</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><code>x</code></dt> <dd>A number.</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p>The natural logarithm (base <a href=\"e\"><code>e</code></a>) of <strong>1</strong> plus the given number. If the number is less than <strong>-1</strong>, <a href=\"../nan\"><code>NaN</code></a> is returned.</p> <h2 id=\"Description\">Description</h2> <p>For very small values of <em>x</em>, adding 1 can reduce or eliminate precision. The double floats used in JS give you about 15 digits of precision. 1 + 1e-15 = 1.000000000000001, but 1 + 1e-16 = 1.000000000000000 and therefore exactly 1.0 in that arithmetic, because digits past 15 are rounded off. </p> <p>When you calculate log(1 + x), you should get an answer very close to x, if x is small (that's why these are called 'natural' logarithms). If you calculate Math.log(1 + 1.1111111111e-15) you should get an answer close to 1.1111111111e-15. Instead, <span style=\"line-height: 1.5;\">you will end up taking the logarithm of </span><span style=\"line-height: 1.5;\">1.00000000000000111022 (the roundoff is in binary so sometimes it gets ugly)</span><span style=\"line-height: 1.5;\">, so you get </span><span style=\"line-height: 1.5;\">the answer 1.11022...e-15, with only 3 correct digits. If, instead, you calculate Math.log1p(</span>1.1111111111e-15<span style=\"line-height: 1.5;\">) you will get a much more accurate answer 1.1111111110999995e-15 with 15 correct digits of precision (actually 16 in this case).</span></p> <p>If the value of <code>x</code> is less than -1, the return value is always <a href=\"../nan\"><code>NaN</code></a>.</p> <p>Because <code>log1p()</code> is a static method of <code>Math</code>, you always use it as <code>Math.log1p()</code>, rather than as a method of a <code>Math</code> object you created (<code>Math</code> is not a constructor).</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Using_Math.log1p()\">Using <code>Math.log1p()</code>\n</h3> <pre data-language=\"js\">Math.log1p(1);  // 0.6931471805599453\nMath.log1p(0);  // 0\nMath.log1p(-1); // -Infinity\nMath.log1p(-2); // NaN\n</pre> <h2 id=\"Polyfill\">Polyfill</h2> <p>This can be emulated with the following function:</p> <pre data-language=\"js\">Math.log1p = Math.log1p || function(x) {\n  return Math.log(1 + x);\n};\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-math.log1p\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Math.log1p' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-math.log1p\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Math.log1p' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 38</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 25</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 25</td>\n<td class=\"bc-supports-yes\"> 8</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 25</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 8</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 0.12</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"exp\"><code>Math.exp()</code></a></li> <li><a href=\"log\"><code>Math.log()</code></a></li> <li><a href=\"expm1\"><code>Math.expm1()</code></a></li> <li><a href=\"log10\"><code>Math.log10()</code></a></li> <li><a href=\"log2\"><code>Math.log2()</code></a></li> <li><a href=\"pow\"><code>Math.pow()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/log1p$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/log1p\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/log1p</a>\n  </p>\n</div>\n","global_objects/math/atan":"<h1>Math.atan</h1> <p>The <code>Math.atan()</code> function returns the arctangent (in radians) of a number, that is</p> <p><math display=\"block\"><semantics><mrow><mstyle mathvariant=\"monospace\"><mrow><mo rspace=\"thinmathspace\" lspace=\"0em\">Math.atan</mo><mo stretchy=\"false\">(</mo><mi>x</mi><mo stretchy=\"false\">)</mo></mrow></mstyle><mo>=</mo><mo rspace=\"0em\" lspace=\"0em\">arctan</mo><mo stretchy=\"false\">(</mo><mi>x</mi><mo stretchy=\"false\">)</mo><mo>=</mo><mtext> the unique </mtext><mspace width=\"thickmathspace\"></mspace><mi>y</mi><mo>∊</mo><mrow><mo>[</mo><mrow><mo>-</mo><mfrac><mi>π</mi><mn>2</mn></mfrac><mo>;</mo><mfrac><mi>π</mi><mn>2</mn></mfrac></mrow><mo>]</mo></mrow><mspace width=\"thinmathspace\"></mspace><mtext>such that</mtext><mspace width=\"thickmathspace\"></mspace><mo rspace=\"0em\" lspace=\"0em\">tan</mo><mo stretchy=\"false\">(</mo><mi>y</mi><mo stretchy=\"false\">)</mo><mo>=</mo><mi>x</mi></mrow><annotation encoding=\"TeX\">\\mathtt{\\operatorname{Math.atan}(x)} = \\arctan(x) = \\text{ the unique } \\; y \\in \\left[-\\frac{\\pi}{2}; \\frac{\\pi}{2}\\right] \\, \\text{such that} \\; \\tan(y) = x</annotation></semantics></math></p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/math-atan.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\">Math.atan(<var>x</var>)</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><code>x</code></dt> <dd>A number.</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p>The arctangent (in radians) of the given number.</p> <h2 id=\"Description\">Description</h2> <p>The <code>Math.atan()</code> method returns a numeric value between <math><semantics><mrow><mo>-</mo><mfrac><mi>π</mi><mn>2</mn></mfrac></mrow><annotation encoding=\"TeX\">-\\frac{\\pi}{2}</annotation></semantics></math> and <math><semantics><mfrac><mi>π</mi><mn>2</mn></mfrac><annotation encoding=\"TeX\">\\frac{\\pi}{2}</annotation></semantics></math> radians.</p> <p>Because <code>atan()</code> is a static method of <code>Math</code>, you always use it as <code>Math.atan()</code>, rather than as a method of a <code>Math</code> object you created (<code>Math</code> is not a constructor).</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Using_Math.atan()\">Using <code>Math.atan()</code>\n</h3> <pre data-language=\"js\">Math.atan(1);   // 0.7853981633974483\nMath.atan(0);   // 0\nMath.atan(-0);  // -0\n\nMath.atan(Infinity); <span class=\"objectBox objectBox-number\">  //  1.5707963267948966\nMath.atan(-Infinity);  // -1.5707963267948966\n\n</span>// The angle that the line [(0,0);(x,y)] forms with the x-axis in a Cartesian coordinate system\nMath.atan(y / x);\n</pre> <p>Note that you may want to avoid using <strong>±</strong><code>Infinity</code> for stylistic reasons. In this case, <a href=\"atan2\"><code>Math.atan2()</code></a> with <code>0</code> as the second argument may be a better solution.</p> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/publications/files/ECMA-ST-ARCH/ECMA-262,%201st%20edition,%20June%201997.pdf\" hreflang=\"en\">ECMAScript 1st Edition (ECMA-262)</a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition. Implemented in JavaScript 1.0.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/5.1/#sec-15.8.2.4\" hreflang=\"en\">ECMAScript 5.1 (ECMA-262)<br><small>The definition of 'Math.atan' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-math.atan\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Math.atan' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-math.atan\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Math.atan' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"acos\"><code>Math.acos()</code></a></li> <li><a href=\"asin\"><code>Math.asin()</code></a></li> <li><a href=\"atan2\"><code>Math.atan2()</code></a></li> <li><a href=\"cos\"><code>Math.cos()</code></a></li> <li><a href=\"sin\"><code>Math.sin()</code></a></li> <li><a href=\"tan\"><code>Math.tan()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/atan$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/atan\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/atan</a>\n  </p>\n</div>\n","global_objects/math/exp":"<h1>Math.exp</h1> <p>The <code>Math.exp()</code> function returns <code>e<sup>x</sup></code>, where <code>x</code> is the argument, and <code>e</code> is <a href=\"e\">Euler's number (also known as Napier's constant)</a>, the base of the natural logarithms.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/math-exp.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\">Math.exp(<var>x</var>)</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><code>x</code></dt> <dd>A number.</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p>A number representing <code>e<sup>x</sup></code>, where <code>e</code> is <a href=\"e\">Euler's number</a> and <code>x</code> is the argument.</p> <h2 id=\"Description\">Description</h2> <p>Because <code>exp()</code> is a static method of <code>Math</code>, you always use it as <code>Math.exp()</code>, rather than as a method of a <code>Math</code> object you created (<code>Math</code> is not a constructor).</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Using_Math.exp()\">Using <code>Math.exp()</code>\n</h3> <pre data-language=\"js\">Math.exp(-1); // 0.36787944117144233\nMath.exp(0);  // 1\nMath.exp(1);  // 2.718281828459045\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/publications/files/ECMA-ST-ARCH/ECMA-262,%201st%20edition,%20June%201997.pdf\" hreflang=\"en\">ECMAScript 1st Edition (ECMA-262)</a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition. Implemented in JavaScript 1.0.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/5.1/#sec-15.8.2.8\" hreflang=\"en\">ECMAScript 5.1 (ECMA-262)<br><small>The definition of 'Math.exp' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-math.exp\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Math.exp' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-math.exp\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Math.exp' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"e\"><code>Math.E</code></a></li> <li><a href=\"expm1\"><code>Math.expm1()</code></a></li> <li><a href=\"log\"><code>Math.log()</code></a></li> <li><a href=\"log10\"><code>Math.log10()</code></a></li> <li><a href=\"log1p\"><code>Math.log1p()</code></a></li> <li><a href=\"log2\"><code>Math.log2()</code></a></li> <li><a href=\"pow\"><code>Math.pow()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/exp$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/exp\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/exp</a>\n  </p>\n</div>\n","global_objects/math/expm1":"<h1>Math.expm1</h1> <p>The <code>Math.expm1()</code> function returns <code>e<sup>x</sup> - 1</code>, where <code>x</code> is the argument, and <a href=\"e\">e</a> the base of the natural logarithms.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/math-expm1.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\">Math.expm1(<var>x</var>)</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><code>x</code></dt> <dd>A number.</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p>A number representing <code>e<sup>x</sup> - 1</code>, where <code>e</code> is <a href=\"e\">Euler's number</a> and <code>x</code> is the argument.</p> <h2 id=\"Description\">Description</h2> <p>Because <code>expm1()</code> is a static method of <code>Math</code>, you always use it as <code>Math.expm1()</code>, rather than as a method of a <code>Math</code> object you created (<code>Math</code> is not a constructor).</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Using_Math.expm1()\">Using <code>Math.expm1()</code>\n</h3> <pre data-language=\"js\">Math.expm1(-1); // -0.6321205588285577 \nMath.expm1(0);  // 0\nMath.expm1(1);  // 1.718281828459045\n</pre> <h2 id=\"Polyfill\">Polyfill</h2> <p>This can be emulated with the help of the <a href=\"exp\"><code>Math.exp()</code></a> function:</p> <pre data-language=\"js\">Math.expm1 = Math.expm1 || function(x) {\n  return Math.exp(x) - 1;\n};\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-math.expm1\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Math.expm1' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-math.expm1\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Math.expm1' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 38</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 25</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 25</td>\n<td class=\"bc-supports-yes\"> 8</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 25</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 8</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 0.12</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"e\"><code>Math.E</code></a></li> <li><a href=\"exp\"><code>Math.exp()</code></a></li> <li><a href=\"log\"><code>Math.log()</code></a></li> <li><a href=\"log10\"><code>Math.log10()</code></a></li> <li><a href=\"log1p\"><code>Math.log1p()</code></a></li> <li><a href=\"log2\"><code>Math.log2()</code></a></li> <li><a href=\"pow\"><code>Math.pow()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/expm1$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/expm1\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/expm1</a>\n  </p>\n</div>\n","global_objects/math/clz32":"<h1>Math.clz32</h1> <p>The <code>Math.clz32()</code> function returns the number of leading zero bits in the 32-bit binary representation of a number.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/math-clz32.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\">Math.clz32(<var>x</var>)</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><var>x</var></dt> <dd>A number.</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p>The number of leading zero bits in the 32-bit binary representation of the given number.</p> <h2 id=\"Description\">Description</h2> <p>\"<code>clz32</code>\" is short for <code>CountLeadingZeroes32</code>.</p> <p>If <code>x</code> is not a number, then it will be converted to a number first, then converted to a 32-bit unsigned integer.</p> <p>If the converted 32-bit unsigned integer is <code>0</code>, then return <code>32</code>, because all bits are <code>0</code>.</p> <p>This function is particularly useful for systems that compile to JS, like <a href=\"https://developer.mozilla.org/en-US/docs/Emscripten\">Emscripten</a>.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Using_Math.clz32()\">Using <code>Math.clz32()</code>\n</h3> <pre data-language=\"js\">Math.clz32(1);                // 31\nMath.clz32(1000);             // 22\nMath.clz32();                 // 32\n\n[NaN, Infinity, -Infinity, 0, -0, null, undefined, 'foo', {}, []].filter(\nfunction(n) {\n  return Math.clz32(n) !== 32\n});                           // []\n\nMath.clz32(true);             // 31\nMath.clz32(3.5);              // 30</pre> <h2 id=\"Count_Leading_Ones_And_Beyond\">Count Leading Ones And Beyond</h2> <p>At present, there is no <code>Math.clon</code> for \"Count Leading Ones\" (named \"clon\", not \"clo\", because \"clo\" and \"clz\" are too similar especially for non-english-speaking people). However, a CLON function can easily be created by inversing the bits of a number and passing the result to `Math.clz` which will work because the inverse of 1 is 0 and vice-versa. Thus, inversing the bits will inverse the measured quanity 0 (of Math.clz), thereby making Math.clz count the number of ones instead of the number of zeros.</p> <pre data-language=\"js\">var clz = Math.clz32;\nfunction clon(integer){\n    return clz(~integer);\n}\n</pre> <p>Further, this teqnique could be extended to creating jumpless \"Count Trailing Zeros\" and \"Count Trailing Ones\" functions as seen below. The <code>ctrz</code> function below fills in all the high bits with the lowest filled bit, then negates the bits to earase all higher set bits so that clz can then be used.</p> <pre data-language=\"js\">var clz = Math.clz32;\nfunction ctrz(integer){ // count trailing zeros\n    // 1. fill in all the higher bits after the first one\n    integer |= integer &lt;&lt; 16;\n    integer |= integer &lt;&lt; 8;\n    integer |= integer &lt;&lt; 4;\n    integer |= integer &lt;&lt; 2;\n    integer |= integer &lt;&lt; 1;\n    // 2. Now, inversing the bits reveals the lowest bits\n    return 32 - clz(~integer);\n}\nfunction ctron(integer){ // count trailing ones\n    // No shift-filling-in-with-ones operator is available in\n    // javascript, so the below code is the fastest\n    return ctrz(~integer);\n    /* Alternate implementation for demonstrational purposes:\n       // 1. erase all the higher bits after the first zero\n       integer &amp;= (integer &lt;&lt; 16) | 0xffff;\n       integer &amp;= (integer &lt;&lt; 8 ) | 0x00ff;\n       integer &amp;= (integer &lt;&lt; 4 ) | 0x000f;\n       integer &amp;= (integer &lt;&lt; 2 ) | 0x0003;\n       integer &amp;= (integer &lt;&lt; 1 ) | 0x0001;\n       // 2. Now, inversing the bits reveals the lowest zeros\n       return 32 - clon(~integer);\n    */\n}\n</pre> <p>Make these helper functions into ASM.JS module; then, you have a true performance masterpiece. Situations like these are exactly what ASM.JS was designed for.</p> <pre data-language=\"js\">var countTrailsMethods = (function(stdlib, foreign, heap) {\n    \"use asm\";\n    var clz = stdlib.Math.clz32;\n    function ctrz(integer) { // count trailing zeros\n        integer = integer | 0; // coerce to an integer\n        // 1. fill in all the higher bits after the first one\n        // ASM.js for some reason does not allow *=,/=,+=,etc.\n        integer = integer | (integer &lt;&lt; 16);\n        integer = integer | (integer &lt;&lt; 8);\n        integer = integer | (integer &lt;&lt; 4);\n        integer = integer | (integer &lt;&lt; 2);\n        integer = integer | (integer &lt;&lt; 1);\n        // 2. Now, inversing the bits reveals the lowest bits\n        return 32 - clz(~integer) |0;\n    }\n    function ctron(integer) { // count trailing ones\n        integer = integer | 0; // coerce to an integer\n        return ctrz(~integer) |0;\n    }\n    // unfourtunately, ASM.JS demands slow crummy objects:\n    return {a: ctrz, b: ctron};\n})(window, null, null);\nvar ctrz = countTrailsMethods.a;\nvar ctron = countTrailsMethods.b;\n</pre>  <h2 id=\"Polyfill\">Polyfill</h2> <p>The following polyfill is the most efficient.</p> <pre data-language=\"js\">if (!Math.clz32) Math.clz32 = (function(log, LN2){\n  return function(x) {\n    // Let n be ToUint32(x).\n    // Let p be the number of leading zero bits in \n    // the 32-bit binary representation of n.\n    // Return p.    \n    if (x == null || x === 0) {\n      return 32;\n    }\n    return 31 - log(x &gt;&gt;&gt; 0) / LN2 | 0; // the \"| 0\" acts like math.floor\n  };\n})(Math.log, Math.LN2);\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <thead> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> </thead> <tbody> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-math.clz32\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Math.clz32' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-math.clz32\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Math.clz32' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 38</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 31</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 25</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 31</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 0.12</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"../math\"><code>Math</code></a></li> <li><a href=\"imul\"><code>Math.imul</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/clz32$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/clz32\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/clz32</a>\n  </p>\n</div>\n","global_objects/math/sign":"<h1>Math.sign</h1> <p>The <code>Math.sign()</code> function returns the sign of a number, indicating whether the number is positive, negative or zero.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/math-sign.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\">Math.sign(<var>x</var>)</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><code>x</code></dt> <dd>A number.</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p>A number representing the sign of the given argument. If the argument is a positive number, negative number, positive zero or negative zero, the function will return <code>1</code>, <code>-1</code>, <code>0</code> or <code>-0</code> respectively. Otherwise, <a href=\"../nan\"><code>NaN</code></a> is returned.</p> <h2 id=\"Description\">Description</h2> <p>Because <code>sign()</code> is a static method of <code>Math</code>, you always use it as <code>Math.sign()</code>, rather than as a method of a <code>Math</code> object you created (<code>Math</code> is not a constructor).</p> <p>This function has 5 kinds of return values, <code>1</code>, <code>-1</code>, <code>0</code>, <code>-0</code>, <code>NaN</code>, which represent \"positive number\", \"negative number\", \"positive zero\", \"negative zero\" and <a href=\"../nan\"><code>NaN</code></a> respectively.</p> <p>The argument passed to this function will be converted to <code>number</code> type implicitly.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Using_Math.sign()\">Using <code>Math.sign()</code>\n</h3> <pre data-language=\"js\">Math.sign(3);     //  1\nMath.sign(-3);    // -1\nMath.sign('-3');  // -1\nMath.sign(0);     //  0\nMath.sign(-0);    // -0\nMath.sign(NaN);   // NaN\nMath.sign('foo'); // NaN\nMath.sign();      // NaN\n</pre> <h2 id=\"Polyfill\">Polyfill</h2> <pre data-language=\"js\">if (!Math.sign) {\n  Math.sign = function(x) {\n    // If x is NaN, the result is NaN.\n    // If x is -0, the result is -0.\n    // If x is +0, the result is +0.\n    // If x is negative and not -0, the result is -1.\n    // If x is positive and not +0, the result is +1.\n    return ((x &gt; 0) - (x &lt; 0)) || +x;\n    // A more aesthetical persuado-representation is shown below\n    //\n    // ( (x &gt; 0) ? 0 : 1 )  // if x is negative then negative one\n    //          +           // else (because you cant be both - and +)\n    // ( (x &lt; 0) ? 0 : -1 ) // if x is positive then positive one\n    //         ||           // if x is 0, -0, or NaN, or not a number,\n    //         +x           // Then the result will be x, (or) if x is\n    //                      // not a number, then x converts to number\n  };\n}\n</pre> <p>In the above polyfill, no extra type-coercing is needed to make <code>(x &gt; 0) or (x &lt; 0)</code> numbers because subtracting them from each other forces a type conversion from boolean to numbers.</p> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-math.sign\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Math.sign' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-math.sign\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Math.sign' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 38</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 25</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 25</td>\n<td class=\"bc-supports-yes\"> 9</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 25</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 0.12</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"abs\"><code>Math.abs()</code></a></li> <li><a href=\"ceil\"><code>Math.ceil()</code></a></li> <li><a href=\"floor\"><code>Math.floor()</code></a></li> <li><a href=\"round\"><code>Math.round()</code></a></li> <li><a href=\"trunc\"><code>Math.trunc()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/sign$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/sign\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/sign</a>\n  </p>\n</div>\n","global_objects/math/cos":"<h1>Math.cos</h1> <p>The <code>Math.cos()</code> static function returns the <a href=\"https://en.wikipedia.org/wiki/cosine\">cosine</a> of the specified angle, which must be specified in <a href=\"https://en.wikipedia.org/wiki/radians\">radians</a>. This value is <math style=\"display: inline;\"> <mstyle displaystyle=\"true\"> <mfrac> <msub> <mrow> <mtext>length</mtext> </mrow> <mrow> <mrow> <mtext>adjacent</mtext> </mrow> </mrow> </msub> <msub> <mrow> <mtext>length</mtext> </mrow> <mrow> <mrow> <mtext>hypotenuse</mtext> </mrow> </mrow> </msub> </mfrac> </mstyle> </math>.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/math-cos.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\">Math.cos(<var>x</var>)</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><code>x</code></dt> <dd>The angle in radians for which to return the cosine.</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p>The cosine of the given number.</p> <h2 id=\"Description\">Description</h2> <p>The <code>Math.cos()</code> method returns a numeric value between -1 and 1, which represents the cosine of the angle.</p> <p>Because <code>cos()</code> is a static method of <code>Math</code>, you always use it as <code>Math.cos()</code>, rather than as a method of a <code>Math</code> object you created (<code>Math</code> is not a constructor).</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Using_Math.cos()\">Using <code>Math.cos()</code>\n</h3> <pre data-language=\"js\">Math.cos(0);           // 1\nMath.cos(1);           // 0.5403023058681398\n\nMath.cos(Math.PI);     // -1\nMath.cos(2 * Math.PI); // 1\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/publications/files/ECMA-ST-ARCH/ECMA-262,%201st%20edition,%20June%201997.pdf\" hreflang=\"en\">ECMAScript 1st Edition (ECMA-262)</a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition. Implemented in JavaScript 1.0.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/5.1/#sec-15.8.2.7\" hreflang=\"en\">ECMAScript 5.1 (ECMA-262)<br><small>The definition of 'Math.cos' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-math.cos\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Math.cos' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-math.cos\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Math.cos' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"acos\"><code>Math.acos()</code></a></li> <li><a href=\"asin\"><code>Math.asin()</code></a></li> <li><a href=\"atan\"><code>Math.atan()</code></a></li> <li><a href=\"atan2\"><code>Math.atan2()</code></a></li> <li><a href=\"sin\"><code>Math.sin()</code></a></li> <li><a href=\"tan\"><code>Math.tan()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/cos$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/cos\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/cos</a>\n  </p>\n</div>\n","global_objects/math/hypot":"<h1>Math.hypot</h1> <p>The <code>Math.hypot()</code> function returns the square root of the sum of squares of its arguments, that is</p> <p><math display=\"block\"><semantics><mrow><mstyle mathvariant=\"monospace\"><mrow><mo rspace=\"thinmathspace\" lspace=\"0em\">Math.hypot</mo><mo stretchy=\"false\">(</mo><msub><mi>v</mi><mn>1</mn></msub><mo>,</mo><msub><mi>v</mi><mn>2</mn></msub><mo>,</mo><mo>…</mo><mo>,</mo><msub><mi>v</mi><mi>n</mi></msub><mo stretchy=\"false\">)</mo></mrow></mstyle><mo>=</mo><msqrt><mrow><munderover><mo>∑</mo><mrow><mi>i</mi><mo>=</mo><mn>1</mn></mrow><mi>n</mi></munderover><msubsup><mi>v</mi><mi>i</mi><mn>2</mn></msubsup></mrow></msqrt><mo>=</mo><msqrt><mrow><msubsup><mi>v</mi><mn>1</mn><mn>2</mn></msubsup><mo>+</mo><msubsup><mi>v</mi><mn>2</mn><mn>2</mn></msubsup><mo>+</mo><mo>…</mo><mo>+</mo><msubsup><mi>v</mi><mi>n</mi><mn>2</mn></msubsup></mrow></msqrt></mrow><annotation encoding=\"TeX\">\\mathtt{\\operatorname{Math.hypot}(v_1, v_2, \\dots, v_n)} = \\sqrt{\\sum_{i=1}^n v_i^2} = \\sqrt{v_1^2 + v_2^2 + \\dots + v_n^2}</annotation></semantics></math></p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/math-hypot.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\">Math.hypot([<var>value1</var>[, <var>value2</var>[, ...]]])</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><code>value1, value2, ...</code></dt> <dd>Numbers.</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p>The square root of the sum of squares of the given arguments. If at least one of the arguments cannot be converted to a number, <a href=\"../nan\"><code>NaN</code></a> is returned.</p> <h2 id=\"Description\">Description</h2> <p>Calculating the hypotenuse of a right triangle, or the magnitude of a complex number, uses the formula <code>Math.sqrt(v1*v1 + v2*v2)</code> where v1 and v2 are either the sides of the triangle, or the real and complex values. For calculating distance in 2 or more dimensions, simply add in more squares inside the square root sign, like <code>Math.sqrt(v1*v1 + v2*v2 + v3*v3 + v4*v4)</code>. </p> <p>This function makes it a little easier and faster, you just call <code>Math.hypot(v1, v2)</code> , or <code>Math.hypot(v1, v2, v3, v4, ...)</code> . </p> <p>It also avoids a problem if the magnitude of your numbers is huge. The largest number you can represent in JS's double floats is <span style=\"line-height: 1.5;\"><code>Number.MAX_VALUE = 1.797...e+308</code> . If your numbers are larger than about 1e154, taking the square of them will result in Infinity, demolishing your results. For example, <code>Math.sqrt(1e200*1e200 + 1e200*1e200) = Infinity</code> . If you use <code>hypot()</code> instead, you get a good answer <code>Math.hypot(1e200, 1e200) = 1.4142...e+200</code> . This is also true with very small numbers. <code>Math.sqrt(1e-200*1e-200 + 1e-200*1e-200) = 0</code>, but </span><code><span style=\"line-height: 1.5;\">Math.hypot(1e-200, 1e-200) =</span></code><span style=\"line-height: 1.5;\"><code>1.4142...e-200</code>, a good answer.</span></p> <p>Because <code>hypot()</code> is a static method of <code>Math</code>, you always use it as <code>Math.hypot()</code>, rather than as a method of a <code>Math</code> object you created (<code>Math</code> is not a constructor).</p> <p>If no arguments are given, the result is +0.</p> <p>If at least one of the arguments cannot be converted to a number, the result is <a href=\"../nan\"><code>NaN</code></a>.</p> <p>With one argument, <code>Math.hypot()</code> returns the same as <code>Math.abs()</code>.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Using_Math.hypot()\">Using <code>Math.hypot()</code>\n</h3> <pre data-language=\"js\">Math.hypot(3, 4);        // 5\nMath.hypot(3, 4, 5);     // 7.0710678118654755\nMath.hypot();            // 0\nMath.hypot(NaN);         // NaN\nMath.hypot(3, 4, 'foo'); // NaN, +'foo' =&gt; NaN\nMath.hypot(3, 4, '5');   // 7.0710678118654755, +'5' =&gt; 5\nMath.hypot(-3);          // 3, the same as Math.abs(-3)\n</pre> <h2 id=\"Polyfill\">Polyfill</h2> <p>This can be emulated using the following function:</p> <pre data-language=\"js\">if (!Math.hypot) Math.hypot = function() {\n  var y = 0, i = arguments.length;\n  while (i--) y += arguments[i] * arguments[i];\n  return Math.sqrt(y);\n};\n</pre> <p>A polyfill that avoids underflows and overflows:</p> <pre data-language=\"js\">if (!Math.hypot) Math.hypot = function (x, y) {\n  // https://bugzilla.mozilla.org/show_bug.cgi?id=896264#c28\n  var max = 0;\n  var s = 0;\n  for (var i = 0; i &lt; arguments.length; i += 1) {\n    var arg = Math.abs(Number(arguments[i]));\n    if (arg &gt; max) {\n      s *= (max / arg) * (max / arg);\n      max = arg;\n    }\n    s += arg === 0 &amp;&amp; max === 0 ? 0 : (arg / max) * (arg / max);\n  }\n  return max === 1 / 0 ? 1 / 0 : max * Math.sqrt(s);\n};\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-math.hypot\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Math.hypot' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-math.hypot\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Math.hypot' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 38</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 27</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 25</td>\n<td class=\"bc-supports-yes\"> 8</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 27</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 8</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 0.12</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"abs\"><code>Math.abs()</code></a></li> <li><a href=\"pow\"><code>Math.pow()</code></a></li> <li><a href=\"sqrt\"><code>Math.sqrt()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/hypot$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/hypot\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/hypot</a>\n  </p>\n</div>\n","global_objects/math/log10":"<h1>Math.log10</h1> <p>The <code>Math.log10()</code> function returns the base 10 logarithm of a number, that is</p> <p><math display=\"block\"><semantics><mrow><mo>∀</mo><mi>x</mi><mo>&gt;</mo><mn>0</mn><mo>,</mo><mstyle mathvariant=\"monospace\"><mrow><mo rspace=\"thinmathspace\" lspace=\"0em\">Math.log10</mo><mo stretchy=\"false\">(</mo><mi>x</mi><mo stretchy=\"false\">)</mo></mrow></mstyle><mo>=</mo><msub><mo rspace=\"0em\" lspace=\"0em\">log</mo><mn>10</mn></msub><mo stretchy=\"false\">(</mo><mi>x</mi><mo stretchy=\"false\">)</mo><mo>=</mo><mtext>the unique</mtext><mspace width=\"thickmathspace\"></mspace><mi>y</mi><mspace width=\"thickmathspace\"></mspace><mtext>such that</mtext><mspace width=\"thickmathspace\"></mspace><msup><mn>10</mn><mi>y</mi></msup><mo>=</mo><mi>x</mi></mrow><annotation encoding=\"TeX\">\\forall x &gt; 0, \\mathtt{\\operatorname{Math.log10}(x)} = \\log_10(x) = \\text{the unique} \\; y \\; \\text{such that} \\; 10^y = x</annotation></semantics></math></p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/math-log10.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\">Math.log10(<var>x</var>)</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><code>x</code></dt> <dd>A number.</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p>The base 10 logarithm of the given number. If the number is negative, <a href=\"../nan\"><code>NaN</code></a> is returned.</p> <h2 id=\"Description\">Description</h2> <p>If the value of <code>x</code> is less than 0, the return value is always <a href=\"../nan\"><code>NaN</code></a>.</p> <p>Because <code>log10()</code> is a static method of <code>Math</code>, you always use it as <code>Math.log10()</code>, rather than as a method of a <code>Math</code> object you created (<code>Math</code> is not a constructor).</p> <p>This function is the equivalent of Math.log(x) / Math.log(10). For log10(e) use the constant <a href=\"log10e\"><code>Math.LOG10E</code></a> which is 1 / <a href=\"ln10\"><code>Math.LN10</code></a>. </p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Using_Math.log10()\">Using <code>Math.log10()</code>\n</h3> <pre data-language=\"js\">Math.log10(2);      // 0.3010299956639812\nMath.log10(1);      // 0\nMath.log10(0);      // -Infinity\nMath.log10(-2);     // NaN\nMath.log10(100000); // 5\n</pre> <h3 id=\"Polyfill\">Polyfill</h3> <p>This can be emulated with the following function:</p> <pre data-language=\"js\">Math.log10 = Math.log10 || function(x) {\n  return Math.log(x) * Math.LOG10E;\n};\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-math.log10\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Math.log10' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-math.log10\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Math.log10' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 38</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 25</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 25</td>\n<td class=\"bc-supports-yes\"> 8</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 25</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 8</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 0.12</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"exp\"><code>Math.exp()</code></a></li> <li><a href=\"log\"><code>Math.log()</code></a></li> <li><a href=\"log1p\"><code>Math.log1p()</code></a></li> <li><a href=\"log2\"><code>Math.log2()</code></a></li> <li><a href=\"pow\"><code>Math.pow()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/log10$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/log10\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/log10</a>\n  </p>\n</div>\n","global_objects/math/log":"<h1>Math.log</h1> <p>The <code>Math.log()</code> function returns the natural logarithm (base <a href=\"e\"><code>e</code></a>) of a number, that is</p> <p><math display=\"block\"><semantics><mrow><mo>∀</mo><mi>x</mi><mo>&gt;</mo><mn>0</mn><mo>,</mo><mstyle mathvariant=\"monospace\"><mrow><mo rspace=\"thinmathspace\" lspace=\"0em\">Math.log</mo><mo stretchy=\"false\">(</mo><mi>x</mi><mo stretchy=\"false\">)</mo></mrow></mstyle><mo>=</mo><mo rspace=\"0em\" lspace=\"0em\">ln</mo><mo stretchy=\"false\">(</mo><mi>x</mi><mo stretchy=\"false\">)</mo><mo>=</mo><mtext>the unique</mtext><mspace width=\"thickmathspace\"></mspace><mi>y</mi><mspace width=\"thickmathspace\"></mspace><mtext>such that</mtext><mspace width=\"thickmathspace\"></mspace><msup><mi>e</mi><mi>y</mi></msup><mo>=</mo><mi>x</mi></mrow><annotation encoding=\"TeX\">\\forall x &gt; 0, \\mathtt{\\operatorname{Math.log}(x)} = \\ln(x) = \\text{the unique} \\; y \\; \\text{such that} \\; e^y = x</annotation></semantics></math></p> <p>The JavaScript <code>Math.log()</code>function is equivalent to <em>ln(x)</em> in mathematics.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/math-log.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\">Math.log(<var>x</var>)</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><code>x</code></dt> <dd>A number.</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p>The natural logarithm (base <a href=\"e\"><code>e</code></a>) of the given number. If the number is negative, <a href=\"../nan\"><code>NaN</code></a> is returned.</p> <h2 id=\"Description\">Description</h2> <p>If the value of <code>x</code> is negative, the return value is always <a href=\"../nan\"><code>NaN</code></a>.</p> <p>Because <code>log()</code> is a static method of <code>Math</code>, you always use it as <code>Math.log()</code>, rather than as a method of a <code>Math</code> object you created (<code>Math</code> is not a constructor).</p> <p>If you need the natural log of 2 or 10, use the constants <a href=\"ln2\"><code>Math.LN2</code></a> or <a href=\"ln10\"><code>Math.LN10</code></a> . If you need a logarithm to base 2 or 10, use <a href=\"log2\"><code>Math.log2()</code></a> or <a href=\"log10\"><code>Math.log10()</code></a> . If you need a logarithm to other bases, use Math.log(x) / Math.log(otherBase) as in the example below; you might want to precalculate 1 / Math.log(otherBase) .</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Using_Math.log()\">Using <code>Math.log()</code>\n</h3> <pre data-language=\"js\">Math.log(-1); // NaN, out of range\nMath.log(0);  // -Infinity\nMath.log(1);  // 0\nMath.log(10); // 2.302585092994046\n</pre> <h3 id=\"Using_Math.log()_with_a_different_base\">Using <code>Math.log()</code> with a different base</h3> <p>The following function returns the logarithm of <code>y</code> with base <code>x</code> (ie. <math><semantics><mrow><msub><mo>log</mo><mi>x</mi></msub><mi>y</mi></mrow><annotation encoding=\"TeX\">\\log_x y</annotation></semantics></math>):</p> <pre data-language=\"js\">function getBaseLog(x, y) {\n  return Math.log(y) / Math.log(x);\n}\n</pre> <p>If you run <code>getBaseLog(10, 1000)</code> it returns <code>2.9999999999999996</code> due to floating-point rounding, which is very close to the actual answer of 3.</p> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/publications/files/ECMA-ST-ARCH/ECMA-262,%201st%20edition,%20June%201997.pdf\" hreflang=\"en\">ECMAScript 1st Edition (ECMA-262)</a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition. Implemented in JavaScript 1.0.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/5.1/#sec-15.8.2.10\" hreflang=\"en\">ECMAScript 5.1 (ECMA-262)<br><small>The definition of 'Math.log' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-math.log\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Math.log' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-math.log\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Math.log' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"exp\"><code>Math.exp()</code></a></li> <li><a href=\"log1p\"><code>Math.log1p()</code></a></li> <li><a href=\"log10\"><code>Math.log10()</code></a></li> <li><a href=\"log2\"><code>Math.log2()</code></a></li> <li><a href=\"pow\"><code>Math.pow()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/log$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/log\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/log</a>\n  </p>\n</div>\n","global_objects/math/log2":"<h1>Math.log2</h1> <p>The <code>Math.log2()</code> function returns the base 2 logarithm of a number, that is</p> <p><math display=\"block\"><semantics><mrow><mo>∀</mo><mi>x</mi><mo>&gt;</mo><mn>0</mn><mo>,</mo><mstyle mathvariant=\"monospace\"><mrow><mo rspace=\"thinmathspace\" lspace=\"0em\">Math.log2</mo><mo stretchy=\"false\">(</mo><mi>x</mi><mo stretchy=\"false\">)</mo></mrow></mstyle><mo>=</mo><msub><mo rspace=\"0em\" lspace=\"0em\">log</mo><mn>2</mn></msub><mo stretchy=\"false\">(</mo><mi>x</mi><mo stretchy=\"false\">)</mo><mo>=</mo><mtext>the unique</mtext><mspace width=\"thickmathspace\"></mspace><mi>y</mi><mspace width=\"thickmathspace\"></mspace><mtext>such that</mtext><mspace width=\"thickmathspace\"></mspace><msup><mn>2</mn><mi>y</mi></msup><mo>=</mo><mi>x</mi></mrow><annotation encoding=\"TeX\">\\forall x &gt; 0, \\mathtt{\\operatorname{Math.log2}(x)} = \\log_2(x) = \\text{the unique} \\; y \\; \\text{such that} \\; 2^y = x</annotation></semantics></math></p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/math-log2.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\">Math.log2(<var>x</var>)</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><code>x</code></dt> <dd>A number.</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p>The base 2 logarithm of the given number. If the number is negative, <a href=\"../nan\"><code>NaN</code></a> is returned.</p> <h2 id=\"Description\">Description</h2> <p>If the value of <code>x</code> is less than 0, the return value is always <a href=\"../nan\"><code>NaN</code></a>.</p> <p>Because <code>log2()</code> is a static method of <code>Math</code>, you always use it as <code>Math.log2()</code>, rather than as a method of a <code>Math</code> object you created (<code>Math</code> is not a constructor).</p> <p>This function is the equivalent of Math.log(x) / Math.log(2). For log2(e) use the constant <a href=\"log2e\"><code>Math.LOG2E</code></a> which is 1 / <a href=\"ln2\"><code>Math.LN2</code></a>. </p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Using_Math.log2()\">Using <code>Math.log2()</code>\n</h3> <pre data-language=\"js\">Math.log2(3);    // 1.584962500721156\nMath.log2(2);    // 1\nMath.log2(1);    // 0\nMath.log2(0);    // -Infinity\nMath.log2(-2);   // NaN\nMath.log2(1024); // 10\n</pre> <h2 id=\"Polyfill\">Polyfill</h2> <p>This Polyfill emulates the <code>Math.log2</code> function. Note that it returns imprecise values on some inputs (like 1 &lt;&lt; 29), wrap into <a href=\"round\"><code>Math.round()</code></a> if working with bit masks.</p> <pre data-language=\"js\">Math.log2 = Math.log2 || function(x) {\n  return Math.log(x) * Math.LOG2E;\n};\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-math.log2\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Math.log2' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-math.log2\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Math.log2' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 38</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 25</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 25</td>\n<td class=\"bc-supports-yes\"> 8</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 25</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 8</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 0.12</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"exp\"><code>Math.exp()</code></a></li> <li><a href=\"log\"><code>Math.log()</code></a></li> <li><a href=\"log10\"><code>Math.log10()</code></a></li> <li><a href=\"log1p\"><code>Math.log1p()</code></a></li> <li><a href=\"pow\"><code>Math.pow()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/log2$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/log2\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/log2</a>\n  </p>\n</div>\n","global_objects/math/min":"<h1>Math.min</h1> <p>The static function <code><strong>Math.min()</strong></code> returns the lowest-valued number passed into it, or <a href=\"../nan\"><code>NaN</code></a> if any parameter isn't a number and can't be converted into one.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/math-min.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\">Math.min([<var>value1</var>[, <var>value2</var>[, ...]]])</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><code>value1, value2, ...</code></dt> <dd>Zero or more numbers among which the lowest value will be selected and returned.</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p>The smallest of the given numbers. If any one or more of the parameters cannot be converted into a number, <a href=\"../nan\"><code>NaN</code></a> is returned. The result is <a href=\"../infinity\"><code>Infinity</code></a> if no parameters are provided.</p> <h2 id=\"Description\">Description</h2> <p>Because <code>min()</code> is a static method of <code>Math</code>, you always use it as <code>Math.min()</code>, rather than as a method of a <code>Math</code> object you created (<code>Math</code> is not a constructor).</p> <p>If no arguments are given, the result is <a href=\"../infinity\"><code>Infinity</code></a>.</p> <p>If at least one of arguments cannot be converted to a number, the result is <a href=\"../nan\"><code>NaN</code></a>.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Using_Math.min()\">Using <code>Math.min()</code>\n</h3> <p>This finds the min of <code>x</code> and <code>y</code> and assigns it to <code>z</code>:</p> <pre data-language=\"js\">var x = 10, y = -20;\nvar z = Math.min(x, y);\n</pre> <h3 id=\"Clipping_a_value_with_Math.min()\">Clipping a value with <code>Math.min()</code>\n</h3> <p><code>Math.min()</code> is often used to clip a value so that it is always less than or equal to a boundary. For instance, this</p> <pre data-language=\"js\">var x = f(foo);\n\nif (x &gt; boundary) {\n  x = boundary;\n}\n</pre> <p>may be written as this</p> <pre data-language=\"js\">var x = Math.min(f(foo), boundary);\n</pre> <p><a href=\"max\"><code>Math.max()</code></a> can be used in a similar way to clip a value at the other end.</p> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/publications/files/ECMA-ST-ARCH/ECMA-262,%201st%20edition,%20June%201997.pdf\" hreflang=\"en\">ECMAScript 1st Edition (ECMA-262)</a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition. Implemented in JavaScript 1.0.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/5.1/#sec-15.8.2.12\" hreflang=\"en\">ECMAScript 5.1 (ECMA-262)<br><small>The definition of 'Math.min' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-math.min\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Math.min' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-math.min\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Math.min' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"max\"><code>Math.max()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/min$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/min\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/min</a>\n  </p>\n</div>\n","global_objects/math/random":"<h1>Math.random</h1> <p>The <code>Math.random()</code> function returns a floating-point, pseudo-random number in the range 0–1 (inclusive of 0, but not 1) with approximately uniform distribution over that range — which you can then scale to your desired range. The implementation selects the initial seed to the random number generation algorithm; it cannot be chosen or reset by the user.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/math-random.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe> <div class=\"note\"> <p><code>Math.random()</code> <em>does not</em> provide cryptographically secure random numbers. Do not use them for anything related to security. Use the Web Crypto API instead, and more precisely the <a href=\"https://developer.mozilla.org/en-US/docs/Web/API/RandomSource/getRandomValues\"><code>window.crypto.getRandomValues()</code></a> method.</p> </div> <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\">Math.random()</pre> <h3 id=\"Return_value\">Return value</h3> <p>A floating-point, pseudo-random number between <code>0</code> (inclusive) and 1 (exclusive).</p> <h2 id=\"Examples\">Examples</h2> <p>Note that as numbers in JavaScript are IEEE 754 floating point numbers with round-to-nearest-even behavior, the ranges claimed for the functions below (excluding the one for <code>Math.random()</code> itself) aren't exact. If extremely large bounds are chosen (2<sup>53</sup> or higher), it's possible in <em>extremely</em> rare cases to calculate the usually-excluded upper bound.</p> <h3 id=\"Getting_a_random_number_between_0_(inclusive)_and_1_(exclusive)\">Getting a random number between 0 (inclusive) and 1 (exclusive)</h3> <pre data-language=\"js\">function getRandom() {\n  return Math.random();\n}\n</pre> <h3 id=\"Getting_a_random_number_between_two_values\">Getting a random number between two values</h3> <p>This example returns a random number between the specified values. The returned value is no lower than (and may possibly equal) <code>min</code>, and is less than (and not equal) <code>max</code>.</p> <pre data-language=\"js\">function getRandomArbitrary(min, max) {\n  return Math.random() * (max - min) + min;\n}\n</pre> <h3 id=\"Getting_a_random_integer_between_two_values\">Getting a random integer between two values</h3> <p>This example returns a random <em>integer</em> between the specified values. The value is no lower than <code>min</code> (or the next integer greater than <code>min</code> if <code>min</code> isn't an integer), and is less than (but not equal to) <code>max</code>.</p> <pre data-language=\"js\">function getRandomInt(min, max) {\n  min = Math.ceil(min);\n  max = Math.floor(max);\n  return Math.floor(Math.random() * (max - min)) + min; //The maximum is exclusive and the minimum is inclusive\n}\n</pre> <div class=\"note\"> <p>It might be tempting to use <code>Math.round()</code> to accomplish that, but doing so would cause your random numbers to follow a non-uniform distribution, which may not be acceptable for your needs.</p> </div> <h3 id=\"Getting_a_random_integer_between_two_values_inclusive\">Getting a random integer between two values, inclusive</h3> <p>While the <code>getRandomInt()</code> function above is inclusive at the minimum, it's exclusive at the maximum. What if you need the results to be inclusive at both the minimum and the maximum? The <code>getRandomIntInclusive()</code> function below accomplishes that.</p> <pre data-language=\"js\">function getRandomIntInclusive(min, max) {\n  min = Math.ceil(min);\n  max = Math.floor(max);\n  return Math.floor(Math.random() * (max - min + 1)) + min; //The maximum is inclusive and the minimum is inclusive \n}</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/publications/files/ECMA-ST-ARCH/ECMA-262,%201st%20edition,%20June%201997.pdf\" hreflang=\"en\">ECMAScript 1st Edition (ECMA-262)</a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition. JavaScript 1.0 (UNIX Only) / JavaScript 1.1 (All platforms).</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/5.1/#sec-15.8.2.14\" hreflang=\"en\">ECMAScript 5.1 (ECMA-262)<br><small>The definition of 'Math.random' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-math.random\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Math.random' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-math.random\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Math.random' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div> <div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/random$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/random\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/random</a>\n  </p>\n</div>\n","global_objects/math/trunc":"<h1>Math.trunc</h1> <p>The <code>Math.trunc()</code> function returns the integer part of a number by removing any fractional digits.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/math-trunc.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\">Math.trunc(<var>x</var>)\n</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><code>x</code></dt> <dd>A number.</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p>The integer part of the given number.</p> <h2 id=\"Description\">Description</h2> <p>Unlike the other three <code>Math</code> methods: <a href=\"floor\"><code>Math.floor()</code></a>, <a href=\"ceil\"><code>Math.ceil()</code></a> and <a href=\"round\"><code>Math.round()</code></a>, the way <code>Math.trunc()</code> works is very simple. It <em>truncates</em> (cuts off) the dot and the digits to the right of it, no matter whether the argument is a positive or negative number.</p> <p>The argument passed to this method will be converted to number type implicitly.</p> <p>Because <code>trunc()</code> is a static method of <code>Math</code>, you always use it as <code>Math.trunc()</code>, rather than as a method of a <code>Math</code> object you created (<code>Math</code> is not a constructor).</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Using_Math.trunc()\">Using <code>Math.trunc()</code>\n</h3> <pre data-language=\"js\">Math.trunc(13.37);    // 13\nMath.trunc(42.84);    // 42\nMath.trunc(0.123);    //  0\nMath.trunc(-0.123);   // -0\nMath.trunc('-1.123'); // -1\nMath.trunc(NaN);      // NaN\nMath.trunc('foo');    // NaN\nMath.trunc();         // NaN\n</pre> <h2 id=\"Polyfill\">Polyfill</h2> <pre data-language=\"js\">if (!Math.trunc) {\n\tMath.trunc = function(v) {\n\t\tv = +v;\n\t\tif (!isFinite(v)) return v;\n\t\t\n\t\treturn (v - v % 1)   ||   (v &lt; 0 ? -0 : v === 0 ? v : 0);\n\t\t\n\t\t// returns:\n\t\t//  0        -&gt;  0\n\t\t// -0        -&gt; -0\n\t\t//  0.2      -&gt;  0\n\t\t// -0.2      -&gt; -0\n\t\t//  0.7      -&gt;  0\n\t\t// -0.7      -&gt; -0\n\t\t//  Infinity -&gt;  Infinity\n\t\t// -Infinity -&gt; -Infinity\n\t\t//  NaN      -&gt;  NaN\n\t\t//  null     -&gt;  0\n\t};\n}\n</pre> <p>or:</p> <pre data-language=\"js\">if (!Math.trunc) {\n\tMath.trunc = function(v) {\n\t\tv = +v;\n\t\treturn (v - v % 1)   ||   (!isFinite(v) || v === 0 ? v : v &lt; 0 ? -0 : 0);\n\t};\n}\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-math.trunc\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Math.trunc' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-math.trunc\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Math.trunc' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 38</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 25</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 25</td>\n<td class=\"bc-supports-yes\"> 8</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 25</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 8</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 0.12</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"abs\"><code>Math.abs()</code></a></li> <li><a href=\"ceil\"><code>Math.ceil()</code></a></li> <li><a href=\"floor\"><code>Math.floor()</code></a></li> <li><a href=\"round\"><code>Math.round()</code></a></li> <li><a href=\"sign\"><code>Math.sign()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/trunc$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/trunc\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/trunc</a>\n  </p>\n</div>\n","global_objects/math/cosh":"<h1>Math.cosh</h1> <p>The <code>Math.cosh()</code> function returns the hyperbolic cosine of a number, that can be expressed using the <a href=\"e\">constant e</a>:</p> <p><math display=\"block\"><semantics><mrow><mstyle mathvariant=\"monospace\"><mo rspace=\"thinmathspace\" lspace=\"0em\">Math.cosh(x)</mo></mstyle><mo>=</mo><mfrac><mrow><msup><mi>e</mi><mi>x</mi></msup><mo>+</mo><msup><mi>e</mi><mrow><mo>-</mo><mi>x</mi></mrow></msup></mrow><mn>2</mn></mfrac></mrow><annotation encoding=\"TeX\">\\mathtt{\\operatorname{Math.cosh(x)}} = \\frac{e^x + e^{-x}}{2}</annotation></semantics></math></p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/math-cosh.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\">Math.cosh(<var>x</var>)</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><code>x</code></dt> <dd>A number.</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p>The hyperbolic cosine of the given number.</p> <h2 id=\"Description\">Description</h2> <p>Because <code>cosh()</code> is a static method of <code>Math</code>, you always use it as <code>Math.cosh()</code>, rather than as a method of a <code>Math</code> object you created (<code>Math</code> is not a constructor).</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Using_Math.cosh()\">Using <code>Math.cosh()</code>\n</h3> <pre data-language=\"js\">Math.cosh(0);  // 1\nMath.cosh(1);  // 1.5430806348152437\nMath.cosh(-1); // 1.5430806348152437\n</pre> <h2 id=\"Polyfill\">Polyfill</h2> <p>This can be emulated with the help of the <a href=\"exp\"><code>Math.exp()</code></a> function:</p> <pre data-language=\"js\">Math.cosh = Math.cosh || function(x) {\n  return (Math.exp(x) + Math.exp(-x)) / 2;\n}\n</pre> <p>or using only one call to the <a href=\"exp\"><code>Math.exp()</code></a> function:</p> <pre data-language=\"js\">Math.cosh = Math.cosh || function(x) {\n  var y = Math.exp(x);\n  return (y + 1 / y) / 2;\n};\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-math.cosh\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Math.cosh' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-math.cosh\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Math.cosh' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 38</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 25</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 25</td>\n<td class=\"bc-supports-yes\"> 8</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 25</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 8</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 0.12</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"acosh\"><code>Math.acosh()</code></a></li> <li><a href=\"asinh\"><code>Math.asinh()</code></a></li> <li><a href=\"atanh\"><code>Math.atanh()</code></a></li> <li><a href=\"sinh\"><code>Math.sinh()</code></a></li> <li><a href=\"tanh\"><code>Math.tanh()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/cosh$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/cosh\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/cosh</a>\n  </p>\n</div>\n","global_objects/math/max":"<h1>Math.max</h1> <p>The <code>Math.max()</code> function returns the largest of zero or more numbers.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/math-max.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\">Math.max([<var>value1</var>[, <var>value2</var>[, ...]]])</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><code>value1, value2, ...</code></dt> <dd>Numbers.</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p>The largest of the given numbers. If at least one of the arguments cannot be converted to a number, <a href=\"../nan\"><code>NaN</code></a> is returned.</p> <h2 id=\"Description\">Description</h2> <p>Because <code>max()</code> is a static method of <code>Math</code>, you always use it as <code>Math.max()</code>, rather than as a method of a <code>Math</code> object you created (<code>Math</code> is not a constructor).</p> <p>If no arguments are given, the result is -<a href=\"../infinity\"><code>Infinity</code></a>.</p> <p>If at least one of arguments cannot be converted to a number, the result is <a href=\"../nan\"><code>NaN</code></a>.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Using_Math.max()\">Using <code>Math.max()</code>\n</h3> <pre data-language=\"js\">Math.max(10, 20);   //  20\nMath.max(-10, -20); // -10\nMath.max(-10, 20);  //  20\n</pre> <h4 id=\"Getting_the_maximum_element_of_an_array\">Getting the maximum element of an array</h4> <p><a href=\"../array/reduce\"><code>Array.reduce()</code></a> can be used to find the maximum element in a numeric array, by comparing each value:</p> <pre data-language=\"js\">var arr = [1,2,3];\nvar max = arr.reduce(function(a, b) {\n    return Math.max(a, b);\n});\n</pre> <p>The following function uses <a href=\"../function/apply\"><code>Function.prototype.apply()</code></a> to get the maximum of an array. <code>getMaxOfArray([1, 2, 3])</code> is equivalent to <code>Math.max(1, 2, 3)</code>, but you can use <code>getMaxOfArray()</code> on programmatically constructed arrays. This should only be used for arrays with relatively few elements.</p> <pre data-language=\"js\">function getMaxOfArray(numArray) {\n  return Math.max.apply(null, numArray);\n}</pre> <p>The new <a href=\"../../operators/spread_syntax\">spread operator</a> is a shorter way of writing the <code>apply</code> solution to get the maximum of an array:</p> <pre data-language=\"js\">var arr = [1, 2, 3];\nvar max = Math.max(...arr);\n</pre> <p>However, both spread (<code>...</code>) and <code>apply</code> will either fail or return the wrong result if the array has too many elements, because they try to pass the array elements as function parameters. See <a href=\"../function/apply#Using_apply_and_built-in_functions\">Using <code>apply</code> and built-in functions</a> for more details. The <code>reduce</code> solution does not have this problem.</p> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/publications/files/ECMA-ST-ARCH/ECMA-262,%201st%20edition,%20June%201997.pdf\" hreflang=\"en\">ECMAScript 1st Edition (ECMA-262)</a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition. Implemented in JavaScript 1.0.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/5.1/#sec-15.8.2.11\" hreflang=\"en\">ECMAScript 5.1 (ECMA-262)<br><small>The definition of 'Math.max' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-math.max\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Math.max' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-math.max\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Math.max' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"min\"><code>Math.min()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/max$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/max\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/max</a>\n  </p>\n</div>\n","global_objects/math/sin":"<h1>Math.sin</h1> <p>The <code>Math.sin()</code> function returns the sine of a number.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/math-sin.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\">Math.sin(<var>x</var>)</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><code>x</code></dt> <dd>A number (given in radians).</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p>The sine of the given number.</p> <h2 id=\"Description\">Description</h2> <p>The <code>Math.sin()</code> method returns a numeric value between -1 and 1, which represents the sine of the angle given in radians.</p> <p>Because <code>sin()</code> is a static method of <code>Math</code>, you always use it as <code>Math.sin()</code>, rather than as a method of a <code>Math</code> object you created (<code>Math</code> is not a constructor).</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Using_Math.sin()\">Using <code>Math.sin()</code>\n</h3> <pre data-language=\"js\">Math.sin(0);           // 0\nMath.sin(1);           // 0.8414709848078965\n\nMath.sin(Math.PI / 2); // 1\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/publications/files/ECMA-ST-ARCH/ECMA-262,%201st%20edition,%20June%201997.pdf\" hreflang=\"en\">ECMAScript 1st Edition (ECMA-262)</a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition. Implemented in JavaScript 1.0.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/5.1/#sec-15.8.2.16\" hreflang=\"en\">ECMAScript 5.1 (ECMA-262)<br><small>The definition of 'Math.sin' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-math.sin\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Math.sin' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-math.sin\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Math.sin' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"acos\"><code>Math.acos()</code></a></li> <li><a href=\"asin\"><code>Math.asin()</code></a></li> <li><a href=\"atan\"><code>Math.atan()</code></a></li> <li><a href=\"atan2\"><code>Math.atan2()</code></a></li> <li><a href=\"cos\"><code>Math.cos()</code></a></li> <li><a href=\"tan\"><code>Math.tan()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/sin$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/sin\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/sin</a>\n  </p>\n</div>\n","global_objects/math/sinh":"<h1>Math.sinh</h1> <p>The <code>Math.sinh()</code> function returns the hyperbolic sine of a number, that can be expressed using the <a href=\"e\">constant e</a>:</p> <p><math display=\"block\"><semantics><mrow><mstyle mathvariant=\"monospace\"><mo rspace=\"thinmathspace\" lspace=\"0em\">Math.sinh(x)</mo></mstyle><mo>=</mo><mfrac><mrow><msup><mi>e</mi><mi>x</mi></msup><mo>-</mo><msup><mi>e</mi><mrow><mo>-</mo><mi>x</mi></mrow></msup></mrow><mn>2</mn></mfrac></mrow><annotation encoding=\"TeX\">\\mathtt{\\operatorname{Math.sinh(x)}} = \\frac{e^x - e^{-x}}{2}</annotation></semantics></math></p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/math-sinh.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\">Math.sinh(<var>x</var>)</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><code>x</code></dt> <dd>A number.</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p>The hyperbolic sine of the given number.</p> <h2 id=\"Description\">Description</h2> <p>Because <code>sinh()</code> is a static method of <code>Math</code>, you always use it as <code>Math.sinh()</code>, rather than as a method of a <code>Math</code> object you created (<code>Math</code> is not a constructor).</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Using_Math.sinh()\">Using <code>Math.sinh()</code>\n</h3> <pre data-language=\"js\">Math.sinh(0); // 0\nMath.sinh(1); // 1.1752011936438014\n</pre> <h2 id=\"Polyfill\">Polyfill</h2> <p>This can be emulated with the help of the <a href=\"exp\"><code>Math.exp()</code></a> function:</p> <pre data-language=\"js\">Math.sinh = Math.sinh || function(x) {\n  return (Math.exp(x) - Math.exp(-x)) / 2;\n}\n</pre> <p>or using only one call to the <a href=\"exp\"><code>Math.exp()</code></a> function:</p> <pre data-language=\"js\">Math.sinh = Math.sinh || function(x) {\n  var y = Math.exp(x);\n  return (y - 1 / y) / 2;\n}\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-math.sinh\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Math.sinh' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-math.sinh\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Math.sinh' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 38</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 25</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 25</td>\n<td class=\"bc-supports-yes\"> 8</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 25</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 8</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 0.12</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"acosh\"><code>Math.acosh()</code></a></li> <li><a href=\"asinh\"><code>Math.asinh()</code></a></li> <li><a href=\"atanh\"><code>Math.atanh()</code></a></li> <li><a href=\"cosh\"><code>Math.cosh()</code></a></li> <li><a href=\"tanh\"><code>Math.tanh()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/sinh$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/sinh\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/sinh</a>\n  </p>\n</div>\n","global_objects/math/sqrt":"<h1>Math.sqrt</h1> <p>The <code>Math.sqrt()</code> function returns the square root of a number, that is</p> <p><math display=\"block\"><semantics><mrow><mo>∀</mo><mi>x</mi><mo>≥</mo><mn>0</mn><mo>,</mo><mstyle mathvariant=\"monospace\"><mrow><mi>M</mi><mi>a</mi><mi>t</mi><mi>h</mi><mo>.</mo><mi>s</mi><mi>q</mi><mi>r</mi><mi>t</mi><mo stretchy=\"false\">(</mo><mi>x</mi><mo stretchy=\"false\">)</mo></mrow></mstyle><mo>=</mo><msqrt><mi>x</mi></msqrt><mo>=</mo><mtext>the unique</mtext><mspace width=\"thickmathspace\"></mspace><mi>y</mi><mo>≥</mo><mn>0</mn><mspace width=\"thickmathspace\"></mspace><mtext>such that</mtext><mspace width=\"thickmathspace\"></mspace><msup><mi>y</mi><mn>2</mn></msup><mo>=</mo><mi>x</mi></mrow><annotation encoding=\"TeX\">\\forall x \\geq 0, \\mathtt{Math.sqrt(x)} = \\sqrt{x} = \\text{the unique} \\; y \\geq 0 \\; \\text{such that} \\; y^2 = x</annotation></semantics></math></p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/math-sqrt.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\">Math.sqrt(<var>x</var>)</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><code>x</code></dt> <dd>A number.</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p>The square root of the given number. If the number is negative, <a href=\"../nan\"><code>NaN</code></a> is returned.</p> <h2 id=\"Description\">Description</h2> <p>If the value of <code>x</code> is negative, <code>Math.sqrt()</code> returns <a href=\"../nan\"><code>NaN</code></a>.</p> <p>Because <code>sqrt()</code> is a static method of <code>Math</code>, you always use it as <code>Math.sqrt()</code>, rather than as a method of a <code>Math</code> object you created (<code>Math</code> is not a constructor).</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Using_Math.sqrt()\">Using <code>Math.sqrt()</code>\n</h3> <pre data-language=\"js\">Math.sqrt(9); // 3\nMath.sqrt(2); // 1.414213562373095\n\nMath.sqrt(1);  // 1\nMath.sqrt(0);  // 0\nMath.sqrt(-1); // NaN\nMath.sqrt(-0); // -0\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/publications/files/ECMA-ST-ARCH/ECMA-262,%201st%20edition,%20June%201997.pdf\" hreflang=\"en\">ECMAScript 1st Edition (ECMA-262)</a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition. Implemented in JavaScript 1.0.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/5.1/#sec-15.8.2.17\" hreflang=\"en\">ECMAScript 5.1 (ECMA-262)<br><small>The definition of 'Math.sqrt' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-math.sqrt\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Math.sqrt' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-math.sqrt\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Math.sqrt' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"cbrt\"><code>Math.cbrt()</code></a></li> <li><a href=\"exp\"><code>Math.exp()</code></a></li> <li><a href=\"log\"><code>Math.log()</code></a></li> <li><a href=\"pow\"><code>Math.pow()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/sqrt$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/sqrt\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/sqrt</a>\n  </p>\n</div>\n","global_objects/math/fround":"<h1>Math.fround</h1> <p class=\"seoSummary\">The <code>Math.fround()</code> function returns the nearest <a href=\"https://en.wikipedia.org/wiki/Single-precision_floating-point_format\">32-bit single precision</a> float representation of a <a href=\"../number\"><code>Number</code></a>.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/math-fround.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\">var <em>singleFloat</em> = Math.fround(<em>doubleFloat</em>);</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><code>doubleFloat</code></dt> <dd>A <a href=\"../number\"><code>Number</code></a>. If the parameter is of a different type, it will get converted to a number or to <a href=\"../nan\"><code>NaN</code></a> if it cannot be converted.</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p>The nearest <a href=\"https://en.wikipedia.org/wiki/Single-precision_floating-point_format\">32-bit single precision</a> float representation of the given number.</p> <h2 id=\"Description\">Description</h2> <p>JavaScript uses 64-bit double floating-point numbers internally, which offer a very high precision. However, sometimes you may be working with 32-bit floating-point numbers, for example if you are reading values from a <a href=\"../float32array\"><code>Float32Array</code></a>. This can create confusion: Checking a 64-bit float and a 32-bit float for equality may fail even though the numbers are seemingly identical.</p> <p>To solve this, <code>Math.fround()</code> can be used to cast the 64-bit float to a 32-bit float. Internally, JavaScript continues to treat the number as a 64-bit float, it just performs a \"round to even\" on the 23rd bit of the mantissa, and sets all following mantissa bits to <code>0</code>. If the number is outside the range of a 32-bit float, <code><a href=\"../infinity\"><code>Infinity</code></a></code> or <code>-Infinity</code> is returned.</p> <p>Because <code>fround()</code> is a static method of <code>Math</code>, you always use it as <code>Math.fround()</code>, rather than as a method of a <code>Math</code> object you created (<code>Math</code> is not a constructor).</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Using_Math.fround()\">Using <code>Math.fround()</code>\n</h3> <p>The number 1.5 can be precisely represented in the binary numeral system, and is identical in 32-bit and 64-bit:</p> <pre data-language=\"js\">Math.fround(1.5); // 1.5\nMath.fround(1.5) === 1.5; // true\n</pre> <p>However, the number 1.337 cannot be precisely represented in the binary numeral system, so it differs in 32-bit and 64-bit:</p> <pre data-language=\"js\">Math.fround(1.337); // 1.3370000123977661\nMath.fround(1.337) === 1.337; // false\n</pre> <p><math><semantics><msup><mn>2</mn><mn>150</mn></msup><annotation encoding=\"TeX\">2^150</annotation></semantics></math> is too big for a 32-bit float, so <code>Infinity</code> is returned:</p> <pre data-language=\"js\">2 ** 150; // 1.42724769270596e+45\nMath.fround(2 ** 150); // Infinity\n</pre> <p>If the parameter cannot be converted to a number, or it is <a href=\"https://en.wikipedia.org/wiki/NaN\">not-a-number</a> (<code>NaN</code>), <code>Math.fround()</code> will return <code>NaN</code>:</p> <pre data-language=\"js\">Math.fround('abc'); // NaN\nMath.fround(NaN); // NaN\n</pre> <h2 id=\"Polyfill\">Polyfill</h2> <p>This can be emulated with the following function, if <a href=\"../float32array\"><code>Float32Array</code></a> are supported:</p> <pre data-language=\"js\">Math.fround = Math.fround || (function (array) {\n  return function(x) {\n    return array[0] = x, array[0];\n  };\n})(new Float32Array(1));\n</pre> <p>Supporting older browsers is slower, but also possible:</p> <pre data-language=\"js\">Math.fround = Math.fround || function(arg) {\n  arg = Number(arg);\n  // Return early for ±0 and NaN.\n  if (!arg) return arg;\n  var sign = arg &lt; 0 ? -1 : 1;\n  if (sign &lt; 0) arg = -arg;\n  // Compute the exponent (8 bits, signed).\n  var exp = Math.floor(Math.log(arg) / Math.LN2);\n  var powexp = Math.pow(2, Math.max(-126, Math.min(exp, 127)));\n  // Handle subnormals: leading digit is zero if exponent bits are all zero.\n  var leading = exp &lt; -127 ? 0 : 1;\n  // Compute 23 bits of mantissa, inverted to round toward zero.\n  var mantissa = Math.round((leading - arg / powexp) * 0x800000);\n  if (mantissa &lt;= -0x800000) return sign * Infinity;\n  return sign * powexp * (leading - mantissa / 0x800000);\n};</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-math.fround\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Math.fround' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-math.fround\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Math.fround' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 38</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 26</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 25</td>\n<td class=\"bc-supports-yes\"> 8</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 26</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 8</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 0.12</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"round\"><code>Math.round()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/fround$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/fround\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/fround</a>\n  </p>\n</div>\n","global_objects/math/pow":"<h1>Math.pow</h1> <p>The <code>Math.pow()</code> function returns the <code>base</code> to the <code>exponent</code> power, that is, <code>base<sup>exponent</sup></code>.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/math-pow.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\">Math.pow(<var>base</var>, <var>exponent</var>)</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><code>base</code></dt> <dd>The base number.</dd> <dt><code>exponent</code></dt> <dd>The exponent used to raise the <code>base</code>.</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p>A number representing the given base taken to the power of the given exponent.</p> <h2 id=\"Description\">Description</h2> <p>Because <code>pow()</code> is a static method of <code>Math</code>, you always use it as <code>Math.pow()</code>, rather than as a method of a <code>Math</code> object you created (<code>Math</code> has no constructor).</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Using_Math.pow()\">Using <code>Math.pow()</code>\n</h3> <pre data-language=\"js\">// simple\nMath.pow(7, 2);    // 49\nMath.pow(7, 3);    // 343\nMath.pow(2, 10);   // 1024\n// fractional exponents\nMath.pow(4, 0.5);  // 2 (square root of 4)\nMath.pow(8, 1/3);  // 2 (cube root of 8)\nMath.pow(2, 0.5);  // 1.4142135623730951 (square root of 2)\nMath.pow(2, 1/3);  // 1.2599210498948732 (cube root of 2)\n// signed exponents\nMath.pow(7, -2);   // 0.02040816326530612 (1/49)\nMath.pow(8, -1/3); // 0.5\n// signed bases\nMath.pow(-7, 2);   // 49 (squares are positive)\nMath.pow(-7, 3);   // -343 (cubes can be negative)\nMath.pow(-7, 0.5); // NaN (negative numbers don't have a real square root)\n// due to \"even\" and \"odd\" roots laying close to each other, \n// and limits in the floating number precision, \n// negative bases with fractional exponents always return NaN\nMath.pow(-7, 1/3); // NaN \n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/publications/files/ECMA-ST-ARCH/ECMA-262,%201st%20edition,%20June%201997.pdf\" hreflang=\"en\">ECMAScript 1st Edition (ECMA-262)</a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition. Implemented in JavaScript 1.0.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/5.1/#sec-15.8.2.13\" hreflang=\"en\">ECMAScript 5.1 (ECMA-262)<br><small>The definition of 'Math.pow' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-math.pow\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Math.pow' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-math.pow\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Math.pow' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"cbrt\"><code>Math.cbrt()</code></a></li> <li><a href=\"exp\"><code>Math.exp()</code></a></li> <li><a href=\"log\"><code>Math.log()</code></a></li> <li><a href=\"sqrt\"><code>Math.sqrt()</code></a></li> <li>\n<a href=\"../../operators/arithmetic_operators#Exponentiation\">Exponentiation operator</a> \n</li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/pow$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/pow\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/pow</a>\n  </p>\n</div>\n","global_objects/math/tanh":"<h1>Math.tanh</h1> <p>The <code>Math.tanh()</code> function returns the hyperbolic tangent of a number, that is</p> <p><math display=\"block\"><semantics><mrow><mo rspace=\"0em\" lspace=\"0em\">tanh</mo><mi>x</mi><mo>=</mo><mfrac><mrow><mo rspace=\"0em\" lspace=\"0em\">sinh</mo><mi>x</mi></mrow><mrow><mo rspace=\"0em\" lspace=\"0em\">cosh</mo><mi>x</mi></mrow></mfrac><mo>=</mo><mfrac><mrow><msup><mi>e</mi><mi>x</mi></msup><mo>-</mo><msup><mi>e</mi><mrow><mo>-</mo><mi>x</mi></mrow></msup></mrow><mrow><msup><mi>e</mi><mi>x</mi></msup><mo>+</mo><msup><mi>e</mi><mrow><mo>-</mo><mi>x</mi></mrow></msup></mrow></mfrac><mo>=</mo><mfrac><mrow><msup><mi>e</mi><mrow><mn>2</mn><mi>x</mi></mrow></msup><mo>-</mo><mn>1</mn></mrow><mrow><msup><mi>e</mi><mrow><mn>2</mn><mi>x</mi></mrow></msup><mo>+</mo><mn>1</mn></mrow></mfrac></mrow><annotation encoding=\"TeX\">\\tanh x = \\frac{\\sinh x}{\\cosh x} = \\frac {e^x - e^{-x}} {e^x + e^{-x}} = \\frac{e^{2x} - 1}{e^{2x}+1}</annotation></semantics></math></p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/math-tanh.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe> <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\">Math.tanh(<var>x</var>)</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><code>x</code></dt> <dd>A number.</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p>The hyperbolic tangent of the given number.</p> <h2 id=\"Description\">Description</h2> <p>Because <code>tanh()</code> is a static method of <code>Math</code>, you always use it as <code>Math.tanh()</code>, rather than as a method of a <code>Math</code> object you created (<code>Math</code> is not a constructor).</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Using_Math.tanh()\">Using <code>Math.tanh()</code>\n</h3> <pre data-language=\"js\">Math.tanh(0);        // 0\nMath.tanh(Infinity); // 1\nMath.tanh(1);        // 0.7615941559557649\n</pre> <h2 id=\"Polyfill\">Polyfill</h2> <p>This can be emulated with the help of the <a href=\"exp\"><code>Math.exp()</code></a> function:</p> <pre data-language=\"js\">Math.tanh = Math.tanh || function(x){\n    var a = Math.exp(+x), b = Math.exp(-x);\n    return a == Infinity ? 1 : b == Infinity ? -1 : (a - b) / (a + b);\n}\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-math.tanh\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Math.tanh' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-math.tanh\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Math.tanh' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 38</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 25</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 25</td>\n<td class=\"bc-supports-yes\"> 8</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 25</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 8</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 0.12</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"acosh\"><code>Math.acosh()</code></a></li> <li><a href=\"asinh\"><code>Math.asinh()</code></a></li> <li><a href=\"atanh\"><code>Math.atanh()</code></a></li> <li><a href=\"cosh\"><code>Math.cosh()</code></a></li> <li><a href=\"sinh\"><code>Math.sinh()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/tanh$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/tanh\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/tanh</a>\n  </p>\n</div>\n","global_objects/math/tan":"<h1>Math.tan</h1> <p>The <code>Math.tan()</code> function returns the tangent of a number.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/math-tan.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\">Math.tan(<var>x</var>)</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><code>x</code></dt> <dd>A number representing an angle in radians.</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p>The tangent of the given number.</p> <h2 id=\"Description\">Description</h2> <p>The <code>Math.tan()</code> method returns a numeric value that represents the tangent of the angle.</p> <p>Because <code>tan()</code> is a static method of <code>Math</code>, you always use it as <code>Math.tan()</code>, rather than as a method of a <code>Math</code> object you created (<code>Math</code> is not a constructor).</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Using_Math.tan()\">Using <code>Math.tan()</code>\n</h3> <pre data-language=\"js\">Math.tan(1); // 1.5574077246549023\n</pre> <p>Because the <code>Math.tan()</code> function accepts radians, but it is often easier to work with degrees, the following function accepts a value in degrees, converts it to radians and returns the tangent.</p> <pre data-language=\"js\">function getTanDeg(deg) {\n  var rad = deg * Math.PI/180;\n  return Math.tan(rad);\n}\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/publications/files/ECMA-ST-ARCH/ECMA-262,%201st%20edition,%20June%201997.pdf\" hreflang=\"en\">ECMAScript 1st Edition (ECMA-262)</a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition. Implemented in JavaScript 1.0.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/5.1/#sec-15.8.2.18\" hreflang=\"en\">ECMAScript 5.1 (ECMA-262)<br><small>The definition of 'Math.tan' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-math.tan\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Math.tan' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-math.tan\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Math.tan' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"acos\"><code>Math.acos()</code></a></li> <li><a href=\"asin\"><code>Math.asin()</code></a></li> <li><a href=\"atan\"><code>Math.atan()</code></a></li> <li><a href=\"atan2\"><code>Math.atan2()</code></a></li> <li><a href=\"cos\"><code>Math.cos()</code></a></li> <li><a href=\"sin\"><code>Math.sin()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/tan$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/tan\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/tan</a>\n  </p>\n</div>\n","global_objects/object/prototype":"<h1>Object.prototype</h1> <p>The <code><strong>Object.prototype</strong></code> property represents the <a href=\"../object\"><code>Object</code></a> prototype object.</p> <div class=\"_table\"><table class=\"standard-table\"> <thead> <tr> <th colspan=\"2\" class=\"header\">Property attributes of <code>Object.prototype</code>\n</th> </tr> </thead> <tbody> <tr> <td>Writable</td> <td>no</td> </tr> <tr> <td>Enumerable</td> <td>no</td> </tr> <tr> <td>Configurable</td> <td>no</td> </tr> </tbody> </table></div> <h2 id=\"Description\">Description</h2> <p>Nearly all objects in JavaScript are instances of <a href=\"../object\"><code>Object</code></a>; a typical object inherits properties (including methods) from <code>Object.prototype</code>, although these properties may be shadowed (a.k.a. overridden). However, an <code>Object</code> may be deliberately created for which this is not true (e.g. by <a href=\"create\"><code>Object.create(null)</code></a>), or it may be altered so that this is no longer true (e.g. with <a href=\"setprototypeof\"><code>Object.setPrototypeOf</code></a>).</p> <p>Changes to the <code>Object</code> prototype object are seen by <strong>all</strong> objects through prototype chaining, unless the properties and methods subject to those changes are overridden further along the prototype chain. This provides a very powerful although potentially dangerous mechanism to override or extend object behavior.</p> <h2 id=\"Properties\">Properties</h2> <dl> <dt><a href=\"constructor\"><code>Object.prototype.constructor</code></a></dt> <dd>Specifies the function that creates an object's prototype.</dd> <dt>\n<a href=\"proto\"><code>Object.prototype.__proto__</code></a> \n</dt> <dd>Points to the object which was used as prototype when the object was instantiated.</dd> <dt>\n<a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/__noSuchMethod__\"><code>Object.prototype.__noSuchMethod__</code></a> \n</dt> <dd>Allows a function to be defined that will be executed when an undefined object member is called as a method.</dd> <dt><s class=\"obsoleteElement\"><a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/count\"><code>Object.prototype.__count__</code></a> </s></dt> <dd><s class=\"obsoleteElement\">Used to return the number of enumerable properties directly on a user-defined object, but has been removed.</s></dd> <dt><s class=\"obsoleteElement\"><a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/parent\"><code>Object.prototype.__parent__</code></a> </s></dt> <dd><s class=\"obsoleteElement\">Used to point to an object's context, but has been removed.</s></dd> </dl> <h2 id=\"Methods\">Methods</h2> <dl> <dt>\n<a href=\"__definegetter__\"><code>Object.prototype.__defineGetter__()</code></a>  \n</dt> <dd>Associates a function with a property that, when accessed, executes that function and returns its return value.</dd> <dt>\n<a href=\"__definesetter__\"><code>Object.prototype.__defineSetter__()</code></a>  \n</dt> <dd>Associates a function with a property that, when set, executes that function which modifies the property.</dd> <dt>\n<a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/__lookupGetter__\"><code>Object.prototype.__lookupGetter__()</code></a>  \n</dt> <dd>Returns the function associated with the specified property by the <a href=\"__definegetter__\"><code>__defineGetter__()</code></a> method.</dd> <dt>\n<a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/__lookupSetter__\"><code>Object.prototype.__lookupSetter__()</code></a>  \n</dt> <dd>Returns the function associated with the specified property by the <a href=\"__definesetter__\"><code>__defineSetter__()</code></a> method.</dd> <dt><a href=\"hasownproperty\"><code>Object.prototype.hasOwnProperty()</code></a></dt> <dd>Returns a boolean indicating whether an object contains the specified property as a direct property of that object and not inherited through the prototype chain.</dd> <dt><a href=\"isprototypeof\"><code>Object.prototype.isPrototypeOf()</code></a></dt> <dd>Returns a boolean indicating whether the object this method is called upon is in the prototype chain of the specified object.</dd> <dt><a href=\"propertyisenumerable\"><code>Object.prototype.propertyIsEnumerable()</code></a></dt> <dd>Returns a boolean indicating if the internal <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Properties\">ECMAScript [[Enumerable]] attribute</a> is set.</dd> <dt>\n<a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/toSource\"><code>Object.prototype.toSource()</code></a> \n</dt> <dd>Returns string containing the source of an object literal representing the object that this method is called upon; you can use this value to create a new object.</dd> <dt><a href=\"tolocalestring\"><code>Object.prototype.toLocaleString()</code></a></dt> <dd>Calls <a href=\"tostring\"><code>toString()</code></a>.</dd> <dt><a href=\"tostring\"><code>Object.prototype.toString()</code></a></dt> <dd>Returns a string representation of the object.</dd> <dt>\n<a href=\"unwatch\"><code>Object.prototype.unwatch()</code></a> \n</dt> <dd>Removes a watchpoint from a property of the object.</dd> <dt><a href=\"valueof\"><code>Object.prototype.valueOf()</code></a></dt> <dd>Returns the primitive value of the specified object.</dd> <dt>\n<a href=\"watch\"><code>Object.prototype.watch()</code></a> \n</dt> <dd>Adds a watchpoint to a property of the object.</dd> <dt><s class=\"obsoleteElement\"><a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/eval\"><code>Object.prototype.eval()</code></a> </s></dt> <dd><s class=\"obsoleteElement\">Used to evaluate a string of JavaScript code in the context of the specified object, but has been removed.</s></dd> </dl> <h2 id=\"Examples\">Examples</h2> <p>When altering the behavior of existing Object.prototype methods, consider injecting code by wrapping your extension before or after the existing logic. For example, this (untested) code will pre-conditionally execute custom logic before the built-in logic or someone else's extension is executed.</p> <p>When a function is called, the arguments to the call are held in the array-like \"variable\" <a href=\"../../functions/arguments\">arguments</a>. For example, in the call \"myFn(a, b, c)\", the arguments within myFn's body will contain 3 array-like elements corresponding to (a, b, c). When modifying prototypes with hooks, simply pass this &amp; the arguments (the call state) to the current behavior by calling apply() on the function. This pattern can be used for any prototype, such as Node.prototype, Function.prototype, etc.</p> <pre data-language=\"js\">var current = Object.prototype.valueOf;\n\n// Since my property \"-prop-value\" is cross-cutting and isn't always\n// on the same prototype chain, I want to modify Object.prototype: \nObject.prototype.valueOf = function() {\n  if (this.hasOwnProperty('-prop-value')) {\n    return this['-prop-value'];\n  } else {\n    // It doesn't look like one of my objects, so let's fall back on \n    // the default behavior by reproducing the current behavior as best we can.\n    // The apply behaves like \"super\" in some other languages.\n    // Even though valueOf() doesn't take arguments, some other hook may.\n    return current.apply(this, arguments);\n  }\n}\n</pre> <p>Since JavaScript doesn't exactly have sub-class objects, prototype is a useful workaround to make a “base class” object of certain functions that act as objects. For example:</p> <pre data-language=\"js\">var Person = function(name) {\n  this.name = name;\n  this.canTalk = true;\n};\n\nPerson.prototype.greet = function() {\n  if (this.canTalk) {\n    console.log('Hi, I am ' + this.name);\n  }\n};\n\nvar Employee = function(name, title) {\n  Person.call(this, name);\n  this.title = title;\n};\n\nEmployee.prototype = Object.create(Person.prototype);\n\nEmployee.prototype.greet = function() {\n  if (this.canTalk) {\n    console.log('Hi, I am ' + this.name + ', the ' + this.title);\n  }\n};\n\nvar Customer = function(name) {\n  Person.call(this, name);\n};\n\nCustomer.prototype = Object.create(Person.prototype);\n\nvar Mime = function(name) {\n  Person.call(this, name);\n  this.canTalk = false;\n};\n\nMime.prototype = Object.create(Person.prototype);\n\nvar bob = new Employee('Bob', 'Builder');\nvar joe = new Customer('Joe');\nvar rg = new Employee('Red Green', 'Handyman');\nvar mike = new Customer('Mike');\nvar mime = new Mime('Mime');\n\nbob.greet();\n// Hi, I am Bob, the Builder\n\njoe.greet();\n// Hi, I am Joe\n\nrg.greet();\n// Hi, I am Red Green, the Handyman\n\nmike.greet();\n// Hi, I am Mike\n\nmime.greet();\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/publications/files/ECMA-ST-ARCH/ECMA-262,%201st%20edition,%20June%201997.pdf\" hreflang=\"en\">ECMAScript 1st Edition (ECMA-262)</a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition. Implemented in JavaScript 1.0.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/5.1/#sec-15.2.3.1\" hreflang=\"en\">ECMAScript 5.1 (ECMA-262)<br><small>The definition of 'Object.prototype' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-object.prototype\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Object.prototype' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-object.prototype\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Object.prototype' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>   <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div>  <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Introduction_to_Object-Oriented_JavaScript\">Introduction to Object-Oriented JavaScript</a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/prototype$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/prototype\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/prototype</a>\n  </p>\n</div>\n","global_objects/object/assign":"<h1>Object.assign</h1> <p>The <code>Object.assign()</code> method is used to copy the values of all enumerable own properties from one or more source objects to a target object. It will return the target object.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/object-assign.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\">Object.assign(<var>target</var>, ...<var>sources</var>)</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><code>target</code></dt> <dd>The target object.</dd> <dt><code>sources</code></dt> <dd>The source object(s).</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p>The target object.</p> <h2 id=\"Description\">Description</h2> <p>Properties in the target object will be overwritten by properties in the sources if they have the same key. Later sources' properties will similarly overwrite earlier ones. </p> <p>The <code>Object.assign()</code> method only copies <em>enumerable</em> and <em>own</em> properties from a source object to a target object. It uses <code>[[Get]]</code> on the source and <code>[[Set]]</code> on the target, so it will invoke getters and setters. Therefore it <em>assigns</em> properties versus just copying or defining new properties. This may make it unsuitable for merging new properties into a prototype if the merge sources contain getters. For copying property definitions, including their enumerability, into prototypes <a href=\"getownpropertydescriptor\"><code>Object.getOwnPropertyDescriptor()</code></a> and <a href=\"defineproperty\"><code>Object.defineProperty()</code></a> should be used instead.</p> <p>Both <a href=\"../string\"><code>String</code></a> and <a href=\"../symbol\"><code>Symbol</code></a> properties are copied.</p> <p>In case of an error, for example if a property is non-writable, a <a href=\"../typeerror\"><code>TypeError</code></a> will be raised, and the <code>target</code> object can be changed if any properties are added before error is raised.</p> <p>Note that <code>Object.assign()</code> does not throw on <a href=\"../null\"><code>null</code></a> or <a href=\"../undefined\"><code>undefined</code></a> source values.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Cloning_an_object\">Cloning an object</h3> <pre data-language=\"js\">var obj = { a: 1 };\nvar copy = Object.assign({}, obj);\nconsole.log(copy); // { a: 1 }\n</pre> <h3 name=\"Deep_Clone\" id=\"Deep_Clone\">Warning for Deep Clone</h3> <p>For deep cloning, we need to use other alternatives because <code>Object.assign()</code> copies property values. If the source value is a reference to an object, it only copies that reference value.</p> <pre data-language=\"js\">function test() {\n  'use strict';\n\n  let obj1 = { a: 0 , b: { c: 0}};\n  let obj2 = Object.assign({}, obj1);\n  console.log(JSON.stringify(obj2)); // { a: 0, b: { c: 0}}\n  \n  obj1.a = 1;\n  console.log(JSON.stringify(obj1)); // { a: 1, b: { c: 0}}\n  console.log(JSON.stringify(obj2)); // { a: 0, b: { c: 0}}\n  \n  obj2.a = 2;\n  console.log(JSON.stringify(obj1)); // { a: 1, b: { c: 0}}\n  console.log(JSON.stringify(obj2)); // { a: 2, b: { c: 0}}\n  \n  obj2.b.c = 3;\n  console.log(JSON.stringify(obj1)); // { a: 1, b: { c: 3}}\n  console.log(JSON.stringify(obj2)); // { a: 2, b: { c: 3}}\n  \n  // Deep Clone\n  obj1 = { a: 0 , b: { c: 0}};\n  let obj3 = JSON.parse(JSON.stringify(obj1));\n  obj1.a = 4;\n  obj1.b.c = 4;\n  console.log(JSON.stringify(obj3)); // { a: 0, b: { c: 0}}\n}\n\ntest();</pre> <h3 id=\"Merging_objects\">Merging objects</h3> <pre data-language=\"js\">var o1 = { a: 1 };\nvar o2 = { b: 2 };\nvar o3 = { c: 3 };\n\nvar obj = Object.assign(o1, o2, o3);\nconsole.log(obj); // { a: 1, b: 2, c: 3 }\nconsole.log(o1);  // { a: 1, b: 2, c: 3 }, target object itself is changed.</pre> <h3 id=\"Merging_objects_with_same_properties\">Merging objects with same properties</h3> <pre data-language=\"js\">var o1 = { a: 1, b: 1, c: 1 };\nvar o2 = { b: 2, c: 2 };\nvar o3 = { c: 3 };\n\nvar obj = Object.assign({}, o1, o2, o3);\nconsole.log(obj); // { a: 1, b: 2, c: 3 }</pre> <p>The properties are overwritten by other objects that have the same properties later in the parameters order.</p> <h3 id=\"Copying_symbol-typed_properties\">Copying symbol-typed properties</h3> <pre data-language=\"js\">var o1 = { a: 1 };\nvar o2 = { [Symbol('foo')]: 2 };\n\nvar obj = Object.assign({}, o1, o2);\nconsole.log(obj); // { a : 1, [Symbol(\"foo\")]: 2 } (cf. bug 1207182 on Firefox)\nObject.getOwnPropertySymbols(obj); // [Symbol(foo)]\n</pre> <h3 id=\"Properties_on_the_prototype_chain_and_non-enumerable_properties_cannot_be_copied\">Properties on the prototype chain and non-enumerable properties cannot be copied</h3> <pre data-language=\"js\">var obj = Object.create({ foo: 1 }, { // foo is on obj's prototype chain.\n  bar: {\n    value: 2  // bar is a non-enumerable property.\n  },\n  baz: {\n    value: 3,\n    enumerable: true  // baz is an own enumerable property.\n  }\n});\n\nvar copy = Object.assign({}, obj);\nconsole.log(copy); // { baz: 3 }\n</pre> <h3 id=\"Primitives_will_be_wrapped_to_objects\">Primitives will be wrapped to objects</h3> <pre data-language=\"js\">var v1 = 'abc';\nvar v2 = true;\nvar v3 = 10;\nvar v4 = Symbol('foo');\n\nvar obj = Object.assign({}, v1, null, v2, undefined, v3, v4); \n// Primitives will be wrapped, null and undefined will be ignored.\n// Note, only string wrappers can have own enumerable properties.\nconsole.log(obj); // { \"0\": \"a\", \"1\": \"b\", \"2\": \"c\" }\n</pre> <h3 id=\"Exceptions_will_interrupt_the_ongoing_copying_task\">Exceptions will interrupt the ongoing copying task</h3> <pre data-language=\"js\">var target = Object.defineProperty({}, 'foo', {\n  value: 1,\n  writable: false\n}); // target.foo is a read-only property\n\nObject.assign(target, { bar: 2 }, { foo2: 3, foo: 3, foo3: 3 }, { baz: 4 });\n// TypeError: \"foo\" is read-only\n// The Exception is thrown when assigning target.foo\n\nconsole.log(target.bar);  // 2, the first source was copied successfully.\nconsole.log(target.foo2); // 3, the first property of the second source was copied successfully.\nconsole.log(target.foo);  // 1, exception is thrown here.\nconsole.log(target.foo3); // undefined, assign method has finished, foo3 will not be copied.\nconsole.log(target.baz);  // undefined, the third source will not be copied either.\n</pre> <h3 id=\"Copying_accessors\">Copying accessors</h3> <pre data-language=\"js\">var obj = {\n  foo: 1,\n  get bar() {\n    return 2;\n  }\n};\n\nvar copy = Object.assign({}, obj); \nconsole.log(copy); \n// { foo: 1, bar: 2 }, the value of copy.bar is obj.bar's getter's return value.\n\n// This is an assign function that copies full descriptors\nfunction completeAssign(target, ...sources) {\n  sources.forEach(source =&gt; {\n    let descriptors = Object.keys(source).reduce((descriptors, key) =&gt; {\n      descriptors[key] = Object.getOwnPropertyDescriptor(source, key);\n      return descriptors;\n    }, {});\n    // by default, Object.assign copies enumerable Symbols too\n    Object.getOwnPropertySymbols(source).forEach(sym =&gt; {\n      let descriptor = Object.getOwnPropertyDescriptor(source, sym);\n      if (descriptor.enumerable) {\n        descriptors[sym] = descriptor;\n      }\n    });\n    Object.defineProperties(target, descriptors);\n  });\n  return target;\n}\n\nvar copy = completeAssign({}, obj);\nconsole.log(copy);\n// { foo:1, get bar() { return 2 } }\n</pre> <h2 id=\"Polyfill\">Polyfill</h2> <p>This <a href=\"https://developer.mozilla.org/en-US/docs/Glossary/Polyfill\">polyfill</a> doesn't support symbol properties, since ES5 doesn't have symbols anyway:</p> <pre data-language=\"js\">if (typeof Object.assign != 'function') {\n  // Must be writable: true, enumerable: false, configurable: true\n  Object.defineProperty(Object, \"assign\", {\n    value: function assign(target, varArgs) { // .length of function is 2\n      'use strict';\n      if (target == null) { // TypeError if undefined or null\n        throw new TypeError('Cannot convert undefined or null to object');\n      }\n\n      var to = Object(target);\n\n      for (var index = 1; index &lt; arguments.length; index++) {\n        var nextSource = arguments[index];\n\n        if (nextSource != null) { // Skip over if undefined or null\n          for (var nextKey in nextSource) {\n            // Avoid bugs when hasOwnProperty is shadowed\n            if (Object.prototype.hasOwnProperty.call(nextSource, nextKey)) {\n              to[nextKey] = nextSource[nextKey];\n            }\n          }\n        }\n      }\n      return to;\n    },\n    writable: true,\n    configurable: true\n  });\n}\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-object.assign\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Object.assign' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-object.assign\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Object.assign' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>   <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 45</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 34</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 32</td>\n<td class=\"bc-supports-yes\"> 9</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 45</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 34</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 5.0</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 4.0.0</td>\n</tr></tbody>\n</table>\n</div>  <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"defineproperties\"><code>Object.defineProperties()</code></a></li> <li><a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Enumerability_and_ownership_of_properties\">Enumerability and ownership of properties</a></li> <li><a href=\"../../operators/spread_syntax#Spread_in_object_literals\">Spread in object literals</a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/assign$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/assign\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/assign</a>\n  </p>\n</div>\n","global_objects/object/entries":"<h1>Object.entries</h1> <p>The <code><strong>Object.entries()</strong></code> method returns an array of a given object's own enumerable property <code>[key, value]</code> pairs, in the same order as that provided by a <a href=\"../../statements/for...in\"><code>for...in</code></a> loop (the difference being that a for-in loop enumerates properties in the prototype chain as well) . The order of the array returned by <strong>Object.entries()</strong> does not depend on how an object is defined. If there is a need for certain ordering then the array needs to be sorted first like <code>Object.entries(obj).sort((a, b) =&gt; a[0] - b[0]);</code>.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/object-entries.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\">Object.entries(<var>obj</var>)</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><code>obj</code></dt> <dd>The object whose enumerable own property <code>[key, value]</code> pairs are to be returned.</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p>An array of the given object's own enumerable property <code>[key, value]</code> pairs.</p> <h2 id=\"Description\">Description</h2> <p><code>Object.entries()</code> returns an array whose elements are arrays corresponding to the enumerable property <code>[key, value]</code> pairs found directly upon <code>object</code>. The ordering of the properties is the same as that given by looping over the property values of the object manually.</p> <h2 id=\"Examples\">Examples</h2> <pre data-language=\"js\">const obj = { foo: 'bar', baz: 42 };\nconsole.log(Object.entries(obj)); // [ ['foo', 'bar'], ['baz', 42] ]\n\n// array like object\nconst obj = { 0: 'a', 1: 'b', 2: 'c' };\nconsole.log(Object.entries(obj)); // [ ['0', 'a'], ['1', 'b'], ['2', 'c'] ]\n\n// array like object with random key ordering\nconst anObj = { 100: 'a', 2: 'b', 7: 'c' };\nconsole.log(Object.entries(anObj)); // [ ['2', 'b'], ['7', 'c'], ['100', 'a'] ]\n\n// getFoo is property which isn't enumerable\nconst myObj = Object.create({}, { getFoo: { value() { return this.foo; } } });\nmyObj.foo = 'bar';\nconsole.log(Object.entries(myObj)); // [ ['foo', 'bar'] ]\n\n// non-object argument will be coerced to an object\nconsole.log(Object.entries('foo')); // [ ['0', 'f'], ['1', 'o'], ['2', 'o'] ]\n\n// returns an empty array for any primitive type, since primitives have no own properties\nconsole.log(Object.entries(100)); // [ ]\n\n// iterate through key-value gracefully\nconst obj = { a: 5, b: 7, c: 9 };\nfor (const [key, value] of Object.entries(obj)) {\n  console.log(`${key} ${value}`); // \"a 5\", \"b 7\", \"c 9\"\n}\n\n// Or, using array extras\nObject.entries(obj).forEach(([key, value]) =&gt; {\n  console.log(`${key} ${value}`); // \"a 5\", \"b 7\", \"c 9\"\n});\n</pre> <h3 id=\"Converting_an_Object_to_a_Map\">Converting an <code>Object</code> to a <code>Map</code>\n</h3> <p>The <a href=\"../map\"><code>new Map()</code></a> constructor accepts an iterable of <code>entries</code>. With <code>Object.entries</code>, you can easily convert from <a href=\"../object\"><code>Object</code></a> to <a href=\"../map\"><code>Map</code></a>:</p> <pre data-language=\"js\">const obj = { foo: 'bar', baz: 42 }; \nconst map = new Map(Object.entries(obj));\nconsole.log(map); // Map { foo: \"bar\", baz: 42 }\n</pre> <h3 id=\"Iterating_through_an_Object\">Iterating through an <code>Object</code>\n</h3> <p>Using <a href=\"../../operators/destructuring_assignment#Array_destructuring\">Array Destructuring</a>, you can iterate through objects easily.</p> <pre data-language=\"js\">const obj = { foo: 'bar', baz: 42 };\nObject.entries(obj).forEach(([key, value]) =&gt; console.log(`${key}: ${value}`)); // \"foo: bar\", \"baz: 42\"\n</pre> <h2 id=\"Polyfill\">Polyfill</h2> <p>To add compatible <code>Object.entries</code> support in older environments that do not natively support it, you can find a demonstrational implementation of Object.entries in the <a href=\"https://github.com/tc39/proposal-object-values-entries\">tc39/proposal-object-values-entries</a> (if you don't need any support for IE), a polyfill in the <a href=\"https://github.com/es-shims/Object.entries\">es-shims/Object.entries</a> repositories, or you can use the simple, ready to deploy polyfill listed below. </p> <pre data-language=\"js\">if (!Object.entries) {\n  Object.entries = function( obj ){\n    var ownProps = Object.keys( obj ),\n        i = ownProps.length,\n        resArray = new Array(i); // preallocate the Array\n    while (i--)\n      resArray[i] = [ownProps[i], obj[ownProps[i]]];\n    \n    return resArray;\n  };\n}\n</pre> <p>For the above polyfill code snippet, if you need support for IE &lt; 9, then you will also need an Object.keys polyfill (such as the one found on the <a href=\"keys\"><code>Object.keys</code></a> page).</p> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <thead> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> </thead> <tbody> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-object.entries\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Object.entries' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/8.0/#sec-object.entries\" hreflang=\"en\">ECMAScript 2017 (ECMA-262)<br><small>The definition of 'Object.entries' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>   <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 54</td>\n<td class=\"bc-supports-yes\"> 14</td>\n<td class=\"bc-supports-yes\"> 47</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 41</td>\n<td class=\"bc-supports-yes\"> 10.1</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 54</td>\n<td class=\"bc-supports-yes\"> 54</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 47</td>\n<td class=\"bc-supports-yes\"> 41</td>\n<td class=\"bc-supports-yes\"> 10.1</td>\n<td class=\"bc-supports-yes\"> 6.0</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes bc-has-history\"> 7.0.0\n<section class=\"bc-history\" id=\"sect1\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 7.0.0\n</dt>\n\n<dt class=\"bc-supports-yes bc-supports\"> 6.5.0<div class=\"bc-icons\">Disabled </div>\n</dt>\n<dd>Disabled From version 6.5.0: this feature is behind the <code>--harmony</code> runtime flag.</dd>\n</dl></section>\n</td>\n</tr></tbody>\n</table>\n</div>  <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Enumerability_and_ownership_of_properties\">Enumerability and ownership of properties</a></li> <li><a href=\"keys\"><code>Object.keys()</code></a></li> <li><a href=\"values\"><code>Object.values()</code></a></li> <li><a href=\"propertyisenumerable\"><code>Object.prototype.propertyIsEnumerable()</code></a></li> <li><a href=\"create\"><code>Object.create()</code></a></li> <li><a href=\"getownpropertynames\"><code>Object.getOwnPropertyNames()</code></a></li> <li><a href=\"../map/entries\"><code>Map.prototype.entries()</code></a></li> <li><a href=\"../map/keys\"><code>Map.prototype.keys()</code></a></li> <li><a href=\"../map/values\"><code>Map.prototype.values()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/entries$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/entries\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/entries</a>\n  </p>\n</div>\n","global_objects/weakset/add":"<h1>weakSet.add</h1> <p>The <code><strong>add()</strong></code> method appends a new object to the end of a <code>WeakSet</code> object.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/weakset-prototype-add.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js taller\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\"><em>ws</em>.add(value);\n</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt>value</dt> <dd>Required. The object to add to the <code>WeakSet</code> collection.</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p>The <code>WeakSet</code> object.</p> <h2 id=\"Using_the_add_method\">Using the <code>add</code> method</h2> <pre data-language=\"js\">var ws = new WeakSet();\n\nws.add(window); // add the window object to the WeakSet\n\nws.has(window); // true\n\n// Weakset only takes objects as arguments\nws.add(1);\n// results in \"TypeError: Invalid value used in weak set\" in Chrome\n// and \"TypeError: 1 is not a non-null object\" in Firefox</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-weakset.prototype.add\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'WeakSet.prototype.add' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-weakset.prototype.add\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'WeakSet.prototype.add' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 36</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 34</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 23</td>\n<td class=\"bc-supports-yes\"> 9</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 37</td>\n<td class=\"bc-supports-yes\"> 36</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 34</td>\n<td class=\"bc-supports-yes\"> 23</td>\n<td class=\"bc-supports-yes\"> 9</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 0.12</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"../weakset\"><code>WeakSet</code></a></li> <li><a href=\"delete\"><code>WeakSet.prototype.delete()</code></a></li> <li><a href=\"has\"><code>WeakSet.prototype.has()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WeakSet/add$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WeakSet/add\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WeakSet/add</a>\n  </p>\n</div>\n","global_objects/object/fromentries":"<h1>Object.fromEntries</h1> <p>The <code><strong>Object.fromEntries()</strong></code> method transforms a list of key-value pairs into an object.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/object-fromentries.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\">Object.fromEntries(<var>iterable</var>);</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><code>iterable</code></dt> <dd>An iterable such as <a href=\"../array\"><code>Array</code></a> or <a href=\"../map\"><code>Map</code></a> or other objects implementing the <a href=\"../../iteration_protocols#The_iterable_protocol\">iterable protocol</a>.</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p>A new object whose properties are given by the entries of the iterable.</p> <h2 id=\"Description\">Description</h2> <p>The <code>Object.fromEntries()</code> method takes a list of key-value pairs and returns a new object whose properties are given by those entries. The <var>iterable</var> argument is expected to be an object that implements an <code>@@iterator</code> method, that returns an iterator object, that produces a two element array-like object, whose first element is a value that will be used as a property key, and whose second element is the value to associate with that property key.</p> <p><code>Object.fromEntries()</code> performs the reverse of <a href=\"entries\"><code>Object.entries()</code></a>.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Converting_a_Map_to_an_Object\">Converting a <code>Map</code> to an <code>Object</code>\n</h3> <p>With <code>Object.fromEntries</code>, you can convert from <a href=\"../map\"><code>Map</code></a> to <a href=\"../object\"><code>Object</code></a>:</p> <pre data-language=\"js\">const map = new Map([ ['foo', 'bar'], ['baz', 42] ]);\nconst obj = Object.fromEntries(map);\nconsole.log(obj); // { foo: \"bar\", baz: 42 }\n</pre> <h3 id=\"Converting_an_Array_to_an_Object\">Converting an <code>Array</code> to an <code>Object</code>\n</h3> <p>With <code>Object.fromEntries</code>, you can convert from <a href=\"../array\"><code>Array</code></a> to <a href=\"../object\"><code>Object</code></a>:</p> <pre data-language=\"js\">const arr = [ ['0', 'a'], ['1', 'b'], ['2', 'c'] ];\nconst obj = Object.fromEntries(arr);\nconsole.log(obj); // { 0: \"a\", 1: \"b\", 2: \"c\" }\n</pre> <h3 id=\"Object_transformations\">Object transformations</h3> <p>With <code>Object.fromEntries</code>, its reverse method <a href=\"entries\"><code>Object.entries()</code></a>, and <a href=\"../array#Methods_2\">array manipulation methods</a>, you are able to transform objects like this:</p> <pre data-language=\"js\">const object1 = { a: 1, b: 2, c: 3 };\n\nconst object2 = Object.fromEntries(\n  Object.entries(object1)\n  .map(([ key, val ]) =&gt; [ key, val * 2 ])\n);\n\nconsole.log(object2);\n// { a: 2, b: 4, c: 6 }</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <thead> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> </tr> </thead> <tbody> <tr> <td>\n<code><a href=\"https://tc39.github.io/proposal-object-from-entries/#sec-object.fromentries\">Object.fromEntries</a></code> proposal</td> <td>Stage 3</td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 63</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 63</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-no\"> No</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"entries\"><code>Object.entries()</code></a></li> <li><a href=\"keys\"><code>Object.keys()</code></a></li> <li><a href=\"values\"><code>Object.values()</code></a></li> <li><a href=\"../map/entries\"><code>Map.prototype.entries()</code></a></li> <li><a href=\"../map/keys\"><code>Map.prototype.keys()</code></a></li> <li><a href=\"../map/values\"><code>Map.prototype.values()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/fromEntries$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/fromEntries\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/fromEntries</a>\n  </p>\n</div>\n","global_objects/object/getownpropertydescriptors":"<h1>Object.getOwnPropertyDescriptors</h1> <p>The <code><strong>Object.getOwnPropertyDescriptors()</strong></code> method returns all own property descriptors of a given object.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/object-getownpropertydescriptors.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe> <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\">Object.getOwnPropertyDescriptors(<var>obj</var>)</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><code>obj</code></dt> <dd>The object for which to get all own property descriptors.</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p>An object containing all own property descriptors of an object. Might be an empty object, if there are no properties.</p> <h2 id=\"Description\">Description</h2> <p>This method permits examination of the precise description of all own properties of an object. A <dfn>property</dfn> in JavaScript consists of either a string-valued name or a <a href=\"../symbol\"><code>Symbol</code></a> and a property descriptor. Further information about property descriptor types and their attributes can be found in <a href=\"defineproperty\"><code>Object.defineProperty()</code></a>.</p> <p>A <dfn>property descriptor</dfn> is a record with some of the following attributes:</p> <dl> <dt><code>value</code></dt> <dd>The value associated with the property (data descriptors only).</dd> <dt><code><strong>writable</strong></code></dt> <dd>\n<code>true</code> if and only if the value associated with the property may be changed (data descriptors only).</dd> <dt><code>get</code></dt> <dd>A function which serves as a getter for the property, or <a href=\"../undefined\"><code>undefined</code></a> if there is no getter (accessor descriptors only).</dd> <dt><code>set</code></dt> <dd>A function which serves as a setter for the property, or <a href=\"../undefined\"><code>undefined</code></a> if there is no setter (accessor descriptors only).</dd> <dt><code>configurable</code></dt> <dd>\n<code>true</code> if and only if the type of this property descriptor may be changed and if the property may be deleted from the corresponding object.</dd> <dt><code>enumerable</code></dt> <dd>\n<code>true</code> if and only if this property shows up during enumeration of the properties on the corresponding object.</dd> </dl> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Creating_a_shallow_clone\">Creating a shallow clone</h3> <p>Whereas the <a href=\"assign\"><code>Object.assign()</code></a> method will only copy enumerable and own properties from a source object to a target object, you are able to use this method and <a href=\"create\"><code>Object.create()</code></a> for a shallow copy between two unknown objects:</p> <pre data-language=\"js\">Object.create(\n  Object.getPrototypeOf(obj), \n  Object.getOwnPropertyDescriptors(obj) \n);\n</pre> <h3 id=\"Creating_a_subclass\">Creating a subclass</h3> <p>A typical way of creating a subclass is to define the subclass, set its prototype to an instance of the superclass, and then define properties on that instance. This can get awkward especially for getters and setters. Instead, you can use this code to set the prototype:</p> <pre data-language=\"js\">function superclass() {}\nsuperclass.prototype = {\n  // Define your methods and properties here\n};\nfunction subclass() {}\nsubclass.prototype = Object.create(\n  superclass.prototype,\n  {\n    // Define your methods and properties here\n  }\n);\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-object.getownpropertydescriptors\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Object.getOwnPropertyDescriptors' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td>Initial definition in ECMAScript 2017.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/8.0/#sec-object.getownpropertydescriptors\" hreflang=\"en\">ECMAScript 2017 (ECMA-262)<br><small>The definition of 'Object.getOwnPropertyDescriptors' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>   <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 54</td>\n<td class=\"bc-supports-yes\"> 15</td>\n<td class=\"bc-supports-yes\"> 50</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 41</td>\n<td class=\"bc-supports-yes\"> 10</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 54</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 50</td>\n<td> ? </td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 6.0</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes bc-has-history\"> 7.0.0\n<section class=\"bc-history\" id=\"sect1\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 7.0.0\n</dt>\n\n<dt class=\"bc-supports-yes bc-supports\"> 6.5.0<div class=\"bc-icons\">Disabled </div>\n</dt>\n<dd>Disabled From version 6.5.0: this feature is behind the <code>--harmony</code> runtime flag.</dd>\n</dl></section>\n</td>\n</tr></tbody>\n</table>\n</div>  <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"getownpropertydescriptor\"><code>Object.getOwnPropertyDescriptor()</code></a></li> <li><a href=\"defineproperty\"><code>Object.defineProperty()</code></a></li> <li><a href=\"https://github.com/tc39/proposal-object-getownpropertydescriptors\">Polyfill</a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/getOwnPropertyDescriptors$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/getOwnPropertyDescriptors\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/getOwnPropertyDescriptors</a>\n  </p>\n</div>\n","global_objects/weakset/prototype":"<h1>WeakSet.prototype</h1> <p>The <code><strong>WeakSet</strong></code><code>.prototype</code> property represents the prototype for the <a href=\"../weakset\"><code>WeakSet</code></a> constructor.</p> <div class=\"_table\"><table class=\"standard-table\"> <thead> <tr> <th colspan=\"2\" class=\"header\">Property attributes of <code>WeakSet.prototype</code>\n</th> </tr> </thead> <tbody> <tr> <td>Writable</td> <td>no</td> </tr> <tr> <td>Enumerable</td> <td>no</td> </tr> <tr> <td>Configurable</td> <td>no</td> </tr> </tbody> </table></div> <h2 id=\"Description\">Description</h2> <p><a href=\"../weakset\"><code>WeakSet</code></a> instances inherit from <a href=\"prototype\"><code>WeakSet.prototype</code></a>. You can use the constructor's prototype object to add properties or methods to all <code>WeakSet</code> instances.</p> <p><code>WeakSet.prototype</code> is itself just an ordinary object:</p> <pre data-language=\"js\">Object.prototype.toString.call(WeakSet.prototype); // \"[object Object]\"</pre> <h2 id=\"Properties\">Properties</h2> <dl> <dt><code>WeakSet.prototype.constructor</code></dt> <dd>Returns the function that created an instance's prototype. This is the <a href=\"../weakset\"><code>WeakSet</code></a> function by default.</dd> </dl> <h2 id=\"Methods\">Methods</h2> <dl> <dt><a href=\"add\"><code>WeakSet.prototype.add(value)</code></a></dt> <dd>Appends a new object with the given value to the <code>WeakSet</code> object.</dd> <dt><a href=\"delete\"><code>WeakSet.prototype.delete(value)</code></a></dt> <dd>Removes the element associated to the <code>value</code>. <code>WeakSet.prototype.has(value)</code> will return <code>false</code> afterwards.</dd> <dt><a href=\"has\"><code>WeakSet.prototype.has(value)</code></a></dt> <dd>Returns a boolean asserting whether an element is present with the given value in the <code>WeakSet</code> object or not.</dd> <dt><s class=\"obsoleteElement\"><a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WeakSet/clear\"><code>WeakSet.prototype.clear()</code></a> </s></dt> <dd><s class=\"obsoleteElement\">Removes all elements from the <code>WeakSet</code> object.</s></dd> </dl> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-weakset.prototype\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'WeakSet.prototype' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-weakset.prototype\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'WeakSet.prototype' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 36</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 34</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 23</td>\n<td class=\"bc-supports-yes\"> 9</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 37</td>\n<td class=\"bc-supports-yes\"> 36</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 34</td>\n<td class=\"bc-supports-yes\"> 23</td>\n<td class=\"bc-supports-yes\"> 9</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 0.12</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"../set/prototype\"><code>Set.prototype</code></a></li> <li><a href=\"../weakmap/prototype\"><code>WeakMap.prototype</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WeakSet/prototype$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WeakSet/prototype\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WeakSet/prototype</a>\n  </p>\n</div>\n","global_objects/object/freeze":"<h1>Object.freeze</h1> <p>The <code><strong>Object.freeze()</strong></code> method <strong>freezes</strong> an object. A frozen object can no longer be changed; freezing an object prevents new properties from being added to it, existing properties from being removed, prevents changing the enumerability, configurability, or writability of existing properties, and prevents the values of existing properties from being changed. In addition, freezing an object also prevents its prototype from being changed. <code>freeze()</code> returns the same object that was passed in.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/object-freeze.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\">Object.freeze(<var>obj</var>)</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><code>obj</code></dt> <dd>The object to freeze.</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p>The object that was passed to the function.</p> <h2 id=\"Description\">Description</h2> <p>Nothing can be added to or removed from the properties set of a frozen object. Any attempt to do so will fail, either silently or by throwing a <a href=\"../typeerror\"><code>TypeError</code></a> exception (most commonly, but not exclusively, when in <a href=\"../../strict_mode\">strict mode</a>).</p> <p>For data properties of a frozen object, values cannot be changed, the writable and configurable attributes are set to false. Accessor properties (getters and setters) work the same (and still give the illusion that you are changing the value). Note that values that are objects can still be modified, unless they are also frozen. As an object, an array can be frozen; after doing so, its elements cannot be altered and no elements can be added to or removed from the array.</p> <p><code>freeze()</code> returns the same object that was passed into the function. It <em>does not</em> create a frozen copy.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Freezing_objects\">Freezing objects</h3> <pre data-language=\"js\">var obj = {\n  prop: function() {},\n  foo: 'bar'\n};\n\n// New properties may be added, existing properties may be\n// changed or removed\nobj.foo = 'baz';\nobj.lumpy = 'woof';\ndelete obj.prop;\n\n// Both the object being passed as well as the returned\n// object will be frozen. It is unnecessary to save the\n// returned object in order to freeze the original.\nvar o = Object.freeze(obj);\n\no === obj; // true\nObject.isFrozen(obj); // === true\n\n// Now any changes will fail\nobj.foo = 'quux'; // silently does nothing\n// silently doesn't add the property\nobj.quaxxor = 'the friendly duck';\n\n// In strict mode such attempts will throw TypeErrors\nfunction fail(){\n  'use strict';\n  obj.foo = 'sparky'; // throws a TypeError\n  delete obj.foo; // throws a TypeError\n  delete obj.quaxxor; // returns true since attribute 'quaxxor' was never added\n  obj.sparky = 'arf'; // throws a TypeError\n}\n\nfail();\n\n// Attempted changes through Object.defineProperty; \n// both statements below throw a TypeError.\nObject.defineProperty(obj, 'ohai', { value: 17 });\nObject.defineProperty(obj, 'foo', { value: 'eit' });\n\n// It's also impossible to change the prototype\n// both statements below will throw a TypeError.\nObject.setPrototypeOf(obj, { x: 20 })\nobj.__proto__ = { x: 20 }\n</pre> <h3 id=\"Freezing_arrays\">Freezing arrays</h3> <pre data-language=\"js\">let a = [0];\nObject.freeze(a); // The array cannot be modified now.\n\na[0]=1; // fails silently\na.push(2); // fails silently\n\n// In strict mode such attempts will throw TypeErrors\nfunction fail() {\n  \"use strict\"\n  a[0] = 1;\n  a.push(2);\n}\n\nfail();</pre> <p>The object being frozen is <em>immutable</em>. However, it is not necessarily <em>constant</em>. The following example shows that a frozen object is not constant (freeze is shallow).</p> <pre data-language=\"js\">obj1 = {\n  internal: {}\n};\n\nObject.freeze(obj1);\nobj1.internal.a = 'aValue';\n\nobj1.internal.a // 'aValue'</pre> <p>To be a constant object, the entire reference graph (direct and indirect references to other objects) must reference only immutable frozen objects. The object being frozen is said to be immutable because the entire object <em>state</em> (values and references to other objects) within the whole object is fixed. Note that strings, numbers, and booleans are always immutable and that Functions and Arrays are objects.</p> <h4 id=\"What_is_shallow_freeze\">What is \"shallow freeze\"?</h4> <p>The result of calling <code>Object.freeze(<var>object</var>)</code> only applies to the immediate properties of <code>object</code> itself and will prevent future property addition, removal or value re-assignment operations <em>only</em> on <code>object</code>. If the value of those properties are objects themselves, those objects are not frozen and may be the target of property addition, removal or value re-assignment operations.</p> <pre data-language=\"js\">var employee = {\n  name: \"Mayank\",\n  designation: \"Developer\",\n  address: {\n    street: \"Rohini\",\n    city: \"Delhi\"\n  }\n};\n\nObject.freeze(employee);\n\nemployee.name = \"Dummy\"; // fails silently in non-strict mode\nemployee.address.city = \"Noida\"; // attributes of child object can be modified\n\nconsole.log(employee.address.city) // Output: \"Noida\"\n</pre> <p>To make an object immutable, recursively freeze each property which is of type object (deep freeze). Use the pattern on a case-by-case basis based on your design when you know the object contains no <em>Unknown prefix: Cycle_(graph_theory).</em> in the reference graph, otherwise an endless loop will be triggered. An enhancement to <code>deepFreeze()</code> would be to have an internal function that receives a path (e.g. an Array) argument so you can suppress calling <code>deepFreeze()</code> recursively when an object is in the process of being made immutable. You still run a risk of freezing an object that shouldn't be frozen, such as [window].</p> <pre data-language=\"js\">function deepFreeze(object) {\n\n  // Retrieve the property names defined on object\n  var propNames = Object.getOwnPropertyNames(object);\n\n  // Freeze properties before freezing self\n  \n  for (let name of propNames) {\n    let value = object[name];\n\n    object[name] = value &amp;&amp; typeof value === \"object\" ? \n      deepFreeze(value) : value;\n  }\n\n  return Object.freeze(object);\n}\n\nvar obj2 = {\n  internal: {\n    a: null\n  }\n};\n\ndeepFreeze(obj2);\n\nobj2.internal.a = 'anotherValue'; // fails silently in non-strict mode\nobj2.internal.a; // null\n</pre> <h2 id=\"Usage_notes\">Usage notes</h2> <p>In ES5, if the argument to this method is not an object (a primitive), then it will cause a <a href=\"../typeerror\"><code>TypeError</code></a>. In ES2015, a non-object argument will be treated as if it were a frozen ordinary object, and be simply returned.</p> <pre data-language=\"js\">&gt; Object.freeze(1)\nTypeError: 1 is not an object // ES5 code\n\n&gt; Object.freeze(1)\n1                             // ES2015 code\n</pre> <p>An <a href=\"https://developer.mozilla.org/en-US/docs/Web/API/ArrayBufferView\"><code>ArrayBufferView</code></a> with elements will cause a <a href=\"../typeerror\"><code>TypeError</code></a>, as they are views over memory and will definitely cause other possible issues:</p> <pre data-language=\"js\">&gt; Object.freeze(new Uint8Array(0)) // No elements\nUint8Array []\n\n&gt; Object.freeze(new Uint8Array(1)) // Has elements\nTypeError: Cannot freeze array buffer views with elements\n\n&gt; Object.freeze(new DataView(new ArrayBuffer(32))) // No elements\nDataView {}\n\n&gt; Object.freeze(new Float64Array(new ArrayBuffer(64), 63, 0)) // No elements\nFloat64Array []\n\n&gt; Object.freeze(new Float64Array(new ArrayBuffer(64), 32, 2)) // Has elements\nTypeError: Cannot freeze array buffer views with elements\n</pre> <p>Note that; as the standard three properties (<code>buf.byteLength</code>, <code>buf.byteOffset</code> and <code>buf.buffer</code>) are read-only (as are those of an <a href=\"../arraybuffer\"><code>ArrayBuffer</code></a> or <a href=\"../sharedarraybuffer\"><code>SharedArrayBuffer</code></a>), there is no reason for attempting to freeze these properties.</p> <h3 id=\"Comparison_to_Object.seal()\">Comparison to <code>Object.seal()</code>\n</h3> <p>Objects sealed with <a href=\"seal\"><code>Object.seal()</code></a> can have their existing properties changed. Existing properties in objects frozen with <code>Object.freeze()</code> are made immutable.</p> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <thead> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> </thead> <tbody> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/5.1/#sec-15.2.3.9\" hreflang=\"en\">ECMAScript 5.1 (ECMA-262)<br><small>The definition of 'Object.freeze' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition. Implemented in JavaScript 1.8.5.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-object.freeze\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Object.freeze' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-object.freeze\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Object.freeze' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 6</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> 9</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 5.1</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"isfrozen\"><code>Object.isFrozen()</code></a></li> <li><a href=\"preventextensions\"><code>Object.preventExtensions()</code></a></li> <li><a href=\"isextensible\"><code>Object.isExtensible()</code></a></li> <li><a href=\"seal\"><code>Object.seal()</code></a></li> <li><a href=\"issealed\"><code>Object.isSealed()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/freeze$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/freeze\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/freeze</a>\n  </p>\n</div>\n","global_objects/object/is":"<h1>Object.is</h1><p>The <code><strong>Object.is()</strong></code> method determines whether two values are <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Equality_comparisons_and_sameness\">the same value</a>.</p> <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\">Object.is(<var>value1</var>, <var>value2</var>);</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><code>value1</code></dt> <dd>The first value to compare.</dd> <dt><code>value2</code></dt> <dd>The second value to compare.</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p>A <a href=\"../boolean\"><code>Boolean</code></a> indicating whether or not the two arguments are the same value.</p> <h2 id=\"Description\">Description</h2> <p><code>Object.is()</code> determines whether two values are <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Equality_comparisons_and_sameness\">the same value</a>. Two values are the same if one of the following holds:</p> <ul> <li>both <a href=\"../undefined\"><code>undefined</code></a>\n</li> <li>both <a href=\"../null\"><code>null</code></a>\n</li> <li>both <code>true</code> or both <code>false</code>\n</li> <li>both strings of the same length with the same characters in the same order</li> <li>both the same object</li> <li>both numbers and <ul> <li>both <code>+0</code>\n</li> <li>both <code>-0</code>\n</li> <li>both <a href=\"../nan\"><code>NaN</code></a>\n</li> <li>or both non-zero and both not <a href=\"../nan\"><code>NaN</code></a> and both have the same value</li> </ul> </li> </ul> <p>This is <em>not</em> the same as being equal according to the <a href=\"../../operators/comparison_operators#Equality\"><code>==</code></a> operator. The <code>==</code> operator applies various coercions to both sides (if they are not the same Type) before testing for equality (resulting in such behavior as <code>\"\" == false</code> being <code>true</code>), but <code>Object.is</code> doesn't coerce either value.</p> <p>This is also <em>not</em> the same as being equal according to the <a href=\"../../operators/comparison_operators#Identity\"><code>===</code></a> operator. The <code>===</code> operator (and the <code>==</code> operator as well) treats the number values <code>-0</code> and <code>+0</code> as equal and treats <a href=\"../number/nan\"><code>Number.NaN</code></a> as not equal to <a href=\"../nan\"><code>NaN</code></a>.</p> <h2 id=\"Examples\">Examples</h2> <pre data-language=\"js\">Object.is('foo', 'foo');     // true\nObject.is(window, window);   // true\n\nObject.is('foo', 'bar');     // false\nObject.is([], []);           // false\n\nvar test = { a: 1 };\nObject.is(test, test);       // true\n\nObject.is(null, null);       // true\n\n// Special Cases\nObject.is(0, -0);            // false\nObject.is(-0, -0);           // true\nObject.is(NaN, 0/0);         // true\n</pre> <h2 id=\"Polyfill\">Polyfill</h2> <pre data-language=\"js\">if (!Object.is) {\n  Object.is = function(x, y) {\n    // SameValue algorithm\n    if (x === y) { // Steps 1-5, 7-10\n      // Steps 6.b-6.e: +0 != -0\n      return x !== 0 || 1 / x === 1 / y;\n    } else {\n      // Step 6.a: NaN == NaN\n      return x !== x &amp;&amp; y !== y;\n    }\n  };\n}</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <thead> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> </thead> <tbody> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-object.is\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Object.is' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-object.is\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Object.is' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 30</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 22</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 9</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 22</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 9</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 0.10</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li>\n<a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Equality_comparisons_and_sameness\">Equality comparisons and sameness</a> — a comparison of all three built-in sameness facilities</li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is</a>\n  </p>\n</div>\n","global_objects/object/isfrozen":"<h1>Object.isFrozen</h1> <p>The <code><strong>Object.isFrozen()</strong></code> determines if an object is <a href=\"freeze\">frozen</a>.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/object-isfrozen.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\">Object.isFrozen(<var>obj</var>)</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><code>obj</code></dt> <dd>The object which should be checked.</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p>A <a href=\"../boolean\"><code>Boolean</code></a> indicating whether or not the given object is frozen.</p> <h2 id=\"Description\">Description</h2> <p>An object is frozen if and only if it is not <a href=\"isextensible\">extensible</a>, all its properties are non-configurable, and all its data properties (that is, properties which are not accessor properties with getter or setter components) are non-writable.</p> <h2 id=\"Examples\">Examples</h2> <pre data-language=\"js\">// A new object is extensible, so it is not frozen.\nObject.isFrozen({}); // === false\n\n// An empty object which is not extensible\n// is vacuously frozen.\nvar vacuouslyFrozen = Object.preventExtensions({});\nObject.isFrozen(vacuouslyFrozen); // === true\n\n// A new object with one property is also extensible,\n// ergo not frozen.\nvar oneProp = { p: 42 };\nObject.isFrozen(oneProp); // === false\n\n// Preventing extensions to the object still doesn't \n// make it frozen, because the property is still \n// configurable (and writable).\nObject.preventExtensions(oneProp);\nObject.isFrozen(oneProp); // === false\n\n// ...but then deleting that property makes the object\n// vacuously frozen.\ndelete oneProp.p;\nObject.isFrozen(oneProp); // === true\n\n// A non-extensible object with a non-writable\n// but still configurable property is not frozen.\nvar nonWritable = { e: 'plep' };\nObject.preventExtensions(nonWritable);\nObject.defineProperty(nonWritable, 'e', {\n  writable: false\n}); // make non-writable\nObject.isFrozen(nonWritable); // === false\n\n// Changing that property to non-configurable\n// then makes the object frozen.\nObject.defineProperty(nonWritable, 'e', {\n  configurable: false\n}); // make non-configurable\nObject.isFrozen(nonWritable); // === true\n\n// A non-extensible object with a non-configurable\n// but still writable property also isn't frozen.\nvar nonConfigurable = { release: 'the kraken!' };\nObject.preventExtensions(nonConfigurable);\nObject.defineProperty(nonConfigurable, 'release', {\n  configurable: false\n});\nObject.isFrozen(nonConfigurable); // === false\n\n// Changing that property to non-writable\n// then makes the object frozen.\nObject.defineProperty(nonConfigurable, 'release', {\n  writable: false\n});\nObject.isFrozen(nonConfigurable); // === true\n\n// A non-extensible object with a configurable\n// accessor property isn't frozen.\nvar accessor = { get food() { return 'yum'; } };\nObject.preventExtensions(accessor);\nObject.isFrozen(accessor); // === false\n\n// ...but make that property non-configurable\n// and it becomes frozen.\nObject.defineProperty(accessor, 'food', {\n  configurable: false\n});\nObject.isFrozen(accessor); // === true\n\n// But the easiest way for an object to be frozen\n// is if Object.freeze has been called on it.\nvar frozen = { 1: 81 };\nObject.isFrozen(frozen); // === false\nObject.freeze(frozen);\nObject.isFrozen(frozen); // === true\n\n// By definition, a frozen object is non-extensible.\nObject.isExtensible(frozen); // === false\n\n// Also by definition, a frozen object is sealed.\nObject.isSealed(frozen); // === true\n</pre> <h2 id=\"Notes\">Notes</h2> <p>In ES5, if the argument to this method is not an object (a primitive), then it will cause a <a href=\"../typeerror\"><code>TypeError</code></a>. In ES2015, a non-object argument will be treated as if it was a frozen ordinary object, simply return <code>true</code>.</p> <pre data-language=\"js\">Object.isFrozen(1);\n// TypeError: 1 is not an object (ES5 code)\n\nObject.isFrozen(1);\n// true                          (ES2015 code)\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/5.1/#sec-15.2.3.12\" hreflang=\"en\">ECMAScript 5.1 (ECMA-262)<br><small>The definition of 'Object.isFrozen' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition. Implemented in JavaScript 1.8.5.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-object.isfrozen\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Object.isFrozen' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-object.isfrozen\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Object.isFrozen' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>   <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 6</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> 9</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 5.1</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div>  <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"freeze\"><code>Object.freeze()</code></a></li> <li><a href=\"preventextensions\"><code>Object.preventExtensions()</code></a></li> <li><a href=\"isextensible\"><code>Object.isExtensible()</code></a></li> <li><a href=\"seal\"><code>Object.seal()</code></a></li> <li><a href=\"issealed\"><code>Object.isSealed()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/isFrozen$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/isFrozen\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/isFrozen</a>\n  </p>\n</div>\n","global_objects/object/create":"<h1>Object.create</h1> <p>The <code><strong>Object.create()</strong></code> method creates a new object, using an existing object as the prototype of the newly created object.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/object-create.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\">Object.create(<var>proto</var>[, <var>propertiesObject</var>])</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><var>proto</var></dt> <dd>The object which should be the prototype of the newly-created object.</dd> <dt><var>propertiesObject</var></dt> <dd>Optional. If specified and not <a href=\"../undefined\"><code>undefined</code></a>, an object whose enumerable own properties (that is, those properties defined upon itself and <em>not</em> enumerable properties along its prototype chain) specify property descriptors to be added to the newly-created object, with the corresponding property names. These properties correspond to the second argument of <a href=\"defineproperties\"><code>Object.defineProperties()</code></a>.</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p>A new object with the specified prototype object and properties.</p> <h3 id=\"Exceptions\">Exceptions</h3> <p>A <a href=\"../typeerror\"><code>TypeError</code></a> exception if the <code>propertiesObject</code> parameter is <a href=\"../null\"><code>null</code></a> or a non-primitive-wrapper object.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Classical_inheritance_with_Object.create()\">Classical inheritance with <code>Object.create()</code>\n</h3> <p>Below is an example of how to use <code>Object.create()</code> to achieve classical inheritance. This is for single inheritance, which is all that JavaScript supports.</p> <pre data-language=\"js\">// Shape - superclass\nfunction Shape() {\n  this.x = 0;\n  this.y = 0;\n}\n\n// superclass method\nShape.prototype.move = function(x, y) {\n  this.x += x;\n  this.y += y;\n  console.info('Shape moved.');\n};\n\n// Rectangle - subclass\nfunction Rectangle() {\n  Shape.call(this); // call super constructor.\n}\n\n// subclass extends superclass\nRectangle.prototype = Object.create(Shape.prototype);\nRectangle.prototype.constructor = Rectangle;\n\nvar rect = new Rectangle();\n\nconsole.log('Is rect an instance of Rectangle?',\n  rect instanceof Rectangle); // true\nconsole.log('Is rect an instance of Shape?',\n  rect instanceof Shape); // true\nrect.move(1, 1); // Outputs, 'Shape moved.'\n</pre> <p>If you wish to inherit from multiple objects, then mixins are a possibility.</p> <pre data-language=\"js\">function MyClass() {\n  SuperClass.call(this);\n  OtherSuperClass.call(this);\n}\n\n// inherit one class\nMyClass.prototype = Object.create(SuperClass.prototype);\n// mixin another\nObject.assign(MyClass.prototype, OtherSuperClass.prototype);\n// re-assign constructor\nMyClass.prototype.constructor = MyClass;\n\nMyClass.prototype.myMethod = function() {\n  // do something\n};\n</pre> <p><a href=\"assign\"><code>Object.assign()</code></a> copies properties from the OtherSuperClass prototype to the MyClass prototype, making them available to all instances of MyClass. <code>Object.assign()</code> was introduced with ES2015 and <a href=\"assign#Polyfill\">can be polyfilled</a>. If support for older browsers is necessary, <code><a href=\"https://api.jquery.com/jQuery.extend/\">jQuery.extend()</a></code> or <code><a href=\"https://lodash.com/docs/#assign\">_.assign()</a></code> can be used.</p> <h3 id=\"Using_propertiesObject_argument_with_Object.create()\">Using <code>propertiesObject</code> argument with <code>Object.create()</code>\n</h3> <pre data-language=\"js\">var o;\n\n// create an object with null as prototype\no = Object.create(null);\n\n\no = {};\n// is equivalent to:\no = Object.create(Object.prototype);\n\n\n// Example where we create an object with a couple of\n// sample properties. (Note that the second parameter\n// maps keys to *property descriptors*.)\no = Object.create(Object.prototype, {\n  // foo is a regular 'value property'\n  foo: {\n    writable: true,\n    configurable: true,\n    value: 'hello'\n  },\n  // bar is a getter-and-setter (accessor) property\n  bar: {\n    configurable: false,\n    get: function() { return 10; },\n    set: function(value) {\n      console.log('Setting `o.bar` to', value);\n    }\n/* with ES2015 Accessors our code can look like this\n    get() { return 10; },\n    set(value) {\n      console.log('Setting `o.bar` to', value);\n    } */\n  }\n});\n\n\nfunction Constructor() {}\no = new Constructor();\n// is equivalent to:\no = Object.create(Constructor.prototype);\n// Of course, if there is actual initialization code\n// in the Constructor function, \n// the Object.create() cannot reflect it\n\n\n// Create a new object whose prototype is a new, empty\n// object and add a single property 'p', with value 42.\no = Object.create({}, { p: { value: 42 } });\n\n// by default properties ARE NOT writable,\n// enumerable or configurable:\no.p = 24;\no.p;\n// 42\n\no.q = 12;\nfor (var prop in o) {\n  console.log(prop);\n}\n// 'q'\n\ndelete o.p;\n// false\n\n// to specify an ES3 property\no2 = Object.create({}, {\n  p: {\n    value: 42,\n    writable: true,\n    enumerable: true,\n    configurable: true\n  }\n});\n</pre> <h2 id=\"Custom_and_Null_objects\">Custom and Null objects</h2> <p>A new object created from a completely custom object (especially one created from the <code>null</code> object, which is basically a custom object with NO members) can behave in unexpected ways. This is especially true when debugging, since common object-property converting/detecting utility functions may generate errors, or simply lose information (especially if using silent error-traps that ignore errors). For example, here are two objects:</p> <pre data-language=\"js\">oco = Object.create( {} );   // create a normal object\nocn = Object.create( null ); // create a \"null\" object\n\n&gt; console.log(oco) // {} -- Seems normal\n&gt; console.log(ocn) // {} -- Seems normal here too, so far\n\noco.p = 1; // create a simple property on normal obj\nocn.p = 0; // create a simple property on \"null\" obj\n\n&gt; console.log(oco) // {p: 1} -- Still seems normal\n&gt; console.log(ocn) // {p: 0} -- Still seems normal here too. BUT WAIT...\n</pre> <p><br> As shown above, all seems normal so far. However, when attempting to actually use these objects, their differences quickly become apparent:</p> <pre data-language=\"js\">&gt; \"oco is: \" + oco // shows \"ocn is: [object Object]\"\n\n&gt; \"ocn is: \" + ocn // throws error: Cannot convert object to primitive value\n</pre> <p><br> Testing just a few of the many most basic built-in functions shows the magnitude of the problem more clearly:</p> <pre data-language=\"js\">&gt; alert(oco) // shows [object Object]\n&gt; alert(ocn) // throws error: Cannot convert object to primitive value\n\n&gt; oco.toString() // shows [object Object]\n&gt; ocn.toString() // throws error: ocn.toString is not a function\n\n&gt; oco.valueOf() // shows {}\n&gt; ocn.valueOf() // throws error: ocn.valueOf is not a function\n\n&gt; oco.hasOwnProperty(\"p\") // shows \"true\"\n&gt; ocn.hasOwnProperty(\"p\") // throws error: ocn.hasOwnProperty is not a function\n\n&gt; oco.constructor // shows \"Object() { [native code] }\"\n&gt; ocn.constructor // shows \"undefined\"\n</pre> <p><br> As said, these differences can make debugging even simple-seeming problems quickly go astray. For example:</p> <p><em>A simple common debugging function:</em></p> <pre data-language=\"js\">// display top-level property name:value pairs of given object\nfunction ShowProperties( b ){\n  for( var i in b ){  console.log( i + \": \" + b[i] + \"\\n\" )  }\n}</pre> <p><br> <em>Not such simple results: (especially if silent error-trapping had hidden the error messages)</em></p> <pre data-language=\"js\">ob={}; ob.po=oco; ob.pn=ocn; // create a compound object using the test objects from above as property values\n\n&gt; ShowProperties( ob ) // display top-level properties\n- po: [object Object]\n- Error: Cannot convert object to primitive value\n\nNote that only first property gets shown.\n</pre> <p><br> <em>(But if same object is created simply in different order -- at least in some implementations...)</em></p> <pre data-language=\"js\">ob={}; ob.pn=ocn; ob.po=oco; // create same compound object again, but create same properties in different order\n\n&gt; ShowProperties( ob ) // display top-level properties\n- Error: Cannot convert object to primitive value\n\nNote that neither property gets shown.</pre> <p>Note that such a different order may arise statically via disparate fixed codings such as here, but also dynamically via whatever the order any such property-adding code-branches actually get executed at runtime as depends on inputs and/or random-variables. Then again, the actual iteration order is not guaranteed no matter what the order members are added.</p> <h4 id=\"Some_NON-solutions\">Some NON-solutions</h4> <p>A good solution for the missing object-methods is not immediately apparent.</p> <p>Adding the missing object-method directly from the standard-object does NOT work:</p> <pre data-language=\"js\">ocn = Object.create( null ); // create \"null\" object (same as before)\n\nocn.toString = Object.toString; // since new object lacks method then try assigning it directly from standard-object\n\n<span style=\"letter-spacing: -0.00333rem;\">&gt; ocn.toString // shows \"toString() { [native code] }\" -- missing method seems to be there now</span>\n&gt; ocn.toString == Object.toString // shows \"true\" -- method seems to be same as the standard object-method\n\n&gt; ocn.toString() // error: Function.prototype.toString requires that 'this' be a Function\n</pre> <p><br> Adding the missing object-method directly to new object's \"prototype\" does not work either, since new object does not have a real prototype (which is really the cause of ALL these problems) and one cannot be <strong>directly</strong> added:</p> <pre data-language=\"js\">ocn = Object.create( null ); // create \"null\" object (same as before)\n\nocn.prototype.toString = Object.toString; // Error: Cannot set property 'toString' of undefined\n\nocn.prototype = {};                       // try to create a prototype\nocn.prototype.toString = Object.toString; // since new object lacks method then try assigning it from standard-object  <span style=\"letter-spacing: -0.00333rem;\">\n\n&gt; ocn.toString() // error: ocn.toString is not a function</span>\n</pre> <p><br> Adding the missing object-method by using the standard-objectas new object's prototype does not work either:</p> <pre data-language=\"js\">ocn = Object.create( null );        // create \"null\" object (same as before) \nObject.setPrototypeOf(ocn, Object); // set new object's prototype to the standard-object\n\n&gt; ocn.toString() // error: Function.prototype.toString requires that 'this' be a Function\n</pre> <h4 id=\"Some_OK_solutions\">Some OK solutions</h4> <p>Again, adding the missing object-method directly from the <strong>standard-object </strong>does NOT work. However, adding the <strong>generic</strong> method directly, DOES:</p> <pre data-language=\"js\">ocn = Object.create( null ); // create \"null\" object (same as before)\n\nocn.toString = toString; // since new object lacks method then assign it directly from generic version\n\n&gt; ocn.toString() // shows \"[object Object]\"\n&gt; \"ocn is: \" + ocn // shows \"ocn is: [object Object]\"\n\n\nob={}; ob.pn=ocn; ob.po=oco; // create a compound object (same as before)\n\n&gt; ShowProperties(ob) // display top-level properties\n- po: [object Object]\n- pn: [object Object]\n</pre> <p>However, setting the generic <strong>prototype</strong> as the new object's prototype works even better:</p> <pre data-language=\"js\">ocn = Object.create( null );                  // create \"null\" object (same as before)\nObject.setPrototypeOf(ocn, Object.prototype); // set new object's prototype to the \"generic\" object (NOT standard-object)\n</pre> <p><em>(In addition to all the string-related functions shown above, this also adds:)</em></p> <pre data-language=\"js\">&gt; ocn.valueOf() // shows {}\n&gt; ocn.hasOwnProperty(\"x\") // shows \"false\"\n&gt; ocn.constructor // shows \"Object() { [native code] }\"\n\n// ...and all the rest of the properties and methods of Object.prototype.\n</pre> <p>As shown, objects modified this way now look very much like ordinary objects.</p> <h2 id=\"Polyfill\">Polyfill</h2> <p>This polyfill covers the main use case, which is creating a new object for which the prototype has been chosen but doesn't take the second argument into account.</p> <p>Note that while the setting of <code>null</code> as <code>[[Prototype]]</code> is supported in the real ES5 <code>Object.create</code>, this polyfill cannot support it due to a limitation inherent in versions of ECMAScript lower than 5.</p> <pre data-language=\"js\"> if (typeof Object.create !== \"function\") {\n    Object.create = function (proto, propertiesObject) {\n        if (typeof proto !== 'object' &amp;&amp; typeof proto !== 'function') {\n            throw new TypeError('Object prototype may only be an Object: ' + proto);\n        } else if (proto === null) {\n            throw new Error(\"This browser's implementation of Object.create is a shim and doesn't support 'null' as the first argument.\");\n        }\n\n        if (typeof propertiesObject != 'undefined') {\n            throw new Error(\"This browser's implementation of Object.create is a shim and doesn't support a second argument.\");\n        }\n\n        function F() {}\n        F.prototype = proto;\n\n        return new F();\n    };\n}\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <thead> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> </thead> <tbody> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/5.1/#sec-15.2.3.5\" hreflang=\"en\">ECMAScript 5.1 (ECMA-262)<br><small>The definition of 'Object.create' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition. Implemented in JavaScript 1.8.5.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-object.create\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Object.create' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-object.create\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Object.create' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>   <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 5</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> 9</td>\n<td class=\"bc-supports-yes\"> 11.6</td>\n<td class=\"bc-supports-yes\"> 5</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> 11.5</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div>  <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"defineproperty\"><code>Object.defineProperty()</code></a></li> <li><a href=\"defineproperties\"><code>Object.defineProperties()</code></a></li> <li><a href=\"isprototypeof\"><code>Object.prototype.isPrototypeOf()</code></a></li> <li><a href=\"../reflect/construct\"><code>Reflect.construct()</code></a></li> <li>John Resig's post on <a href=\"http://ejohn.org/blog/objectgetprototypeof/\">getPrototypeOf()</a>\n</li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/create$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/create\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/create</a>\n  </p>\n</div>\n","global_objects/object/issealed":"<h1>Object.isSealed</h1> <p>The <code><strong>Object.isSealed()</strong></code> method determines if an object is sealed.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/object-issealed.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\">Object.isSealed(<var>obj</var>)</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><code>obj</code></dt> <dd>The object which should be checked.</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p>A <a href=\"../boolean\"><code>Boolean</code></a> indicating whether or not the given object is sealed.</p> <h2 id=\"Description\">Description</h2> <p>Returns <code>true</code> if the object is sealed, otherwise <code>false</code>. An object is sealed if it is not <a href=\"isextensible\">extensible</a> and if all its properties are non-configurable and therefore not removable (but not necessarily non-writable).</p> <h2 id=\"Examples\">Examples</h2> <pre data-language=\"js\">// Objects aren't sealed by default.\nvar empty = {};\nObject.isSealed(empty); // === false\n\n// If you make an empty object non-extensible,\n// it is vacuously sealed.\nObject.preventExtensions(empty);\nObject.isSealed(empty); // === true\n\n// The same is not true of a non-empty object,\n// unless its properties are all non-configurable.\nvar hasProp = { fee: 'fie foe fum' };\nObject.preventExtensions(hasProp);\nObject.isSealed(hasProp); // === false\n\n// But make them all non-configurable\n// and the object becomes sealed.\nObject.defineProperty(hasProp, 'fee', {\n  configurable: false\n});\nObject.isSealed(hasProp); // === true\n\n// The easiest way to seal an object, of course,\n// is Object.seal.\nvar sealed = {};\nObject.seal(sealed);\nObject.isSealed(sealed); // === true\n\n// A sealed object is, by definition, non-extensible.\nObject.isExtensible(sealed); // === false\n\n// A sealed object might be frozen,\n// but it doesn't have to be.\nObject.isFrozen(sealed); // === true \n// (all properties also non-writable)\n\nvar s2 = Object.seal({ p: 3 });\nObject.isFrozen(s2); // === false \n// ('p' is still writable)\n\nvar s3 = Object.seal({ get p() { return 0; } });\nObject.isFrozen(s3); // === true\n// (only configurability matters for accessor properties)\n</pre> <h2 id=\"Notes\">Notes</h2> <p>In ES5, if the argument to this method is not an object (a primitive), then it will cause a <a href=\"../typeerror\"><code>TypeError</code></a>. In ES2015, a non-object argument will be treated as if it was a sealed ordinary object, simply return <code>true</code>.</p> <pre data-language=\"js\">Object.isSealed(1);\n// TypeError: 1 is not an object (ES5 code)\n\nObject.isSealed(1);\n// true                          (ES2015 code)\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/5.1/#sec-15.2.3.11\" hreflang=\"en\">ECMAScript 5.1 (ECMA-262)<br><small>The definition of 'Object.isSealed' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition. Implemented in JavaScript 1.8.5.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-object.issealed\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Object.isSealed' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-object.issealed\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Object.isSealed' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>   <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 6</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> 9</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 5.1</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div>  <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"seal\"><code>Object.seal()</code></a></li> <li><a href=\"preventextensions\"><code>Object.preventExtensions()</code></a></li> <li><a href=\"isextensible\"><code>Object.isExtensible()</code></a></li> <li><a href=\"freeze\"><code>Object.freeze()</code></a></li> <li><a href=\"isfrozen\"><code>Object.isFrozen()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/isSealed$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/isSealed\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/isSealed</a>\n  </p>\n</div>\n","global_objects/weakset/delete":"<h1>weakSet.delete</h1> <p>The <code><strong>delete()</strong></code> method removes the specified element from a <code>WeakSet</code> object.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/weakset-prototype-delete.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\"><em>ws</em>.delete(value);</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt>value</dt> <dd>Required. The object remove from the <code>WeakSet</code> object.</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p><code>true</code> if an element in the <code>WeakMap</code> object has been removed successfully. <code>false</code> if the key is not found in the <code>WeakMap</code> or if the key is not an object.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Using_the_delete_method\">Using the <code>delete</code> method</h3> <pre data-language=\"js\">var ws = new WeakSet();\nvar obj = {};\n\nws.add(window);\n\nws.delete(obj);    // Returns false. No obj found to be deleted.\nws.delete(window); // Returns true.  Successfully removed.\n\nws.has(window);    // Returns false. The window is no longer present in the WeakSet.\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-weakset.prototype.delete\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'WeakSet.prototype.delete' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-weakset.prototype.delete\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'WeakSet.prototype.delete' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 36</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 34</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 23</td>\n<td class=\"bc-supports-yes\"> 9</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 37</td>\n<td class=\"bc-supports-yes\"> 36</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 34</td>\n<td class=\"bc-supports-yes\"> 23</td>\n<td class=\"bc-supports-yes\"> 9</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 0.12</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"../weakset\"><code>WeakSet</code></a></li> <li><a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WeakSet/clear\"><code>WeakSet.prototype.clear()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WeakSet/delete$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WeakSet/delete\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WeakSet/delete</a>\n  </p>\n</div>\n","global_objects/weakset/has":"<h1>weakSet.has</h1> <p>The <code><strong>has()</strong></code> method returns a boolean indicating whether an object exists in a <code>WeakSet</code> or not.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/weakset-prototype-has.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\"><em>ws</em>.has(value);</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt>value</dt> <dd>Required. The object to test for presence in the <code>WeakSet</code>.</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <dl> <dt>Boolean</dt> <dd>Returns <code>true</code> if an element with the specified value exists in the <code>WeakSet</code> object; otherwise <code>false</code>.</dd> </dl> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Using_the_has_method\">Using the <code>has</code> method</h3> <pre data-language=\"js\">var ws = new WeakSet();\nvar obj = {};\nws.add(window);\n\nmySet.has(window);  // returns true\nmySet.has(obj);     // returns false\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-weakset.prototype.has\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'WeakSet.prototype.has' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-weakset.prototype.has\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'WeakSet.prototype.has' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 36</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 34</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 23</td>\n<td class=\"bc-supports-yes\"> 9</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 37</td>\n<td class=\"bc-supports-yes\"> 36</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 34</td>\n<td class=\"bc-supports-yes\"> 23</td>\n<td class=\"bc-supports-yes\"> 9</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 0.12</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"../weakset\"><code>WeakSet</code></a></li> <li><a href=\"add\"><code>WeakSet.prototype.add()</code></a></li> <li><a href=\"delete\"><code>WeakSet.prototype.delete()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WeakSet/has$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WeakSet/has\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WeakSet/has</a>\n  </p>\n</div>\n","global_objects/weakmap/delete":"<h1>weakMap.delete</h1> <p>The <code><strong>delete()</strong></code> method removes the specified element from a <code>WeakMap</code> object.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/weakmap-prototype-delete.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\"><em>wm</em>.delete(key);</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt>key</dt> <dd>Required. The key of the element to remove from the <code>WeakMap</code> object.</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p><code>true</code> if an element in the <code>WeakMap</code> object has been removed successfully. <code>false</code> if the key is not found in the <code>WeakMap</code> or if the key is not an object.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Using_the_delete_method\">Using the <code>delete</code> method</h3> <pre data-language=\"js\">var wm = new WeakMap();\nwm.set(window, 'foo');\n\nwm.delete(window); // Returns true. Successfully removed.\n\nwm.has(window);    // Returns false. The window object is no longer in the WeakMap.\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-weakmap.prototype.delete\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'WeakMap.prototype.delete' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-weakmap.prototype.delete\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'WeakMap.prototype.delete' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 36</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes bc-has-history\"> 6\n<section class=\"bc-history\" id=\"sect1\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 6\n</dt>\n<dd> Prior to Firefox 38, this method threw a <code>TypeError</code> when the key parameter was not an object. This has been fixed in version 38 and later to return <code>false</code> as per the ES2015 standard.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-yes\"> 11</td>\n<td class=\"bc-supports-yes\"> 23</td>\n<td class=\"bc-supports-yes\"> 8</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 37</td>\n<td class=\"bc-supports-yes\"> 36</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes bc-has-history\"> 6\n<section class=\"bc-history\" id=\"sect2\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 6\n</dt>\n<dd> Prior to Firefox 38, this method threw a <code>TypeError</code> when the key parameter was not an object. This has been fixed in version 38 and later to return <code>false</code> as per the ES2015 standard.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-yes\"> 23</td>\n<td class=\"bc-supports-yes\"> 8</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes bc-has-history\"> 0.12\n<section class=\"bc-history\" id=\"sect3\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 0.12\n</dt>\n\n<dt class=\"bc-supports-yes bc-supports\"> 0.10<div class=\"bc-icons\">Disabled </div>\n</dt>\n<dd>Disabled From version 0.10: this feature is behind the <code>--harmony</code> runtime flag.</dd>\n</dl></section>\n</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"../weakmap\"><code>WeakMap</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WeakMap/delete$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WeakMap/delete\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WeakMap/delete</a>\n  </p>\n</div>\n","global_objects/weakmap/has":"<h1>weakMap.has</h1> <p>The <code><strong>has()</strong></code> method returns a boolean indicating whether an element with the specified key exists in the <code>WeakMap</code> object or not.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/weakmap-prototype-has.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\"><em>wm</em>.has(key);</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt>key</dt> <dd>Required. The key of the element to test for presence in the <code>WeakMap</code> object.</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <dl> <dt>Boolean</dt> <dd>Returns <code>true</code> if an element with the specified key exists in the <code>WeakMap</code> object; otherwise <code>false</code>.</dd> </dl> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Using_the_has_method\">Using the <code>has</code> method</h3> <pre data-language=\"js\">var wm = new WeakMap();\nwm.set(window, 'foo');\n\nwm.has(window); // returns true\nwm.has('baz');  // returns false\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-weakmap.prototype.has\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'WeakMap.prototype.has' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-weakmap.prototype.has\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'WeakMap.prototype.has' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 36</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes bc-has-history\"> 6\n<section class=\"bc-history\" id=\"sect1\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 6\n</dt>\n<dd> Prior to Firefox 38, this method threw a <code>TypeError</code> when the key parameter was not an object. This has been fixed in version 38 and later to return <code>false</code> as per the ES2015 standard.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-yes\"> 11</td>\n<td class=\"bc-supports-yes\"> 23</td>\n<td class=\"bc-supports-yes\"> 8</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 37</td>\n<td class=\"bc-supports-yes\"> 36</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes bc-has-history\"> 6\n<section class=\"bc-history\" id=\"sect2\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 6\n</dt>\n<dd> Prior to Firefox 38, this method threw a <code>TypeError</code> when the key parameter was not an object. This has been fixed in version 38 and later to return <code>false</code> as per the ES2015 standard.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-yes\"> 23</td>\n<td class=\"bc-supports-yes\"> 8</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes bc-has-history\"> 0.12\n<section class=\"bc-history\" id=\"sect3\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 0.12\n</dt>\n\n<dt class=\"bc-supports-yes bc-supports\"> 0.10<div class=\"bc-icons\">Disabled </div>\n</dt>\n<dd>Disabled From version 0.10: this feature is behind the <code>--harmony</code> runtime flag.</dd>\n</dl></section>\n</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"../weakmap\"><code>WeakMap</code></a></li> <li><a href=\"set\"><code>WeakMap.prototype.set()</code></a></li> <li><a href=\"get\"><code>WeakMap.prototype.get()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WeakMap/has$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WeakMap/has\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WeakMap/has</a>\n  </p>\n</div>\n","global_objects/object/keys":"<h1>Object.keys</h1> <p>The <code><strong>Object.keys()</strong></code> method returns an array of a given object's own property <code>names</code>, in the same order as we get with a normal loop.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/object-keys.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\">Object.keys(<var>obj</var>)</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><code>obj</code></dt> <dd>The object of which the enumerable's own properties are to be returned.</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p>An array of strings that represent all the enumerable properties of the given object.</p> <h2 id=\"Description\">Description</h2> <p><code>Object.keys()</code> returns an array whose elements are strings corresponding to the enumerable properties found directly upon <code>object</code>. The ordering of the properties is the same as that given by looping over the properties of the object manually.</p> <h2 id=\"Examples\">Examples</h2> <pre data-language=\"js\">// simple array\nvar arr = ['a', 'b', 'c'];\nconsole.log(Object.keys(arr)); // console: ['0', '1', '2']\n\n// array like object\nvar obj = { 0: 'a', 1: 'b', 2: 'c' };\nconsole.log(Object.keys(obj)); // console: ['0', '1', '2']\n\n// array like object with random key ordering\nvar anObj = { 100: 'a', 2: 'b', 7: 'c' };\nconsole.log(Object.keys(anObj)); // console: ['2', '7', '100']\n\n// getFoo is a property which isn't enumerable\nvar myObj = Object.create({}, {\n  getFoo: {\n    value: function () { return this.foo; }\n  } \n});\nmyObj.foo = 1;\nconsole.log(Object.keys(myObj)); // console: ['foo']\n</pre> <p>If you want all properties, even non-enumerables, see <a href=\"getownpropertynames\"><code>Object.getOwnPropertyNames()</code></a>.</p> <h2 id=\"Notes\">Notes</h2> <p>In ES5, if the argument to this method is not an object (a primitive), then it will cause a <a href=\"../typeerror\"><code>TypeError</code></a>. In ES2015, a non-object argument will be coerced to an object.</p> <pre data-language=\"js\">Object.keys('foo');\n// TypeError: \"foo\" is not an object (ES5 code)\n\nObject.keys('foo');\n// [\"0\", \"1\", \"2\"]                   (ES2015 code)\n</pre> <h2 id=\"Polyfill\">Polyfill</h2> <p>To add compatible <code>Object.keys</code> support in older environments that do not natively support it, copy the following snippet:</p> <pre data-language=\"js\">// From https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/keys\nif (!Object.keys) {\n  Object.keys = (function() {\n    'use strict';\n    var hasOwnProperty = Object.prototype.hasOwnProperty,\n        hasDontEnumBug = !({ toString: null }).propertyIsEnumerable('toString'),\n        dontEnums = [\n          'toString',\n          'toLocaleString',\n          'valueOf',\n          'hasOwnProperty',\n          'isPrototypeOf',\n          'propertyIsEnumerable',\n          'constructor'\n        ],\n        dontEnumsLength = dontEnums.length;\n\n    return function(obj) {\n      if (typeof obj !== 'function' &amp;&amp; (typeof obj !== 'object' || obj === null)) {\n        throw new TypeError('Object.keys called on non-object');\n      }\n\n      var result = [], prop, i;\n\n      for (prop in obj) {\n        if (hasOwnProperty.call(obj, prop)) {\n          result.push(prop);\n        }\n      }\n\n      if (hasDontEnumBug) {\n        for (i = 0; i &lt; dontEnumsLength; i++) {\n          if (hasOwnProperty.call(obj, dontEnums[i])) {\n            result.push(dontEnums[i]);\n          }\n        }\n      }\n      return result;\n    };\n  }());\n}\n</pre> <p>Please note that the above code includes non-enumerable keys in IE7 (and maybe IE8), when passing in an object from a different window.</p> <p>For a simple Browser Polyfill, see <a href=\"http://tokenposts.blogspot.com.au/2012/04/javascript-objectkeys-browser.html\">Javascript - Object.keys Browser Compatibility</a>.</p> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <thead> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> </thead> <tbody> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/5.1/#sec-15.2.3.14\" hreflang=\"en\">ECMAScript 5.1 (ECMA-262)<br><small>The definition of 'Object.keys' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition. Implemented in JavaScript 1.8.5.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-object.keys\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Object.keys' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-object.keys\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Object.keys' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>   <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 5</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> 9</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 5</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div>  <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Enumerability_and_ownership_of_properties\">Enumerability and ownership of properties</a></li> <li><a href=\"propertyisenumerable\"><code>Object.prototype.propertyIsEnumerable()</code></a></li> <li><a href=\"create\"><code>Object.create()</code></a></li> <li><a href=\"getownpropertynames\"><code>Object.getOwnPropertyNames()</code></a></li> <li><a href=\"values\"><code>Object.values()</code></a></li> <li><a href=\"entries\"><code>Object.entries()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/keys$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/keys\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/keys</a>\n  </p>\n</div>\n","global_objects/object/seal":"<h1>Object.seal</h1> <p>The <code><strong>Object.seal()</strong></code> method seals an object, preventing new properties from being added to it and marking all existing properties as non-configurable. Values of present properties can still be changed as long as they are writable.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/object-prototype-seal.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\">Object.seal(<var>obj</var>)</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><var>obj</var></dt> <dd>The object which should be sealed.<br> It can be a Function or other non-primitive value.</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p>The object being sealed.</p> <h2 id=\"Description\">Description</h2> <p>By default, objects are <a href=\"isextensible\">extensible</a> (new properties can be added to them). Sealing an object prevents new properties from being added and marks all existing properties as non-configurable. This has the effect of making the set of properties on the object fixed and immutable. Making all properties non-configurable also prevents them from being converted from data properties to accessor properties and vice versa, but it does not prevent the values of data properties from being changed. Attempting to delete or add properties to a sealed object, or to convert a data property to accessor or vice versa, will fail, either silently or by throwing a <a href=\"../typeerror\"><code>TypeError</code></a> (most commonly, although not exclusively, when in <a href=\"../../strict_mode\">strict mode</a> code).</p> <p>The prototype chain remains untouched. However, the <a href=\"proto\"><code>__proto__</code></a>  property is sealed as well.</p> <p>Returns a reference to the passed object.</p> <h2 id=\"Examples\">Examples</h2> <pre data-language=\"js\">var obj = {\n  prop: function() {},\n  foo: 'bar'\n};\n\n// New properties may be added, existing properties\n// may be changed or removed.\nobj.foo = 'baz';\nobj.lumpy = 'woof';\ndelete obj.prop;\n\nvar o = Object.seal(obj);\n\no === obj; // true\nObject.isSealed(obj); // === true\n\n// Changing property values on a sealed object\n// still works.\nobj.foo = 'quux';\n\n// But you can't convert data properties to accessors,\n// or vice versa.\nObject.defineProperty(obj, 'foo', {\n  get: function() { return 'g'; }\n}); // throws a TypeError\n\n// Now any changes, other than to property values,\n// will fail.\nobj.quaxxor = 'the friendly duck';\n// silently doesn't add the property\ndelete obj.foo;\n// silently doesn't delete the property\n\n// ...and in strict mode such attempts\n// will throw TypeErrors.\nfunction fail() {\n  'use strict';\n  delete obj.foo; // throws a TypeError\n  obj.sparky = 'arf'; // throws a TypeError\n}\nfail();\n\n// Attempted additions through\n// Object.defineProperty will also throw.\nObject.defineProperty(obj, 'ohai', {\n  value: 17\n}); // throws a TypeError\nObject.defineProperty(obj, 'foo', {\n  value: 'eit'\n}); // changes existing property value\n</pre> <h2 id=\"Notes\">Notes</h2> <p>In ES5, if the argument to this method is not an object (a primitive), then it will cause a <a href=\"../typeerror\"><code>TypeError</code></a>. In ES2015, a non-object argument will be treated as if it was a sealed ordinary object, simply return it.</p> <pre data-language=\"js\">Object.seal(1);\n// TypeError: 1 is not an object (ES5 code)\n\nObject.seal(1);\n// 1                             (ES2015 code)\n</pre> <h3 id=\"Comparison_to_Object.freeze()\">Comparison to <code>Object.freeze()</code>\n</h3> <p>Existing properties in objects frozen with <a href=\"freeze\"><code>Object.freeze()</code></a> are made immutable. Objects sealed with <code>Object.seal()</code> can have their existing properties changed.</p> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <thead> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> </thead> <tbody> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/5.1/#sec-15.2.3.8\" hreflang=\"en\">ECMAScript 5.1 (ECMA-262)<br><small>The definition of 'Object.seal' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition. Implemented in JavaScript 1.8.5.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-object.seal\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Object.seal' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-object.seal\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Object.seal' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 6</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> 9</td>\n<td class=\"bc-supports-yes\"> 12</td>\n<td class=\"bc-supports-yes\"> 5.1</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"issealed\"><code>Object.isSealed()</code></a></li> <li><a href=\"preventextensions\"><code>Object.preventExtensions()</code></a></li> <li><a href=\"isextensible\"><code>Object.isExtensible()</code></a></li> <li><a href=\"freeze\"><code>Object.freeze()</code></a></li> <li><a href=\"isfrozen\"><code>Object.isFrozen()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/seal$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/seal\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/seal</a>\n  </p>\n</div>\n","global_objects/weakmap/prototype":"<h1>WeakMap.prototype</h1> <p>The <code><strong>WeakMap</strong></code><code>.prototype</code> property represents the prototype for the <a href=\"../weakmap\"><code>WeakMap</code></a> constructor.</p> <div class=\"_table\"><table class=\"standard-table\"> <thead> <tr> <th colspan=\"2\" class=\"header\">Property attributes of <code>WeakMap.prototype</code>\n</th> </tr> </thead> <tbody> <tr> <td>Writable</td> <td>no</td> </tr> <tr> <td>Enumerable</td> <td>no</td> </tr> <tr> <td>Configurable</td> <td>no</td> </tr> </tbody> </table></div> <h2 id=\"Description\">Description</h2> <p><a href=\"../weakmap\"><code>WeakMap</code></a> instances inherit from <a href=\"prototype\"><code>WeakMap.prototype</code></a>. You can use the constructor's prototype object to add properties or methods to all <code>WeakMap</code> instances.</p> <p><code>WeakMap.prototype</code> is itself just an ordinary object:</p> <pre data-language=\"js\">Object.prototype.toString.call(WeakMap.prototype); // \"[object Object]\"</pre> <h2 id=\"Properties\">Properties</h2> <dl> <dt><code>WeakMap.prototype.constructor</code></dt> <dd>Returns the function that created an instance's prototype. This is the <a href=\"../weakmap\"><code>WeakMap</code></a> function by default.</dd> </dl> <h2 id=\"Methods\">Methods</h2> <dl> <dt><a href=\"delete\"><code>WeakMap.prototype.delete(key)</code></a></dt> <dd>Removes any value associated to the <code>key</code>. <code>WeakMap.prototype.has(key)</code> will return <code>false</code> afterwards.</dd> <dt><a href=\"get\"><code>WeakMap.prototype.get(key)</code></a></dt> <dd>Returns the value associated to the <code>key</code>, or <code>undefined</code> if there is none.</dd> <dt><a href=\"has\"><code>WeakMap.prototype.has(key)</code></a></dt> <dd>Returns a Boolean asserting whether a value has been associated to the <code>key</code> in the <code>WeakMap</code> object or not.</dd> <dt><a href=\"set\"><code>WeakMap.prototype.set(key, value)</code></a></dt> <dd>Sets the value for the <code>key</code> in the <code>WeakMap</code> object. Returns the <code>WeakMap</code> object.</dd> <dt><s class=\"obsoleteElement\"><a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WeakMap/clear\"><code>WeakMap.prototype.clear()</code></a> </s></dt> <dd><s class=\"obsoleteElement\">Removes all key/value pairs from the <code>WeakMap</code> object. Note that it is possible to implement a <code>WeakMap</code>-like object that has a <code>.clear()</code> method by encapsulating a <code>WeakMap</code> object that hasn't it (see example on page <a href=\"../weakmap\"><code>WeakMap</code></a>)</s></dd> </dl> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-weakmap.prototype\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'WeakMap.prototype' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-weakmap.prototype\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'WeakMap.prototype' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 36</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 6</td>\n<td class=\"bc-supports-yes\"> 11</td>\n<td class=\"bc-supports-yes\"> 23</td>\n<td class=\"bc-supports-yes\"> 8</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 37</td>\n<td class=\"bc-supports-yes\"> 36</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 6</td>\n<td class=\"bc-supports-yes\"> 23</td>\n<td class=\"bc-supports-yes\"> 8</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes bc-has-history\"> 0.12\n<section class=\"bc-history\" id=\"sect1\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 0.12\n</dt>\n\n<dt class=\"bc-supports-yes bc-supports\"> 0.10<div class=\"bc-icons\">Disabled </div>\n</dt>\n<dd>Disabled From version 0.10: this feature is behind the <code>--harmony</code> runtime flag.</dd>\n</dl></section>\n</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"../map/prototype\"><code>Map.prototype</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WeakMap/prototype$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WeakMap/prototype\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WeakMap/prototype</a>\n  </p>\n</div>\n","global_objects/weakmap/get":"<h1>weakMap.get</h1> <p>The <code><strong>get()</strong></code> method returns a specified element from a <code>WeakMap</code> object.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/weakmap-prototype-get.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\"><em>wm</em>.get(key);</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt>key</dt> <dd>Required. The key of the element to return from the <code>WeakMap</code> object.</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p>The element associated with the specified key in the <code>WeakMap</code> object. If the key can't be found, <a href=\"../undefined\"><code>undefined</code></a> is returned.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Using_the_get_method\">Using the <code>get</code> method</h3> <pre data-language=\"js\">var wm = new WeakMap();\nwm.set(window, 'foo');\n\nwm.get(window); // Returns \"foo\".\nwm.get('baz');  // Returns undefined.\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-weakmap.prototype.get\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'WeakMap.prototype.get' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-weakmap.prototype.get\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'WeakMap.prototype.get' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 36</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes bc-has-history\"> 6\n<section class=\"bc-history\" id=\"sect1\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 6\n</dt>\n<dd> Prior to Firefox 38, this method threw a <code>TypeError</code> when the key parameter was not an object. However, the ES2015 specification specifies to return <code>undefined</code> instead. Furthermore, <code>WeakMap.prototype.get</code> accepted an optional second argument as a fallback value, which is not part of the standard. Both non-standard behaviors are removed in version 38 and higher.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-yes\"> 11</td>\n<td class=\"bc-supports-yes\"> 23</td>\n<td class=\"bc-supports-yes\"> 8</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 37</td>\n<td class=\"bc-supports-yes\"> 36</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes bc-has-history\"> 6\n<section class=\"bc-history\" id=\"sect2\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 6\n</dt>\n<dd> Prior to Firefox 38, this method threw a <code>TypeError</code> when the key parameter was not an object. However, the ES2015 specification specifies to return <code>undefined</code> instead. Furthermore, <code>WeakMap.prototype.get</code> accepted an optional second argument as a fallback value, which is not part of the standard. Both non-standard behaviors are removed in version 38 and higher.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-yes\"> 23</td>\n<td class=\"bc-supports-yes\"> 8</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes bc-has-history\"> 0.12\n<section class=\"bc-history\" id=\"sect3\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 0.12\n</dt>\n\n<dt class=\"bc-supports-yes bc-supports\"> 0.10<div class=\"bc-icons\">Disabled </div>\n</dt>\n<dd>Disabled From version 0.10: this feature is behind the <code>--harmony</code> runtime flag.</dd>\n</dl></section>\n</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"../weakmap\"><code>WeakMap</code></a></li> <li><a href=\"set\"><code>WeakMap.set()</code></a></li> <li><a href=\"has\"><code>WeakMap.has()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WeakMap/get$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WeakMap/get\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WeakMap/get</a>\n  </p>\n</div>\n","global_objects/webassembly/compilestreaming":"<h1>WebAssembly.compileStreaming</h1> <p>The <code>WebAssembly.compileStreaming()</code> function compiles a <a href=\"module\"><code>WebAssembly.Module</code></a> directly from a streamed underlying source. This function is useful if it is necessary to a compile a module before it can be instantiated (otherwise, the <a href=\"instantiatestreaming\"><code>WebAssembly.instantiateStreaming()</code></a> function should be used).</p> <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\">Promise&lt;WebAssembly.Module&gt; WebAssembly.compileStreaming(<em>source</em>);</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><em>source</em></dt> <dd>A <a href=\"https://developer.mozilla.org/en-US/docs/Web/API/Response\"><code>Response</code></a> object or a promise that will fulfill with one, representing the underlying source of a .wasm module you want to stream and compile.</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p>A <code>Promise</code> that resolves to a <a href=\"module\"><code>WebAssembly.Module</code></a> object representing the compiled module.</p> <h3 id=\"Exceptions\">Exceptions</h3> <ul> <li>If <code>bufferSource</code> is not a <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Typed_arrays\">typed array</a>, a <a href=\"../typeerror\"><code>TypeError</code></a> is thrown.</li> <li>If compilation fails, the promise rejects with a <a href=\"compileerror\"><code>WebAssembly.CompileError</code></a>.</li> </ul> <h2 id=\"Examples\">Examples</h2> <p>The following example (see our <a href=\"https://github.com/mdn/webassembly-examples/blob/master/js-api-examples/compile-streaming.html\">compile-streaming.html</a> demo on GitHub, and <a href=\"https://mdn.github.io/webassembly-examples/js-api-examples/compile-streaming.html\">view it live</a> also) directly streams a .wasm module from an underlying source then compiles it to a <a href=\"module\"><code>WebAssembly.Module</code></a> object. Because the <code>compileStreaming()</code> function accepts a promise for a <a href=\"https://developer.mozilla.org/en-US/docs/Web/API/Response\"><code>Response</code></a> object, you can directly pass it a <a href=\"https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/fetch\"><code>WindowOrWorkerGlobalScope.fetch()</code></a> call, and it will pass the response into the function when it fulfills.</p> <pre data-language=\"js\">var importObject = { imports: { imported_func: arg =&gt; console.log(arg) } };\n\nWebAssembly.compileStreaming(fetch('simple.wasm'))\n.then(module =&gt; WebAssembly.instantiate(module, importObject))\n.then(instance =&gt; instance.exports.exported_func());</pre> <p>The resulting module instance is then instantiated using <a href=\"instantiate\"><code>WebAssembly.instantiate()</code></a>, and the exported function invoked.</p> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <thead> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> </thead> <tbody> <tr> <td><a href=\"https://github.com/WebAssembly/design/blob/master/Web.md#webassemblycompilestreaming\" hreflang=\"en\">WebAssembly features for web embedding<br><small>The definition of 'compileStreaming()' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td>Initial draft definition.</td> </tr> </tbody> </table></div> <h2 name=\"Browser_compatibility\" id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>   <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 61</td>\n<td class=\"bc-supports-yes\"> 16</td>\n<td class=\"bc-supports-yes\"> 58</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 47</td>\n<td class=\"bc-supports-no\"> No</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 61</td>\n<td class=\"bc-supports-yes\"> 61</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 58</td>\n<td> ? </td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-no\"> No</td>\n</tr></tbody>\n</table>\n</div>  <h2 id=\"See_also\">See also</h2> <ul> <li>\n<a href=\"https://developer.mozilla.org/en-US/docs/WebAssembly\">WebAssembly</a> overview page</li> <li><a href=\"https://developer.mozilla.org/en-US/docs/WebAssembly/Concepts\">WebAssembly concepts</a></li> <li><a href=\"https://developer.mozilla.org/en-US/docs/WebAssembly/Using_the_JavaScript_API\">Using the WebAssembly JavaScript API</a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/compileStreaming$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/compileStreaming\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/compileStreaming</a>\n  </p>\n</div>\n","global_objects/webassembly/global":"<h1>WebAssembly.global</h1> <p>A <code>WebAssembly.Global</code> object represents a global variable instance, accessible from both JavaScript and importable/exportable across one or more <a href=\"module\"><code>WebAssembly.Module</code></a> instances. This allows dynamic linking of multiple modules.</p> <h2 id=\"Constructor_Syntax\">Constructor Syntax</h2> <pre class=\"syntaxbox\">var myGlobal = new WebAssembly.Global(<em>descriptor</em>, <em>value</em>);</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><em>descriptor</em></dt> <dd>A <code>GlobalDescriptor</code> dictionary object, which contains two properties: <ul> <li>\n<code>value</code>: A <a href=\"https://developer.mozilla.org/en-US/docs/Web/API/USVString\"><code>USVString</code></a> representing the data type of the global. This can be one of <code>i32</code>, <code>i64</code>, <code>f32</code>, and <code>f64</code>.</li> <li>\n<code>mutable</code>: A boolean value that determines whether the global is mutable or not. By default, this is <code>false</code>.</li> </ul> </dd> <dt><em>value</em></dt> <dd>The value the variable contains. This can be any value, as long as its type matches the variable's data type. If no value is specified, a typed 0 value is used, as specified by the <a href=\"https://webassembly.github.io/spec/js-api/#defaultvalue\"><code>DefaultValue</code> algorithm</a>.</dd> </dl> <h2 id=\"Function_properties_of_the_Global_constructor\">Function properties of the Global constructor</h2> <p>None.</p> <h2 id=\"Global_instances\">Global instances</h2> <p>All <code>Global</code> instances inherit from the <code>Global()</code> constructor's <a href=\"global/prototype\">prototype object</a> — this can be modified to affect all <code>Global</code> instances.</p> <h3 id=\"Instance_properties\">Instance properties</h3> <dl> <dt><code>Global.prototype.constructor</code></dt> <dd>Returns the function that created this object's instance. By default this is the <a href=\"global\"><code>WebAssembly.Global()</code></a> constructor.</dd> <dt><code>Global.prototype[@@toStringTag]</code></dt> <dd>The initial value of the <a href=\"../symbol/tostringtag\">@@toStringTag</a> property is the String value \"WebAssembly.Global\".</dd> <dt><code>Global.prototype.value</code></dt> <dd>The value contained inside the global variable — this can be used to directly set and get the global's value.</dd> </dl> <h3 id=\"Instance_methods\">Instance methods</h3> <dl> <dt><code>Global.prototype.valueOf()</code></dt> <dd>Old-style method that returns the value contained inside the global variable.</dd> </dl> <h2 id=\"Examples\">Examples</h2> <p>The following example shows a new global instance being created using the <code>WebAssembly.Global()</code> constructor. It is being defined as a mutable <code>i32</code> type, with a value of 0.</p> <p>The value of the global is then changed, first to <code>42</code> using the <code>Global.value</code> property, and then to 43 using the <code>incGlobal()</code> function exported out of the <code>global.wasm</code> module (this adds 1 to whatever value is given to it and then returns the new value).</p> <pre data-language=\"js\">const output = document.getElementById('output');\n\nfunction assertEq(msg, got, expected) {\n    output.innerHTML += `Testing ${msg}: `;\n    if (got !== expected)\n        output.innerHTML += `FAIL!&lt;br&gt;Got: ${got}&lt;br&gt;Expected: ${expected}&lt;br&gt;`;\n    else\n        output.innerHTML += `SUCCESS! Got: ${got}&lt;br&gt;`;\n}\n\nassertEq(\"WebAssembly.Global exists\", typeof WebAssembly.Global, \"function\");\n\nconst global = new WebAssembly.Global({value:'i32', mutable:true}, 0);\n\nWebAssembly.instantiateStreaming(fetch('global.wasm'), { js: { global } })\n.then(({instance}) =&gt; {\n    assertEq(\"getting initial value from wasm\", instance.exports.getGlobal(), 0);\n    global.value = 42;\n    assertEq(\"getting JS-updated value from wasm\", instance.exports.getGlobal(), 42);\n    instance.exports.incGlobal();\n    assertEq(\"getting wasm-updated value from JS\", global.value, 43);\n});</pre> <div class=\"note\"> <p><strong>Note</strong>: You can see the example <a href=\"https://mdn.github.io/webassembly-examples/js-api-examples/global.html\">running live on GitHub</a>; see also the <a href=\"https://github.com/mdn/webassembly-examples/blob/master/js-api-examples/global.html\">source code</a>.</p> </div> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <thead> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> </thead> <tbody> <tr> <td><a href=\"https://webassembly.github.io/spec/js-api/#globals\" hreflang=\"en\">WebAssembly JavaScript Interface<br><small>The definition of 'WebAssembly.Global()' in that specification.</small></a></td> <td><span class=\"spec-WD\">Working Draft</span></td> <td>Initial draft definition.</td> </tr> </tbody> </table></div> <h2 name=\"Browser_compatibility\" id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>   <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 69</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 62</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Global/value\"><code>value</code></a></th>\n<td class=\"bc-supports-yes\"> 69</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 62</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Global/valueOf\"><code>valueOf</code></a></th>\n<td class=\"bc-supports-yes\"> 69</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 62</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n</tr>\n</tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 69</td>\n<td class=\"bc-supports-yes\"> 69</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 62</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Global/value\"><code>value</code></a></th>\n<td class=\"bc-supports-yes\"> 69</td>\n<td class=\"bc-supports-yes\"> 69</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 62</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Global/valueOf\"><code>valueOf</code></a></th>\n<td class=\"bc-supports-yes\"> 69</td>\n<td class=\"bc-supports-yes\"> 69</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 62</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n</tr>\n</tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-no\"> No</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Global/value\"><code>value</code></a></th>\n<td class=\"bc-supports-no\"> No</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Global/valueOf\"><code>valueOf</code></a></th>\n<td class=\"bc-supports-no\"> No</td>\n</tr>\n</tbody>\n</table>\n</div>  <h2 id=\"See_also\">See also</h2> <ul> <li>\n<a href=\"https://developer.mozilla.org/en-US/docs/WebAssembly\">WebAssembly</a> overview page</li> <li><a href=\"https://developer.mozilla.org/en-US/docs/WebAssembly/Concepts\">WebAssembly concepts</a></li> <li><a href=\"https://developer.mozilla.org/en-US/docs/WebAssembly/Using_the_JavaScript_API\">Using the WebAssembly JavaScript API</a></li> <li><a href=\"https://github.com/WebAssembly/mutable-global/blob/master/proposals/mutable-global/Overview.md\">Import/Export mutable globals proposal</a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Global$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Global\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Global</a>\n  </p>\n</div>\n","global_objects/webassembly/compile":"<h1>WebAssembly.compile</h1> <p>The <code>WebAssembly.compile()</code> function compiles a <a href=\"module\"><code>WebAssembly.Module</code></a> from WebAssembly binary code. This function is useful if it is necessary to a compile a module before it can be instantiated (otherwise, the <a href=\"instantiate\"><code>WebAssembly.instantiate()</code></a> function should be used).</p> <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\">Promise&lt;WebAssembly.Module&gt; WebAssembly.compile(bufferSource);</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><em>bufferSource</em></dt> <dd>A <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Typed_arrays\">typed array</a> or <a href=\"../arraybuffer\">ArrayBuffer</a> containing the binary code of the .wasm module you want to compile.</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p>A <code>Promise</code> that resolves to a <a href=\"module\"><code>WebAssembly.Module</code></a> object representing the compiled module.</p> <h3 id=\"Exceptions\">Exceptions</h3> <ul> <li>If <code>bufferSource</code> is not a <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Typed_arrays\">typed array</a>, a <a href=\"../typeerror\"><code>TypeError</code></a> is thrown.</li> <li>If compilation fails, the promise rejects with a <a href=\"compileerror\"><code>WebAssembly.CompileError</code></a>.</li> </ul> <h2 id=\"Examples\">Examples</h2> <p>The following example compiles the loaded simple.wasm byte code using the <code>compile()</code> function and then sends it to a <a href=\"https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API\">worker</a> using <a href=\"https://developer.mozilla.org/en-US/docs/Web/API/Worker/postMessage\">postMessage()</a>.</p> <pre data-language=\"js\">var worker = new Worker(\"wasm_worker.js\");\n\nfetch('simple.wasm').then(response =&gt;\n  response.arrayBuffer()\n).then(bytes =&gt;\n  WebAssembly.compile(bytes)\n).then(mod =&gt;\n  worker.postMessage(mod)\n);</pre> <div class=\"note\"> <p><strong>Note</strong>: You'll probably want to use <a href=\"compilestreaming\"><code>WebAssembly.compileStreaming()</code></a> in most cases, as it is more efficient than <code>compile()</code>.</p> </div> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <thead> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> </thead> <tbody> <tr> <td><a href=\"https://webassembly.github.io/spec/js-api/#webassemblycompile\" hreflang=\"en\">WebAssembly JavaScript Interface<br><small>The definition of 'compile()' in that specification.</small></a></td> <td><span class=\"spec-WD\">Working Draft</span></td> <td>Initial draft definition.</td> </tr> </tbody> </table></div> <h2 name=\"Browser_compatibility\" id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>   <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 57</td>\n<td class=\"bc-supports-yes\"> 16</td>\n<td class=\"bc-supports-yes bc-has-history\"> 52\n<section class=\"bc-history\" id=\"sect1\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 52\n</dt>\n<dd> Disabled in the Firefox 52 Extended Support Release (ESR).</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 44</td>\n<td class=\"bc-supports-yes\"> 11</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 57</td>\n<td class=\"bc-supports-yes\"> 57</td>\n<td class=\"bc-supports-yes bc-has-history\"> Yes<div class=\"bc-icons\">Disabled </div>\n<section class=\"bc-history\" id=\"sect2\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> Yes<div class=\"bc-icons\">Disabled </div>\n</dt>\n<dd>Disabled This feature is behind the <code>Experimental JavaScript Features</code> preference.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-yes bc-has-history\"> 52\n<section class=\"bc-history\" id=\"sect3\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 52\n</dt>\n<dd> Disabled in the Firefox 52 Extended Support Release (ESR).</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-yes\"> 44</td>\n<td class=\"bc-supports-yes\"> 11</td>\n<td class=\"bc-supports-yes\"> 7.0</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 8.0.0</td>\n</tr></tbody>\n</table>\n</div>  <h2 id=\"See_also\">See also</h2> <ul> <li>\n<a href=\"https://developer.mozilla.org/en-US/docs/WebAssembly\">WebAssembly</a> overview page</li> <li><a href=\"https://developer.mozilla.org/en-US/docs/WebAssembly/Concepts\">WebAssembly concepts</a></li> <li><a href=\"https://developer.mozilla.org/en-US/docs/WebAssembly/Using_the_JavaScript_API\">Using the WebAssembly JavaScript API</a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/compile$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/compile\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/compile</a>\n  </p>\n</div>\n","global_objects/object/values":"<h1>Object.values</h1> <p>The <code><strong>Object.values()</strong></code> method returns an array of a given object's own enumerable property values, in the same order as that provided by a <a href=\"../../statements/for...in\"><code>for...in</code></a> loop (the difference being that a for-in loop enumerates properties in the prototype chain as well).</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/object-values.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\">Object.values(<var>obj</var>)</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><code>obj</code></dt> <dd>The object whose enumerable own property values are to be returned.</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p>An array containing the given object's own enumerable property values.</p> <h2 id=\"Description\">Description</h2> <p><code>Object.values()</code> returns an array whose elements are the enumerable property values found on the object. The ordering of the properties is the same as that given by looping over the property values of the object manually.</p> <h2 id=\"Examples\">Examples</h2> <pre data-language=\"js\">var obj = { foo: 'bar', baz: 42 };\nconsole.log(Object.values(obj)); // ['bar', 42]\n\n// array like object\nvar obj = { 0: 'a', 1: 'b', 2: 'c' };\nconsole.log(Object.values(obj)); // ['a', 'b', 'c']\n\n// array like object with random key ordering\n// when we use numeric keys, the value returned in a numerical order according to the keys\nvar an_obj = { 100: 'a', 2: 'b', 7: 'c' };\nconsole.log(Object.values(an_obj)); // ['b', 'c', 'a']\n\n// getFoo is property which isn't enumerable\nvar my_obj = Object.create({}, { getFoo: { value: function() { return this.foo; } } });\nmy_obj.foo = 'bar';\nconsole.log(Object.values(my_obj)); // ['bar']\n\n// non-object argument will be coerced to an object\nconsole.log(Object.values('foo')); // ['f', 'o', 'o']\n</pre> <h2 id=\"Polyfill\">Polyfill</h2> <p>To add compatible <code>Object.values</code> support in older environments that do not natively support it, you can find a Polyfill in the <a href=\"https://github.com/tc39/proposal-object-values-entries\">tc39/proposal-object-values-entries</a> or in the <a href=\"https://github.com/es-shims/Object.values\">es-shims/Object.values</a> repositories.</p> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-object.values\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Object.values' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/8.0/#sec-object.values\" hreflang=\"en\">ECMAScript 2017 (ECMA-262)<br><small>The definition of 'Object.values' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>   <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 54</td>\n<td class=\"bc-supports-yes\"> 14</td>\n<td class=\"bc-supports-yes\"> 47</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 41</td>\n<td class=\"bc-supports-yes\"> 10.1</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 54</td>\n<td class=\"bc-supports-yes\"> 54</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 47</td>\n<td class=\"bc-supports-yes\"> 41</td>\n<td class=\"bc-supports-yes\"> 10.3</td>\n<td class=\"bc-supports-yes\"> 6.0</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes bc-has-history\"> 7.0.0\n<section class=\"bc-history\" id=\"sect1\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 7.0.0\n</dt>\n\n<dt class=\"bc-supports-yes bc-supports\"> 6.5.0<div class=\"bc-icons\">Disabled </div>\n</dt>\n<dd>Disabled From version 6.5.0: this feature is behind the <code>--harmony</code> runtime flag.</dd>\n</dl></section>\n</td>\n</tr></tbody>\n</table>\n</div>  <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Enumerability_and_ownership_of_properties\">Enumerability and ownership of properties</a></li> <li><a href=\"keys\"><code>Object.keys()</code></a></li> <li><a href=\"entries\"><code>Object.entries()</code></a></li> <li><a href=\"propertyisenumerable\"><code>Object.prototype.propertyIsEnumerable()</code></a></li> <li><a href=\"create\"><code>Object.create()</code></a></li> <li><a href=\"getownpropertynames\"><code>Object.getOwnPropertyNames()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/values$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/values\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/values</a>\n  </p>\n</div>\n","global_objects/weakmap/set":"<h1>weakMap.set</h1> <p>The <code><strong>set()</strong></code> method adds a new element with a specified <code>key</code> and <code>value</code> to a <code>WeakMap</code> object.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/weakmap-prototype-set.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\"><em>wm</em>.set(key, value);</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt>key</dt> <dd>Required. The key of the element to add to the <code>WeakMap</code> object.</dd> <dt>value</dt> <dd>Required. The value of the element to add to the <code>WeakMap</code> object.</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p>The <code>WeakMap</code> object.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Using_the_set_method\">Using the <code>set</code> method</h3> <pre data-language=\"js\">var wm = new WeakMap();\nvar obj = {};\n\n// Add new elements to the WeakMap\nwm.set(obj, 'foo').set(window, 'bar'); // chainable\n\n// Update an element in the WeakMap\nwm.set(obj, 'baz');\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-weakmap.prototype.set\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'WeakMap.prototype.set' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-weakmap.prototype.set\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'WeakMap.prototype.set' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 36</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes bc-has-history\"> 6\n<section class=\"bc-history\" id=\"sect1\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 6\n</dt>\n<dd> Prior to Firefox 38, this method threw a <code>TypeError</code> when the key parameter was not an object. This has been fixed in version 38 and later to return <code>false</code> as per the ES2015 standard.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-partial bc-has-history\">11\n<section class=\"bc-history\" id=\"sect2\"><dl>\n<dt class=\"bc-supports-partial bc-supports\">11\n</dt>\n<dd> Returns 'undefined' instead of the 'Map' object.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-yes\"> 23</td>\n<td class=\"bc-supports-yes\"> 8</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 37</td>\n<td class=\"bc-supports-yes\"> 36</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes bc-has-history\"> 6\n<section class=\"bc-history\" id=\"sect3\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 6\n</dt>\n<dd> Prior to Firefox 38, this method threw a <code>TypeError</code> when the key parameter was not an object. This has been fixed in version 38 and later to return <code>false</code> as per the ES2015 standard.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-yes\"> 23</td>\n<td class=\"bc-supports-yes\"> 8</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes bc-has-history\"> 0.12\n<section class=\"bc-history\" id=\"sect4\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 0.12\n</dt>\n\n<dt class=\"bc-supports-yes bc-supports\"> 0.10<div class=\"bc-icons\">Disabled </div>\n</dt>\n<dd>Disabled From version 0.10: this feature is behind the <code>--harmony</code> runtime flag.</dd>\n</dl></section>\n</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"Firefox-specific_notes\">Firefox-specific notes</h2> <ul> <li>Prior to Firefox 33 (Firefox 33 / Thunderbird 33 / SeaMonkey 2.30), <code>WeakMap.prototype.set</code> returned <code>undefined</code> and was not chainable. This has been fixed (<a href=\"https://bugzilla.mozilla.org/show_bug.cgi?id=1031632\">bug 1031632</a>). The behavior can be found in Chrome/v8 as well (<a href=\"https://code.google.com/p/v8/issues/detail?id=3410\">issue</a>).</li> </ul> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"../weakmap\"><code>WeakMap</code></a></li> <li><a href=\"get\"><code>WeakMap.prototype.get()</code></a></li> <li><a href=\"has\"><code>WeakMap.prototype.has()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WeakMap/set$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WeakMap/set\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WeakMap/set</a>\n  </p>\n</div>\n","global_objects/webassembly/validate":"<h1>WebAssembly.validate</h1> <p>The <code>WebAssembly.validate()</code> function validates a given <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Typed_arrays\">typed array</a> of WebAssembly binary code, returning whether the bytes form a valid wasm module (<code>true</code>) or not (<code>false</code>).</p> <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\">WebAssembly.validate(bufferSource);</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><code>bufferSource</code></dt> <dd>A <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Typed_arrays\">typed array</a> or <a href=\"../arraybuffer\">ArrayBuffer</a> containing WebAssembly binary code to be validated.</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p>A boolean that specifies whether <code>bufferSource</code> is valid wasm code (<code>true</code>) or not (<code>false</code>).</p> <h3 id=\"Exceptions\">Exceptions</h3> <p>If <code>bufferSource</code> is not a <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Typed_arrays\">typed array</a> or <a href=\"../arraybuffer\">ArrayBuffer</a>, a <a href=\"../typeerror\"><code>TypeError</code></a> is thrown.</p> <h2 id=\"Examples\">Examples</h2> <p>The following example (see the validate.html <a href=\"https://github.com/mdn/webassembly-examples/blob/master/js-api-examples/validate.html\">source code</a>, and <a href=\"https://mdn.github.io/webassembly-examples/js-api-examples/validate.html\">see it live too</a>) fetches a .wasm module and converts it into a typed array. The <code>validate()</code> method is then used to check whether the module is valid.</p> <pre data-language=\"js\">fetch('simple.wasm').then(response =&gt;\n  response.arrayBuffer()\n).then(function(bytes) {\n  var valid = WebAssembly.validate(bytes);\n  console.log(\"The given bytes are \"\n    + (valid ? \"\" : \"not \") + \"a valid wasm module\");\n});\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <thead> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> </thead> <tbody> <tr> <td><a href=\"https://webassembly.github.io/spec/js-api/#webassemblyvalidate\" hreflang=\"en\">WebAssembly JavaScript Interface<br><small>The definition of 'validate()' in that specification.</small></a></td> <td><span class=\"spec-WD\">Working Draft</span></td> <td>Initial draft definition.</td> </tr> </tbody> </table></div> <h2 name=\"Browser_compatibility\" id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>   <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 57</td>\n<td class=\"bc-supports-yes\"> 16</td>\n<td class=\"bc-supports-yes bc-has-history\"> 52\n<section class=\"bc-history\" id=\"sect1\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 52\n</dt>\n<dd> Disabled in the Firefox 52 Extended Support Release (ESR).</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 44</td>\n<td class=\"bc-supports-yes\"> 11</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 57</td>\n<td class=\"bc-supports-yes\"> 57</td>\n<td class=\"bc-supports-yes bc-has-history\"> Yes<div class=\"bc-icons\">Disabled </div>\n<section class=\"bc-history\" id=\"sect2\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> Yes<div class=\"bc-icons\">Disabled </div>\n</dt>\n<dd>Disabled This feature is behind the <code>Experimental JavaScript Features</code> preference.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-yes bc-has-history\"> 52\n<section class=\"bc-history\" id=\"sect3\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 52\n</dt>\n<dd> Disabled in the Firefox 52 Extended Support Release (ESR).</dd>\n</dl></section>\n</td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 11</td>\n<td class=\"bc-supports-yes\"> 7.0</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 8.0.0</td>\n</tr></tbody>\n</table>\n</div>  <h2 id=\"See_also\">See also</h2> <ul> <li>\n<a href=\"https://developer.mozilla.org/en-US/docs/WebAssembly\">WebAssembly</a> overview page</li> <li><a href=\"https://developer.mozilla.org/en-US/docs/WebAssembly/Concepts\">WebAssembly concepts</a></li> <li><a href=\"https://developer.mozilla.org/en-US/docs/WebAssembly/Using_the_JavaScript_API\">Using the WebAssembly JavaScript API</a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/validate$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/validate\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/validate</a>\n  </p>\n</div>\n","global_objects/webassembly/instantiatestreaming":"<h1>WebAssembly.instantiateStreaming</h1> <p>The <code>WebAssembly.instantiateStreaming()</code> function compiles and instantiates a WebAssembly module directly from a streamed underlying source. This is the most efficient, optimized way to load wasm code.</p> <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\">Promise&lt;ResultObject&gt; WebAssembly.instantiateStreaming(<em>source</em>, <em>importObject</em>);</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><em>source</em></dt> <dd>A <a href=\"https://developer.mozilla.org/en-US/docs/Web/API/Response\"><code>Response</code></a> object or a promise that will fulfill with one, representing the underlying source of a .wasm module you want to stream, compile, and instantiate.</dd> <dt>\n<em>importObject</em> <span class=\"inlineIndicator optional optionalInline\">Optional</span>\n</dt> <dd>An object containing the values to be imported into the newly-created <code>Instance</code>, such as functions or <a href=\"memory\"><code>WebAssembly.Memory</code></a> objects. There must be one matching property for each declared import of the compiled module or else a <a href=\"linkerror\">WebAssembly.LinkError</a> is thrown.</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p>A <code>Promise</code> that resolves to a <code>ResultObject</code> which contains two fields:</p> <ul> <li>\n<code>module</code>: A <a href=\"module\"><code>WebAssembly.Module</code></a> object representing the compiled WebAssembly module. This <code>Module</code> can be instantiated again or shared via <a href=\"https://developer.mozilla.org/en-US/docs/Web/API/Worker/postMessage\">postMessage()</a>.</li> <li>\n<code>instance</code>: A <a href=\"instance\"><code>WebAssembly.Instance</code></a> object that contains all the <a href=\"https://developer.mozilla.org/en-US/docs/WebAssembly/Exported_functions\">Exported WebAssembly functions</a>.</li> </ul> <h3 id=\"Exceptions\">Exceptions</h3> <ul> <li>If either of the parameters are not of the correct type or structure, a <a href=\"../typeerror\"><code>TypeError</code></a> is thrown.</li> <li>If the operation fails, the promise rejects with a <a href=\"compileerror\"><code>WebAssembly.CompileError</code></a>, <a href=\"linkerror\"><code>WebAssembly.LinkError</code></a>, or <a href=\"runtimeerror\"><code>WebAssembly.RuntimeError</code></a>, depending on the cause of the failure.</li> </ul> <h2 id=\"Examples\">Examples</h2> <p>The following example (see our <a href=\"https://github.com/mdn/webassembly-examples/blob/master/js-api-examples/instantiate-streaming.html\">instantiate-streaming.html</a> demo on GitHub, and <a href=\"https://mdn.github.io/webassembly-examples/js-api-examples/instantiate-streaming.html\">view it live</a> also) directly streams a .wasm module from an underlying source then compiles and instantiates it, the promise fulfilling with a <code>ResultObject</code>. Because the <code>instantiateStreaming()</code> function accepts a promise for a <a href=\"https://developer.mozilla.org/en-US/docs/Web/API/Response\"><code>Response</code></a> object, you can directly pass it a <a href=\"https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/fetch\"><code>WindowOrWorkerGlobalScope.fetch()</code></a> call, and it will pass the response into the function when it fulfills.</p> <pre data-language=\"js\">var importObject = { imports: { imported_func: arg =&gt; console.log(arg) } };\n\nWebAssembly.instantiateStreaming(fetch('simple.wasm'), importObject)\n.then(obj =&gt; obj.instance.exports.exported_func());</pre> <p>The <code>ResultObject</code>'s instance member is then accessed, and the contained exported function invoked.</p> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <thead> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> </thead> <tbody> <tr> <td><a href=\"https://github.com/WebAssembly/design/blob/master/Web.md#webassemblyinstantiatestreaming\" hreflang=\"en\">WebAssembly features for web embedding<br><small>The definition of 'instantiateStreaming()' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td>Initial draft definition.</td> </tr> </tbody> </table></div> <h2 name=\"Browser_compatibility\" id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>   <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 61</td>\n<td class=\"bc-supports-yes\"> 16</td>\n<td class=\"bc-supports-yes\"> 58</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 47</td>\n<td class=\"bc-supports-no\"> No</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 61</td>\n<td class=\"bc-supports-yes\"> 61</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 58</td>\n<td> ? </td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-no\"> No</td>\n</tr></tbody>\n</table>\n</div>  <h2 id=\"See_also\">See also</h2> <ul> <li>\n<a href=\"https://developer.mozilla.org/en-US/docs/WebAssembly\">WebAssembly</a> overview page</li> <li><a href=\"https://developer.mozilla.org/en-US/docs/WebAssembly/Concepts\">WebAssembly concepts</a></li> <li><a href=\"https://developer.mozilla.org/en-US/docs/WebAssembly/Using_the_JavaScript_API\">Using the WebAssembly JavaScript API</a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/instantiateStreaming$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/instantiateStreaming\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/instantiateStreaming</a>\n  </p>\n</div>\n","global_objects/webassembly/instantiate":"<h1>WebAssembly.instantiate</h1> <p>The <code>WebAssembly.instantiate()</code> function allows you to compile and instantiate WebAssembly code. This function has two overloads:</p> <ul> <li>The primary overload takes the WebAssembly binary code, in the form of a <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Typed_arrays\">typed array</a> or <a href=\"../arraybuffer\">ArrayBuffer</a>, and performs both compilation and instantiation in one step. The returned <code>Promise</code> resolves to both a compiled <a href=\"module\"><code>WebAssembly.Module</code></a> and its first <a href=\"instance\"><code>WebAssembly.Instance</code></a>.</li> <li>The secondary overload takes an already-compiled <a href=\"module\"><code>WebAssembly.Module</code></a> and returns a <code>Promise</code> that resolves to an <code>Instance</code> of that <code>Module</code>. This overload is useful if the <code>Module</code> has already been compiled.</li> </ul> <div class=\"warning\"> <p><strong>Important</strong>: This method is not the most efficient way of fetching and instantiating wasm modules. If at all possible, you should use the newer <a href=\"instantiatestreaming\"><code>WebAssembly.instantiateStreaming()</code></a> method instead, which fetches, compiles, and instantiates a module all in one step, directly from the raw bytecode, so doesn't require conversion to an <a href=\"https://developer.mozilla.org/en-US/docs/Web/API/ArrayBuffer\"><code>ArrayBuffer</code></a>.</p> </div> <h2 id=\"Syntax\">Syntax</h2> <h3 id=\"Primary_overload_—_taking_wasm_binary_code\">Primary overload — taking wasm binary code</h3> <pre class=\"syntaxbox\">Promise&lt;ResultObject&gt; WebAssembly.instantiate(bufferSource, importObject);\n</pre> <h4 id=\"Parameters\">Parameters</h4> <dl> <dt><em>bufferSource</em></dt> <dd>A <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Typed_arrays\">typed array</a> or <a href=\"../arraybuffer\">ArrayBuffer</a> containing the binary code of the .wasm module you want to compile.</dd> <dt>\n<em>importObject</em> <span class=\"inlineIndicator optional optionalInline\">Optional</span>\n</dt> <dd>An object containing the values to be imported into the newly-created <code>Instance</code>, such as functions or <a href=\"memory\"><code>WebAssembly.Memory</code></a> objects. There must be one matching property for each declared import of the compiled module or else a <a href=\"linkerror\">WebAssembly.LinkError</a> is thrown.</dd> </dl> <h4 id=\"Return_value\">Return value</h4> <p>A <code>Promise</code> that resolves to a <code>ResultObject</code> which contains two fields:</p> <ul> <li>\n<code>module</code>: A <a href=\"module\"><code>WebAssembly.Module</code></a> object representing the compiled WebAssembly module. This <code>Module</code> can be instantiated again, shared via <a href=\"https://developer.mozilla.org/en-US/docs/Web/API/Worker/postMessage\">postMessage()</a> or <a href=\"https://developer.mozilla.org/en-US/docs/WebAssembly/Caching_modules\">cached in IndexedDB</a>.</li> <li>\n<code>instance</code>: A <a href=\"instance\"><code>WebAssembly.Instance</code></a> object that contains all the <a href=\"https://developer.mozilla.org/en-US/docs/WebAssembly/Exported_functions\">Exported WebAssembly functions</a>.</li> </ul> <h4 id=\"Exceptions\">Exceptions</h4> <ul> <li>If either of the parameters are not of the correct type or structure, a <a href=\"../typeerror\"><code>TypeError</code></a> is thrown.</li> <li>If the operation fails, the promise rejects with a <a href=\"compileerror\"><code>WebAssembly.CompileError</code></a>, <a href=\"linkerror\"><code>WebAssembly.LinkError</code></a>, or <a href=\"runtimeerror\"><code>WebAssembly.RuntimeError</code></a>, depending on the cause of the failure.</li> </ul> <h3 id=\"Secondary_overload_—_taking_a_module_object_instance\">Secondary overload — taking a module object instance</h3> <pre class=\"syntaxbox\">Promise&lt;WebAssembly.Instance&gt; WebAssembly.instantiate(module, importObject);\n</pre> <h4 id=\"Parameters_2\">Parameters</h4> <dl> <dt><em>module</em></dt> <dd>The <a href=\"module\"><code>WebAssembly.Module</code></a> object to be instantiated.</dd> <dt>\n<em>importObject</em> <span class=\"inlineIndicator optional optionalInline\">Optional</span>\n</dt> <dd>An object containing the values to be imported into the newly-created <code>Instance</code>, such as functions or <a href=\"memory\"><code>WebAssembly.Memory</code></a> objects. There must be one matching property for each declared import of <code>module</code> or else a <a href=\"linkerror\">WebAssembly.LinkError</a> is thrown.</dd> </dl> <h4 id=\"Return_value_2\">Return value</h4> <p>A <code>Promise</code> that resolves to an <a href=\"instance\"><code>WebAssembly.Instance</code></a> object.</p> <h4 id=\"Exceptions_2\">Exceptions</h4> <ul> <li>If either of the parameters are not of the correct type or structure, a <a href=\"../typeerror\"><code>TypeError</code></a> is thrown.</li> <li>If the operation fails, the promise rejects with a <a href=\"compileerror\"><code>WebAssembly.CompileError</code></a>, <a href=\"linkerror\"><code>WebAssembly.LinkError</code></a>, or <a href=\"runtimeerror\"><code>WebAssembly.RuntimeError</code></a>, depending on the cause of the failure.</li> </ul> <h2 id=\"Examples\">Examples</h2> <p><strong>Note</strong>: You'll probably want to use <a href=\"instantiatestreaming\"><code>WebAssembly.instantiateStreaming()</code></a> in most cases, as it is more efficient than <code>instantiate()</code>.</p> <h3 id=\"First_overload_example\">First overload example</h3> <p>After fetching some WebAssembly bytecode using fetch, we compile and instantiate the module using the <a href=\"instantiate\"><code>WebAssembly.instantiate()</code></a> function, importing a JavaScript function into the WebAssembly Module in the process. We then call an <a href=\"https://developer.mozilla.org/en-US/docs/WebAssembly/Exported_functions\">Exported WebAssembly function</a> that is exported by the <code>Instance</code>.</p> <pre data-language=\"js\">var importObject = {\n  imports: {\n    imported_func: function(arg) {\n      console.log(arg);\n    }\n  }\n};\n\nfetch('simple.wasm').then(response =&gt;\n  response.arrayBuffer()\n).then(bytes =&gt;\n  WebAssembly.instantiate(bytes, importObject)\n).then(result =&gt;\n  result.instance.exports.exported_func()\n);</pre> <div class=\"note\"> <p><strong>Note</strong>: You can also find this example at <a href=\"https://github.com/mdn/webassembly-examples/blob/master/js-api-examples/index.html\">index.html</a> on GitHub (<a href=\"https://mdn.github.io/webassembly-examples/js-api-examples/\">view it live also</a>).</p> </div> <h3 id=\"Second_overload_example\">Second overload example</h3> <p>The following example (see our <a href=\"https://github.com/mdn/webassembly-examples/blob/master/js-api-examples/index-compile.html\">index-compile.html</a> demo on GitHub, and <a href=\"https://mdn.github.io/webassembly-examples/js-api-examples/index-compile.html\">view it live</a> also) compiles the loaded simple.wasm byte code using the <a href=\"compilestreaming\"><code>WebAssembly.compileStreaming()</code></a> method and then sends it to a <a href=\"https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API\">worker</a> using <a href=\"https://developer.mozilla.org/en-US/docs/Web/API/Worker/postMessage\">postMessage()</a>.</p> <pre data-language=\"js\">var worker = new Worker(\"wasm_worker.js\");\n\nWebAssembly.compileStreaming(fetch('simple.wasm'))\n.then(mod =&gt;\n  worker.postMessage(mod)\n);</pre> <p>In the worker (see <code><a href=\"https://github.com/mdn/webassembly-examples/blob/master/js-api-examples/wasm_worker.js\">wasm_worker.js</a></code>) we define an import object for the module to use, then set up an event handler to receive the module from the main thread. When the module is received, we create an instance from it using the <a href=\"instantiate\"><code>WebAssembly.instantiate()</code></a> method and invoke an exported function from inside it.</p> <pre data-language=\"js\">var importObject = {\n  imports: {\n    imported_func: function(arg) {\n      console.log(arg);\n    }\n  }\n};\n\nonmessage = function(e) {\n  console.log('module received from main thread');\n  var mod = e.data;\n\n  WebAssembly.instantiate(mod, importObject).then(function(instance) {\n    instance.exports.exported_func();\n  });\n};</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <thead> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> </thead> <tbody> <tr> <td><a href=\"https://webassembly.github.io/spec/js-api/#webassemblyinstantiate\" hreflang=\"en\">WebAssembly JavaScript Interface<br><small>The definition of 'instantiate()' in that specification.</small></a></td> <td><span class=\"spec-WD\">Working Draft</span></td> <td>Initial draft definition.</td> </tr> </tbody> </table></div> <h2 name=\"Browser_compatibility\" id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>   <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 57</td>\n<td class=\"bc-supports-yes\"> 16</td>\n<td class=\"bc-supports-yes bc-has-history\"> 52\n<section class=\"bc-history\" id=\"sect1\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 52\n</dt>\n<dd> Disabled in the Firefox 52 Extended Support Release (ESR).</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 44</td>\n<td class=\"bc-supports-yes\"> 11</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 57</td>\n<td class=\"bc-supports-yes\"> 57</td>\n<td class=\"bc-supports-yes bc-has-history\"> Yes<div class=\"bc-icons\">Disabled </div>\n<section class=\"bc-history\" id=\"sect2\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> Yes<div class=\"bc-icons\">Disabled </div>\n</dt>\n<dd>Disabled This feature is behind the <code>Experimental JavaScript Features</code> preference.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-yes bc-has-history\"> 52\n<section class=\"bc-history\" id=\"sect3\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 52\n</dt>\n<dd> Disabled in the Firefox 52 Extended Support Release (ESR).</dd>\n</dl></section>\n</td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 11</td>\n<td class=\"bc-supports-yes\"> 7.0</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 8.0.0</td>\n</tr></tbody>\n</table>\n</div>  <h2 id=\"See_also\">See also</h2> <ul> <li>\n<a href=\"https://developer.mozilla.org/en-US/docs/WebAssembly\">WebAssembly</a> overview page</li> <li><a href=\"https://developer.mozilla.org/en-US/docs/WebAssembly/Concepts\">WebAssembly concepts</a></li> <li><a href=\"https://developer.mozilla.org/en-US/docs/WebAssembly/Using_the_JavaScript_API\">Using the WebAssembly JavaScript API</a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/instantiate$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/instantiate\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/instantiate</a>\n  </p>\n</div>\n","global_objects/string/fromcharcode":"<h1>String.fromCharCode</h1> <p>The static <code>String.fromCharCode()</code> method returns a string created from the specified sequence of UTF-16 code units.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/string-fromcharcode.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\">String.fromCharCode(<var>num1</var>[, ...[, <var>numN</var>]])</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><code>num1, ..., num<em>N</em></code></dt> <dd>A sequence of numbers that are UTF-16 code units. The range is between 0 and 65535 (0xFFFF). Numbers greater than 0xFFFF are truncated. No validity checks are performed.</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p>A string of length N consisting of the N specified UTF-16 code units.</p> <h2 id=\"Description\">Description</h2> <p>This method returns a string and not a <a href=\"../string\"><code>String</code></a> object.</p> <p>Because <code>fromCharCode()</code> is a static method of <a href=\"../string\"><code>String</code></a>, you always use it as <code>String.fromCharCode()</code>, rather than as a method of a <a href=\"../string\"><code>String</code></a> object you created.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Using_fromCharCode()\">Using <code>fromCharCode()</code>\n</h3> <p>The following example returns the string \"ABC\".</p> <pre data-language=\"js\">String.fromCharCode(65, 66, 67);  // returns \"ABC\"\nString.fromCharCode(0x2014)       // returns \"—\"\nString.fromCharCode(0x12014)      // also returns \"—\"; the digit 1 is truncated and ignored\n</pre> <h2 id=\"Getting_it_to_work_with_higher_values\">Getting it to work with higher values</h2> <p>Although most common Unicode values can be represented with one 16-bit number (as expected early on during JavaScript standardization) and <code>fromCharCode()</code> can be used to return a single character for the most common values (i.e., UCS-2 values which are the subset of UTF-16 with the most common characters), in order to deal with ALL legal Unicode values (up to 21 bits), <code>fromCharCode()</code> alone is inadequate. Since the higher code point characters use two (lower value) \"surrogate\" numbers to form a single character, <a href=\"fromcodepoint\"><code>String.fromCodePoint()</code></a> (part of the ES2015 standard) can be used to return such a pair and thus adequately represent these higher valued characters.</p> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/publications/files/ECMA-ST-ARCH/ECMA-262,%201st%20edition,%20June%201997.pdf\" hreflang=\"en\">ECMAScript 1st Edition (ECMA-262)</a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition. Implemented in JavaScript 1.2.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/5.1/#sec-15.5.3.2\" hreflang=\"en\">ECMAScript 5.1 (ECMA-262)<br><small>The definition of 'StringfromCharCode' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-string.fromcharcodes\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'String.fromCharCode' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-string.fromcharcodes\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'String.fromCharCode' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"fromcodepoint\"><code>String.fromCodePoint()</code></a></li> <li><a href=\"charat\"><code>String.prototype.charAt()</code></a></li> <li><a href=\"charcodeat\"><code>String.prototype.charCodeAt()</code></a></li> <li><a href=\"codepointat\"><code>String.prototype.codePointAt()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/fromCharCode$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/fromCharCode\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/fromCharCode</a>\n  </p>\n</div>\n","global_objects/string/blink":"<h1>string.blink</h1> <div class=\"blockIndicator deprecated deprecatedHeader\"> <p><strong> Deprecated</strong><br>This feature is no longer recommended. Though some browsers might still support it, it may have already been removed from the relevant web standards, may be in the process of being dropped, or may only be kept for compatibility purposes. Avoid using it, and update existing code if possible; see the <a href=\"#Browser_compatibility\">compatibility table</a> at the bottom of this page to guide your decision. Be aware that this feature may cease to work at any time.</p> </div> <p>The <code>blink()</code> method creates a <a href=\"https://developer.mozilla.org/en-US/docs/Web/HTML/Element/blink\"><code>&lt;blink&gt;</code></a> HTML element that causes a string to blink.</p> <div class=\"warning\"> <p><strong>Warning:</strong> Blinking text is frowned upon by several accessibility standards. The <code>&lt;blink&gt;</code> element itself is non-standard and deprecated!</p> </div> <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\"><var>str</var>.blink()</pre> <h3 id=\"Return_value\">Return value</h3> <p>A string containing a <a href=\"https://developer.mozilla.org/en-US/docs/Web/HTML/Element/blink\"><code>&lt;blink&gt;</code></a> HTML element.</p> <h2 id=\"Description\">Description</h2> <p>The <code>blink()</code> method embeds a string in a <code>&lt;blink&gt;</code> tag: <code>\"&lt;blink&gt;str&lt;/blink&gt;\"</code>.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Using_blink()\">Using <code>blink()</code>\n</h3> <p>The following example uses string methods to change the formatting of a string:</p> <pre data-language=\"js\">var worldString = 'Hello, world';\n\nconsole.log(worldString.blink());   // &lt;blink&gt;Hello, world&lt;/blink&gt;\nconsole.log(worldString.bold());    // &lt;b&gt;Hello, world&lt;/b&gt;\nconsole.log(worldString.italics()); // &lt;i&gt;Hello, world&lt;/i&gt;\nconsole.log(worldString.strike());  // &lt;strike&gt;Hello, world&lt;/strike&gt;</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-string.prototype.blink\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'String.prototype.blink' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition. Implemented in JavaScript 1.0. Defined in the (normative) Annex B for Additional ECMAScript Features for Web Browsers.</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-string.prototype.blink\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'String.prototype.blink' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td>Defined in the (normative) Annex B for Additional ECMAScript Features for Web Browsers.</td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support \n</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support \n</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support \n</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"bold\"><code>String.prototype.bold()</code></a></li> <li><a href=\"italics\"><code>String.prototype.italics()</code></a></li> <li><a href=\"strike\"><code>String.prototype.strike()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/blink$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/blink\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/blink</a>\n  </p>\n</div>\n","global_objects/string/bold":"<h1>string.bold</h1> <div class=\"blockIndicator deprecated deprecatedHeader\"> <p><strong> Deprecated</strong><br>This feature is no longer recommended. Though some browsers might still support it, it may have already been removed from the relevant web standards, may be in the process of being dropped, or may only be kept for compatibility purposes. Avoid using it, and update existing code if possible; see the <a href=\"#Browser_compatibility\">compatibility table</a> at the bottom of this page to guide your decision. Be aware that this feature may cease to work at any time.</p> </div> <p>The <code>bold()</code> method creates a <a href=\"https://developer.mozilla.org/en-US/docs/Web/HTML/Element/b\"><code>&lt;b&gt;</code></a> HTML element that causes a string to be displayed as bold.</p> <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\"><var>str</var>.bold()</pre> <h3 id=\"Return_value\">Return value</h3> <p>A string containing a <a href=\"https://developer.mozilla.org/en-US/docs/Web/HTML/Element/b\"><code>&lt;b&gt;</code></a> HTML element.</p> <h2 id=\"Description\">Description</h2> <p>The <code>bold()</code> method embeds a string in a <code>&lt;b&gt;</code> tag: <code>\"&lt;b&gt;str&lt;/b&gt;\"</code>.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Using_bold()\">Using <code>bold()</code>\n</h3> <p>The following example uses string methods to change the formatting of a string:</p> <pre data-language=\"js\">var worldString = 'Hello, world';\n\nconsole.log(worldString.blink());   // &lt;blink&gt;Hello, world&lt;/blink&gt;\nconsole.log(worldString.bold());    // &lt;b&gt;Hello, world&lt;/b&gt;\nconsole.log(worldString.italics()); // &lt;i&gt;Hello, world&lt;/i&gt;\nconsole.log(worldString.strike());  // &lt;strike&gt;Hello, world&lt;/strike&gt;</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-string.prototype.bold\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'String.prototype.bold' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition. Implemented in JavaScript 1.0. Defined in the (normative) Annex B for Additional ECMAScript Features for Web Browsers.</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-string.prototype.bold\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'String.prototype.bold' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td>Defined in the (normative) Annex B for Additional ECMAScript Features for Web Browsers.</td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support \n</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support \n</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support \n</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"blink\"><code>String.prototype.blink()</code></a></li> <li><a href=\"italics\"><code>String.prototype.italics()</code></a></li> <li><a href=\"strike\"><code>String.prototype.strike()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/bold$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/bold\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/bold</a>\n  </p>\n</div>\n","global_objects/string/length":"<h1>string.length</h1> <p>The <code>length</code> property of a <a href=\"../string\"><code>String</code></a> object indicates the length of a string, in UTF-16 code units.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/string-length.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe> <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\"><var>str</var>.length</pre> <h2 id=\"Description\">Description</h2> <p>This property returns the number of code units in the string. <a href=\"https://en.wikipedia.org/wiki/UTF-16\">UTF-16</a>, the string format used by JavaScript, uses a single 16-bit code unit to represent the most common characters, but needs to use two code units for less commonly-used characters, so it's possible for the value returned by <code>length</code> to not match the actual number of characters in the string.</p> <p>ECMASCript 2016 (ed. 7) established a maximum length of <code>2^53 - 1</code> elements. Previously, no maximum length was specified. </p> <p>For an empty string, <code>length</code> is 0.</p> <p>The static property <code>String.length</code> returns the value 1.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Basic_usage\">Basic usage</h3> <pre data-language=\"js\">var x = 'Mozilla';\nvar empty = '';\n\nconsole.log('Mozilla is ' + x.length + ' code units long');\n/* \"Mozilla is 7 code units long\" */\n\nconsole.log('The empty string has a length of ' + empty.length);\n/* \"The empty string has a length of 0\" */</pre> <h3 id=\"Assigning_to_length\">Assigning to length</h3> <pre data-language=\"js\">var myString = \"bluebells\";\n\n// Attempting to assign a value to a string's .length property has no observable effect. \nmyString.length = 4;\nconsole.log(myString);\n/* \"bluebells\" */\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/publications/files/ECMA-ST-ARCH/ECMA-262,%201st%20edition,%20June%201997.pdf\" hreflang=\"en\">ECMAScript 1st Edition (ECMA-262)</a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition. Implemented in JavaScript 1.0.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/5.1/#sec-15.5.5.1\" hreflang=\"en\">ECMAScript 5.1 (ECMA-262)<br><small>The definition of 'String.prototype.length' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-properties-of-string-instances-length\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'String.prototype.length' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-properties-of-string-instances-length\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'String.prototype.length' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"http://developer.teradata.com/blog/jasonstrimpel/2011/11/javascript-string-length-and-internationalizing-web-applications\">JavaScript <code>String.length</code> and Internationalizing Web Applications</a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/length$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/length\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/length</a>\n  </p>\n</div>\n","global_objects/string/big":"<h1>string.big</h1> <div class=\"blockIndicator deprecated deprecatedHeader\"> <p><strong> Deprecated</strong><br>This feature is no longer recommended. Though some browsers might still support it, it may have already been removed from the relevant web standards, may be in the process of being dropped, or may only be kept for compatibility purposes. Avoid using it, and update existing code if possible; see the <a href=\"#Browser_compatibility\">compatibility table</a> at the bottom of this page to guide your decision. Be aware that this feature may cease to work at any time.</p> </div> <p>The <code>big()</code> method creates a <a href=\"https://developer.mozilla.org/en-US/docs/Web/HTML/Element/big\"><code>&lt;big&gt;</code></a> HTML element that causes a string to be displayed in a big font.</p> <div class=\"note\"> <p><strong>Usage note:</strong> The &lt;big&gt; element has been removed in <a href=\"https://developer.mozilla.org/en-US/docs/Web/Guide/HTML/HTML5\">HTML5</a> and shouldn't be used anymore. Instead web developers should use <a href=\"https://developer.mozilla.org/en-US/docs/Web/CSS\">CSS</a> properties.</p> </div> <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\"><var>str</var>.big()</pre> <h3 id=\"Return_value\">Return value</h3> <p>A string containing a <a href=\"https://developer.mozilla.org/en-US/docs/Web/HTML/Element/big\"><code>&lt;big&gt;</code></a> HTML element.</p> <h2 id=\"Description\">Description</h2> <p>The <code>big()</code> method embeds a string in a <code>&lt;big&gt;</code> tag: <code>\"&lt;big&gt;str&lt;/big&gt;\"</code>.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Using_big()\">Using <code>big()</code>\n</h3> <p>The following example uses string methods to change the size of a string:</p> <pre data-language=\"js\">var worldString = 'Hello, world';\n\nconsole.log(worldString.small());     // &lt;small&gt;Hello, world&lt;/small&gt;\nconsole.log(worldString.big());       // &lt;big&gt;Hello, world&lt;/big&gt;\nconsole.log(worldString.fontsize(7)); // &lt;fontsize=7&gt;Hello, world&lt;/fontsize&gt;\n</pre> <p>With the <a href=\"https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/style\"><code>element.style</code></a> object you can get the element's <code>style</code> attribute and manipulate it more generically, for example:</p> <pre data-language=\"js\">document.getElementById('yourElemId').style.fontSize = '2em';\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-string.prototype.big\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'String.prototype.big' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition. Implemented in JavaScript 1.0. Defined in the (normative) Annex B for Additional ECMAScript Features for Web Browsers.</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-string.prototype.big\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'String.prototype.big' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td>Defined in the (normative) Annex B for Additional ECMAScript Features for Web Browsers.</td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support \n</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support \n</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support \n</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"fontsize\"><code>String.prototype.fontsize()</code></a></li> <li><a href=\"small\"><code>String.prototype.small()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/big$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/big\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/big</a>\n  </p>\n</div>\n","global_objects/string/codepointat":"<h1>string.codePointAt</h1> <p>The <code>codePointAt()</code> method returns a non-negative integer that is the Unicode code point value.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/string-codepointat.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\"><var>str</var>.codePointAt(<var>pos</var>)</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><code>pos</code></dt> <dd>Position of an element in the String to return the code point value from.</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p>A number representing the code point value of the character at the given index; <a href=\"../undefined\"><code>undefined</code></a> if there is no element at <code>pos</code>.</p> <h2 id=\"Description\">Description</h2> <p>If there is no element at the specified position, <a href=\"../undefined\"><code>undefined</code></a> is returned. If no UTF-16 surrogate pair begins at <code>pos</code>, the code unit at <code>pos</code> is returned.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Using_codePointAt()\">Using <code>codePointAt()</code>\n</h3> <pre data-language=\"js\">'ABC'.codePointAt(1);          // 66\n'\\uD800\\uDC00'.codePointAt(0); // 65536\n\n'XYZ'.codePointAt(42); // undefined\n</pre> <h2 id=\"Polyfill\">Polyfill</h2> <p>The following extends Strings to include the <code>codePointAt()</code> function as specified in ECMAScript 2015 for browsers not supporting it natively.</p> <pre data-language=\"js\">/*! https://mths.be/codepointat v0.2.0 by @mathias */\nif (!String.prototype.codePointAt) {\n  (function() {\n    'use strict'; // needed to support `apply`/`call` with `undefined`/`null`\n    var defineProperty = (function() {\n      // IE 8 only supports `Object.defineProperty` on DOM elements\n      try {\n        var object = {};\n        var $defineProperty = Object.defineProperty;\n        var result = $defineProperty(object, object, object) &amp;&amp; $defineProperty;\n      } catch(error) {}\n      return result;\n    }());\n    var codePointAt = function(position) {\n      if (this == null) {\n        throw TypeError();\n      }\n      var string = String(this);\n      var size = string.length;\n      // `ToInteger`\n      var index = position ? Number(position) : 0;\n      if (index != index) { // better `isNaN`\n        index = 0;\n      }\n      // Account for out-of-bounds indices:\n      if (index &lt; 0 || index &gt;= size) {\n        return undefined;\n      }\n      // Get the first code unit\n      var first = string.charCodeAt(index);\n      var second;\n      if ( // check if it’s the start of a surrogate pair\n        first &gt;= 0xD800 &amp;&amp; first &lt;= 0xDBFF &amp;&amp; // high surrogate\n        size &gt; index + 1 // there is a next code unit\n      ) {\n        second = string.charCodeAt(index + 1);\n        if (second &gt;= 0xDC00 &amp;&amp; second &lt;= 0xDFFF) { // low surrogate\n          // https://mathiasbynens.be/notes/javascript-encoding#surrogate-formulae\n          return (first - 0xD800) * 0x400 + second - 0xDC00 + 0x10000;\n        }\n      }\n      return first;\n    };\n    if (defineProperty) {\n      defineProperty(String.prototype, 'codePointAt', {\n        'value': codePointAt,\n        'configurable': true,\n        'writable': true\n      });\n    } else {\n      String.prototype.codePointAt = codePointAt;\n    }\n  }());\n}\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-string.prototype.codepointat\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'String.prototype.codePointAt' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-string.prototype.codepointat\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'String.prototype.codePointAt' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 41</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 29</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 28</td>\n<td class=\"bc-supports-yes\"> 10</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 29</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 10</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes bc-has-history\"> 4.0.0\n<section class=\"bc-history\" id=\"sect1\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 4.0.0\n</dt>\n\n<dt class=\"bc-supports-yes bc-supports\"> 0.12<div class=\"bc-icons\">Disabled </div>\n</dt>\n<dd>Disabled From version 0.12: this feature is behind the <code>--harmony</code> runtime flag.</dd>\n</dl></section>\n</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"fromcodepoint\"><code>String.fromCodePoint()</code></a></li> <li><a href=\"fromcharcode\"><code>String.fromCharCode()</code></a></li> <li><a href=\"charcodeat\"><code>String.prototype.charCodeAt()</code></a></li> <li><a href=\"charat\"><code>String.prototype.charAt()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/codePointAt$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/codePointAt\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/codePointAt</a>\n  </p>\n</div>\n","global_objects/string/fromcodepoint":"<h1>String.fromCodePoint</h1> <p>The static <code>String.fromCodePoint()</code> method returns a string created by using the specified sequence of code points.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/string-fromcodepoint.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\">String.fromCodePoint(<var>num1</var>[, ...[, <var>numN</var>]])</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><code>num1, ..., num<em>N</em></code></dt> <dd>A sequence of code points.</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p>A string created by using the specified sequence of code points.</p> <h3 id=\"Exceptions\">Exceptions</h3> <ul> <li>A <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Not_a_codepoint\"><code>RangeError</code></a> is thrown if an invalid Unicode code point is given (e.g. \"RangeError: NaN is not a valid code point\").</li> </ul> <h2 id=\"Description\">Description</h2> <p>This method returns a string and not a <a href=\"../string\"><code>String</code></a> object.</p> <p>Because <code>fromCodePoint()</code> is a static method of <a href=\"../string\"><code>String</code></a>, you always use it as <code>String.fromCodePoint()</code>, rather than as a method of a <a href=\"../string\"><code>String</code></a> object you created.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Using_fromCodePoint()\">Using <code>fromCodePoint()</code>\n</h3> <pre data-language=\"js\">String.fromCodePoint(42);       // \"*\"\nString.fromCodePoint(65, 90);   // \"AZ\"\nString.fromCodePoint(0x404);    // \"\\u0404\"\nString.fromCodePoint(0x2F804);  // \"\\uD87E\\uDC04\"\nString.fromCodePoint(194564);   // \"\\uD87E\\uDC04\"\nString.fromCodePoint(0x1D306, 0x61, 0x1D307) // \"\\uD834\\uDF06a\\uD834\\uDF07\"\n\nString.fromCodePoint('_');      // RangeError\nString.fromCodePoint(Infinity); // RangeError\nString.fromCodePoint(-1);       // RangeError\nString.fromCodePoint(3.14);     // RangeError\nString.fromCodePoint(3e-2);     // RangeError\nString.fromCodePoint(NaN);      // RangeError\n</pre> <pre data-language=\"js\">// String.fromCharCode() alone cannot get the character at such a high code point\n// The following, on the other hand, can return a 4-byte character as well as the\n// usual 2-byte ones (i.e., it can return a single character which actually has\n// a string length of 2 instead of 1!)\nconsole.log(String.fromCodePoint(0x2F804)); // or 194564 in decimal\n</pre> <h2 id=\"Polyfill\">Polyfill</h2> <p>The <code>String.fromCodePoint</code> method has been added to ECMAScript 2015 and may not be supported in all web browsers or environments yet. Use the code below for a polyfill:</p> <pre data-language=\"js\">if (!String.fromCodePoint) (function(stringFromCharCode) {\n    var fromCodePoint = function(_) {\n      var codeUnits = [], codeLen = 0, result = \"\";\n      for (var index=0, len = arguments.length; index !== len; ++index) {\n        var codePoint = +arguments[index];\n        // correctly handles all cases including `NaN`, `-Infinity`, `+Infinity`\n        // The surrounding `!(...)` is required to correctly handle `NaN` cases\n        // The (codePoint&gt;&gt;&gt;0) === codePoint clause handles decimals and negatives\n        if (!(codePoint &lt; 0x10FFFF &amp;&amp; (codePoint&gt;&gt;&gt;0) === codePoint))\n          throw RangeError(\"Invalid code point: \" + codePoint);\n        if (codePoint &lt;= 0xFFFF) { // BMP code point\n          codeLen = codeUnits.push(codePoint);\n        } else { // Astral code point; split in surrogate halves\n          // https://mathiasbynens.be/notes/javascript-encoding#surrogate-formulae\n          codePoint -= 0x10000;\n          codeLen = codeUnits.push(\n            (codePoint &gt;&gt; 10) + 0xD800,  // highSurrogate\n            (codePoint % 0x400) + 0xDC00 // lowSurrogate\n          );\n        }\n        if (codeLen &gt;= 0x3fff) {\n          result += stringFromCharCode.apply(null, codeUnits);\n          codeUnits.length = 0;\n        }\n      }\n      return result + stringFromCharCode.apply(null, codeUnits);\n    };\n    try { // IE 8 only supports `Object.defineProperty` on DOM elements\n      Object.defineProperty(String, \"fromCodePoint\", {\n        \"value\": fromCodePoint, \"configurable\": true, \"writable\": true\n      });\n    } catch(e) {\n      String.fromCodePoint = fromCodePoint;\n    }\n}(String.fromCharCode));\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-string.fromcodepoint\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'String.fromCodePoint' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-string.fromcodepoint\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'String.fromCodePoint' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 41</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 29</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 28</td>\n<td class=\"bc-supports-yes\"> 10</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 29</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 10</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes bc-has-history\"> 4.0.0\n<section class=\"bc-history\" id=\"sect1\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 4.0.0\n</dt>\n\n<dt class=\"bc-supports-yes bc-supports\"> 0.12<div class=\"bc-icons\">Disabled </div>\n</dt>\n<dd>Disabled From version 0.12: this feature is behind the <code>--harmony</code> runtime flag.</dd>\n</dl></section>\n</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"fromcharcode\"><code>String.fromCharCode()</code></a></li> <li><a href=\"charat\"><code>String.prototype.charAt()</code></a></li> <li><a href=\"codepointat\"><code>String.prototype.codePointAt()</code></a></li> <li><a href=\"charcodeat\"><code>String.prototype.charCodeAt()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/fromCodePoint$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/fromCodePoint\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/fromCodePoint</a>\n  </p>\n</div>\n","global_objects/string/anchor":"<h1>string.anchor</h1> <div class=\"blockIndicator deprecated deprecatedHeader\"> <p><strong> Deprecated</strong><br>This feature is no longer recommended. Though some browsers might still support it, it may have already been removed from the relevant web standards, may be in the process of being dropped, or may only be kept for compatibility purposes. Avoid using it, and update existing code if possible; see the <a href=\"#Browser_compatibility\">compatibility table</a> at the bottom of this page to guide your decision. Be aware that this feature may cease to work at any time.</p> </div> <p>The <code>anchor()</code> method creates an <a href=\"https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a\"><code>&lt;a&gt;</code></a> HTML anchor element that is used as a hypertext target.</p> <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\"><var>str</var>.anchor(<var>name</var>)</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><code>name</code></dt> <dd>A string representing the <code>name</code> attribute of the a tag to be created.</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p>A string containing an <a href=\"https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a\"><code>&lt;a&gt;</code></a> HTML element.</p> <h2 id=\"Description\">Description</h2> <p>Use the <code>anchor()</code> method to programmatically create and display an anchor in a document.</p> <p>In the syntax, the text string represents the literal text that you want the user to see. The <code>name</code> parameter string represents the <code>name</code> attribute of the <a href=\"https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a\"><code>&lt;a&gt;</code></a> element.</p> <p>Anchors created with the <code>anchor()</code> method become elements in the <a href=\"https://developer.mozilla.org/en-US/docs/Web/API/Document/anchors\"><code>document.anchors</code></a> array.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Using_anchor()\">Using <code>anchor()</code>\n</h3> <pre data-language=\"js\">var myString = 'Table of Contents';\n\ndocument.body.innerHTML = myString.anchor('contents_anchor');\n</pre> <p>will output the following HTML:</p> <pre data-language=\"html\">&lt;a name=\"contents_anchor\"&gt;Table of Contents&lt;/a&gt;\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-string.prototype.anchor\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'String.prototype.anchor' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition. Implemented in JavaScript 1.0. Defined in the (normative) Annex B for Additional ECMAScript Features for Web Browsers.</td> </tr> </tbody> </table></div> <h2 id=\"Polyfill\">Polyfill</h2> <pre data-language=\"html\">if (!String.prototype.anchor)\n    String.prototype.anchor = function(x){\n        return '&lt;a name=\"' + x + '\"&gt;' + this + '&lt;/a&gt;'\n    }\n</pre> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support \n</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes bc-has-history\"> 1\n<section class=\"bc-history\" id=\"sect1\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 1\n</dt>\n<dd> Starting with version 17, the quotation mark (\") is replaced by its HTML reference character (<code>\"</code>) in strings supplied for the <code>name</code> parameter.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support \n</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support \n</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"link\"><code>String.prototype.link()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/anchor$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/anchor\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/anchor</a>\n  </p>\n</div>\n","global_objects/string/charcodeat":"<h1>string.charCodeAt</h1> <p>The <code>charCodeAt()</code> method returns an integer between 0 and 65535 representing the UTF-16 code unit at the given index.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/string-charcodeat.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <p>The UTF-16 code unit matches the Unicode code point for code points that can be represented in a single UTF-16 code unit. If the Unicode code point cannot be represented in a single UTF-16 code unit (because its value is greater than 0x10000) then the code unit returned will be the first part of a surrogate pair for the code point. If you want the entire code point value, use <code>codePointAt</code>().</p> <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\"><var>str</var>.charCodeAt(<var>index</var>)</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><code>index</code></dt> <dd>An integer greater than or equal to 0 and less than the length of the string; if it is not a number, it defaults to 0.</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p>A number representing the UTF-16 code unit value of the character at the given index; <a href=\"../nan\"><code>NaN</code></a> if <code>index</code> is out of range.</p> <h2 id=\"Description\">Description</h2> <p>Unicode code points range from 0 to 1114111 (0x10FFFF). The first 128 Unicode code points are a direct match of the ASCII character encoding. For information on Unicode, see the <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Values,_variables,_and_literals#Unicode\">JavaScript Guide</a>.</p> <p>Note that <code>charCodeAt()</code> will always return a value that is less than 65536. This is because the higher code points are represented by a pair of (lower valued) \"surrogate\" pseudo-characters which are used to comprise the real character. Because of this, in order to examine or reproduce the full character for individual characters of value 65536 and above, for such characters, it is necessary to retrieve not only <code>charCodeAt(i)</code>, but also <code>charCodeAt(i+1)</code> (as if examining/reproducing a string with two letters), or to use codePointAt(i) instead. See example 2 and 3 below.</p> <p><code>charCodeAt()</code> returns <a href=\"../nan\"><code>NaN</code></a> if the given index is less than 0 or is equal to or greater than the length of the string.</p> <p>Backward compatibility: In historic versions (like JavaScript 1.2) the <code>charCodeAt()</code> method returns a number indicating the ISO-Latin-1 codeset value of the character at the given index. The ISO-Latin-1 codeset ranges from 0 to 255. The first 0 to 127 are a direct match of the ASCII character set.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Using_charCodeAt()\">Using <code>charCodeAt()</code>\n</h3> <p>The following example returns 65, the Unicode value for A.</p> <pre data-language=\"js\">'ABC'.charCodeAt(0); // returns 65\n</pre> <h3 id=\"Fixing_charCodeAt()_to_handle_non-Basic-Multilingual-Plane_characters_if_their_presence_earlier_in_the_string_is_unknown\">Fixing <code>charCodeAt()</code> to handle non-Basic-Multilingual-Plane characters if their presence earlier in the string is unknown</h3> <p>This version might be used in for loops and the like when it is unknown whether non-BMP characters exist before the specified index position.</p> <pre data-language=\"js\">function fixedCharCodeAt(str, idx) {\n  // ex. fixedCharCodeAt('\\uD800\\uDC00', 0); // 65536\n  // ex. fixedCharCodeAt('\\uD800\\uDC00', 1); // false\n  idx = idx || 0;\n  var code = str.charCodeAt(idx);\n  var hi, low;\n  \n  // High surrogate (could change last hex to 0xDB7F\n  // to treat high private surrogates \n  // as single characters)\n  if (0xD800 &lt;= code &amp;&amp; code &lt;= 0xDBFF) {\n    hi = code;\n    low = str.charCodeAt(idx + 1);\n    if (isNaN(low)) {\n      throw 'High surrogate not followed by ' +\n        'low surrogate in fixedCharCodeAt()';\n    }\n    return ((hi - 0xD800) * 0x400) +\n      (low - 0xDC00) + 0x10000;\n  }\n  if (0xDC00 &lt;= code &amp;&amp; code &lt;= 0xDFFF) { // Low surrogate\n    // We return false to allow loops to skip\n    // this iteration since should have already handled\n    // high surrogate above in the previous iteration\n    return false;\n    // hi = str.charCodeAt(idx - 1);\n    // low = code;\n    // return ((hi - 0xD800) * 0x400) +\n    //   (low - 0xDC00) + 0x10000;\n  }\n  return code;\n}\n</pre> <h3 id=\"Fixing_charCodeAt()_to_handle_non-Basic-Multilingual-Plane_characters_if_their_presence_earlier_in_the_string_is_known\">Fixing <code>charCodeAt()</code> to handle non-Basic-Multilingual-Plane characters if their presence earlier in the string is known</h3> <pre data-language=\"js\">function knownCharCodeAt(str, idx) {\n  str += '';\n  var code,\n      end = str.length;\n\n  var surrogatePairs = /[\\uD800-\\uDBFF][\\uDC00-\\uDFFF]/g;\n  while ((surrogatePairs.exec(str)) != null) {\n    var li = surrogatePairs.lastIndex;\n    if (li - 2 &lt; idx) {\n      idx++;\n    }\n    else {\n      break;\n    }\n  }\n\n  if (idx &gt;= end || idx &lt; 0) {\n    return NaN;\n  }\n\n  code = str.charCodeAt(idx);\n\n  var hi, low;\n  if (0xD800 &lt;= code &amp;&amp; code &lt;= 0xDBFF) {\n    hi = code;\n    low = str.charCodeAt(idx + 1);\n    // Go one further, since one of the \"characters\"\n    // is part of a surrogate pair\n    return ((hi - 0xD800) * 0x400) +\n      (low - 0xDC00) + 0x10000;\n  }\n  return code;\n}\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/publications/files/ECMA-ST-ARCH/ECMA-262,%201st%20edition,%20June%201997.pdf\" hreflang=\"en\">ECMAScript 1st Edition (ECMA-262)</a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition. Implemented in JavaScript 1.2.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/5.1/#sec-15.5.4.5\" hreflang=\"en\">ECMAScript 5.1 (ECMA-262)<br><small>The definition of 'String.prototype.charCodeAt' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-string.prototype.charcodeat\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'String.prototype.charCodeAt' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-string.prototype.charcodeat\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'String.prototype.charCodeAt' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"fromcharcode\"><code>String.fromCharCode()</code></a></li> <li><a href=\"charat\"><code>String.prototype.charAt()</code></a></li> <li><a href=\"fromcodepoint\"><code>String.fromCodePoint()</code></a></li> <li><a href=\"codepointat\"><code>String.prototype.codePointAt()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/charCodeAt$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/charCodeAt\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/charCodeAt</a>\n  </p>\n</div>\n","global_objects/string/concat":"<h1>string.concat</h1> <p>The <code>concat()</code> method concatenates the string arguments to the calling string and returns a new string.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/string-concat.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\"><var>str</var>.concat(<var>string2[</var>, <var>string3</var>, ..., <var>stringN</var>])</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><code>string2...string<em>N</em></code></dt> <dd>Strings to concatenate to this string.</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p>A new string containing the combined text of the strings provided.</p> <h2 id=\"Description\">Description</h2> <p>The <code>concat()</code> function concatenates the string arguments to the calling string and returns a new string. Changes to the original string or the returned string don't affect the other. If the arguments are not of the type string, they are converted to string values before concatenating.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Using_concat()\">Using <code>concat()</code>\n</h3> <p>The following example combines strings into a new string.</p> <pre data-language=\"js\">var hello = 'Hello, ';\nconsole.log(hello.concat('Kevin', '. Have a nice day.'));\n/* Hello, Kevin. Have a nice day. */\n\nvar greetList = ['Hello', ' ', 'Venkat', '!'];\n\"\".concat(...greetList); // \"Hello Venkat!\"\n\n\"\".concat({}); // [object Object]\n\"\".concat([]); // \"\"\n\"\".concat(null); // \"null\"\n\"\".concat(true); // \"true\"\n\"\".concat(4, 5); // \"45\"\n\n</pre> <h2 id=\"Performance\">Performance</h2> <p>It is strongly recommended that the <a href=\"../../operators/assignment_operators\">assignment operators</a> (<code>+</code>, <code>+=</code>) are used instead of the <code>concat()</code> method. <br> According to this <a href=\"https://jsperf.com/concat-vs-plus-vs-join\">performance test</a>, the <a href=\"../../operators/assignment_operators\">assignment operators</a> are several times faster.</p> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/publications/files/ECMA-ST-ARCH/ECMA-262,%203rd%20edition,%20December%201999.pdf\" hreflang=\"en\">ECMAScript 3rd Edition (ECMA-262)</a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition. Implemented in JavaScript 1.2.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/5.1/#sec-15.5.4.6\" hreflang=\"en\">ECMAScript 5.1 (ECMA-262)<br><small>The definition of 'String.prototype.concat' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-string.prototype.concat\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'String.prototype.concat' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-string.prototype.concat\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'String.prototype.concat' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"../array/concat\"><code>Array.prototype.concat()</code></a></li> <li><a href=\"../../operators/assignment_operators\">Assignment operators</a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/concat$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/concat\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/concat</a>\n  </p>\n</div>\n","global_objects/string/endswith":"<h1>string.endsWith</h1> <p>The <code>endsWith()</code> method determines whether a string ends with the characters of a specified string, returning <code>true</code> or <code>false</code> as appropriate.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/string-endswith.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\"><var>str</var>.endsWith(<var>searchString</var>[, <var>length</var>])</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><code>searchString</code></dt> <dd>The characters to be searched for at the end of this string.</dd> <dt><code>length</code></dt> <dd>Optional. If provided it is used as the length of <code>str</code>. If omitted, the default value is the length of the string.</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p><code>true</code> if the given characters are found at the end of the string; otherwise, <code>false</code>.</p> <h2 id=\"Description\">Description</h2> <p>This method lets you determine whether or not a string ends with another string. This method is case-sensitive.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Using_endsWith()\">Using <code>endsWith()</code>\n</h3> <pre data-language=\"js\">var str = 'To be, or not to be, that is the question.';\n\nconsole.log(str.endsWith('question.')); // true\nconsole.log(str.endsWith('to be'));     // false\nconsole.log(str.endsWith('to be', 19)); // true\n</pre> <h2 id=\"Polyfill\">Polyfill</h2> <p>This method has been added to the ECMAScript 6 specification and may not be available in all JavaScript implementations yet. However, you can polyfill <code>String.prototype.endsWith()</code> with the following snippet:</p> <pre data-language=\"js\">if (!String.prototype.endsWith) {\n\tString.prototype.endsWith = function(search, this_len) {\n\t\tif (this_len === undefined || this_len &gt; this.length) {\n\t\t\tthis_len = this.length;\n\t\t}\n\t\treturn this.substring(this_len - search.length, this_len) === search;\n\t};\n}\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-string.prototype.endswith\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'String.prototype.endsWith' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-string.prototype.endswith\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'String.prototype.endsWith' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 41</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 17</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 28</td>\n<td class=\"bc-supports-yes\"> 9</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 36</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 17</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 9</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes bc-has-history\"> 4.0.0\n<section class=\"bc-history\" id=\"sect1\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 4.0.0\n</dt>\n\n<dt class=\"bc-supports-yes bc-supports\"> 0.12<div class=\"bc-icons\">Disabled </div>\n</dt>\n<dd>Disabled From version 0.12: this feature is behind the <code>--harmony</code> runtime flag.</dd>\n</dl></section>\n</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"startswith\"><code>String.prototype.startsWith()</code></a></li> <li><a href=\"includes\"><code>String.prototype.includes()</code></a></li> <li><a href=\"indexof\"><code>String.prototype.indexOf()</code></a></li> <li><a href=\"lastindexof\"><code>String.prototype.lastIndexOf()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/endsWith$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/endsWith\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/endsWith</a>\n  </p>\n</div>\n","global_objects/string/fixed":"<h1>string.fixed</h1> <div class=\"blockIndicator deprecated deprecatedHeader\"> <p><strong> Deprecated</strong><br>This feature is no longer recommended. Though some browsers might still support it, it may have already been removed from the relevant web standards, may be in the process of being dropped, or may only be kept for compatibility purposes. Avoid using it, and update existing code if possible; see the <a href=\"#Browser_compatibility\">compatibility table</a> at the bottom of this page to guide your decision. Be aware that this feature may cease to work at any time.</p> </div> <p>The <code>fixed()</code> method creates a <a href=\"https://developer.mozilla.org/en-US/docs/Web/HTML/Element/tt\"><code>&lt;tt&gt;</code></a> HTML element that causes a string to be displayed in fixed-pitch font.</p> <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\"><var>str</var>.fixed()</pre> <h3 id=\"Return_value\">Return value</h3> <p>A string representing a <a href=\"https://developer.mozilla.org/en-US/docs/Web/HTML/Element/tt\"><code>&lt;tt&gt;</code></a> HTML element.</p> <h2 id=\"Description\">Description</h2> <p>The <code>fixed()</code> method embeds a string in a <code>&lt;tt&gt;</code> tag: <code>\"&lt;tt&gt;str&lt;/tt&gt;\"</code>.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Using_fixed()\">Using <code>fixed()</code>\n</h3> <p>The following example uses the <code>fixed</code> method to change the formatting of a string:</p> <pre data-language=\"js\">var worldString = 'Hello, world';\nconsole.log(worldString.fixed()); // \"&lt;tt&gt;Hello, world&lt;/tt&gt;\"\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-string.prototype.fixed\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'String.prototype.fixed' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition. Implemented in JavaScript 1.0. Defined in the (normative) Annex B for Additional ECMAScript Features for Web Browsers.</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-string.prototype.fixed\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'String.prototype.fixed' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td>Defined in the (normative) Annex B for Additional ECMAScript Features for Web Browsers.</td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support \n</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support \n</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support \n</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"bold\"><code>String.prototype.bold()</code></a></li> <li><a href=\"italics\"><code>String.prototype.italics()</code></a></li> <li><a href=\"strike\"><code>String.prototype.strike()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/fixed$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/fixed\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/fixed</a>\n  </p>\n</div>\n","global_objects/string/fontsize":"<h1>string.fontsize</h1> <div class=\"blockIndicator deprecated deprecatedHeader\"> <p><strong> Deprecated</strong><br>This feature is no longer recommended. Though some browsers might still support it, it may have already been removed from the relevant web standards, may be in the process of being dropped, or may only be kept for compatibility purposes. Avoid using it, and update existing code if possible; see the <a href=\"#Browser_compatibility\">compatibility table</a> at the bottom of this page to guide your decision. Be aware that this feature may cease to work at any time.</p> </div> <p>The <code>fontsize()</code> method creates a <a href=\"https://developer.mozilla.org/en-US/docs/Web/HTML/Element/font\"><code>&lt;font&gt;</code></a> HTML element that causes a string to be displayed in the specified font size.</p> <div class=\"note\"> <p><strong>Usage note:</strong> The &lt;font&gt; element has been removed in <a href=\"https://developer.mozilla.org/en-US/docs/Web/Guide/HTML/HTML5\">HTML5</a> and shouldn't be used anymore. Instead web developers should use <a href=\"https://developer.mozilla.org/en-US/docs/Web/CSS\">CSS</a> properties.</p> </div> <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\"><var>str</var>.fontsize(<var>size</var>)</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><code>size</code></dt> <dd>An integer between 1 and 7, a string representing a signed integer between 1 and 7.</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p>A string containing a <a href=\"https://developer.mozilla.org/en-US/docs/Web/HTML/Element/font\"><code>&lt;font&gt;</code></a> HTML element.</p> <h2 id=\"Description\">Description</h2> <p>When you specify size as an integer, you set the font size of <code>str</code> to one of the 7 defined sizes. When you specify <code>size</code> as a string such as \"-2\", you adjust the font size of <code>str</code> relative to the size set in the <a href=\"https://developer.mozilla.org/en-US/docs/Web/HTML/Element/basefont\"><code>&lt;basefont&gt;</code></a> tag.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Using_fontsize()\">Using <code>fontsize()</code>\n</h3> <p>The following example uses string methods to change the size of a string:</p> <pre data-language=\"js\">var worldString = 'Hello, world';\n\nconsole.log(worldString.small());     // &lt;small&gt;Hello, world&lt;/small&gt;\nconsole.log(worldString.big());       // &lt;big&gt;Hello, world&lt;/big&gt;\nconsole.log(worldString.fontsize(7)); // &lt;font size=\"7\"&gt;Hello, world&lt;/fontsize&gt;\n</pre> <p>With the <a href=\"https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/style\"><code>element.style</code></a> object you can get the element's <code>style</code> attribute and manipulate it more generically, for example:</p> <pre data-language=\"js\">document.getElementById('yourElemId').style.fontSize = '0.7em';\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-string.prototype.fontsize\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'String.prototype.fontsize' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition. Implemented in JavaScript 1.0. Defined in the (normative) Annex B for Additional ECMAScript Features for Web Browsers.</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-string.prototype.fontsize\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'String.prototype.fontsize' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td>Defined in the (normative) Annex B for Additional ECMAScript Features for Web Browsers.</td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support \n</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support \n</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support \n</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"big\"><code>String.prototype.big()</code></a></li> <li><a href=\"small\"><code>String.prototype.small()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/fontsize$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/fontsize\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/fontsize</a>\n  </p>\n</div>\n","global_objects/string/prototype":"<h1>String.prototype</h1> <p>The <code>String.prototype</code> property represents the <a href=\"../string\"><code>String</code></a> prototype object.</p> <div class=\"_table\"><table class=\"standard-table\"> <thead> <tr> <th colspan=\"2\" class=\"header\">Property attributes of <code>String.prototype</code>\n</th> </tr> </thead> <tbody> <tr> <td>Writable</td> <td>no</td> </tr> <tr> <td>Enumerable</td> <td>no</td> </tr> <tr> <td>Configurable</td> <td>no</td> </tr> </tbody> </table></div> <h2 id=\"Description\">Description</h2> <p>All <a href=\"../string\"><code>String</code></a> instances inherit from <code>String.prototype</code>. Changes to the <code>String</code> prototype object are propagated to all <a href=\"../string\"><code>String</code></a> instances.</p> <h2 id=\"Properties\">Properties</h2> <dl> <dt><code>String.prototype.constructor</code></dt> <dd>Specifies the function that creates an object's prototype.</dd> <dt><a href=\"length\"><code>String.prototype.length</code></a></dt> <dd>Reflects the length of the string.</dd> <dt><code><em>N</em></code></dt> <dd>Used to access the character in the <em>N</em>th position where <em>N</em> is an integer between 0 and one less than the value of <a href=\"length\"><code>length</code></a>. These properties are read-only.</dd> </dl> <h2 id=\"Methods\">Methods</h2> <h3 id=\"Methods_unrelated_to_HTML\">Methods unrelated to HTML</h3> <dl> <dt><a href=\"charat\"><code>String.prototype.charAt()</code></a></dt> <dd>Returns the character (exactly one UTF-16 code unit) at the specified index.</dd> <dt><a href=\"charcodeat\"><code>String.prototype.charCodeAt()</code></a></dt> <dd>Returns a number that is the UTF-16 code unit value at the given index.</dd> <dt><a href=\"codepointat\"><code>String.prototype.codePointAt()</code></a></dt> <dd>Returns a nonnegative integer Number that is the code point value of the UTF-16 encoded code point starting at the specified index.</dd> <dt><a href=\"concat\"><code>String.prototype.concat()</code></a></dt> <dd>Combines the text of two strings and returns a new string.</dd> <dt><a href=\"includes\"><code>String.prototype.includes()</code></a></dt> <dd>Determines whether one string may be found within another string.</dd> <dt><a href=\"endswith\"><code>String.prototype.endsWith()</code></a></dt> <dd>Determines whether a string ends with the characters of another string.</dd> <dt><a href=\"indexof\"><code>String.prototype.indexOf()</code></a></dt> <dd>Returns the index within the calling <a href=\"../string\"><code>String</code></a> object of the first occurrence of the specified value, or -1 if not found.</dd> <dt><a href=\"lastindexof\"><code>String.prototype.lastIndexOf()</code></a></dt> <dd>Returns the index within the calling <a href=\"../string\"><code>String</code></a> object of the last occurrence of the specified value, or -1 if not found.</dd> <dt><a href=\"localecompare\"><code>String.prototype.localeCompare()</code></a></dt> <dd>Returns a number indicating whether a reference string comes before or after or is the same as the given string in sort order.</dd> <dt><a href=\"match\"><code>String.prototype.match()</code></a></dt> <dd>Used to match a regular expression against a string.</dd> <dt><a href=\"normalize\"><code>String.prototype.normalize()</code></a></dt> <dd>Returns the Unicode Normalization Form of the calling string value.</dd> <dt><a href=\"padend\"><code>String.prototype.padEnd()</code></a></dt> <dd>Pads the current string from the end with a given string to create a new string from a given length.</dd> <dt><a href=\"padstart\"><code>String.prototype.padStart()</code></a></dt> <dd>Pads the current string from the start with a given string to create a new string from a given length.</dd> <dt><s class=\"obsoleteElement\"><a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/quote\"><code>String.prototype.quote()</code></a> </s></dt> <dd><s class=\"obsoleteElement\">Wraps the string in double quotes (\"<code>\"</code>\").</s></dd> <dt><a href=\"repeat\"><code>String.prototype.repeat()</code></a></dt> <dd>Returns a string consisting of the elements of the object repeated the given times.</dd> <dt><a href=\"replace\"><code>String.prototype.replace()</code></a></dt> <dd>Used to find a match between a regular expression and a string, and to replace the matched substring with a new substring.</dd> <dt><a href=\"search\"><code>String.prototype.search()</code></a></dt> <dd>Executes the search for a match between a regular expression and a specified string.</dd> <dt><a href=\"slice\"><code>String.prototype.slice()</code></a></dt> <dd>Extracts a section of a string and returns a new string.</dd> <dt><a href=\"split\"><code>String.prototype.split()</code></a></dt> <dd>Splits a <a href=\"../string\"><code>String</code></a> object into an array of strings by separating the string into substrings.</dd> <dt><a href=\"startswith\"><code>String.prototype.startsWith()</code></a></dt> <dd>Determines whether a string begins with the characters of another string.</dd> <dt>\n<a href=\"substr\"><code>String.prototype.substr()</code></a> \n</dt> <dd>Returns the characters in a string beginning at the specified location through the specified number of characters.</dd> <dt><a href=\"substring\"><code>String.prototype.substring()</code></a></dt> <dd>Returns the characters in a string between two indexes into the string.</dd> <dt><a href=\"tolocalelowercase\"><code>String.prototype.toLocaleLowerCase()</code></a></dt> <dd>The characters within a string are converted to lower case while respecting the current locale. For most languages, this will return the same as <a href=\"tolowercase\"><code>toLowerCase()</code></a>.</dd> <dt><a href=\"tolocaleuppercase\"><code>String.prototype.toLocaleUpperCase()</code></a></dt> <dd>The characters within a string are converted to upper case while respecting the current locale. For most languages, this will return the same as <a href=\"touppercase\"><code>toUpperCase()</code></a>.</dd> <dt><a href=\"tolowercase\"><code>String.prototype.toLowerCase()</code></a></dt> <dd>Returns the calling string value converted to lower case.</dd> <dt>\n<a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/toSource\"><code>String.prototype.toSource()</code></a> \n</dt> <dd>Returns an object literal representing the specified object; you can use this value to create a new object. Overrides the <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/toSource\"><code>Object.prototype.toSource()</code></a> method.</dd> <dt><a href=\"tostring\"><code>String.prototype.toString()</code></a></dt> <dd>Returns a string representing the specified object. Overrides the <a href=\"../object/tostring\"><code>Object.prototype.toString()</code></a> method.</dd> <dt><a href=\"touppercase\"><code>String.prototype.toUpperCase()</code></a></dt> <dd>Returns the calling string value converted to uppercase.</dd> <dt><a href=\"trim\"><code>String.prototype.trim()</code></a></dt> <dd>Trims whitespace from the beginning and end of the string. Part of the ECMAScript 5 standard.</dd> <dt>\n<a href=\"trimstart\"><code>String.prototype.trimStart()</code></a><br> <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/trimLeft\"><code>String.prototype.trimLeft()</code></a>\n</dt> <dd>Trims whitespace from the beginning of the string.</dd> <dt>\n<a href=\"trimend\"><code>String.prototype.trimEnd()</code></a><br> <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/trimRight\"><code>String.prototype.trimRight()</code></a>\n</dt> <dd>Trims whitespace from the end of the string.</dd> <dt><a href=\"valueof\"><code>String.prototype.valueOf()</code></a></dt> <dd>Returns the primitive value of the specified object. Overrides the <a href=\"../object/valueof\"><code>Object.prototype.valueOf()</code></a> method.</dd> <dt><a href=\"@@iterator\"><code>String.prototype[@@iterator]()</code></a></dt> <dd>Returns a new <code>Iterator</code> object that iterates over the code points of a String value, returning each code point as a String value.</dd> </dl> <h3 id=\"HTML_wrapper_methods\">HTML wrapper methods</h3> <p>These methods are of limited use, as they provide only a subset of the available HTML tags and attributes.</p> <dl> <dt>\n<a href=\"anchor\"><code>String.prototype.anchor()</code></a> \n</dt> <dd>\n<code><a href=\"https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a#attr-name\">&lt;a name=\"name\"&gt;</a></code> (hypertext target)</dd> <dt>\n<a href=\"big\"><code>String.prototype.big()</code></a> \n</dt> <dd><a href=\"https://developer.mozilla.org/en-US/docs/Web/HTML/Element/big\"><code>&lt;big&gt;</code></a></dd> <dt>\n<a href=\"blink\"><code>String.prototype.blink()</code></a> \n</dt> <dd><a href=\"https://developer.mozilla.org/en-US/docs/Web/HTML/Element/blink\"><code>&lt;blink&gt;</code></a></dd> <dt>\n<a href=\"bold\"><code>String.prototype.bold()</code></a> \n</dt> <dd><a href=\"https://developer.mozilla.org/en-US/docs/Web/HTML/Element/b\"><code>&lt;b&gt;</code></a></dd> <dt>\n<a href=\"fixed\"><code>String.prototype.fixed()</code></a> \n</dt> <dd><a href=\"https://developer.mozilla.org/en-US/docs/Web/HTML/Element/tt\"><code>&lt;tt&gt;</code></a></dd> <dt>\n<a href=\"fontcolor\"><code>String.prototype.fontcolor()</code></a> \n</dt> <dd><code><a href=\"https://developer.mozilla.org/en-US/docs/Web/HTML/Element/font#attr-color\">&lt;font color=\"color\"&gt;</a></code></dd> <dt>\n<a href=\"fontsize\"><code>String.prototype.fontsize()</code></a> \n</dt> <dd><code><a href=\"https://developer.mozilla.org/en-US/docs/Web/HTML/Element/font#attr-size\">&lt;font size=\"size\"&gt;</a></code></dd> <dt>\n<a href=\"italics\"><code>String.prototype.italics()</code></a> \n</dt> <dd><a href=\"https://developer.mozilla.org/en-US/docs/Web/HTML/Element/i\"><code>&lt;i&gt;</code></a></dd> <dt>\n<a href=\"link\"><code>String.prototype.link()</code></a> \n</dt> <dd>\n<code><a href=\"https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a#attr-href\">&lt;a href=\"url\"&gt;</a></code> (link to URL)</dd> <dt>\n<a href=\"small\"><code>String.prototype.small()</code></a> \n</dt> <dd><a href=\"https://developer.mozilla.org/en-US/docs/Web/HTML/Element/small\"><code>&lt;small&gt;</code></a></dd> <dt>\n<a href=\"strike\"><code>String.prototype.strike()</code></a> \n</dt> <dd><a href=\"https://developer.mozilla.org/en-US/docs/Web/HTML/Element/strike\"><code>&lt;strike&gt;</code></a></dd> <dt>\n<a href=\"sub\"><code>String.prototype.sub()</code></a> \n</dt> <dd><a href=\"https://developer.mozilla.org/en-US/docs/Web/HTML/Element/sub\"><code>&lt;sub&gt;</code></a></dd> <dt>\n<a href=\"sup\"><code>String.prototype.sup()</code></a> \n</dt> <dd><a href=\"https://developer.mozilla.org/en-US/docs/Web/HTML/Element/sup\"><code>&lt;sup&gt;</code></a></dd> </dl> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/publications/files/ECMA-ST-ARCH/ECMA-262,%201st%20edition,%20June%201997.pdf\" hreflang=\"en\">ECMAScript 1st Edition (ECMA-262)</a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/5.1/#sec-15.5.3.1\" hreflang=\"en\">ECMAScript 5.1 (ECMA-262)<br><small>The definition of 'String.prototype' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-string.prototype\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'String.prototype' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-string.prototype\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'String.prototype' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"../string\"><code>String</code></a></li> <li><a href=\"../function/prototype\"><code>Function.prototype</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/prototype$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/prototype\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/prototype</a>\n  </p>\n</div>\n","global_objects/string/fontcolor":"<h1>string.fontcolor</h1> <div class=\"blockIndicator deprecated deprecatedHeader\"> <p><strong> Deprecated</strong><br>This feature is no longer recommended. Though some browsers might still support it, it may have already been removed from the relevant web standards, may be in the process of being dropped, or may only be kept for compatibility purposes. Avoid using it, and update existing code if possible; see the <a href=\"#Browser_compatibility\">compatibility table</a> at the bottom of this page to guide your decision. Be aware that this feature may cease to work at any time.</p> </div> <p>The <code>fontcolor()</code> method creates a <a href=\"https://developer.mozilla.org/en-US/docs/Web/HTML/Element/font\"><code>&lt;font&gt;</code></a> HTML element that causes a string to be displayed in the specified font color.</p> <div class=\"note\"> <p><strong>Usage note:</strong> The &lt;font&gt; element has been removed in <a href=\"https://developer.mozilla.org/en-US/docs/Web/Guide/HTML/HTML5\">HTML5</a> and shouldn't be used anymore. Instead web developers should use <a href=\"https://developer.mozilla.org/en-US/docs/Web/CSS\">CSS</a> properties.</p> </div> <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\"><var>str</var>.fontcolor(<var>color</var>)</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><code>color</code></dt> <dd>A string expressing the color as a hexadecimal RGB triplet or as a string literal. String literals for color names are listed in the <a href=\"https://developer.mozilla.org/en-US/docs/Web/CSS/color_value\">CSS color reference</a>.</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p>A string containing a <a href=\"https://developer.mozilla.org/en-US/docs/Web/HTML/Element/font\"><code>&lt;font&gt;</code></a> HTML element.</p> <h2 id=\"Description\">Description</h2> <p>If you express color as a hexadecimal RGB triplet, you must use the format <code>rrggbb</code>. For example, the hexadecimal RGB values for salmon are red=FA, green=80, and blue=72, so the RGB triplet for salmon is <code>\"FA8072\"</code>.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Using_fontcolor()\">Using <code>fontcolor()</code>\n</h3> <p>The following example uses the <code>fontcolor()</code> method to change the color of a string by producing a string with the HTML <code>&lt;font&gt;</code> tag.</p> <pre data-language=\"js\">var worldString = 'Hello, world';\n\nconsole.log(worldString.fontcolor('red') +  ' is red in this line');\n// '&lt;font color=\"red\"&gt;Hello, world&lt;/font&gt; is red in this line'\n\nconsole.log(worldString.fontcolor('FF00') + ' is red in hexadecimal in this line');\n// '&lt;font color=\"FF00\"&gt;Hello, world&lt;/font&gt; is red in hexadecimal in this line'\n</pre> <p>With the <a href=\"https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/style\"><code>element.style</code></a> object you can get the element's <code>style</code> attribute and manipulate it more generically, for example:</p> <pre data-language=\"js\">document.getElementById('yourElemId').style.color = 'red';\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-string.prototype.fontcolor\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'String.prototype.fontcolor' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition. Implemented in JavaScript 1.0. Defined in the (normative) Annex B for Additional ECMAScript Features for Web Browsers.</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-string.prototype.fontcolor\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'String.prototype.fontcolor' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td>Defined in the (normative) Annex B for Additional ECMAScript Features for Web Browsers.</td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support \n</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support \n</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support \n</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"fontsize\"><code>String.prototype.fontsize()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/fontcolor$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/fontcolor\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/fontcolor</a>\n  </p>\n</div>\n","global_objects/string/italics":"<h1>string.italics</h1> <div class=\"blockIndicator deprecated deprecatedHeader\"> <p><strong> Deprecated</strong><br>This feature is no longer recommended. Though some browsers might still support it, it may have already been removed from the relevant web standards, may be in the process of being dropped, or may only be kept for compatibility purposes. Avoid using it, and update existing code if possible; see the <a href=\"#Browser_compatibility\">compatibility table</a> at the bottom of this page to guide your decision. Be aware that this feature may cease to work at any time.</p> </div> <p>The <code>italics()</code> method creates an <a href=\"https://developer.mozilla.org/en-US/docs/Web/HTML/Element/i\"><code>&lt;i&gt;</code></a> HTML element that causes a string to be italic.</p> <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\"><var>str</var>.italics()</pre> <h3 id=\"Return_value\">Return value</h3> <p>A string containing a <a href=\"https://developer.mozilla.org/en-US/docs/Web/HTML/Element/i\"><code>&lt;i&gt;</code></a> HTML element.</p> <h2 id=\"Description\">Description</h2> <p>The <code>italics()</code> method embeds a string in an <code>&lt;i&gt;</code> tag: <code>\"&lt;i&gt;str&lt;/i&gt;\"</code>.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Using_italics()\">Using <code>italics()</code>\n</h3> <p>The following example uses string methods to change the formatting of a string:</p> <pre data-language=\"js\">var worldString = 'Hello, world';\nconsole.log(worldString.blink());  // &lt;blink&gt;Hello, world&lt;/blink&gt;\nconsole.log(worldString.bold());  // &lt;b&gt;Hello, world&lt;/b&gt;\nconsole.log(worldString.italics()); // &lt;i&gt;Hello, world&lt;/i&gt;\nconsole.log(worldString.strike());  // &lt;strike&gt;Hello, world&lt;/strike&gt;\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-string.prototype.italics\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'String.prototype.italics' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition. Implemented in JavaScript 1.0. Defined in the (normative) Annex B for Additional ECMAScript Features for Web Browsers.</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-string.prototype.italics\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'String.prototype.italics' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td>Defined in the (normative) Annex B for Additional ECMAScript Features for Web Browsers.</td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support \n</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support \n</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support \n</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"blink\"><code>String.prototype.blink()</code></a></li> <li><a href=\"bold\"><code>String.prototype.bold()</code></a></li> <li><a href=\"strike\"><code>String.prototype.strike()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/italics$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/italics\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/italics</a>\n  </p>\n</div>\n","global_objects/string/padend":"<h1>string.padEnd</h1> <p>The <code>padEnd()</code> method pads the current string with a given string (repeated, if needed) so that the resulting string reaches a given length. The padding is applied from the end (right) of the current string.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/string-padend.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\"><var>str</var>.padEnd(<var>targetLength</var> [, <var>padString</var>])</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><code>targetLength</code></dt> <dd>The length of the resulting string once the current string has been padded. If the value is lower than the current string's length, the current string will be returned as is.</dd> <dt>\n<code>padString</code> <span class=\"inlineIndicator optional optionalInline\">Optional</span>\n</dt> <dd>The string to pad the current string with. If this string is too long to stay within the target length, it will be truncated and the left-most part will be applied. The default value for this parameter is \" \" (U+0020).</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p>A <a href=\"../string\"><code>String</code></a> of the specified length with the pad string applied at the end of the current string.</p> <h2 id=\"Examples\">Examples</h2> <pre data-language=\"js\">'abc'.padEnd(10);          // \"abc       \"\n'abc'.padEnd(10, \"foo\");   // \"abcfoofoof\"\n'abc'.padEnd(6, \"123456\"); // \"abc123\"\n'abc'.padEnd(1);           // \"abc\"</pre> <h2 id=\"Polyfill\">Polyfill</h2> <p>Running the following code before any other code will create <code>String.prototype.padEnd()</code> if it's not natively available.</p> <pre data-language=\"js\">// https://github.com/uxitten/polyfill/blob/master/string.polyfill.js\n// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/padEnd\nif (!String.prototype.padEnd) {\n    String.prototype.padEnd = function padEnd(targetLength,padString) {\n        targetLength = targetLength&gt;&gt;0; //floor if number or convert non-number to 0;\n        padString = String((typeof padString !== 'undefined' ? padString : ' '));\n        if (this.length &gt; targetLength) {\n            return String(this);\n        }\n        else {\n            targetLength = targetLength-this.length;\n            if (targetLength &gt; padString.length) {\n                padString += padString.repeat(targetLength/padString.length); //append to original to ensure we are longer than needed\n            }\n            return String(this) + padString.slice(0,targetLength);\n        }\n    };\n}\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-string.prototype.padend\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'String.prototype.padEnd' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td>Initial definition in ECMAScript 2017.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/8.0/#sec-string.prototype.padend\" hreflang=\"en\">ECMAScript 2017 (ECMA-262)<br><small>The definition of 'String.prototype.padEnd' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 57</td>\n<td class=\"bc-supports-yes\"> 15</td>\n<td class=\"bc-supports-yes\"> 48</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 44</td>\n<td class=\"bc-supports-yes\"> 10</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 57</td>\n<td class=\"bc-supports-yes\"> 57</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 48</td>\n<td class=\"bc-supports-yes\"> 44</td>\n<td class=\"bc-supports-yes\"> 10</td>\n<td class=\"bc-supports-yes\"> 7.0</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes bc-has-history\"> 8.0.0\n<section class=\"bc-history\" id=\"sect1\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 8.0.0\n</dt>\n\n<dt class=\"bc-supports-yes bc-supports\"> 7.0.0<div class=\"bc-icons\">Disabled </div>\n</dt>\n<dd>Disabled From version 7.0.0: this feature is behind the <code>--harmony</code> runtime flag.</dd>\n</dl></section>\n</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"padstart\"><code>String.prototype.padStart()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/padEnd$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/padEnd\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/padEnd</a>\n  </p>\n</div>\n","global_objects/string/padstart":"<h1>string.padStart</h1> <p>The <code>padStart()</code> method pads the current string with another string (multiple times, if needed) until the resulting string reaches the given length. The padding is applied from the start (left) of the current string.</p>  <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/string-padstart.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>   <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\"><var>str</var>.padStart(<var>targetLength</var> [, <var>padString</var>])</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><code>targetLength</code></dt> <dd>The length of the resulting string once the current string has been padded. If the value is less than the current string's length, the current string is returned as is.</dd> <dt>\n<code>padString</code> <span class=\"inlineIndicator optional optionalInline\">Optional</span>\n</dt> <dd>The string to pad the current string with. If this padding string is too long to stay within the <code>targetLength</code>, it will be truncated from the right. The default value is <code>\" \"</code> (U+0020 'SPACE').</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p>A <a href=\"../string\"><code>String</code></a> of the specified length with the pad string applied from the start.</p> <h2 id=\"Examples\">Examples</h2> <pre data-language=\"js\">'abc'.padStart(10);         // \"       abc\"\n'abc'.padStart(10, \"foo\");  // \"foofoofabc\"\n'abc'.padStart(6,\"123465\"); // \"123abc\"\n'abc'.padStart(8, \"0\");     // \"00000abc\"\n'abc'.padStart(1);          // \"abc\"</pre> <h2 id=\"Polyfill\">Polyfill</h2> <p>Running the following code before any other code will create <code>String.prototype.padStart()</code> if it's not natively available.</p> <pre data-language=\"js\">// https://github.com/uxitten/polyfill/blob/master/string.polyfill.js\n// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/padStart\nif (!String.prototype.padStart) {\n    String.prototype.padStart = function padStart(targetLength, padString) {\n        targetLength = targetLength &gt;&gt; 0; //truncate if number, or convert non-number to 0;\n        padString = String(typeof padString !== 'undefined' ? padString : ' ');\n        if (this.length &gt;= targetLength) {\n            return String(this);\n        } else {\n            targetLength = targetLength - this.length;\n            if (targetLength &gt; padString.length) {\n                padString += padString.repeat(targetLength / padString.length); //append to original to ensure we are longer than needed\n            }\n            return padString.slice(0, targetLength) + String(this);\n        }\n    };\n}\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-string.prototype.padstart\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'String.prototype.padStart' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td>Initial definition in ECMAScript 2017.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/8.0/#sec-string.prototype.padstart\" hreflang=\"en\">ECMAScript 2017 (ECMA-262)<br><small>The definition of 'String.prototype.padStart' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 57</td>\n<td class=\"bc-supports-yes\"> 15</td>\n<td class=\"bc-supports-yes\"> 48</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 44</td>\n<td class=\"bc-supports-yes\"> 10</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 57</td>\n<td class=\"bc-supports-yes\"> 57</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 48</td>\n<td class=\"bc-supports-yes\"> 44</td>\n<td class=\"bc-supports-yes\"> 10</td>\n<td class=\"bc-supports-yes\"> 7.0</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes bc-has-history\"> 8.0.0\n<section class=\"bc-history\" id=\"sect1\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 8.0.0\n</dt>\n\n<dt class=\"bc-supports-yes bc-supports\"> 7.0.0<div class=\"bc-icons\">Disabled </div>\n</dt>\n<dd>Disabled From version 7.0.0: this feature is behind the <code>--harmony</code> runtime flag.</dd>\n</dl></section>\n</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"padend\"><code>String.prototype.padEnd()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/padStart$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/padStart\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/padStart</a>\n  </p>\n</div>\n","global_objects/string/includes":"<h1>string.includes</h1> <p>The <code>includes()</code> method determines whether one string may be found within another string, returning <code>true</code> or <code>false</code> as appropriate.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/string-includes.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\"><var>str</var>.includes(<var>searchString</var>[, <var>position</var>])</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><code>searchString</code></dt> <dd>A string to be searched for within this string.</dd> <dt>\n<code>position</code> <span class=\"inlineIndicator optional optionalInline\">Optional</span>\n</dt> <dd>The position within the string at which to begin searching for <code>searchString</code>. (defaults to 0).</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p><code>true</code> if the search string is found anywhere within the given string; otherwise, <code>false</code> if not.</p> <h2 id=\"Description\">Description</h2> <p>This method lets you determine whether or not a string includes another string.</p> <h3 id=\"Case-sensitivity\">Case-sensitivity</h3> <p>The <code>includes()</code> method is case sensitive. For example, the following expression returns false:</p> <pre data-language=\"js\">'Blue Whale'.includes('blue'); // returns false\n</pre> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Using_includes()\">Using <code>includes()</code>\n</h3> <pre data-language=\"js\">var str = 'To be, or not to be, that is the question.';\n\nconsole.log(str.includes('To be'));       // true\nconsole.log(str.includes('question'));    // true\nconsole.log(str.includes('nonexistent')); // false\nconsole.log(str.includes('To be', 1));    // false\nconsole.log(str.includes('TO BE'));       // false\n</pre> <h2 id=\"Polyfill\">Polyfill</h2> <p>This method has been added to the ECMAScript 2015 specification and may not be available in all JavaScript implementations yet. However, you can easily polyfill this method:</p> <pre data-language=\"js\">if (!String.prototype.includes) {\n  Object.defineProperty(String.prototype, 'includes', {\n    value: function(search, start) {\n      if (typeof start !== 'number') {\n        start = 0\n      }\n      \n      if (start + search.length &gt; this.length) {\n        return false\n      } else {\n        return this.indexOf(search, start) !== -1\n      }\n    }\n  })\n}\n\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-string.prototype.includes\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'String.prototype.includes' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-string.prototype.includes\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'String.prototype.includes' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 41</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes bc-has-history\"> 40\n<section class=\"bc-history\" id=\"sect1\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 40\n</dt>\n\n<dt class=\"bc-supports-no bc-supports\">18 — 48\n</dt>\n<dd> Uses the non-standard name: <code>contains</code>\n</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 9</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes bc-has-history\"> 40\n<section class=\"bc-history\" id=\"sect2\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 40\n</dt>\n\n<dt class=\"bc-supports-no bc-supports\">18 — 48\n</dt>\n<dd> Uses the non-standard name: <code>contains</code>\n</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 9</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 4.0.0</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"String.prototype.contains\">String.prototype.contains</h2> <p>In Firefox 18 - 39, the name of this method was <code>contains()</code>. It was renamed to <code>includes()</code> in <a href=\"https://bugzilla.mozilla.org/show_bug.cgi?id=1102219\">bug 1102219</a> due to the following reason:</p> <p>It's been <a href=\"https://bugzilla.mozilla.org/show_bug.cgi?id=789036\">reported</a> that some websites using MooTools 1.2 broke on Firefox 17. This version of MooTools checks whether <code>String.prototype.contains()</code> exists and, if it doesn't, MooTools adds its own function. With the introduction of this function in Firefox 17, the behavior of that check changed in a way that causes code based on MooTools' <code>String.prototype.contains()</code> implementation to break. As a result, the implementation was <a href=\"https://hg.mozilla.org/releases/mozilla-aurora/rev/086db97198a8\">disabled</a> in Firefox 17 and <code>String.prototype.contains()</code> was available one version later, in Firefox 18, when <a href=\"https://bugzilla.mozilla.org/show_bug.cgi?id=789036#c32\">outreach to MooTools </a>was leading to the <a href=\"http://mootools.net/blog/2013/02/19/mootools-1-2-6-released\">release of MooTools version 1.2.6</a>.</p> <p>MooTools 1.3 forces its own version of <code>String.prototype.contains()</code>, so websites relying on it should not break. However, you should note that <a href=\"http://mootools.net/core/docs/1.3.2/Types/String#String-method:-contains\">MooTools 1.3 signature</a> and ECMAScript 2015 signatures for this method differ (on the second argument). Later, <a href=\"https://github.com/mootools/mootools-core/blob/master/Docs/Types/String.md#note\">MooTools 1.5+ changed the signature to match the ES2015 standard.</a></p> <p>In Firefox 48, <code>String.prototype.contains()</code> has been removed. Use <code>String.prototype.includes()</code> only.</p> <h2 id=\"See_also\">See also</h2> <ul> <li>\n<a href=\"../array/includes\"><code>Array.prototype.includes()</code></a> \n</li> <li>\n<a href=\"../typedarray/includes\"><code>TypedArray.prototype.includes()</code></a> \n</li> <li><a href=\"indexof\"><code>String.prototype.indexOf()</code></a></li> <li><a href=\"lastindexof\"><code>String.prototype.lastIndexOf()</code></a></li> <li><a href=\"startswith\"><code>String.prototype.startsWith()</code></a></li> <li><a href=\"endswith\"><code>String.prototype.endsWith()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/includes$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/includes\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/includes</a>\n  </p>\n</div>\n","global_objects/string/charat":"<h1>string.charAt</h1> <p>The <a href=\"../string\"><code>String</code></a> object's <code>charAt()</code> method returns a new string consisting of the single UTF-16 code unit located at the specified offset into the string.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/string-charat.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\"><em>character</em> = <em>str</em>.charAt(<em>index</em>)</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><code>index</code></dt> <dd>An integer between 0 and 1-less-than the length of the string. If no index is provided, the default is 0, so the first character in the string is returned.</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p>A string representing the character (exactly one UTF-16 code unit) at the specified index; empty string if <code>index</code> is out of range.</p> <h2 id=\"Description\">Description</h2> <p>Characters in a string are indexed from left to right. The index of the first character is 0, and the index of the last character in a string called <code>stringName</code> is <code>stringName.length - 1</code>. If the <code>index</code> you supply is out of this range, JavaScript returns an empty string.</p> <p>If no index is provided to <code>charAt()</code>, the default is 0.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Displaying_characters_at_different_locations_in_a_string\">Displaying characters at different locations in a string</h3> <p>The following example displays characters at different locations in the string <code>\"Brave new world\"</code>:</p> <pre data-language=\"js\">var anyString = 'Brave new world';\nconsole.log(\"The character at index 0   is '\" + anyString.charAt()   + \"'\"); \n// No index was provided, used 0 as default\n\nconsole.log(\"The character at index 0   is '\" + anyString.charAt(0)   + \"'\");\nconsole.log(\"The character at index 1   is '\" + anyString.charAt(1)   + \"'\");\nconsole.log(\"The character at index 2   is '\" + anyString.charAt(2)   + \"'\");\nconsole.log(\"The character at index 3   is '\" + anyString.charAt(3)   + \"'\");\nconsole.log(\"The character at index 4   is '\" + anyString.charAt(4)   + \"'\");\nconsole.log(\"The character at index 999 is '\" + anyString.charAt(999) + \"'\");\n</pre> <p>These lines display the following:</p> <pre data-language=\"js\">The character at index 0   is 'B'\n\nThe character at index 0   is 'B'\nThe character at index 1   is 'r'\nThe character at index 2   is 'a'\nThe character at index 3   is 'v'\nThe character at index 4   is 'e'\nThe character at index 999 is ''\n</pre> <h3 id=\"Getting_whole_characters\">Getting whole characters</h3> <p>The following provides a means of ensuring that going through a string loop always provides a whole character, even if the string contains characters that are not in the Basic Multi-lingual Plane.</p> <pre data-language=\"js\">var str = 'A \\uD87E\\uDC04 Z'; // We could also use a non-BMP character directly\nfor (var i = 0, chr; i &lt; str.length; i++) {\n  if ((chr = getWholeChar(str, i)) === false) {\n    continue;\n  }\n  // Adapt this line at the top of each loop, passing in the whole string and\n  // the current iteration and returning a variable to represent the \n  // individual character\n\n  console.log(chr);\n}\n\nfunction getWholeChar(str, i) {\n  var code = str.charCodeAt(i);\n\n  if (Number.isNaN(code)) {\n    return ''; // Position not found\n  }\n  if (code &lt; 0xD800 || code &gt; 0xDFFF) {\n    return str.charAt(i);\n  }\n\n  // High surrogate (could change last hex to 0xDB7F to treat high private\n  // surrogates as single characters)\n  if (0xD800 &lt;= code &amp;&amp; code &lt;= 0xDBFF) {\n    if (str.length &lt;= (i + 1)) {\n      throw 'High surrogate without following low surrogate';\n    }\n    var next = str.charCodeAt(i + 1);\n      if (0xDC00 &gt; next || next &gt; 0xDFFF) {\n        throw 'High surrogate without following low surrogate';\n      }\n      return str.charAt(i) + str.charAt(i + 1);\n  }\n  // Low surrogate (0xDC00 &lt;= code &amp;&amp; code &lt;= 0xDFFF)\n  if (i === 0) {\n    throw 'Low surrogate without preceding high surrogate';\n  }\n  var prev = str.charCodeAt(i - 1);\n\n  // (could change last hex to 0xDB7F to treat high private\n  // surrogates as single characters)\n  if (0xD800 &gt; prev || prev &gt; 0xDBFF) {\n    throw 'Low surrogate without preceding high surrogate';\n  }\n  // We can pass over low surrogates now as the second component\n  // in a pair which we have already processed\n  return false;\n}\n</pre> <p>In an ECMAScript 2016 environment which allows destructured assignment, the following is a more succinct and somewhat more flexible alternative in that it does incrementing for an incrementing variable automatically (if the character warrants it in being a surrogate pair).</p> <pre data-language=\"js\">var str = 'A\\uD87E\\uDC04Z'; // We could also use a non-BMP character directly\nfor (var i = 0, chr; i &lt; str.length; i++) {\n  [chr, i] = getWholeCharAndI(str, i);\n  // Adapt this line at the top of each loop, passing in the whole string and\n  // the current iteration and returning an array with the individual character\n  // and 'i' value (only changed if a surrogate pair)\n\n  console.log(chr);\n}\n\nfunction getWholeCharAndI(str, i) {\n  var code = str.charCodeAt(i);\n\n  if (Number.isNaN(code)) {\n    return ''; // Position not found\n  }\n  if (code &lt; 0xD800 || code &gt; 0xDFFF) {\n    return [str.charAt(i), i]; // Normal character, keeping 'i' the same\n  }\n\n  // High surrogate (could change last hex to 0xDB7F to treat high private \n  // surrogates as single characters)\n  if (0xD800 &lt;= code &amp;&amp; code &lt;= 0xDBFF) {\n    if (str.length &lt;= (i + 1)) {\n      throw 'High surrogate without following low surrogate';\n    }\n    var next = str.charCodeAt(i + 1);\n      if (0xDC00 &gt; next || next &gt; 0xDFFF) {\n        throw 'High surrogate without following low surrogate';\n      }\n      return [str.charAt(i) + str.charAt(i + 1), i + 1];\n  }\n  // Low surrogate (0xDC00 &lt;= code &amp;&amp; code &lt;= 0xDFFF)\n  if (i === 0) {\n    throw 'Low surrogate without preceding high surrogate';\n  }\n  var prev = str.charCodeAt(i - 1);\n\n  // (could change last hex to 0xDB7F to treat high private surrogates\n  // as single characters)\n  if (0xD800 &gt; prev || prev &gt; 0xDBFF) {\n    throw 'Low surrogate without preceding high surrogate';\n  }\n  // Return the next character instead (and increment)\n  return [str.charAt(i + 1), i + 1];\n}\n</pre> <h3 id=\"Fixing_charAt()_to_support_non-Basic-Multilingual-Plane_(BMP)_characters\">Fixing <code>charAt()</code> to support non-Basic-Multilingual-Plane (BMP) characters</h3> <p>While the example above may be more frequently useful for those wishing to support non-BMP characters (since it does not require the caller to know where any non-BMP character might appear), in the event that one <em>does</em> wish, in choosing a character by index, to treat the surrogate pairs within a string as the single characters they represent, one can use the following:</p> <pre data-language=\"js\">function fixedCharAt(str, idx) {\n  var ret = '';\n  str += '';\n  var end = str.length;\n\n  var surrogatePairs = /[\\uD800-\\uDBFF][\\uDC00-\\uDFFF]/g;\n  while ((surrogatePairs.exec(str)) != null) {\n    var li = surrogatePairs.lastIndex;\n    if (li - 2 &lt; idx) {\n      idx++;\n    } else {\n      break;\n    }\n  }\n\n  if (idx &gt;= end || idx &lt; 0) {\n    return '';\n  }\n\n  ret += str.charAt(idx);\n\n  if (/[\\uD800-\\uDBFF]/.test(ret) &amp;&amp; /[\\uDC00-\\uDFFF]/.test(str.charAt(idx + 1))) {\n    // Go one further, since one of the \"characters\" is part of a surrogate pair\n    ret += str.charAt(idx + 1);\n  }\n  return ret;\n}\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/publications/files/ECMA-ST-ARCH/ECMA-262,%201st%20edition,%20June%201997.pdf\" hreflang=\"en\">ECMAScript 1st Edition (ECMA-262)</a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/5.1/#sec-15.5.4.4\" hreflang=\"en\">ECMAScript 5.1 (ECMA-262)<br><small>The definition of 'String.prototype.charAt' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-string.prototype.charat\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'String.prototype.charAt' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-string.prototype.charat\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'String.prototype.charAt' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"indexof\"><code>String.prototype.indexOf()</code></a></li> <li><a href=\"lastindexof\"><code>String.prototype.lastIndexOf()</code></a></li> <li><a href=\"charcodeat\"><code>String.prototype.charCodeAt()</code></a></li> <li><a href=\"codepointat\"><code>String.prototype.codePointAt()</code></a></li> <li><a href=\"split\"><code>String.prototype.split()</code></a></li> <li><a href=\"fromcodepoint\"><code>String.fromCodePoint()</code></a></li> <li><a href=\"https://mathiasbynens.be/notes/javascript-unicode\">JavaScript has a Unicode problem – Mathias Bynens</a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/charAt$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/charAt\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/charAt</a>\n  </p>\n</div>\n","global_objects/string/indexof":"<h1>string.indexOf</h1> <p>The <code>indexOf()</code> method returns the index within the calling <a href=\"../string\"><code>String</code></a> object of the first occurrence of the specified value, starting the search at <code>fromIndex</code>. Returns -1 if the value is not found.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/string-indexof.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <div class=\"note\">\n<strong>Note:</strong> For the Array method, see <a href=\"../array/indexof\"><code>Array.prototype.indexOf()</code></a>.</div> <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\"><var>str</var>.indexOf(<var>searchValue</var>[, <var>fromIndex</var>])</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><var>searchValue</var></dt> <dd>A string representing the value to search for.</dd> <dt>\n<var>fromIndex</var> <span class=\"inlineIndicator optional optionalInline\">Optional</span>\n</dt> <dd>An integer representing the index at which to start the search; the default value is <code>0</code>. For <code>fromIndex</code> values lower than <code>0</code> or greater than <code>str.length</code>, the search starts at index <code>0</code> and <code>str.length</code> respectively.</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p>The index of the first occurrence of <var>searchValue</var>, or <strong>-1</strong> if not found.<br> An empty string <var>searchValue</var> will match at any index between <code>0</code> and <code>str.length</code></p> <h2 id=\"Description\">Description</h2> <p>Characters in a string are indexed from left to right. The index of the first character is 0, and the index of the last character of a string called <code>stringName</code> is <code>stringName.length - 1</code>.</p> <pre data-language=\"js\">'Blue Whale'.indexOf('Blue');     // returns  0\n'Blue Whale'.indexOf('Blute');    // returns -1\n'Blue Whale'.indexOf('Whale', 0); // returns  5\n'Blue Whale'.indexOf('Whale', 5); // returns  5\n'Blue Whale'.indexOf('Whale', 7); // returns -1\n'Blue Whale'.indexOf('');         // returns  0\n'Blue Whale'.indexOf('', 9);      // returns  9\n'Blue Whale'.indexOf('', 10);     // returns 10\n'Blue Whale'.indexOf('', 11);     // returns 10\n</pre> <p>The <code>indexOf()</code> method is case sensitive. For example, the following expression returns -1:</p> <pre data-language=\"js\">'Blue Whale'.indexOf('blue'); // returns -1\n</pre> <h3 id=\"Checking_occurrences\">Checking occurrences</h3> <p>Note that '0' doesn't evaluate to <code>true</code> and '-1' doesn't evaluate to <code>false</code>. Therefore, when checking if a specific string exists within another string the correct way to check would be:</p> <pre data-language=\"js\">'Blue Whale'.indexOf('Blue') !== -1; // true\n'Blue Whale'.indexOf('Bloe') !== -1; // false\n</pre> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Using_indexOf()\">Using <code>indexOf()</code>\n</h3> <p>The following example uses <code>indexOf()</code> to locate values in the string <code>\"Brave new world\"</code>.</p> <pre data-language=\"js\">var str = 'Brave new world';\n\nconsole.log('Index of first w from start is ' + str.indexOf('w'));  // logs 8\nconsole.log('Index of \"new\" from start is ' + str.indexOf('new'));  // logs 6\n</pre> <h3 id=\"indexOf()_and_case-sensitivity\">\n<code>indexOf()</code> and case-sensitivity</h3> <p>The following example defines two string variables. The variables contain the same string except that the second string contains uppercase letters. The first <a href=\"https://developer.mozilla.org/en-US/docs/Web/API/Console/log\"><code>console.log()</code></a> method displays 19. But because the <code>indexOf()</code> method is case sensitive, the string <code>\"cheddar\"</code> is not found in <code>myCapString</code>, so the second <code>console.log()</code> method displays -1.</p> <pre data-language=\"js\">var myString    = 'brie, pepper jack, cheddar';\nvar myCapString = 'Brie, Pepper Jack, Cheddar';\n\nconsole.log('myString.indexOf(\"cheddar\") is ' + myString.indexOf('cheddar'));\n// logs 19\nconsole.log('myCapString.indexOf(\"cheddar\") is ' + myCapString.indexOf('cheddar'));\n// logs -1\n</pre> <h3 id=\"Using_indexOf()_to_count_occurrences_of_a_letter_in_a_string\">Using <code>indexOf()</code> to count occurrences of a letter in a string</h3> <p>The following example sets <code>count</code> to the number of occurrences of the letter <code>e</code> in the string <code>str</code>:</p> <pre data-language=\"js\">var str = 'To be, or not to be, that is the question.';\nvar count = 0;\nvar pos = str.indexOf('e');\n\nwhile (pos !== -1) {\n  count++;\n  pos = str.indexOf('e', pos + 1);\n}\n\nconsole.log(count); // displays 4\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <thead> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> </thead> <tbody> <tr> <td><a href=\"https://www.ecma-international.org/publications/files/ECMA-ST-ARCH/ECMA-262,%201st%20edition,%20June%201997.pdf\" hreflang=\"en\">ECMAScript 1st Edition (ECMA-262)</a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/5.1/#sec-15.5.4.7\" hreflang=\"en\">ECMAScript 5.1 (ECMA-262)<br><small>The definition of 'String.prototype.indexOf' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-string.prototype.indexof\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'String.prototype.indexOf' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-string.prototype.indexof\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'String.prototype.indexOf' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"charat\"><code>String.prototype.charAt()</code></a></li> <li><a href=\"lastindexof\"><code>String.prototype.lastIndexOf()</code></a></li> <li><a href=\"includes\"><code>String.prototype.includes()</code></a></li> <li><a href=\"split\"><code>String.prototype.split()</code></a></li> <li><a href=\"../array/indexof\"><code>Array.prototype.indexOf()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/indexOf$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/indexOf\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/indexOf</a>\n  </p>\n</div>\n","global_objects/string/lastindexof":"<h1>string.lastIndexOf</h1> <p>The <code>lastIndexOf()</code> method returns the index within the calling <a href=\"../string\"><code>String</code></a> object of the last occurrence of the specified value, searching backwards from <code>fromIndex</code>. Returns -1 if the value is not found.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/string-lastindexof.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\"><var>str</var>.lastIndexOf(<var>searchValue</var>[, <var>fromIndex</var>])</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><code>searchValue</code></dt> <dd>A string representing the value to search for. If <code>searchValue</code> is an empty string, then <code>fromIndex</code> is returned.</dd> <dt>\n<code>fromIndex </code><span class=\"inlineIndicator optional optionalInline\">Optional</span>\n</dt> <dd>The index of the last character in the string to be considered as the beginning of a match. The default value is <code>+Infinity</code>. If <code>fromIndex &gt;= str.length</code>, the whole string is searched. If <code>fromIndex &lt; 0</code>, the behavior will be the same as if it would be <code>0</code>.</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p>The index of the last occurrence of the specified value; <strong>-1</strong> if not found.</p> <h2 id=\"Description\">Description</h2> <p>Characters in a string are indexed from left to right. The index of the first character is 0, and the index of the last character is <code>str.length - 1</code>.</p> <pre data-language=\"js\">'canal'.lastIndexOf('a');     // returns 3\n'canal'.lastIndexOf('a', 2);  // returns 1\n'canal'.lastIndexOf('a', 0);  // returns -1\n'canal'.lastIndexOf('x');     // returns -1\n'canal'.lastIndexOf('c', -5); // returns 0\n'canal'.lastIndexOf('c', 0);  // returns 0\n'canal'.lastIndexOf('');      // returns 5\n'canal'.lastIndexOf('', 2);   // returns 2\n</pre> <div class=\"note\"> <p><strong>Note:</strong> <code>'abab'.lastIndexOf('ab', 2)</code> will return 2 and not 0, as fromIndex limits only the beginning of the match.</p> </div> <h3 id=\"Case-sensitivity\">Case-sensitivity</h3> <p>The <code>lastIndexOf()</code> method is case sensitive. For example, the following expression returns -1:</p> <pre data-language=\"js\">'Blue Whale, Killer Whale'.lastIndexOf('blue'); // returns -1\n</pre> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Using_indexOf()_and_lastIndexOf()\">Using <code>indexOf()</code> and <code>lastIndexOf()</code>\n</h3> <p>The following example uses <a href=\"indexof\"><code>indexOf()</code></a> and <code>lastIndexOf()</code> to locate values in the string <code>\"Brave new world\"</code>.</p> <pre data-language=\"js\">var anyString = 'Brave new world';\n\nconsole.log('The index of the first w from the beginning is ' + anyString.indexOf('w'));\n// logs 8\nconsole.log('The index of the first w from the end is ' + anyString.lastIndexOf('w')); \n// logs 10\nconsole.log('The index of \"new\" from the beginning is ' + anyString.indexOf('new'));\n// logs 6\nconsole.log('The index of \"new\" from the end is ' + anyString.lastIndexOf('new'));\n// logs 6\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/publications/files/ECMA-ST-ARCH/ECMA-262,%201st%20edition,%20June%201997.pdf\" hreflang=\"en\">ECMAScript 1st Edition (ECMA-262)</a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/5.1/#sec-15.5.4.8\" hreflang=\"en\">ECMAScript 5.1 (ECMA-262)<br><small>The definition of 'String.prototype.lastIndexOf' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-string.prototype.lastindexof\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'String.prototype.lastIndexOf' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-string.prototype.lastindexof\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'String.prototype.lastIndexOf' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> 6</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"charat\"><code>String.prototype.charAt()</code></a></li> <li><a href=\"indexof\"><code>String.prototype.indexOf()</code></a></li> <li><a href=\"split\"><code>String.prototype.split()</code></a></li> <li><a href=\"../array/indexof\"><code>Array.prototype.indexOf()</code></a></li> <li><a href=\"../array/lastindexof\"><code>Array.prototype.lastIndexOf()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/lastIndexOf$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/lastIndexOf\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/lastIndexOf</a>\n  </p>\n</div>\n","global_objects/string/link":"<h1>string.link</h1> <div class=\"blockIndicator deprecated deprecatedHeader\"> <p><strong> Deprecated</strong><br>This feature is no longer recommended. Though some browsers might still support it, it may have already been removed from the relevant web standards, may be in the process of being dropped, or may only be kept for compatibility purposes. Avoid using it, and update existing code if possible; see the <a href=\"#Browser_compatibility\">compatibility table</a> at the bottom of this page to guide your decision. Be aware that this feature may cease to work at any time.</p> </div> <p>The <code>link()</code> method creates a string representing the code for an <a href=\"https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a\"><code>&lt;a&gt;</code></a> HTML element to be used as a hypertext link to another URL.</p> <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\"><var>str</var>.link(<var>url</var>)</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><code>url</code></dt> <dd>Any string that specifies the <code>href</code> attribute of the <code>&lt;a&gt;</code> tag; it should be a valid URL (relative or absolute), with any <code>&amp;</code> characters escaped as <code>&amp;amp;</code>, and any <code>\"</code> characters escaped as <code>&amp;quot;</code>.</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p>A string containing an <a href=\"https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a\"><code>&lt;a&gt;</code></a> HTML element.</p> <h2 id=\"Description\">Description</h2> <p>Use the <code>link()</code> method to create an HTML snippet for a hypertext link. The returned string can then be added to the document via <a href=\"https://developer.mozilla.org/en-US/docs/Web/API/Document/write\"><code>document.write()</code></a> or <a href=\"https://developer.mozilla.org/en-US/docs/Web/API/Element/innerHTML\"><code>element.innerHTML</code></a>.</p> <p>Links created with the <code>link()</code> method become elements in the <code>links</code> array of the <code>document</code> object. See <a href=\"https://developer.mozilla.org/en-US/docs/Web/API/Document/links\"><code>document.links</code></a>.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Using_link()\">Using <code>link()</code>\n</h3> <p>The following example displays the word \"MDN\" as a hypertext link that returns the user to the Mozilla Developer Network.</p> <pre data-language=\"js\">var hotText = 'MDN';\nvar URL = 'https://developer.mozilla.org/';\n\nconsole.log('Click to return to ' + hotText.link(URL));\n// Click to return to &lt;a href=\"https://developer.mozilla.org/\"&gt;MDN&lt;/a&gt;\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-string.prototype.link\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'String.prototype.link' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition. Implemented in JavaScript 1.0. Defined in the (normative) Annex B for Additional ECMAScript Features for Web Browsers.</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-string.prototype.link\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'String.prototype.link' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td>Defined in the (normative) Annex B for Additional ECMAScript Features for Web Browsers.</td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support \n</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support \n</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support \n</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"anchor\"><code>String.prototype.anchor()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/link$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/link\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/link</a>\n  </p>\n</div>\n","global_objects/string/small":"<h1>string.small</h1> <div class=\"blockIndicator deprecated deprecatedHeader\"> <p><strong> Deprecated</strong><br>This feature is no longer recommended. Though some browsers might still support it, it may have already been removed from the relevant web standards, may be in the process of being dropped, or may only be kept for compatibility purposes. Avoid using it, and update existing code if possible; see the <a href=\"#Browser_compatibility\">compatibility table</a> at the bottom of this page to guide your decision. Be aware that this feature may cease to work at any time.</p> </div> <p>The <code>small()</code> method creates a <a href=\"https://developer.mozilla.org/en-US/docs/Web/HTML/Element/small\"><code>&lt;small&gt;</code></a> HTML element that causes a string to be displayed in a small font.</p> <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\"><var>str</var>.small()</pre> <h3 id=\"Return_value\">Return value</h3> <p>A string containing a <a href=\"https://developer.mozilla.org/en-US/docs/Web/HTML/Element/small\"><code>&lt;small&gt;</code></a> HTML element.</p> <h2 id=\"Description\">Description</h2> <p>The <code>small()</code> method embeds a string in a <code>&lt;small&gt;</code> tag: <code>\"&lt;small&gt;str&lt;/small&gt;\"</code>.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Using_small()\">Using <code>small()</code>\n</h3> <p>The following example uses string methods to change the size of a string:</p> <pre data-language=\"js\">var worldString = 'Hello, world';\n\nconsole.log(worldString.small());     // &lt;small&gt;Hello, world&lt;/small&gt;\nconsole.log(worldString.big());       // &lt;big&gt;Hello, world&lt;/big&gt;\nconsole.log(worldString.fontsize(7)); // &lt;font size=\"7\"&gt;Hello, world&lt;/fontsize&gt;\n</pre> <p>With the <a href=\"https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/style\"><code>element.style</code></a> object you can get the element's <code>style</code> attribute and manipulate it more generically, for example:</p> <pre data-language=\"js\">document.getElementById('yourElemId').style.fontSize = '0.7em';\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-string.prototype.small\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'String.prototype.small' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition. Implemented in JavaScript 1.0. Defined in the (normative) Annex B for Additional ECMAScript Features for Web Browsers.</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-string.prototype.small\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'String.prototype.small' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td>Defined in the (normative) Annex B for Additional ECMAScript Features for Web Browsers.</td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support \n</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support \n</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support \n</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"fontsize\"><code>String.prototype.fontsize()</code></a></li> <li><a href=\"big\"><code>String.prototype.big()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/small$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/small\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/small</a>\n  </p>\n</div>\n","global_objects/string/substr":"<h1>string.substr</h1> <div class=\"warning\">Warning: Although <code>String.prototype.substr(…)</code> is not strictly deprecated (as in \"removed from the Web standards\"), it is considered a <strong>legacy function</strong> and should be avoided when possible. It is not part of the core JavaScript language and may be removed in the future. If at all possible, use the <code><a href=\"substring\">substring()</a></code> method instead.</div> <p class=\"seoSummary\">The <code>substr()</code> method returns a portion of the string, starting at the specified index and extending for a given number of characters afterward.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/string-substr.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\"><var>str</var>.substr(<var>start</var>[, <var>length]</var>)</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><code>start</code></dt> <dd>The index of the first character to include in the returned substring.</dd> <dt><code>length</code></dt> <dd>Optional. The number of characters to extract.</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p>A new string containing the specified part of the given string.</p> <h2 id=\"Description\">Description</h2> <p><code>substr()</code> extracts <code>length</code> characters from a <code>string</code>, counting from the <code>start</code> index.</p> <p>If <code>start</code> is a positive number, the index starts counting at the start of the string. Its value is capped at <code>str.length</code>.<br> If <code>start</code> is a negative number, the index starts counting from the end of the string. Its value is capped at <code>-str.length</code>.<br> Note: In Microsoft JScript, negative values of the <code>start</code> argument are not considered to refer to the end of the string.</p> <p>If <code>length</code> is omitted, <code>substr()</code> extracts characters to the end of the string.<br> If <code>length</code> is <a href=\"../undefined\"><code>undefined</code></a>, <code>substr()</code> extracts characters to the end of the string.<br> If <code>length</code> is a negative number, it is treated as 0.</p> <p>For both <code>start</code> and <code>length</code>, NaN is treated as 0.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Using_substr()\">Using <code>substr()</code>\n</h3> <pre data-language=\"js\">var aString = 'Mozilla';\n\nconsole.log(aString.substr(0, 1));   // 'M'\nconsole.log(aString.substr(1, 0));   // ''\nconsole.log(aString.substr(-1, 1));  // 'a'\nconsole.log(aString.substr(1, -1));  // ''\nconsole.log(aString.substr(-3));     // 'lla'\nconsole.log(aString.substr(1));      // 'ozilla'\nconsole.log(aString.substr(-20, 2)); // 'Mo'\nconsole.log(aString.substr(20, 2));  // ''\n</pre> <h2 id=\"Polyfill\">Polyfill</h2> <p>Microsoft's JScript does not support negative values for the start index. To use this feature in JScript, you can use the following code:</p> <pre data-language=\"js\">// only run when the substr() function is broken\nif ('ab'.substr(-1) != 'b') {\n  /**\n   *  Get the substring of a string\n   *  @param  {integer}  start   where to start the substring\n   *  @param  {integer}  length  how many characters to return\n   *  @return {string}\n   */\n  String.prototype.substr = function(substr) {\n    return function(start, length) {\n      // call the original method\n      return substr.call(this,\n      \t// did we get a negative start, calculate how much it is from the beginning of the string\n        // adjust the start parameter for negative value\n        start &lt; 0 ? this.length + start : start,\n        length)\n    }\n  }(String.prototype.substr);\n}\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/publications/files/ECMA-ST-ARCH/ECMA-262,%203rd%20edition,%20December%201999.pdf\" hreflang=\"en\">ECMAScript 3rd Edition (ECMA-262)</a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Defined in the (informative) Compatibility Annex B. Implemented in JavaScript 1.0.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/5.1/#sec-B.2.3\" hreflang=\"en\">ECMAScript 5.1 (ECMA-262)<br><small>The definition of 'String.prototype.substr' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Defined in the (informative) Compatibility Annex B</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-string.prototype.substr\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'String.prototype.substr' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Defined in the (normative) Annex B for Additional ECMAScript Features for Web Browsers</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-string.prototype.substr\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'String.prototype.substr' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td>Defined in the (normative) Annex B for Additional ECMAScript Features for Web Browsers</td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support \n</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support \n</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support \n</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"slice\"><code>String.prototype.slice()</code></a></li> <li><a href=\"substring\"><code>String.prototype.substring()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/substr$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/substr\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/substr</a>\n  </p>\n</div>\n","global_objects/string/repeat":"<h1>string.repeat</h1> <p>The <code>repeat()</code> method constructs and returns a new string which contains the specified number of copies of the string on which it was called, concatenated together.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/string-repeat.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\"><var>str</var>.repeat(<var>count</var>);\n</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><code>count</code></dt> <dd>An integer between 0 and +∞: [0, +∞), indicating the number of times to repeat the string in the newly-created string that is to be returned.</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p>A new string containing the specified number of copies of the given string.</p> <h3 id=\"Exceptions\">Exceptions</h3> <ul> <li>\n<a href=\"../../errors/negative_repetition_count\"><code>RangeError</code></a>: repeat count must be non-negative.</li> <li>\n<a href=\"../../errors/resulting_string_too_large\"><code>RangeError</code></a>: repeat count must be less than infinity and not overflow maximum string size.</li> </ul> <h2 id=\"Examples\">Examples</h2> <pre data-language=\"js\">'abc'.repeat(-1);   // RangeError\n'abc'.repeat(0);    // ''\n'abc'.repeat(1);    // 'abc'\n'abc'.repeat(2);    // 'abcabc'\n'abc'.repeat(3.5);  // 'abcabcabc' (count will be converted to integer)\n'abc'.repeat(1/0);  // RangeError\n\n({ toString: () =&gt; 'abc', repeat: String.prototype.repeat }).repeat(2);\n// 'abcabc' (repeat() is a generic method)\n</pre> <h2 id=\"Polyfill\">Polyfill</h2> <p>This method has been added to the ECMAScript 2015 specification and may not be available in all JavaScript implementations yet. However, you can polyfill <code>String.prototype.repeat()</code> with the following snippet:</p> <pre dir=\"rtl\" data-language=\"js\">if (!String.prototype.repeat) {\n  String.prototype.repeat = function(count) {\n    'use strict';\n    if (this == null) {\n      throw new TypeError('can\\'t convert ' + this + ' to object');\n    }\n    var str = '' + this;\n    count = +count;\n    if (count != count) {\n      count = 0;\n    }\n    if (count &lt; 0) {\n      throw new RangeError('repeat count must be non-negative');\n    }\n    if (count == Infinity) {\n      throw new RangeError('repeat count must be less than infinity');\n    }\n    count = Math.floor(count);\n    if (str.length == 0 || count == 0) {\n      return '';\n    }\n    // Ensuring count is a 31-bit integer allows us to heavily optimize the\n    // main part. But anyway, most current (August 2014) browsers can't handle\n    // strings 1 &lt;&lt; 28 chars or longer, so:\n    if (str.length * count &gt;= 1 &lt;&lt; 28) {\n      throw new RangeError('repeat count must not overflow maximum string size');\n    }\n    var maxCount = str.length * count;\n    count = Math.floor(Math.log(count) / Math.log(2));\n    while (count) {\n       str += str;\n       count--;\n    }\n    str += str.substring(0, maxCount - str.length);\n    return str;\n  }\n}\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-string.prototype.repeat\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'String.prototype.repeat' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-string.prototype.repeat\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'String.prototype.repeat' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 41</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 24</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 9</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 36</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 24</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 9</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes bc-has-history\"> 4.0.0\n<section class=\"bc-history\" id=\"sect1\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 4.0.0\n</dt>\n\n<dt class=\"bc-supports-yes bc-supports\"> 0.12<div class=\"bc-icons\">Disabled </div>\n</dt>\n<dd>Disabled From version 0.12: this feature is behind the <code>--harmony</code> runtime flag.</dd>\n</dl></section>\n</td>\n</tr></tbody>\n</table>\n</div><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/repeat$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/repeat\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/repeat</a>\n  </p>\n</div>\n","global_objects/string/slice":"<h1>string.slice</h1> <p>The <code>slice()</code> method extracts a section of a string and returns it as a new string, without modifying the original string.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/string-slice.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\"><var>str</var>.slice(<var>beginIndex</var>[, <var>endIndex</var>])</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><code>beginIndex</code></dt> <dd>The zero-based index at which to begin extraction. If negative, it is treated as <code>strLength + beginIndex</code> where <code>strLength</code> is the length of the string (for example, if <code>beginIndex</code> is <code>-3</code> it is treated as <code>strLength - 3</code>). If <code>beginIndex</code> is greater than or equal to the length of the string, <code>slice()</code> returns an empty string.</dd> <dt><code>endIndex</code></dt> <dd>Optional. The zero-based index <em>before</em> which to end extraction. The character at this index will not be included. If <code>endIndex</code> is omitted, <code>slice()</code> extracts to the end of the string. If negative, it is treated as <code>strLength + endIndex</code> where <code>strLength</code> is the length of the string (for example, if <code>endIndex</code> is <code>-3</code> it is treated as <code>strLength - 3)</code>.</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p>A new string containing the extracted section of the string.</p> <h2 id=\"Description\">Description</h2> <p><code>slice()</code> extracts the text from one string and returns a new string. Changes to the text in one string do not affect the other string.</p> <p><code>slice()</code> extracts up to but not including <code>endIndex</code>. <code>str.slice(1, 4)</code> extracts the second character through the fourth character (characters indexed 1, 2, and 3).</p> <p>As an example, <code>str.slice(2, -1)</code> extracts the third character through the second to last character in the string.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Using_slice()_to_create_a_new_string\">Using <code>slice()</code> to create a new string</h3> <p>The following example uses <code>slice()</code> to create a new string.</p> <pre data-language=\"js\">var str1 = 'The morning is upon us.', // the length of str1 is 23.\n    str2 = str1.slice(1, 8),\n    str3 = str1.slice(4, -2),\n    str4 = str1.slice(12),\n    str5 = str1.slice(30);\nconsole.log(str2); // OUTPUT: he morn\nconsole.log(str3); // OUTPUT: morning is upon u\nconsole.log(str4); // OUTPUT: is upon us.\nconsole.log(str5); // OUTPUT: \"\"\n</pre> <h3 id=\"Using_slice()_with_negative_indexes\">Using <code>slice()</code> with negative indexes</h3> <p>The following example uses <code>slice()</code> with negative indexes.</p> <pre data-language=\"js\">var str = 'The morning is upon us.';\nstr.slice(-3);     // returns 'us.'\nstr.slice(-3, -1); // returns 'us'\nstr.slice(0, -1);  // returns 'The morning is upon us'\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/publications/files/ECMA-ST-ARCH/ECMA-262,%203rd%20edition,%20December%201999.pdf\" hreflang=\"en\">ECMAScript 3rd Edition (ECMA-262)</a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition. Implemented in JavaScript 1.2.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/5.1/#sec-15.5.4.13\" hreflang=\"en\">ECMAScript 5.1 (ECMA-262)<br><small>The definition of 'String.prototype.slice' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-string.prototype.slice\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'String.prototype.slice' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-string.prototype.slice\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'String.prototype.slice' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li>\n<a href=\"substr\"><code>String.prototype.substr()</code></a> \n</li> <li><a href=\"substring\"><code>String.prototype.substring()</code></a></li> <li><a href=\"../array/slice\"><code>Array.prototype.slice()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/slice$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/slice\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/slice</a>\n  </p>\n</div>\n","global_objects/string/sup":"<h1>string.sup</h1> <div class=\"blockIndicator deprecated deprecatedHeader\"> <p><strong> Deprecated</strong><br>This feature is no longer recommended. Though some browsers might still support it, it may have already been removed from the relevant web standards, may be in the process of being dropped, or may only be kept for compatibility purposes. Avoid using it, and update existing code if possible; see the <a href=\"#Browser_compatibility\">compatibility table</a> at the bottom of this page to guide your decision. Be aware that this feature may cease to work at any time.</p> </div> <p>The <code>sup()</code> method creates a <a href=\"https://developer.mozilla.org/en-US/docs/Web/HTML/Element/sup\"><code>&lt;sup&gt;</code></a> HTML element that causes a string to be displayed as superscript.</p> <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\"><var>str</var>.sup()</pre> <h3 id=\"Return_value\">Return value</h3> <p>A string containing a <a href=\"https://developer.mozilla.org/en-US/docs/Web/HTML/Element/sup\"><code>&lt;sup&gt;</code></a> HTML element.</p> <h2 id=\"Description\">Description</h2> <p>The <code>sup()</code> method embeds a string in a <code>&lt;sup&gt;</code> tag: <code>\"&lt;sup&gt;str&lt;/sup&gt;\"</code>.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Using_sub()_and_sup()_methods\">Using <code>sub()</code> and <code>sup()</code> methods</h3> <p>The following example uses the <a href=\"sub\"><code>sub()</code></a> and <code>sup()</code> methods to format a string:</p> <pre data-language=\"js\">var superText = 'superscript';\nvar subText = 'subscript';\n\nconsole.log('This is what a ' + superText.sup() + ' looks like.');\n// \"This is what a &lt;sup&gt;superscript&lt;/sup&gt; looks like.\"\n\nconsole.log('This is what a ' + subText.sub() + ' looks like.');\n// \"This is what a &lt;sub&gt;subscript&lt;/sub&gt; looks like.\"\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-string.prototype.sup\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'String.prototype.sup' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition. Implemented in JavaScript 1.0. Defined in the (normative) Annex B for Additional ECMAScript Features for Web Browsers.</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-string.prototype.sup\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'String.prototype.sup' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td>Defined in the (normative) Annex B for Additional ECMAScript Features for Web Browsers.</td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support \n</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support \n</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support \n</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"sub\"><code>String.prototype.sub()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/sup$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/sup\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/sup</a>\n  </p>\n</div>\n","global_objects/string/substring":"<h1>string.substring</h1> <p>The <code>substring()</code> method returns the part of the <code>string</code> between the start and end indexes, or to the end of the string.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/string-substring.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\"><var>str</var>.substring(<var>indexStart</var>[, <var>indexEnd</var>])</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><code><var>indexStart</var></code></dt> <dd>The index of the first character to include in the returned substring.</dd> <dt><code>indexEnd</code></dt> <dd>Optional. The index of the first character to exclude from the returned substring.</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p>A new string containing the specified part of the given string.</p> <h2 id=\"Description\">Description</h2> <p><code>substring()</code> extracts characters from <code>indexStart</code> up to <em>but not including</em> <code>indexEnd</code>. In particular:</p> <ul> <li>If <code>indexEnd</code> is omitted, <code>substring()</code> extracts characters to the end of the string.</li> <li>If <code><var>indexStart</var></code> is equal to <code><var>indexEnd</var></code>, <code>substring()</code> returns an empty string.</li> <li>If <code>indexStart</code> is greater than <code>indexEnd</code>, then the effect of <code>substring()</code> is as if the two arguments were swapped; See example below.</li> </ul> <p>Any argument value that is less than 0 or greater than <code>stringName.length</code> is treated as if it were 0 and <code>stringName.length</code> respectively. Any argument value that is <a href=\"../nan\"><code>NaN</code></a> is treated as if it were 0.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Using_substring()\">Using <code>substring()</code>\n</h3> <p>The following example uses <code>substring()</code> to display characters from the string <code>'Mozilla'</code>:</p> <pre data-language=\"js\">var anyString = 'Mozilla';\n\n// Displays 'M'\nconsole.log(anyString.substring(0, 1));\nconsole.log(anyString.substring(1, 0));\n\n// Displays 'Mozill'\nconsole.log(anyString.substring(0, 6));\n\n// Displays 'lla'\nconsole.log(anyString.substring(4));\nconsole.log(anyString.substring(4, 7));\nconsole.log(anyString.substring(7, 4));\n\n// Displays 'Mozilla'\nconsole.log(anyString.substring(0, 7));\nconsole.log(anyString.substring(0, 10));\n</pre> <h3 id=\"Using_substring()_with_length_property\">Using <code>substring()</code> with <code>length</code> property</h3> <p>The following example uses the <code>substring()</code> method and <a href=\"length\"><code>length</code></a> property to extract the last characters of a particular string. This method may be easier to remember, given that you don't need to know the starting and ending indices as you would in the above examples.</p> <pre data-language=\"js\">// Displays 'illa' the last 4 characters\nvar anyString = 'Mozilla';\nvar anyString4 = anyString.substring(anyString.length - 4);\nconsole.log(anyString4);\n\n// Displays 'zilla' the last 5 characters\nvar anyString = 'Mozilla';\nvar anyString5 = anyString.substring(anyString.length - 5);\nconsole.log(anyString5);\n</pre> <h3 id=\"Difference_between_substring()_and_substr()\">Difference between <code>substring()</code> and <code>substr()</code>\n</h3> <p>There's a subtle difference between the <code>substring()</code> and <code><a href=\"substr\">substr()</a></code> methods, and you should be careful not get them confused.</p> <p>The arguments of <code>substring()</code> represent the starting and ending indexes, while the arguments of <code>substr()</code> represent the starting index and the length of characters to include in the returned string.</p> <pre data-language=\"js\">var text = 'Mozilla';\nconsole.log(text.substring(2,5)); // =&gt; \"zil\"\nconsole.log(text.substr(2,3)); // =&gt; \"zil\"</pre> <h3 id=\"Replacing_a_substring_within_a_string\">Replacing a substring within a string</h3> <p>The following example replaces a substring within a string. It will replace both individual characters and substrings. The function call at the end of the example changes the string <code>'Brave New World'</code> to <code>'Brave New Web'</code>.</p> <pre data-language=\"js\">// Replaces oldS with newS in the string fullS\nfunction replaceString(oldS, newS, fullS) {\n  for (var i = 0; i &lt; fullS.length; ++i) {\n    if (fullS.substring(i, i + oldS.length) == oldS) {\n      fullS = fullS.substring(0, i) + newS + fullS.substring(i + oldS.length, fullS.length);\n    }\n  }\n  return fullS;\n}\n\nreplaceString('World', 'Web', 'Brave New World');\n</pre> <p>Note that this can result in an infinite loop if <code>oldS</code> is itself a substring of <code>newS</code> — for example, if you attempted to replace 'World' with 'OtherWorld' here. A better method for replacing strings is as follows:</p> <pre data-language=\"js\">function replaceString(oldS, newS, fullS) {\n  return fullS.split(oldS).join(newS);\n}\n</pre> <p>The code above serves as an example for substring operations. If you need to replace substrings, most of the time you will want to use <a href=\"replace\"><code>String.prototype.replace()</code></a>.</p> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/publications/files/ECMA-ST-ARCH/ECMA-262,%201st%20edition,%20June%201997.pdf\" hreflang=\"en\">ECMAScript 1st Edition (ECMA-262)</a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Implemented in JavaScript 1.0.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/5.1/#sec-15.5.4.15\" hreflang=\"en\">ECMAScript 5.1 (ECMA-262)<br><small>The definition of 'String.prototype.substring' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-string.prototype.substring\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'String.prototype.substring' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-string.prototype.substring\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'String.prototype.substring' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li>\n<a href=\"substr\"><code>String.prototype.substr()</code></a> \n</li> <li><a href=\"slice\"><code>String.prototype.slice()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/substring$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/substring\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/substring</a>\n  </p>\n</div>\n","global_objects/string/tolocalelowercase":"<h1>string.toLocaleLowerCase</h1> <p>The <code>toLocaleLowerCase()</code> method returns the calling string value converted to lower case, according to any locale-specific case mappings.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/string-tolocalelowercase.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\"><var>str</var>.toLocaleLowerCase()\n<var>str</var>.toLocaleLowerCase(locale) \n<var>str</var>.toLocaleLowerCase([locale, locale, ...])\n</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt>\n<code>locale</code> <span class=\"inlineIndicator optional optionalInline\">Optional</span>\n</dt> <dd>The <code>locale</code> parameter indicates the locale to be used to convert to lower case according to any locale-specific case mappings. If multiple locales are given in an <a href=\"../array\"><code>Array</code></a>, the <a href=\"https://tc39.github.io/ecma402/#sec-bestavailablelocale\">best available locale</a> is used. The default locale is the host environment’s current locale.</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p>A new string representing the calling string converted to lower case, according to any locale-specific case mappings.</p> <h3 id=\"Exceptions\">Exceptions</h3> <ul> <li>A <a href=\"../rangeerror\"><code>RangeError</code></a> (\"invalid language tag: xx_yy\") is thrown if a <code>locale</code> argument isn't a valid language tag.</li> <li>A <a href=\"../typeerror\"><code>TypeError</code></a> (\"invalid element in locales argument\") is thrown if an array element isn't of type string.</li> </ul> <h2 id=\"Description\">Description</h2> <p>The <code>toLocaleLowerCase()</code> method returns the value of the string converted to lower case according to any locale-specific case mappings. <code>toLocaleLowerCase()</code> does not affect the value of the string itself. In most cases, this will produce the same result as <a href=\"tolowercase\"><code>toLowerCase()</code></a>, but for some locales, such as Turkish, whose case mappings do not follow the default case mappings in Unicode, there may be a different result.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Using_toLocaleLowerCase()\">Using <code>toLocaleLowerCase()</code>\n</h3> <pre data-language=\"js\">'ALPHABET'.toLocaleLowerCase(); // 'alphabet'\n\n'\\u0130'.toLocaleLowerCase('tr') === 'i';    // true\n'\\u0130'.toLocaleLowerCase('en-US') === 'i'; // false\n\nlet locales = ['tr', 'TR', 'tr-TR', 'tr-u-co-search', 'tr-x-turkish'];\n'\\u0130'.toLocaleLowerCase(locales) === 'i'; // true\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/publications/files/ECMA-ST-ARCH/ECMA-262,%203rd%20edition,%20December%201999.pdf\" hreflang=\"en\">ECMAScript 3rd Edition (ECMA-262)</a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition. Implemented in JavaScript 1.2.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/5.1/#sec-15.5.4.17\" hreflang=\"en\">ECMAScript 5.1 (ECMA-262)<br><small>The definition of 'String.prototype.toLocaleLowerCase' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-string.prototype.tolocalelowercase\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'String.prototype.toLocaleLowerCase' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-string.prototype.tolocalelowercase\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'String.prototype.toLocaleLowerCase' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma402/#sup-string.prototype.tolocalelowercase\" hreflang=\"en\">ECMAScript Internationalization API 4.0 (ECMA-402)<br><small>The definition of 'String.prototype.toLocaleLowerCase' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td>ES Intl 2017 added the <code>locale</code> parameter.</td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><code>locale</code></th>\n<td> ? </td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 55</td>\n<td> ? </td>\n<td> ? </td>\n<td> ? </td>\n</tr>\n</tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><code>locale</code></th>\n<td> ? </td>\n<td> ? </td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 55</td>\n<td> ? </td>\n<td> ? </td>\n<td> ? </td>\n</tr>\n</tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><code>locale</code></th>\n<td> ? </td>\n</tr>\n</tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"tolocaleuppercase\"><code>String.prototype.toLocaleUpperCase()</code></a></li> <li><a href=\"tolowercase\"><code>String.prototype.toLowerCase()</code></a></li> <li><a href=\"touppercase\"><code>String.prototype.toUpperCase()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/toLocaleLowerCase$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/toLocaleLowerCase\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/toLocaleLowerCase</a>\n  </p>\n</div>\n","global_objects/string/sub":"<h1>string.sub</h1> <div class=\"blockIndicator deprecated deprecatedHeader\"> <p><strong> Deprecated</strong><br>This feature is no longer recommended. Though some browsers might still support it, it may have already been removed from the relevant web standards, may be in the process of being dropped, or may only be kept for compatibility purposes. Avoid using it, and update existing code if possible; see the <a href=\"#Browser_compatibility\">compatibility table</a> at the bottom of this page to guide your decision. Be aware that this feature may cease to work at any time.</p> </div> <p>The <code>sub()</code> method creates a <a href=\"https://developer.mozilla.org/en-US/docs/Web/HTML/Element/sub\"><code>&lt;sub&gt;</code></a> HTML element that causes a string to be displayed as subscript.</p> <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\"><var>str</var>.sub()</pre> <h3 id=\"Return_value\">Return value</h3> <p>A string containing a <a href=\"https://developer.mozilla.org/en-US/docs/Web/HTML/Element/sub\"><code>&lt;sub&gt;</code></a> HTML element.</p> <h2 id=\"Description\">Description</h2> <p>The <code>sub()</code> method embeds a string in a <code>&lt;sub&gt;</code> tag: <code>\"&lt;sub&gt;str&lt;/sub&gt;\"</code>.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Using_sub()_and_sup()_methods\">Using <code>sub()</code> and <code>sup()</code> methods</h3> <p>The following example uses the <code>sub()</code> and <a href=\"sup\"><code>sup()</code></a> methods to format a string:</p> <pre data-language=\"js\">var superText = 'superscript'; \nvar subText = 'subscript'; \n\nconsole.log('This is what a ' + superText.sup() + ' looks like.'); \n// This is what a &lt;sup&gt;superscript&lt;/sup&gt; looks like \n\nconsole.log('This is what a ' + subText.sub() + ' looks like.'); \n// This is what a &lt;sub&gt;subscript&lt;/sub&gt; looks like.\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-string.prototype.sub\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'String.prototype.sub' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition. Implemented in JavaScript 1.0. Defined in the (normative) Annex B for Additional ECMAScript Features for Web Browsers.</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-string.prototype.sub\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'String.prototype.sub' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td>Defined in the (normative) Annex B for Additional ECMAScript Features for Web Browsers.</td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support \n</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support \n</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support \n</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"sup\"><code>String.prototype.sup()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/sub$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/sub\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/sub</a>\n  </p>\n</div>\n","global_objects/string/tolocaleuppercase":"<h1>string.toLocaleUpperCase</h1> <p>The <code>toLocaleUpperCase()</code> method returns the calling string value converted to upper case, according to any locale-specific case mappings.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/string-tolocaleuppercase.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\"><var>str</var>.toLocaleUpperCase()\n<var>str</var>.toLocaleUpperCase(locale) \n<var>str</var>.toLocaleUpperCase([locale, locale, ...])\n</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt>\n<code>locale</code> <span class=\"inlineIndicator optional optionalInline\">Optional</span>\n</dt> <dd>The <code>locale</code> parameter indicates the locale to be used to convert to upper case according to any locale-specific case mappings. If multiple locales are given in an <a href=\"../array\"><code>Array</code></a>, the <a href=\"https://tc39.github.io/ecma402/#sec-bestavailablelocale\">best available locale</a> is used. The default locale is the host environment’s current locale.</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p>A new string representing the calling string converted to upper case, according to any locale-specific case mappings.</p> <h3 id=\"Exceptions\">Exceptions</h3> <ul> <li>A <a href=\"../rangeerror\"><code>RangeError</code></a> (\"invalid language tag: xx_yy\") is thrown if a <code>locale</code> argument isn't a valid language tag.</li> <li>A <a href=\"../typeerror\"><code>TypeError</code></a> (\"invalid element in locales argument\") is thrown if an array element isn't of type string.</li> </ul> <h2 id=\"Description\">Description</h2> <p>The <code>toLocaleUpperCase()</code> method returns the value of the string converted to upper case according to any locale-specific case mappings. <code>toLocaleUpperCase()</code> does not affect the value of the string itself. In most cases, this will produce the same result as <a href=\"touppercase\"><code>toUpperCase()</code></a>, but for some locales, such as Turkish, whose case mappings do not follow the default case mappings in Unicode, there may be a different result.</p> <p>Also notice that conversion is not necessarily a 1:1 character mapping, as some characters might result in two (or even more) characters when transformed to upper-case. Therefore the length of the result string can differ from the input length. This also implies that the conversion is not stable, so i.E. the following can return <code>false</code>:<br> <code>x.toLocaleLowerCase() === x.toLocaleUpperCase().toLocaleLowerCase()</code></p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Using_toLocaleUpperCase()\">Using <code>toLocaleUpperCase()</code>\n</h3> <pre data-language=\"js\">'alphabet'.toLocaleUpperCase(); // 'ALPHABET'\n\n'Gesäß'.toLocaleUpperCase(); // 'GESÄSS'\n\n'i\\u0307'.toLocaleUpperCase('lt-LT'); // 'I'\n\nlet locales = ['lt', 'LT', 'lt-LT', 'lt-u-co-phonebk', 'lt-x-lietuva'];\n'i\\u0307'.toLocaleUpperCase(locales); // 'I'</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/publications/files/ECMA-ST-ARCH/ECMA-262,%203rd%20edition,%20December%201999.pdf\" hreflang=\"en\">ECMAScript 3rd Edition (ECMA-262)</a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition. Implemented in JavaScript 1.2.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/5.1/#sec-15.5.4.19\" hreflang=\"en\">ECMAScript 5.1 (ECMA-262)<br><small>The definition of 'String.prototype.toLocaleUpperCase' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-string.prototype.tolocaleuppercase\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'String.prototype.toLocaleUpperCase' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-string.prototype.tolocaleuppercase\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'String.prototype.toLocaleUpperCase' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma402/#sup-string.prototype.tolocaleuppercase\" hreflang=\"en\">ECMAScript Internationalization API 4.0 (ECMA-402)<br><small>The definition of 'String.prototype.toLocaleUpperCase' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td>ES Intl 2017 added the <code>locale</code> parameter.</td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><code>locale</code></th>\n<td> ? </td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 55</td>\n<td> ? </td>\n<td> ? </td>\n<td> ? </td>\n</tr>\n</tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><code>locale</code></th>\n<td> ? </td>\n<td> ? </td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 55</td>\n<td> ? </td>\n<td> ? </td>\n<td> ? </td>\n</tr>\n</tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><code>locale</code></th>\n<td> ? </td>\n</tr>\n</tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"tolocalelowercase\"><code>String.prototype.toLocaleLowerCase()</code></a></li> <li><a href=\"tolowercase\"><code>String.prototype.toLowerCase()</code></a></li> <li><a href=\"touppercase\"><code>String.prototype.toUpperCase()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/toLocaleUpperCase$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/toLocaleUpperCase\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/toLocaleUpperCase</a>\n  </p>\n</div>\n","global_objects/string/tostring":"<h1>string.toString</h1> <p>The <code>toString()</code> method returns a string representing the specified object.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/string-tostring.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe> <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\"><var>str</var>.toString()</pre> <h3 id=\"Return_value\">Return value</h3> <p>A string representing the calling object.</p> <h2 id=\"Description\">Description</h2> <p>The <a href=\"../string\"><code>String</code></a> object overrides the <code>toString()</code> method of the <a href=\"../object\"><code>Object</code></a> object; it does not inherit <a href=\"../object/tostring\"><code>Object.prototype.toString()</code></a>. For <a href=\"../string\"><code>String</code></a> objects, the <code>toString()</code> method returns a string representation of the object and is the same as the <a href=\"valueof\"><code>String.prototype.valueOf()</code></a> method.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Using_toString()\">Using <code>toString()</code>\n</h3> <p>The following example displays the string value of a <a href=\"../string\"><code>String</code></a> object:</p> <pre data-language=\"js\">var x = new String('Hello world');\n\nconsole.log(x.toString()); // logs 'Hello world'\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/publications/files/ECMA-ST-ARCH/ECMA-262,%203rd%20edition,%20December%201999.pdf\" hreflang=\"en\">ECMAScript 3rd Edition (ECMA-262)</a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition. Implemented in JavaScript 1.1.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/5.1/#sec-15.5.4.2\" hreflang=\"en\">ECMAScript 5.1 (ECMA-262)<br><small>The definition of 'String.prototype.toString' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-string.prototype.tostring\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'String.prototype.toString' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-string.prototype.tostring\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'String.prototype.toString' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/toSource\"><code>Object.prototype.toSource()</code></a></li> <li><a href=\"valueof\"><code>String.prototype.valueOf()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/toString$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/toString\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/toString</a>\n  </p>\n</div>\n","global_objects/string/startswith":"<h1>string.startsWith</h1> <p>The <code>startsWith()</code> method determines whether a string begins with the characters of a specified string, returning <code>true</code> or <code>false</code> as appropriate.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/string-startswith.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\"><var>str</var>.startsWith(<var>searchString</var>[, <var>position</var>])</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><code>searchString</code></dt> <dd>The characters to be searched for at the start of this string.</dd> <dt>\n<code>position </code><span class=\"inlineIndicator optional optionalInline\">Optional</span>\n</dt> <dd>The position in this string at which to begin searching for <code>searchString</code>; defaults to 0.</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p><code>true</code> if the given characters are found at the beginning of the string; otherwise, <code>false</code>.</p> <h2 id=\"Description\">Description</h2> <p>This method lets you determine whether or not a string begins with another string. This method is case-sensitive.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Using_startsWith()\">Using <code>startsWith()</code>\n</h3> <pre data-language=\"js\">//startswith\nvar str = 'To be, or not to be, that is the question.';\n\nconsole.log(str.startsWith('To be'));         // true\nconsole.log(str.startsWith('not to be'));     // false\nconsole.log(str.startsWith('not to be', 10)); // true\n</pre> <h2 id=\"Polyfill\">Polyfill</h2> <p>This method has been added to the ECMAScript 2015 specification and may not be available in all JavaScript implementations yet. However, you can polyfill <code>String.prototype.startsWith()</code> with the following snippet:</p> <pre data-language=\"js\">if (!String.prototype.startsWith) {\n\tString.prototype.startsWith = function(search, pos) {\n\t\treturn this.substr(!pos || pos &lt; 0 ? 0 : +pos, search.length) === search;\n\t};\n}\n</pre> <p>A more robust (fully ES2015 specification compliant), but less performant and compact, Polyfill is available <a href=\"https://github.com/mathiasbynens/String.prototype.startsWith\">on GitHub by Mathias Bynens</a>.</p> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-string.prototype.startswith\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'String.prototype.startsWith' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-string.prototype.startswith\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'String.prototype.startsWith' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 41</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 17</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 28</td>\n<td class=\"bc-supports-yes\"> 9</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 36</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 17</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 9</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes bc-has-history\"> 4.0.0\n<section class=\"bc-history\" id=\"sect1\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 4.0.0\n</dt>\n\n<dt class=\"bc-supports-yes bc-supports\"> 0.12<div class=\"bc-icons\">Disabled </div>\n</dt>\n<dd>Disabled From version 0.12: this feature is behind the <code>--harmony</code> runtime flag.</dd>\n</dl></section>\n</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"endswith\"><code>String.prototype.endsWith()</code></a></li> <li><a href=\"includes\"><code>String.prototype.includes()</code></a></li> <li><a href=\"indexof\"><code>String.prototype.indexOf()</code></a></li> <li><a href=\"lastindexof\"><code>String.prototype.lastIndexOf()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/startsWith$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/startsWith\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/startsWith</a>\n  </p>\n</div>\n","global_objects/string/strike":"<h1>string.strike</h1> <div class=\"blockIndicator deprecated deprecatedHeader\"> <p><strong> Deprecated</strong><br>This feature is no longer recommended. Though some browsers might still support it, it may have already been removed from the relevant web standards, may be in the process of being dropped, or may only be kept for compatibility purposes. Avoid using it, and update existing code if possible; see the <a href=\"#Browser_compatibility\">compatibility table</a> at the bottom of this page to guide your decision. Be aware that this feature may cease to work at any time.</p> </div> <p>The <code>strike()</code> method creates a <a href=\"https://developer.mozilla.org/en-US/docs/Web/HTML/Element/strike\"><code>&lt;strike&gt;</code></a> HTML element that causes a string to be displayed as struck-out text.</p> <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\"><var>str</var>.strike()</pre> <h3 id=\"Return_value\">Return value</h3> <p>A string containing a <a href=\"https://developer.mozilla.org/en-US/docs/Web/HTML/Element/strike\"><code>&lt;strike&gt;</code></a> HTML element.</p> <h2 id=\"Description\">Description</h2> <p>The <code>strike()</code> method embeds a string in a <code>&lt;strike&gt;</code> tag: <code>\"&lt;strike&gt;str&lt;/strike&gt;\"</code>.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Using_strike()\">Using <code>strike()</code>\n</h3> <p>The following example uses string methods to change the formatting of a string:</p> <pre data-language=\"js\">var worldString = 'Hello, world'; \n\nconsole.log(worldString.blink()); // &lt;blink&gt;Hello, world&lt;/blink&gt; \nconsole.log(worldString.bold()); // &lt;b&gt;Hello, world&lt;/b&gt; \nconsole.log(worldString.italics()); // &lt;i&gt;Hello, world&lt;/i&gt; \nconsole.log(worldString.strike()); // &lt;strike&gt;Hello, world&lt;/strike&gt;\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-string.prototype.strike\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'String.prototype.strike' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition. Implemented in JavaScript 1.0. Defined in the (normative) Annex B for Additional ECMAScript Features for Web Browsers.</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-string.prototype.strike\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'String.prototype.strike' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td>Defined in the (normative) Annex B for Additional ECMAScript Features for Web Browsers.</td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support \n</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support \n</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support \n</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"blink\"><code>String.prototype.blink()</code></a></li> <li><a href=\"bold\"><code>String.prototype.bold()</code></a></li> <li><a href=\"italics\"><code>String.prototype.italics()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/strike$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/strike\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/strike</a>\n  </p>\n</div>\n","global_objects/string/tolowercase":"<h1>string.toLowerCase</h1> <p>The <code>toLowerCase()</code> method returns the calling string value converted to lower case.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/string-tolowercase.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\"><var>str</var>.toLowerCase()</pre> <h3 id=\"Return_value\">Return value</h3> <p>A new string representing the calling string converted to lower case.</p> <h2 id=\"Description\">Description</h2> <p>The <code>toLowerCase()</code> method returns the value of the string converted to lower case. <code>toLowerCase()</code> does not affect the value of the string <code>str</code> itself.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Using_toLowerCase()\">Using <code>toLowerCase()</code>\n</h3> <pre data-language=\"js\">console.log('ALPHABET'.toLowerCase()); // 'alphabet'\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/publications/files/ECMA-ST-ARCH/ECMA-262,%201st%20edition,%20June%201997.pdf\" hreflang=\"en\">ECMAScript 1st Edition (ECMA-262)</a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition. Implemented in JavaScript 1.0.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/5.1/#sec-15.5.4.16\" hreflang=\"en\">ECMAScript 5.1 (ECMA-262)<br><small>The definition of 'String.prototype.toLowerCase' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-string.prototype.tolowercase\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'String.prototype.toLowerCase' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-string.prototype.tolowercase\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'String.prototype.toLowerCase' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"tolocalelowercase\"><code>String.prototype.toLocaleLowerCase()</code></a></li> <li><a href=\"tolocaleuppercase\"><code>String.prototype.toLocaleUpperCase()</code></a></li> <li><a href=\"touppercase\"><code>String.prototype.toUpperCase()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/toLowerCase$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/toLowerCase\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/toLowerCase</a>\n  </p>\n</div>\n","global_objects/string/touppercase":"<h1>string.toUpperCase</h1> <p>The <code>toUpperCase()</code> method returns the calling string value converted to uppercase (the value will be converted to a string if it isn't one).</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/string-touppercase.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\"><var>str</var>.toUpperCase()</pre> <h3 id=\"Return_value\">Return value</h3> <p>A new string representing the calling string converted to upper case.</p> <h2 id=\"Description\">Description</h2> <p>The <code>toUpperCase()</code> method returns the value of the string converted to uppercase. This method does not affect the value of the string itself since JavaScript strings are immutable.<br> <br> You cannot call this method on <code>null</code> or <code>undefined</code> (via <code>Function.prototype.call</code>, for example) , if you do, a <code>TypeError</code> will be thrown.<br> </p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Usage\">Usage:</h3> <pre data-language=\"js\">console.log('alphabet'.toUpperCase()); // 'ALPHABET'\n</pre> <h3 id=\"Conversion_of_non-string_this_values_to_strings\" class=\"brush: js\">Conversion of non-string <code>this</code> values to strings</h3> <p class=\"brush: js\">This method will convert any non-string value to a string, when you set its <code>this</code> to a value that is not a string: ​​​​</p> <pre>const a = String.prototype.toUpperCase.call({\n  toString: function toString() {\n    return 'abcdef';\n  }\n});\n\nconst b = String.prototype.toUpperCase.call(true);\n\n// prints out 'ABCDEF TRUE'.\nconsole.log(a, b);\n</pre> <h3 id=\"Calling_on_undefined_and_null\">Calling on <code>undefined</code> and <code>null</code>\n</h3> <pre>// TypeError\nString.prototype.toUpperCase.call(undefined);\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/publications/files/ECMA-ST-ARCH/ECMA-262,%201st%20edition,%20June%201997.pdf\" hreflang=\"en\">ECMAScript 1st Edition (ECMA-262)</a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition. Implemented in JavaScript 1.0.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/5.1/#sec-15.5.4.18\" hreflang=\"en\">ECMAScript 5.1 (ECMA-262)<br><small>The definition of 'String.prototype.toUpperCase' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-string.prototype.touppercase\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'String.prototype.toUpperCase' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-string.prototype.touppercase\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'String.prototype.toUpperCase' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"tolocalelowercase\"><code>String.prototype.toLocaleLowerCase()</code></a></li> <li><a href=\"tolocaleuppercase\"><code>String.prototype.toLocaleUpperCase()</code></a></li> <li><a href=\"tolowercase\"><code>String.prototype.toLowerCase()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/toUpperCase$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/toUpperCase\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/toUpperCase</a>\n  </p>\n</div>\n","global_objects/string/trimstart":"<h1>string.trimStart</h1> <p>The <code>trimStart()</code> method removes whitespace from the beginning of a string. <code>trimLeft()</code> is an alias of this method.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/string-trimstart.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\"><var>str</var>.trimStart();\n<var>str</var>.trimLeft();</pre> <h3 id=\"Return_value\">Return value</h3> <p>A new string representing the calling string stripped of whitespace from its beginning (left end).</p> <h2 id=\"Description\">Description</h2> <p>The <code>trimStart()</code> / <code>trimLeft()</code> methods return the string stripped of whitespace from its left end. <code>trimLeft()</code> or <code>trimStart()</code> do not affect the value of the string itself.</p> <h3 id=\"Aliasing\">Aliasing</h3> <p>For consistency with functions like <a href=\"padstart\"><code>String.prototype.padStart</code></a> the standard method name is <code>trimStart</code>. However, for web compatibility reasons, <code>trimLeft</code> remains as an alias to <code>trimStart</code>. In some engines this means:</p> <pre data-language=\"js\">String.prototype.trimLeft.name === \"trimStart\";</pre> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Using_trimStart()\">Using <code>trimStart()</code>\n</h3> <p>The following example displays the lowercase string <code>'foo '</code>:</p> <pre data-language=\"js\">var str = '   foo  ';\n\nconsole.log(str.length); // 8\n\nstr = str.trimStart();\nconsole.log(str.length); // 5\nconsole.log(str);        // 'foo  '\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <thead> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> </thead> <tbody> <tr> <td>\n<code><a href=\"https://github.com/tc39/proposal-string-left-right-trim/#stringprototypetrimstart--stringprototypetrimend\">String.prototype.{trimStart,trimEnd}</a></code> proposal</td> <td>Stage 1</td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes bc-has-history\"> 66\n<section class=\"bc-history\" id=\"sect1\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 66\n</dt>\n\n<dt class=\"bc-supports-yes bc-supports\"> Yes\n</dt>\n<dd> Uses the non-standard name: <code>trimLeft</code>\n</dd>\n</dl></section>\n</td>\n<td> ? </td>\n<td class=\"bc-supports-yes bc-has-history\"> 61\n<section class=\"bc-history\" id=\"sect2\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 61\n</dt>\n\n<dt class=\"bc-supports-yes bc-supports\"> 3.5\n</dt>\n<dd> Uses the non-standard name: <code>trimLeft</code>\n</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 53</td>\n<td> ? </td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes bc-has-history\"> 66\n<section class=\"bc-history\" id=\"sect3\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 66\n</dt>\n\n<dt class=\"bc-supports-yes bc-supports\"> Yes\n</dt>\n<dd> Uses the non-standard name: <code>trimLeft</code>\n</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-yes bc-has-history\"> 66\n<section class=\"bc-history\" id=\"sect4\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 66\n</dt>\n\n<dt class=\"bc-supports-yes bc-supports\"> Yes\n</dt>\n<dd> Uses the non-standard name: <code>trimLeft</code>\n</dd>\n</dl></section>\n</td>\n<td> ? </td>\n<td class=\"bc-supports-yes bc-has-history\"> 61\n<section class=\"bc-history\" id=\"sect5\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 61\n</dt>\n\n<dt class=\"bc-supports-yes bc-supports\"> 4\n</dt>\n<dd> Uses the non-standard name: <code>trimLeft</code>\n</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-yes\"> 53</td>\n<td> ? </td>\n<td> ? </td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 10.0.0</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"Polyfill\">Polyfill</h2> <pre data-language=\"js\">//https://github.com/FabioVergani/js-Polyfill_String-trimStart\n\n(function(w){\n    var String=w.String, Proto=String.prototype;\n\n    (function(o,p){\n        if(p in o?o[p]?false:true:true){\n            var r=/^\\s+/;\n            o[p]=o.trimLeft||function(){\n                return this.replace(r,'')\n            }\n        }\n    })(Proto,'trimStart');\n\n})(window); \n\n\n/*\nES6:\n(w=&gt;{\n    const String=w.String, Proto=String.prototype;\n\n    ((o,p)=&gt;{\n        if(p in o?o[p]?false:true:true){\n            const r=/^\\s+/;\n            o[p]=o.trimLeft||function(){\n                return this.replace(r,'')\n            }\n        }\n    })(Proto,'trimStart');\n\n})(window);\n*/</pre> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"trim\"><code>String.prototype.trim()</code></a></li> <li><a href=\"trimend\"><code>String.prototype.trimEnd()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/trimStart$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/trimStart\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/trimStart</a>\n  </p>\n</div>\n","global_objects/string/valueof":"<h1>string.valueOf</h1> <p>The <code>valueOf()</code> method returns the primitive value of a <a href=\"../string\"><code>String</code></a> object.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/string-valueof.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe> <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\"><var>str</var>.valueOf()</pre> <h3 id=\"Return_value\">Return value</h3> <p>A string representing the primitive value of a given <a href=\"../string\"><code>String</code></a> object.</p> <h2 id=\"Description\">Description</h2> <p>The <code>valueOf()</code> method of <a href=\"../string\"><code>String</code></a> returns the primitive value of a <a href=\"../string\"><code>String</code></a> object as a string data type. This value is equivalent to <a href=\"tostring\"><code>String.prototype.toString()</code></a>.</p> <p>This method is usually called internally by JavaScript and not explicitly in code.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Using_valueOf()\">Using <code>valueOf()</code>\n</h3> <pre data-language=\"js\">var x = new String('Hello world');\nconsole.log(x.valueOf()); // Displays 'Hello world'\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/publications/files/ECMA-ST-ARCH/ECMA-262,%201st%20edition,%20June%201997.pdf\" hreflang=\"en\">ECMAScript 1st Edition (ECMA-262)</a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition. Implemented in JavaScript 1.1.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/5.1/#sec-15.5.4.3\" hreflang=\"en\">ECMAScript 5.1 (ECMA-262)<br><small>The definition of 'String.prototype.valueOf' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-string.prototype.valueof\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'String.prototype.valueOf' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-string.prototype.valueof\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'String.prototype.valueOf' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"tostring\"><code>String.prototype.toString()</code></a></li> <li><a href=\"../object/valueof\"><code>Object.prototype.valueOf()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/valueOf$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/valueOf\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/valueOf</a>\n  </p>\n</div>\n","global_objects/webassembly/memory/buffer":"<h1>WebAssembly.memory.buffer</h1> <p>The <code>buffer</code> prototype property of the <code><a href=\"../memory\">Memory</a></code> object returns the buffer contained in the memory.</p> <pre class=\"syntaxbox\">memory.buffer\n</pre> <h2 id=\"Examples\">Examples</h2> <p>The following example (see <a href=\"https://github.com/mdn/webassembly-examples/blob/master/js-api-examples/memory.html\">memory.html</a> on GitHub, and <a href=\"https://mdn.github.io/webassembly-examples/js-api-examples/memory.html\">view it live also</a>) fetches and instantiates the loaded memory.wasm byte code using the <a href=\"../instantiatestreaming\"><code>WebAssembly.instantiateStreaming()</code></a> method, while importing the memory created in the line above. It then stores some values in that memory, then exports a function and uses it to sum some values.</p> <pre data-language=\"js\">WebAssembly.instantiateStreaming(fetch('memory.wasm'), { js: { mem: memory } })\n.then(obj =&gt; {\n  var i32 = new Uint32Array(memory.buffer);\n  for (var i = 0; i &lt; 10; i++) {\n    i32[i] = i;\n  }\n  var sum = obj.instance.exports.accumulate(0, 10);\n  console.log(sum);\n});</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <thead> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> </thead> <tbody> <tr> <td><a href=\"https://webassembly.github.io/spec/js-api/#webassemblymemoryprototypebuffer\" hreflang=\"en\">WebAssembly JavaScript Interface<br><small>The definition of 'buffer' in that specification.</small></a></td> <td><span class=\"spec-WD\">Working Draft</span></td> <td>Initial draft definition.</td> </tr> </tbody> </table></div> <h2 name=\"Browser_compatibility\" id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>   <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 57</td>\n<td class=\"bc-supports-yes\"> 16</td>\n<td class=\"bc-supports-yes bc-has-history\"> 52\n<section class=\"bc-history\" id=\"sect1\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 52\n</dt>\n<dd> Disabled in the Firefox 52 Extended Support Release (ESR).</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 44</td>\n<td class=\"bc-supports-yes\"> 11</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 57</td>\n<td class=\"bc-supports-yes\"> 57</td>\n<td class=\"bc-supports-yes bc-has-history\"> Yes<div class=\"bc-icons\">Disabled </div>\n<section class=\"bc-history\" id=\"sect2\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> Yes<div class=\"bc-icons\">Disabled </div>\n</dt>\n<dd>Disabled This feature is behind the <code>Experimental JavaScript Features</code> preference.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-yes bc-has-history\"> 52\n<section class=\"bc-history\" id=\"sect3\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 52\n</dt>\n<dd> Disabled in the Firefox 52 Extended Support Release (ESR).</dd>\n</dl></section>\n</td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 11</td>\n<td class=\"bc-supports-yes\"> 7.0</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 8.0.0</td>\n</tr></tbody>\n</table>\n</div>  <h2 id=\"See_also\">See also</h2> <ul> <li>\n<a href=\"https://developer.mozilla.org/en-US/docs/WebAssembly\">WebAssembly</a> overview page</li> <li><a href=\"https://developer.mozilla.org/en-US/docs/WebAssembly/Concepts\">WebAssembly concepts</a></li> <li><a href=\"https://developer.mozilla.org/en-US/docs/WebAssembly/Using_the_JavaScript_API\">Using the WebAssembly JavaScript API</a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Memory/buffer$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Memory/buffer\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Memory/buffer</a>\n  </p>\n</div>\n","global_objects/webassembly/memory/grow":"<h1>WebAssembly.memory.grow</h1> <p>The <code>grow()</code> protoype method of the <code><a href=\"../memory\">Memory</a></code> object increases the size of the memory instance by a specified number of WebAssembly pages.</p> <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\">memory.grow(<em>number</em>);\n</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><em>number</em></dt> <dd>The number of WebAssembly pages you want to grow the memory by (each one is 64KiB in size).</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p>The previous size of the memory, in units of WebAssembly pages.</p> <h2 id=\"Examples\">Examples</h2> <p>The following example creates a new WebAssembly Memory instance with an initial size of 1 page (64KiB), and a maximum size of 10 pages (640KiB).</p> <pre data-language=\"js\">var memory = new WebAssembly.Memory({initial:1, maximum:10});</pre> <p>We can then grow the instance by one page like so:</p> <pre data-language=\"js\">const bytesPerPage = 64 * 1024;\nconsole.log(memory.buffer.byteLength / bytesPerPage);  // \"1\"\nconsole.log(memory.grow(1));                           // \"1\"\nconsole.log(memory.buffer.byteLength / bytesPerPage);  // \"2\"\n</pre> <p>Note the return value of <code>grow()</code> here is the previous number of WebAssembly pages.</p> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <thead> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> </thead> <tbody> <tr> <td><a href=\"https://webassembly.github.io/spec/js-api/#webassemblymemoryprototypegrow\" hreflang=\"en\">WebAssembly JavaScript Interface<br><small>The definition of 'grow()' in that specification.</small></a></td> <td><span class=\"spec-WD\">Working Draft</span></td> <td>Initial draft definition.</td> </tr> </tbody> </table></div> <h2 name=\"Browser_compatibility\" id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>   <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 57</td>\n<td class=\"bc-supports-yes\"> 16</td>\n<td class=\"bc-supports-yes bc-has-history\"> 52\n<section class=\"bc-history\" id=\"sect1\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 52\n</dt>\n<dd> Disabled in the Firefox 52 Extended Support Release (ESR).</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 44</td>\n<td class=\"bc-supports-yes\"> 11</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 57</td>\n<td class=\"bc-supports-yes\"> 57</td>\n<td class=\"bc-supports-yes bc-has-history\"> Yes<div class=\"bc-icons\">Disabled </div>\n<section class=\"bc-history\" id=\"sect2\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> Yes<div class=\"bc-icons\">Disabled </div>\n</dt>\n<dd>Disabled This feature is behind the <code>Experimental JavaScript Features</code> preference.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-yes bc-has-history\"> 52\n<section class=\"bc-history\" id=\"sect3\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 52\n</dt>\n<dd> Disabled in the Firefox 52 Extended Support Release (ESR).</dd>\n</dl></section>\n</td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 11</td>\n<td class=\"bc-supports-yes\"> 7.0</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 8.0.0</td>\n</tr></tbody>\n</table>\n</div>  <h2 id=\"See_also\">See also</h2> <ul> <li>\n<a href=\"https://developer.mozilla.org/en-US/docs/WebAssembly\">WebAssembly</a> overview page</li> <li><a href=\"https://developer.mozilla.org/en-US/docs/WebAssembly/Concepts\">WebAssembly concepts</a></li> <li><a href=\"https://developer.mozilla.org/en-US/docs/WebAssembly/Using_the_JavaScript_API\">Using the WebAssembly JavaScript API</a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Memory/grow$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Memory/grow\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Memory/grow</a>\n  </p>\n</div>\n","global_objects/string/raw":"<h1>String.raw</h1> <p>The static <code>String.raw()</code> method is a tag function of <a href=\"../../template_literals\">template literals</a>, similar to the <code>r</code> prefix in Python or the <code>@</code> prefix in C# for string literals (yet there is a difference: see explanations in <a href=\"https://bugs.chromium.org/p/v8/issues/detail?id=5016\">this issue</a>). It's used to get the raw string form of template strings, that is, substitutions (e.g. <font face=\"consolas, Liberation Mono, courier, monospace\"><span style=\"background-color: rgba(220, 220, 220, 0.5);\">${foo}</span></font>) are processed, but escapes (e.g. <code>\\n</code>) are not.</p> <p><iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/string-raw.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe></p> <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\">String.raw(<var>callSite</var>, <var>...substitutions</var>)\n\nString.raw`templateString`\n</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><code>callSite</code></dt> <dd>Well-formed template call site object, like <code>{ raw: ['foo', 'bar', 'baz'] }</code>.</dd> <dt><code>...substitutions</code></dt> <dd>Contains substitution values.</dd> <dt><code>templateString</code></dt> <dd>A <a href=\"../../template_literals\">template string</a>, optionally with substitutions (<code>${...}</code>).</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p>The raw string form of a given template string.</p> <h3 id=\"Exceptions\">Exceptions</h3> <dl> <dt><a href=\"../typeerror\"><code>TypeError</code></a></dt> <dd>A <a href=\"../typeerror\"><code>TypeError</code></a> is thrown if the first argument is not a well formed object.</dd> </dl> <h2 id=\"Description\">Description</h2> <p>In most cases, <code>String.raw()</code> is used with template strings. The first syntax mentioned above is only rarely used, because the JavaScript engine will call this with proper arguments for you, just like with other <a href=\"../../template_literals#Tagged_template_literals\">tag functions</a>.</p> <p><code>String.raw()</code> is the only built-in tag function of template strings; it works just like the default template function and performs concatenation. You can even re-implement it with normal JavaScript code.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Using_String.raw()\">Using <code>String.raw()</code>\n</h3> <pre data-language=\"js\">String.raw`Hi\\n${2+3}!`;\n// 'Hi\\n5!', the character after 'Hi'\n// is not a newline character,\n// '\\' and 'n' are two characters.\n\nString.raw`Hi\\u000A!`;\n// 'Hi\\u000A!', same here, this time we will get the\n//  \\, u, 0, 0, 0, A, 6 characters.\n// All kinds of escape characters will be ineffective\n// and backslashes will be present in the output string.\n// You can confirm this by checking the .length property\n// of the string.\n\nlet name = 'Bob';\nString.raw`Hi\\n${name}!`;\n// 'Hi\\nBob!', substitutions are processed.\n\n// Normally you would not call String.raw() as a function,\n// but to simulate `t${0}e${1}s${2}t` you can do:\nString.raw({ raw: 'test' }, 0, 1, 2); // 't0e1s2t'\n// Note that 'test', a string, is an array-like object\n// The following is equivalent to\n// `foo${2 + 3}bar${'Java' + 'Script'}baz`\nString.raw({\n  raw: ['foo', 'bar', 'baz'] \n}, 2 + 3, 'Java' + 'Script'); // 'foo5barJavaScriptbaz'\n\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-string.raw\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'String.raw' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-string.raw\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'String.raw' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 41</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 34</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 10</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 41</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 34</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 10</td>\n<td class=\"bc-supports-yes\"> 4.0</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 4.0.0</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"../../template_literals\">Template strings</a></li> <li><a href=\"../string\"><code>String</code></a></li> <li><a href=\"../../lexical_grammar\">Lexical grammar</a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/raw$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/raw\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/raw</a>\n  </p>\n</div>\n","global_objects/webassembly/instance/prototype":"<h1>WebAssembly.instance.prototype</h1> <div class=\"blockIndicator experimental indicator-warning\"> <p> <strong>This is an <a href=\"https://developer.mozilla.org/en-US/docs/MDN/Contribute/Guidelines/Conventions_definitions#Experimental\">experimental technology</a></strong><br>Check the <a href=\"#Browser_compatibility\">Browser compatibility table</a> carefully before using this in production.</p> </div> <p>The <code><strong>WebAssembly.Instance</strong></code><code>.prototype</code> property represents the prototype for the <a href=\"../instance\"><code>WebAssembly.Instance()</code></a> constructor.</p> <div class=\"_table\"><table class=\"standard-table\"> <thead> <tr> <th colspan=\"2\" class=\"header\">Property attributes of <code>WebAssembly.Instance.prototype</code>\n</th> </tr> </thead> <tbody> <tr> <td>Writable</td> <td>no</td> </tr> <tr> <td>Enumerable</td> <td>no</td> </tr> <tr> <td>Configurable</td> <td>no</td> </tr> </tbody> </table></div> <h2 id=\"Description\">Description</h2> <p>All <a href=\"../instance\"><code>WebAssembly.Instance</code></a> instances inherit from <code>Instance.prototype</code>. The prototype object of the <a href=\"../instance\"><code>WebAssembly.Instance()</code></a> constructor can be modified to affect all <a href=\"../instance\"><code>WebAssembly.Instance</code></a> instances.</p> <h2 id=\"Properties\">Properties</h2> <dl> <dt><code>Instance.prototype.constructor</code></dt> <dd>Returns the function that created this object's instance. By default this is the <a href=\"../instance\"><code>WebAssembly.Instance()</code></a> constructor.</dd> <dt>\n<code><a href=\"exports\">Instance.prototype.exports</a></code> <span class=\"inlineIndicator readOnly readOnlyInline\">Read only </span>\n</dt> <dd>Returns an object containing as its members all the functions exported from the WebAssembly module instance, to allow them to be accessed and used by JavaScript.</dd> </dl> <h2 id=\"Methods\">Methods</h2> <p>None.</p> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <thead> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> </thead> <tbody> <tr> <td><a href=\"https://webassembly.github.io/spec/js-api/#webassemblymodule-objects\" hreflang=\"en\">WebAssembly JavaScript Interface<br><small>The definition of 'WebAssembly.Module()' in that specification.</small></a></td> <td><span class=\"spec-WD\">Working Draft</span></td> <td>Initial draft definition.</td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>   <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 57</td>\n<td class=\"bc-supports-yes\"> 16</td>\n<td class=\"bc-supports-yes bc-has-history\"> 52\n<section class=\"bc-history\" id=\"sect1\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 52\n</dt>\n<dd> Disabled in the Firefox 52 Extended Support Release (ESR).</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 44</td>\n<td class=\"bc-supports-yes\"> 11</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 57</td>\n<td class=\"bc-supports-yes\"> 57</td>\n<td class=\"bc-supports-yes bc-has-history\"> Yes<div class=\"bc-icons\">Disabled </div>\n<section class=\"bc-history\" id=\"sect2\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> Yes<div class=\"bc-icons\">Disabled </div>\n</dt>\n<dd>Disabled This feature is behind the <code>Experimental JavaScript Features</code> preference.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-yes bc-has-history\"> 52\n<section class=\"bc-history\" id=\"sect3\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 52\n</dt>\n<dd> Disabled in the Firefox 52 Extended Support Release (ESR).</dd>\n</dl></section>\n</td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 11</td>\n<td class=\"bc-supports-yes\"> 7.0</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 8.0.0</td>\n</tr></tbody>\n</table>\n</div>  <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"../instance\"><code>WebAssembly.Instance()</code></a></li> <li>\n<a href=\"https://developer.mozilla.org/en-US/docs/WebAssembly\">WebAssembly</a> overview page</li> <li><a href=\"https://developer.mozilla.org/en-US/docs/WebAssembly/Concepts\">WebAssembly concepts</a></li> <li><a href=\"https://developer.mozilla.org/en-US/docs/WebAssembly/Using_the_JavaScript_API\">Using the WebAssembly JavaScript API</a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Instance/prototype$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Instance/prototype\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Instance/prototype</a>\n  </p>\n</div>\n","global_objects/webassembly/instance/exports":"<h1>WebAssembly.instance.exports</h1> <p>The <code>exports</code> readonly property of the <a href=\"../instance\"><code>WebAssembly.Instance</code></a> object prototype returns an object containing as its members all the functions exported from the WebAssembly module instance, to allow them to be accessed and used by JavaScript.</p> <pre class=\"syntaxbox\">instance.exports</pre> <h2 id=\"Examples\">Examples</h2> <p>After fetching some WebAssembly bytecode using fetch, we compile and instantiate the module using the <a href=\"../instantiatestreaming\"><code>WebAssembly.instantiateStreaming()</code></a> function, importing a JavaScript function into the WebAssembly Module in the process. We then call an <a href=\"https://developer.mozilla.org/en-US/docs/WebAssembly/Exported_functions\">Exported WebAssembly function</a> that is exported by the <code>Instance</code>.</p> <pre data-language=\"js\">var importObject = {\n  imports: {\n    imported_func: function(arg) {\n      console.log(arg);\n    }\n  }\n};\n\nWebAssembly.instantiateStreaming(fetch('simple.wasm'), importObject)\n.then(obj =&gt; obj.instance.exports.exported_func());</pre> <div class=\"note\"> <p><strong>Note</strong>: You can also find this example as <a href=\"https://github.com/mdn/webassembly-examples/blob/master/js-api-examples/instantiate-streaming.html\">instantiate-streaming.html</a> on GitHub (<a href=\"https://mdn.github.io/webassembly-examples/js-api-examples/instantiate-streaming.html\">view it live also</a>).</p> </div> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <thead> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> </thead> <tbody> <tr> <td><a href=\"https://webassembly.github.io/spec/js-api/#webassemblyinstance-objects\" hreflang=\"en\">WebAssembly JavaScript Interface<br><small>The definition of 'WebAssembly.Instance objects' in that specification.</small></a></td> <td><span class=\"spec-WD\">Working Draft</span></td> <td>Initial draft definition.</td> </tr> </tbody> </table></div> <h2 name=\"Browser_compatibility\" id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>   <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 57</td>\n<td class=\"bc-supports-yes\"> 16</td>\n<td class=\"bc-supports-yes bc-has-history\"> 52\n<section class=\"bc-history\" id=\"sect1\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 52\n</dt>\n<dd> Disabled in the Firefox 52 Extended Support Release (ESR).</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 44</td>\n<td class=\"bc-supports-yes\"> 11</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 57</td>\n<td class=\"bc-supports-yes\"> 57</td>\n<td class=\"bc-supports-yes bc-has-history\"> Yes<div class=\"bc-icons\">Disabled </div>\n<section class=\"bc-history\" id=\"sect2\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> Yes<div class=\"bc-icons\">Disabled </div>\n</dt>\n<dd>Disabled This feature is behind the <code>Experimental JavaScript Features</code> preference.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-yes bc-has-history\"> 52\n<section class=\"bc-history\" id=\"sect3\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 52\n</dt>\n<dd> Disabled in the Firefox 52 Extended Support Release (ESR).</dd>\n</dl></section>\n</td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 11</td>\n<td class=\"bc-supports-yes\"> 7.0</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 8.0.0</td>\n</tr></tbody>\n</table>\n</div>  <h2 id=\"See_also\">See also</h2> <ul> <li>\n<a href=\"https://developer.mozilla.org/en-US/docs/WebAssembly\">WebAssembly</a> overview page</li> <li><a href=\"https://developer.mozilla.org/en-US/docs/WebAssembly/Concepts\">WebAssembly concepts</a></li> <li><a href=\"https://developer.mozilla.org/en-US/docs/WebAssembly/Using_the_JavaScript_API\">Using the WebAssembly JavaScript API</a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Instance/exports$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Instance/exports\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Instance/exports</a>\n  </p>\n</div>\n","global_objects/webassembly/memory/prototype":"<h1>WebAssembly.memory.prototype</h1> <div class=\"blockIndicator experimental indicator-warning\"> <p> <strong>This is an <a href=\"https://developer.mozilla.org/en-US/docs/MDN/Contribute/Guidelines/Conventions_definitions#Experimental\">experimental technology</a></strong><br>Check the <a href=\"#Browser_compatibility\">Browser compatibility table</a> carefully before using this in production.</p> </div> <p>The <code><strong>WebAssembly.Memory</strong></code><code>.prototype</code> property represents the prototype for the <a href=\"../memory\"><code>WebAssembly.Memory()</code></a> constructor.</p> <div class=\"_table\"><table class=\"standard-table\"> <thead> <tr> <th colspan=\"2\" class=\"header\">Property attributes of <code>WebAssembly.Memory.prototype</code>\n</th> </tr> </thead> <tbody> <tr> <td>Writable</td> <td>no</td> </tr> <tr> <td>Enumerable</td> <td>no</td> </tr> <tr> <td>Configurable</td> <td>no</td> </tr> </tbody> </table></div> <h2 id=\"Description\">Description</h2> <p>All <a href=\"../memory\"><code>WebAssembly.Memory</code></a> instances inherit from <code>Memory.prototype</code>. The prototype object of the <a href=\"../memory\"><code>WebAssembly.Memory()</code></a> constructor can be modified to affect all <a href=\"../memory\"><code>WebAssembly.Memory</code></a> instances.</p> <h2 id=\"Properties\">Properties</h2> <dl> <dt><code>Memory.prototype.constructor</code></dt> <dd>Returns the function that created this object's instance. By default this is the <a href=\"../memory\"><code>WebAssembly.Memory()</code></a> constructor.</dd> <dt><a href=\"buffer\"><code>Memory.prototype.buffer</code></a></dt> <dd>An accessor property that returns the buffer contained in the memory.</dd> <dt> <h2 id=\"Methods\">Methods</h2> </dt> <dt><a href=\"grow\"><code>Memory.prototype.grow()</code></a></dt> <dd>Increases the size of the memory instance by a specified number of WebAssembly pages (each one is 64KB in size).</dd> </dl> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <thead> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> </thead> <tbody> <tr> <td><a href=\"https://webassembly.github.io/spec/js-api/#webassemblymemory-objects\" hreflang=\"en\">WebAssembly JavaScript Interface<br><small>The definition of 'Memory' in that specification.</small></a></td> <td><span class=\"spec-WD\">Working Draft</span></td> <td>Initial draft definition.</td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>   <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 57</td>\n<td class=\"bc-supports-yes\"> 16</td>\n<td class=\"bc-supports-yes bc-has-history\"> 52\n<section class=\"bc-history\" id=\"sect1\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 52\n</dt>\n<dd> Disabled in the Firefox 52 Extended Support Release (ESR).</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 44</td>\n<td class=\"bc-supports-yes\"> 11</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 57</td>\n<td class=\"bc-supports-yes\"> 57</td>\n<td class=\"bc-supports-yes bc-has-history\"> Yes<div class=\"bc-icons\">Disabled </div>\n<section class=\"bc-history\" id=\"sect2\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> Yes<div class=\"bc-icons\">Disabled </div>\n</dt>\n<dd>Disabled This feature is behind the <code>Experimental JavaScript Features</code> preference.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-yes bc-has-history\"> 52\n<section class=\"bc-history\" id=\"sect3\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 52\n</dt>\n<dd> Disabled in the Firefox 52 Extended Support Release (ESR).</dd>\n</dl></section>\n</td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 11</td>\n<td class=\"bc-supports-yes\"> 7.0</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 8.0.0</td>\n</tr></tbody>\n</table>\n</div>  <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"../memory\"><code>WebAssembly.Memory()</code></a></li> <li>\n<a href=\"https://developer.mozilla.org/en-US/docs/WebAssembly\">WebAssembly</a> overview page</li> <li><a href=\"https://developer.mozilla.org/en-US/docs/WebAssembly/Concepts\">WebAssembly concepts</a></li> <li><a href=\"https://developer.mozilla.org/en-US/docs/WebAssembly/Using_the_JavaScript_API\">Using the WebAssembly JavaScript API</a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Memory/prototype$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Memory/prototype\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Memory/prototype</a>\n  </p>\n</div>\n","global_objects/string/trimend":"<h1>string.trimEnd</h1> <p>The <code>trimEnd()</code> method removes whitespace from the end of a string. <code>trimRight()</code> is an alias of this method.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/string-trimend.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\"><var>str</var>.trimEnd();\n<var>str</var>.trimRight();</pre> <h3 id=\"Return_value\">Return value</h3> <p>A new string representing the calling string stripped of whitespace from its (right) end.</p> <h2 id=\"Description\">Description</h2> <p>The <code>trimEnd()</code> / <code>trimRight()</code> methods return the string stripped of whitespace from its right end. <code>trimEnd()</code> or <code>trimRight()</code> do not affect the value of the string itself.</p> <h3 id=\"Aliasing\">Aliasing</h3> <p>For consistency with functions like <a href=\"padend\"><code>String.prototype.padEnd</code></a> the standard method name is <code>trimEnd</code>. However, for web compatibility reasons, <code>trimRight</code> remains as an alias to <code>trimEnd</code>. In some engines this means:</p> <pre data-language=\"js\">String.prototype.trimRight.name === \"trimEnd\";</pre> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Using_trimEnd()\">Using <code>trimEnd()</code>\n</h3> <p>The following example displays the lowercase string <code>' foo'</code>:</p> <pre data-language=\"js\">var str = '   foo  ';\n\nconsole.log(str.length); // 8\n\nstr = str.trimEnd();\nconsole.log(str.length); // 6\nconsole.log(str);        // '   foo'\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <thead> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> </thead> <tbody> <tr> <td>\n<code><a href=\"https://github.com/tc39/proposal-string-left-right-trim/#stringprototypetrimstart--stringprototypetrimend\">String.prototype.{trimStart,trimEnd}</a></code> proposal</td> <td>Stage 1</td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes bc-has-history\"> 66\n<section class=\"bc-history\" id=\"sect1\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 66\n</dt>\n\n<dt class=\"bc-supports-yes bc-supports\"> Yes\n</dt>\n<dd> Uses the non-standard name: <code>trimRight</code>\n</dd>\n</dl></section>\n</td>\n<td> ? </td>\n<td class=\"bc-supports-yes bc-has-history\"> 61\n<section class=\"bc-history\" id=\"sect2\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 61\n</dt>\n\n<dt class=\"bc-supports-yes bc-supports\"> 3.5\n</dt>\n<dd> Uses the non-standard name: <code>trimRight</code>\n</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 53</td>\n<td> ? </td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes bc-has-history\"> 66\n<section class=\"bc-history\" id=\"sect3\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 66\n</dt>\n\n<dt class=\"bc-supports-yes bc-supports\"> Yes\n</dt>\n<dd> Uses the non-standard name: <code>trimRight</code>\n</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-yes bc-has-history\"> 66\n<section class=\"bc-history\" id=\"sect4\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 66\n</dt>\n\n<dt class=\"bc-supports-yes bc-supports\"> Yes\n</dt>\n<dd> Uses the non-standard name: <code>trimRight</code>\n</dd>\n</dl></section>\n</td>\n<td> ? </td>\n<td class=\"bc-supports-yes bc-has-history\"> 61\n<section class=\"bc-history\" id=\"sect5\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 61\n</dt>\n\n<dt class=\"bc-supports-yes bc-supports\"> 4\n</dt>\n<dd> Uses the non-standard name: <code>trimRight</code>\n</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-yes\"> 53</td>\n<td> ? </td>\n<td> ? </td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 10.0.0</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"trim\"><code>String.prototype.trim()</code></a></li> <li><a href=\"trimstart\"><code>String.prototype.trimStart()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/trimEnd$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/trimEnd\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/trimEnd</a>\n  </p>\n</div>\n","global_objects/string/@@iterator":"<h1>string.@@iterator</h1> <p>The <code>[@@iterator]()</code> method returns a new <code>Iterator</code> object that iterates over the code points of a String value, returning each code point as a String value.</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/string-iterator.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\"><var>str</var>[Symbol.iterator]</pre> <h3 id=\"Return_value\">Return value</h3> <p>A new <code>Iterator</code> object.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Using_iterator()\">Using <code>[@@iterator]()</code>\n</h3> <pre data-language=\"js\">var str = 'A\\uD835\\uDC68';\n\nvar strIter = str[Symbol.iterator]();\n\nconsole.log(strIter.next().value); // \"A\"\nconsole.log(strIter.next().value); // \"\\uD835\\uDC68\"\n</pre> <h3 id=\"Using_iterator()_with_for..of\">Using <code>[@@iterator]()</code> with <code>for..of</code>\n</h3> <pre data-language=\"js\">var str = 'A\\uD835\\uDC68B\\uD835\\uDC69C\\uD835\\uDC6A';\n\nfor (var v of str) {\n  console.log(v);\n}\n// \"A\"\n// \"\\uD835\\uDC68\"\n// \"B\"\n// \"\\uD835\\uDC69\"\n// \"C\"\n// \"\\uD835\\uDC6A\"\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-string.prototype-@@iterator\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'String.prototype[@@iterator]()' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-string.prototype-@@iterator\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'String.prototype[@@iterator]()' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes bc-has-history\"> 36\n<section class=\"bc-history\" id=\"sect1\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 36\n</dt>\n\n<dt class=\"bc-supports-no bc-supports\">27 — 36\n</dt>\n<dd> A placeholder property named <code>@@iterator</code> is used.</dd>\n<dd> Uses the non-standard name: <code>@@iterator</code>\n</dd>\n<dt class=\"bc-supports-no bc-supports\">17 — 27\n</dt>\n<dd> A placeholder property named <code>iterator</code> is used.</dd>\n<dd> Uses the non-standard name: <code>iterator</code>\n</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td> ? </td>\n<td class=\"bc-supports-yes bc-has-history\"> 36\n<section class=\"bc-history\" id=\"sect2\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 36\n</dt>\n\n<dt class=\"bc-supports-no bc-supports\">27 — 36\n</dt>\n<dd> A placeholder property named <code>@@iterator</code> is used.</dd>\n<dd> Uses the non-standard name: <code>@@iterator</code>\n</dd>\n<dt class=\"bc-supports-no bc-supports\">17 — 27\n</dt>\n<dd> A placeholder property named <code>iterator</code> is used.</dd>\n<dd> Uses the non-standard name: <code>iterator</code>\n</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 0.12</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"../../iteration_protocols\">Iteration protocols</a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/@@iterator$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/@@iterator\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/@@iterator</a>\n  </p>\n</div>\n","global_objects/webassembly/module/customsections":"<h1>WebAssembly.module.customSections</h1> <p>The <code>WebAssembly.customSections()</code> function returns a copy of the contents of all custom sections in the given module with the given string name.</p> <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\">var custSec = WebAssembly.Module.customSections(<em>module</em>, <em>sectionName</em>);</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><em>module</em></dt> <dd>The <a href=\"../module\"><code>WebAssembly.Module</code></a> object whose custom sections are being considered.</dd> <dt><em>sectionName</em></dt> <dd>The string name of the desired custom section.</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p>A (possibly empty) array containing <a href=\"https://developer.mozilla.org/en-US/docs/Web/API/ArrayBuffer\"><code>ArrayBuffer</code></a> copies of the contents of all custom sections matching <code>sectionName</code>.</p> <h3 id=\"Exceptions\">Exceptions</h3> <p>If <code>module</code> is not a <a href=\"../module\"><code>WebAssembly.Module</code></a> object instance, a <a href=\"../../typeerror\"><code>TypeError</code></a> is thrown.</p> <h2 id=\"Custom_sections\">Custom sections</h2> <p>A wasm module is comprised of a sequence of <strong>sections</strong>. Most of these sections are fully specified and validated by the wasm spec, but modules can also contain <strong>custom sections</strong> that are ignored and skipped over during validation. (Read <a href=\"https://github.com/WebAssembly/design/blob/master/BinaryEncoding.md#high-level-structure\">High level structure</a> for information on section structures, and how normal sections (\"known sections\") and custom sections are distinguished.)</p> <p>This provides developers with a way to include custom data inside wasm modules for other purposes, for example the <a href=\"https://github.com/WebAssembly/design/blob/master/BinaryEncoding.md#name-section\">name custom section</a>, which allows developers to provide names for all the functions and locals in the module (like \"symbols\" in a native build).</p> <p>Note that the WebAssembly text format currently doesn't have a syntax specified for adding new custom sections; you can however add a name section to your wasm during conversion from text format over to .wasm. The wast2wasm command available as part of the <a href=\"https://github.com/webassembly/wabt\">wabt tool</a> has a <code>--debug-names</code> option — specify this during conversion to get a .wasm with a names custom section, for example:</p> <pre data-language=\"bash\">wast2wasm simple-name-section.was -o simple-name-section.wasm --debug-names</pre> <h2 id=\"Example\">Example</h2> <p>The following example (see the custom-section.html <a href=\"https://github.com/mdn/webassembly-examples/blob/master/other-examples/custom-section.html\">source</a> and <a href=\"https://mdn.github.io/webassembly-examples/other-examples/custom-section.html\">live example</a>) compiles the loaded simple-name-section.wasm byte code.</p> <p>We then do a check using <code>WebAssembly.Module.customSections</code>, looking to see whether the module instance contains a \"name\" custom section by checking that its <code>length</code> is more than 0. Since there is a \"name\" section in the example, an <code>ArrayBuffer</code> object is returned.</p> <pre data-language=\"js\">WebAssembly.compileStreaming(fetch('simple-name-section.wasm'))\n.then(function(mod) {\n  var nameSections = WebAssembly.Module.customSections(mod, \"name\");\n  if (nameSections.length != 0) {\n    console.log(\"Module contains a name section\");\n    console.log(nameSections[0]);\n  };\n});</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <thead> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> </thead> <tbody> <tr> <td><a href=\"https://webassembly.github.io/spec/js-api/#webassemblymodulecustomsections\" hreflang=\"en\">WebAssembly JavaScript Interface<br><small>The definition of 'customSections()' in that specification.</small></a></td> <td><span class=\"spec-WD\">Working Draft</span></td> <td>Initial draft definition.</td> </tr> </tbody> </table></div> <h2 name=\"Browser_compatibility\" id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>   <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 57</td>\n<td class=\"bc-supports-yes\"> 16</td>\n<td class=\"bc-supports-yes bc-has-history\"> 52\n<section class=\"bc-history\" id=\"sect1\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 52\n</dt>\n<dd> Disabled in the Firefox 52 Extended Support Release (ESR).</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 44</td>\n<td class=\"bc-supports-yes\"> 11</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 57</td>\n<td class=\"bc-supports-yes\"> 57</td>\n<td class=\"bc-supports-yes bc-has-history\"> Yes<div class=\"bc-icons\">Disabled </div>\n<section class=\"bc-history\" id=\"sect2\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> Yes<div class=\"bc-icons\">Disabled </div>\n</dt>\n<dd>Disabled This feature is behind the <code>Experimental JavaScript Features</code> preference.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-yes bc-has-history\"> 52\n<section class=\"bc-history\" id=\"sect3\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 52\n</dt>\n<dd> Disabled in the Firefox 52 Extended Support Release (ESR).</dd>\n</dl></section>\n</td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 11</td>\n<td class=\"bc-supports-yes\"> 7.0</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 8.0.0</td>\n</tr></tbody>\n</table>\n</div>  <h2 id=\"See_also\">See also</h2> <ul> <li>\n<a href=\"https://developer.mozilla.org/en-US/docs/WebAssembly\">WebAssembly</a> overview page</li> <li><a href=\"https://developer.mozilla.org/en-US/docs/WebAssembly/Concepts\">WebAssembly concepts</a></li> <li><a href=\"https://developer.mozilla.org/en-US/docs/WebAssembly/Using_the_JavaScript_API\">Using the WebAssembly JavaScript API</a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Module/customSections$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Module/customSections\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Module/customSections</a>\n  </p>\n</div>\n","global_objects/webassembly/module/exports":"<h1>WebAssembly.module.exports</h1> <p>The <code>WebAssembly.exports()</code> function returns an array containing descriptions of all the declared exports of the given <code>Module</code>.</p> <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\">var exports = WebAssembly.Module.exports(module);</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><em>module</em></dt> <dd>A <a href=\"../module\"><code>WebAssembly.Module</code></a> object.</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p>An array containing objects representing the exported functions of the given module.</p> <h3 id=\"Exceptions\">Exceptions</h3> <p>If module is not a <a href=\"../module\"><code>WebAssembly.Module</code></a> object instance, a <a href=\"../../typeerror\"><code>TypeError</code></a> is thrown.</p> <h2 id=\"Examples\">Examples</h2> <p>The following example (see our <a href=\"https://github.com/mdn/webassembly-examples/blob/master/js-api-examples/index-compile.html\">index-compile.html</a> demo on GitHub, and <a href=\"https://mdn.github.io/webassembly-examples/js-api-examples/index-compile.html\">view it live</a> also) compiles the loaded simple.wasm byte code using the <a href=\"../compilestreaming\"><code>WebAssembly.compileStreaming()</code></a> method and then sends it to a <a href=\"https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API\">worker</a> using <a href=\"https://developer.mozilla.org/en-US/docs/Web/API/Worker/postMessage\">postMessage()</a>.</p> <pre data-language=\"js\">var worker = new Worker(\"wasm_worker.js\");\n\nWebAssembly.compileStreaming(fetch('simple.wasm'))\n.then(mod =&gt;\n  worker.postMessage(mod)\n);</pre> <p>In the worker (see <code><a href=\"https://github.com/mdn/webassembly-examples/blob/master/js-api-examples/wasm_worker.js\">wasm_worker.js</a></code>) we define an import object for the module to use, then set up an event handler to receive the module from the main thread. when the module is received, we create an instance from it using the <a href=\"../instantiate\"><code>WebAssembly.Instantiate()</code></a> method, invoke an exported function from inside it, then show how we can return information on the available exports on a module using <code>WebAssembly.Module.exports</code>.</p> <pre data-language=\"js\">var importObject = {\n  imports: {\n    imported_func: function(arg) {\n      console.log(arg);\n    }\n  }\n};\n\nonmessage = function(e) {\n  console.log('module received from main thread');\n  var mod = e.data;\n\n  WebAssembly.instantiate(mod, importObject).then(function(instance) {\n    instance.exports.exported_func();\n  });\n\n  var exports = WebAssembly.Module.exports(mod);\n  console.log(exports[0]);\n};</pre> <p>The <code>exports[0]</code> output looks like this:</p> <pre data-language=\"js\">{ name: \"exported_func\", kind: \"function\" }</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <thead> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> </thead> <tbody> <tr> <td><a href=\"https://webassembly.github.io/spec/js-api/#webassemblymoduleexports\" hreflang=\"en\">WebAssembly JavaScript Interface<br><small>The definition of 'exports()' in that specification.</small></a></td> <td><span class=\"spec-WD\">Working Draft</span></td> <td>Initial draft definition.</td> </tr> </tbody> </table></div> <h2 name=\"Browser_compatibility\" id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>   <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 57</td>\n<td class=\"bc-supports-yes\"> 16</td>\n<td class=\"bc-supports-yes bc-has-history\"> 52\n<section class=\"bc-history\" id=\"sect1\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 52\n</dt>\n<dd> Disabled in the Firefox 52 Extended Support Release (ESR).</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 44</td>\n<td class=\"bc-supports-yes\"> 11</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 57</td>\n<td class=\"bc-supports-yes\"> 57</td>\n<td class=\"bc-supports-yes bc-has-history\"> Yes<div class=\"bc-icons\">Disabled </div>\n<section class=\"bc-history\" id=\"sect2\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> Yes<div class=\"bc-icons\">Disabled </div>\n</dt>\n<dd>Disabled This feature is behind the <code>Experimental JavaScript Features</code> preference.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-yes bc-has-history\"> 52\n<section class=\"bc-history\" id=\"sect3\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 52\n</dt>\n<dd> Disabled in the Firefox 52 Extended Support Release (ESR).</dd>\n</dl></section>\n</td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 11</td>\n<td class=\"bc-supports-yes\"> 7.0</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 8.0.0</td>\n</tr></tbody>\n</table>\n</div>  <h2 id=\"See_also\">See also</h2> <ul> <li>\n<a href=\"https://developer.mozilla.org/en-US/docs/WebAssembly\">WebAssembly</a> overview page</li> <li><a href=\"https://developer.mozilla.org/en-US/docs/WebAssembly/Concepts\">WebAssembly concepts</a></li> <li><a href=\"https://developer.mozilla.org/en-US/docs/WebAssembly/Using_the_JavaScript_API\">Using the WebAssembly JavaScript API</a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Module/exports$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Module/exports\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Module/exports</a>\n  </p>\n</div>\n","global_objects/webassembly/module/imports":"<h1>WebAssembly.module.imports</h1> <p>The <code>WebAssembly.imports()</code> function returns an array containing descriptions of all the declared imports of the given <code>Module</code>.</p> <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\">var custSec = WebAssembly.Module.imports(module);</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><em>module</em></dt> <dd>A <a href=\"../module\"><code>WebAssembly.Module</code></a> object.</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p>An array containing objects representing the imported functions of the given module.</p> <h3 id=\"Exceptions\">Exceptions</h3> <p>If module is not a <a href=\"../module\"><code>WebAssembly.Module</code></a> object instance, a <a href=\"../../typeerror\"><code>TypeError</code></a> is thrown.</p> <h2 id=\"Example\">Example</h2> <p>The following example (see imports.html <a href=\"https://github.com/mdn/webassembly-examples/blob/master/js-api-examples/imports.html\">source code</a>; <a href=\"https://mdn.github.io/webassembly-examples/js-api-examples/imports.html\">see it live also</a>) compiles the loaded simple.wasm module. This module is then queried for its imports.</p> <pre data-language=\"js\">WebAssembly.compileStreaming(fetch('simple.wasm'))\n.then(function(mod) {\n  var imports = WebAssembly.Module.imports(mod);\n  console.log(imports[0]);\n});\n</pre> <p>The output looks like this:</p> <pre data-language=\"js\">{ module: \"imports\", name: \"imported_func\", kind: \"function\" }</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <thead> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> </thead> <tbody> <tr> <td><a href=\"https://webassembly.github.io/spec/js-api/#webassemblymoduleimports\" hreflang=\"en\">WebAssembly JavaScript Interface<br><small>The definition of 'imports()' in that specification.</small></a></td> <td><span class=\"spec-WD\">Working Draft</span></td> <td>Initial draft definition.</td> </tr> </tbody> </table></div> <h2 name=\"Browser_compatibility\" id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>   <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 57</td>\n<td class=\"bc-supports-yes\"> 16</td>\n<td class=\"bc-supports-yes bc-has-history\"> 52\n<section class=\"bc-history\" id=\"sect1\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 52\n</dt>\n<dd> Disabled in the Firefox 52 Extended Support Release (ESR).</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 44</td>\n<td class=\"bc-supports-yes\"> 11</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 57</td>\n<td class=\"bc-supports-yes\"> 57</td>\n<td class=\"bc-supports-yes bc-has-history\"> Yes<div class=\"bc-icons\">Disabled </div>\n<section class=\"bc-history\" id=\"sect2\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> Yes<div class=\"bc-icons\">Disabled </div>\n</dt>\n<dd>Disabled This feature is behind the <code>Experimental JavaScript Features</code> preference.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-yes bc-has-history\"> 52\n<section class=\"bc-history\" id=\"sect3\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 52\n</dt>\n<dd> Disabled in the Firefox 52 Extended Support Release (ESR).</dd>\n</dl></section>\n</td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 11</td>\n<td class=\"bc-supports-yes\"> 7.0</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 8.0.0</td>\n</tr></tbody>\n</table>\n</div>  <h2 id=\"See_also\">See also</h2> <ul> <li>\n<a href=\"https://developer.mozilla.org/en-US/docs/WebAssembly\">WebAssembly</a> overview page</li> <li><a href=\"https://developer.mozilla.org/en-US/docs/WebAssembly/Concepts\">WebAssembly concepts</a></li> <li><a href=\"https://developer.mozilla.org/en-US/docs/WebAssembly/Using_the_JavaScript_API\">Using the WebAssembly JavaScript API</a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Module/imports$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Module/imports\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Module/imports</a>\n  </p>\n</div>\n","global_objects/webassembly/module/prototype":"<h1>WebAssembly.module.prototype</h1> <p>The <code><strong>WebAssembly.Module</strong></code><code>.prototype</code> property represents the prototype for the <a href=\"../module\"><code>WebAssembly.Module()</code></a> constructor.</p> <div class=\"_table\"><table class=\"standard-table\"> <thead> <tr> <th colspan=\"2\" class=\"header\">Property attributes of <code>WebAssembly.Module.prototype</code>\n</th> </tr> </thead> <tbody> <tr> <td>Writable</td> <td>no</td> </tr> <tr> <td>Enumerable</td> <td>no</td> </tr> <tr> <td>Configurable</td> <td>no</td> </tr> </tbody> </table></div> <h2 id=\"Description\">Description</h2> <p>All <a href=\"../module\"><code>WebAssembly.Module</code></a> instances inherit from <code>Module.prototype</code>. The prototype object of the <a href=\"../module\"><code>WebAssembly.Module()</code></a> constructor can be modified to affect all <a href=\"../module\"><code>WebAssembly.Module</code></a> instances.</p> <h2 id=\"Properties\">Properties</h2> <dl> <dt><code>Module.prototype.constructor</code></dt> <dd>Returns the function that created this object's instance. By default this is the <a href=\"../module\"><code>WebAssembly.Module()</code></a> constructor.</dd> <dt><code>Module.prototype[@@toStringTag]</code></dt> <dd>The initial value of the <a href=\"../../symbol/tostringtag\">@@toStringTag</a> property is the String value \"WebAssembly.Module\".</dd> </dl> <h2 id=\"Methods\">Methods</h2> <p>None.</p> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <thead> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> </thead> <tbody> <tr> <td><a href=\"https://webassembly.github.io/spec/js-api/#webassemblymodule-objects\" hreflang=\"en\">WebAssembly JavaScript Interface<br><small>The definition of 'WebAssembly.Module()' in that specification.</small></a></td> <td><span class=\"spec-WD\">Working Draft</span></td> <td>Initial draft definition.</td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>   <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 57</td>\n<td class=\"bc-supports-yes\"> 16</td>\n<td class=\"bc-supports-yes bc-has-history\"> 52\n<section class=\"bc-history\" id=\"sect1\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 52\n</dt>\n<dd> Disabled in the Firefox 52 Extended Support Release (ESR).</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 44</td>\n<td class=\"bc-supports-yes\"> 11</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 57</td>\n<td class=\"bc-supports-yes\"> 57</td>\n<td class=\"bc-supports-yes bc-has-history\"> Yes<div class=\"bc-icons\">Disabled </div>\n<section class=\"bc-history\" id=\"sect2\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> Yes<div class=\"bc-icons\">Disabled </div>\n</dt>\n<dd>Disabled This feature is behind the <code>Experimental JavaScript Features</code> preference.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-yes bc-has-history\"> 52\n<section class=\"bc-history\" id=\"sect3\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 52\n</dt>\n<dd> Disabled in the Firefox 52 Extended Support Release (ESR).</dd>\n</dl></section>\n</td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 11</td>\n<td class=\"bc-supports-yes\"> 7.0</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 8.0.0</td>\n</tr></tbody>\n</table>\n</div>  <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"../module\"><code>WebAssembly.Module()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Module/prototype$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Module/prototype\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Module/prototype</a>\n  </p>\n</div>\n","global_objects/string/trim":"<h1>string.trim</h1> <p>The <code>trim()</code> method removes whitespace from both ends of a string. Whitespace in this context is all the whitespace characters (space, tab, no-break space, etc.) and all the line terminator characters (LF, CR, etc.).</p> <iframe src=\"https://interactive-examples.mdn.mozilla.net/pages/js/string-trim.html\" frameborder=\"0\" width=\"100%\" class=\"interactive interactive-js\" height=\"250\"></iframe>  <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\"><var>str</var>.trim()</pre> <h3 id=\"Return_value\">Return value</h3> <p>A new string representing the calling string stripped of whitespace from both ends.</p> <h2 id=\"Description\">Description</h2> <p>The <code>trim()</code> method returns the string stripped of whitespace from both ends. <code>trim()</code> does not affect the value of the string itself.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Using_trim()\">Using <code>trim()</code>\n</h3> <p>The following example displays the lowercase string <code>'foo'</code>:</p> <pre data-language=\"js\">var orig = '   foo  ';\nconsole.log(orig.trim()); // 'foo'\n\n// Another example of .trim() removing whitespace from just one side.\n\nvar orig = 'foo    ';\nconsole.log(orig.trim()); // 'foo'\n</pre> <h2 id=\"Polyfill\">Polyfill</h2> <p>Running the following code before any other code will create <code>trim()</code> if it's not natively available.</p> <pre data-language=\"js\">if (!String.prototype.trim) {\n  String.prototype.trim = function () {\n    return this.replace(/^[\\s\\uFEFF\\xA0]+|[\\s\\uFEFF\\xA0]+$/g, '');\n  };\n}\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/5.1/#sec-15.5.4.20\" hreflang=\"en\">ECMAScript 5.1 (ECMA-262)<br><small>The definition of 'String.prototype.trim' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition. Implemented in JavaScript 1.8.1.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-string.prototype.trim\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'String.prototype.trim' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-string.prototype.trim\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'String.prototype.trim' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String/trim\">Basic support</a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 3.5</td>\n<td class=\"bc-supports-yes\"> 9</td>\n<td class=\"bc-supports-yes\"> 10.5</td>\n<td class=\"bc-supports-yes\"> 5</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String/trim\">Basic support</a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String/trim\">Basic support</a></th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"trimstart\"><code>String.prototype.trimStart()</code></a></li> <li><a href=\"trimend\"><code>String.prototype.trimEnd()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/Trim$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/Trim\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/Trim</a>\n  </p>\n</div>\n","global_objects/webassembly/table/prototype":"<h1>WebAssembly.table.prototype</h1> <div class=\"blockIndicator experimental indicator-warning\"> <p> <strong>This is an <a href=\"https://developer.mozilla.org/en-US/docs/MDN/Contribute/Guidelines/Conventions_definitions#Experimental\">experimental technology</a></strong><br>Check the <a href=\"#Browser_compatibility\">Browser compatibility table</a> carefully before using this in production.</p> </div> <p>The <code><strong>WebAssembly.Table</strong></code><code>.prototype</code> property represents the prototype for the <a href=\"../table\"><code>WebAssembly.Table()</code></a> constructor.</p> <div class=\"_table\"><table class=\"standard-table\"> <thead> <tr> <th colspan=\"2\" class=\"header\">Property attributes of <code>WebAssembly.Table.prototype</code>\n</th> </tr> </thead> <tbody> <tr> <td>Writable</td> <td>no</td> </tr> <tr> <td>Enumerable</td> <td>no</td> </tr> <tr> <td>Configurable</td> <td>no</td> </tr> </tbody> </table></div> <h2 id=\"Description\">Description</h2> <p>All <a href=\"../table\"><code>WebAssembly.Table</code></a> instances inherit from <code>Table.prototype</code>. The prototype object of the <a href=\"../table\"><code>WebAssembly.Table()</code></a> constructor can be modified to affect all <a href=\"../table\"><code>WebAssembly.Table</code></a> instances.</p> <h2 id=\"Properties\">Properties</h2> <dl> <dt><code>Table.prototype.constructor</code></dt> <dd>Returns the function that created this object's instance. By default this is the <a href=\"../table\"><code>WebAssembly.Table()</code></a> constructor.</dd> <dt><a href=\"length\"><code>Table.prototype.length</code></a></dt> <dd>Returns the length of the table, i.e. the number of references stored in the table.</dd> <dt> <h2 id=\"Methods\">Methods</h2> </dt> <dt><a href=\"get\"><code>Table.prototype.get()</code></a></dt> <dd>Accessor function — gets a reference stored at a given index.</dd> <dt><a href=\"grow\"><code>Table.prototype.grow()</code></a></dt> <dd>Increases the size of the Table instance by a specified number of references.</dd> <dt><a href=\"set\"><code>Table.prototype.set()</code></a></dt> <dd>Mutates a reference stored at a given index to a different value.</dd> </dl> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <thead> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> </thead> <tbody> <tr> <td><a href=\"https://webassembly.github.io/spec/js-api/#webassemblytable-objects\" hreflang=\"en\">WebAssembly JavaScript Interface<br><small>The definition of 'Table' in that specification.</small></a></td> <td><span class=\"spec-WD\">Working Draft</span></td> <td>Initial draft definition.</td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>   <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 57</td>\n<td class=\"bc-supports-yes\"> 16</td>\n<td class=\"bc-supports-yes bc-has-history\"> 52\n<section class=\"bc-history\" id=\"sect1\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 52\n</dt>\n<dd> Disabled in the Firefox 52 Extended Support Release (ESR).</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 44</td>\n<td class=\"bc-supports-yes\"> 11</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 57</td>\n<td class=\"bc-supports-yes\"> 57</td>\n<td class=\"bc-supports-yes bc-has-history\"> Yes<div class=\"bc-icons\">Disabled </div>\n<section class=\"bc-history\" id=\"sect2\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> Yes<div class=\"bc-icons\">Disabled </div>\n</dt>\n<dd>Disabled This feature is behind the <code>Experimental JavaScript Features</code> preference.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-yes bc-has-history\"> 52\n<section class=\"bc-history\" id=\"sect3\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 52\n</dt>\n<dd> Disabled in the Firefox 52 Extended Support Release (ESR).</dd>\n</dl></section>\n</td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 11</td>\n<td class=\"bc-supports-yes\"> 7.0</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 8.0.0</td>\n</tr></tbody>\n</table>\n</div>  <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"../table\"><code>WebAssembly.Table</code></a></li> <li>\n<a href=\"https://developer.mozilla.org/en-US/docs/WebAssembly\">WebAssembly</a> overview page</li> <li><a href=\"https://developer.mozilla.org/en-US/docs/WebAssembly/Concepts\">WebAssembly concepts</a></li> <li><a href=\"https://developer.mozilla.org/en-US/docs/WebAssembly/Using_the_JavaScript_API\">Using the WebAssembly JavaScript API</a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Table/prototype$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Table/prototype\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Table/prototype</a>\n  </p>\n</div>\n","global_objects/webassembly/table/set":"<h1>WebAssembly.table.set</h1> <p>The <code><strong>set()</strong></code> prototype method of the <a href=\"../table\"><code>WebAssembly.Table</code></a> object mutates a reference stored at a given index to a different value.</p> <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\">table.set(<em>index</em>, <em>value</em>);\n</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><em>index</em></dt> <dd>The index of the function reference you want to mutate.</dd> <dt><em>value</em></dt> <dd>The value you want to mutate the reference to. This must be an <a href=\"https://developer.mozilla.org/en-US/docs/WebAssembly/Exported_functions\">exported WebAssembly function</a>, a JavaScript wrapper for an underlying wasm function.</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p>Void.</p> <h3 id=\"Exceptions\">Exceptions</h3> <ul> <li>If <em>index</em> is greater than or equal to <a href=\"length\"><code>Table.prototype.length</code></a>, a <a href=\"../../rangeerror\"><code>RangeError</code></a> is thrown.</li> <li>If <em>value</em> is not an exported WebAssembly function or <code><a href=\"../../null\">null</a></code>, a <a href=\"../../typeerror\"><code>TypeError</code></a> is thrown.</li> </ul> <h2 id=\"Examples\">Examples</h2> <p>The following example (see table2.html <a href=\"https://github.com/mdn/webassembly-examples/blob/master/js-api-examples/table2.html\">source code</a> and <a href=\"https://mdn.github.io/webassembly-examples/js-api-examples/table2.html\">live version</a>) creates a new WebAssembly Table instance with an initial size of 2 references. We then print out the table length and contents of the two indexes (retrieved via <a href=\"get\"><code>Table.prototype.get()</code></a>) to show that the length is two, and the indexes currently contain no function references (they currently return <a href=\"../../null\"><code>null</code></a>).</p> <pre data-language=\"js\">var tbl = new WebAssembly.Table({initial:2, element:\"anyfunc\"});\nconsole.log(tbl.length);\nconsole.log(tbl.get(0));\nconsole.log(tbl.get(1));</pre> <p>We then create an import object that contains a reference to the table:</p> <pre data-language=\"js\">var importObj = {\n  js: {\n    tbl:tbl\n  }\n};</pre> <p>Finally, we load and instantiate a wasm module (table2.wasm) using the <a href=\"../instantiatestreaming\"><code>WebAssembly.instantiateStreaming()</code></a>, log the table length, and invoke the two referenced functions that are now stored in the table (the table2.wasm module (see <a href=\"https://github.com/mdn/webassembly-examples/blob/master/text-format-examples/table2.was\">text representation</a>) adds two function references to the table, both of which print out a simple value):</p> <pre data-language=\"js\">WebAssembly.instantiateStreaming(fetch('table2.wasm'), importObject)\n.then(function(obj) {\n  console.log(tbl.length);\n  console.log(tbl.get(0)());\n  console.log(tbl.get(1)());\n});</pre> <p>Note how you've got to include a second function invocation operator at the end of the accessor to actually invoke the referenced function and log the value stored inside it (e.g. <code>get(0)()</code> rather than <code>get(0)</code>) .</p> <p>This example shows that we're creating and accessing the table from JavaScript, but the same table is visible and callable inside the wasm instance too.</p> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <thead> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> </thead> <tbody> <tr> <td><a href=\"https://webassembly.github.io/spec/js-api/#webassemblytableprototypeset\" hreflang=\"en\">WebAssembly JavaScript Interface<br><small>The definition of 'set()' in that specification.</small></a></td> <td><span class=\"spec-WD\">Working Draft</span></td> <td>Initial draft definition.</td> </tr> </tbody> </table></div> <h2 name=\"Browser_compatibility\" id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>   <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 57</td>\n<td class=\"bc-supports-yes\"> 16</td>\n<td class=\"bc-supports-yes bc-has-history\"> 52\n<section class=\"bc-history\" id=\"sect1\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 52\n</dt>\n<dd> Disabled in the Firefox 52 Extended Support Release (ESR).</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 44</td>\n<td class=\"bc-supports-yes\"> 11</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 57</td>\n<td class=\"bc-supports-yes\"> 57</td>\n<td class=\"bc-supports-yes bc-has-history\"> Yes<div class=\"bc-icons\">Disabled </div>\n<section class=\"bc-history\" id=\"sect2\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> Yes<div class=\"bc-icons\">Disabled </div>\n</dt>\n<dd>Disabled This feature is behind the <code>Experimental JavaScript Features</code> preference.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-yes bc-has-history\"> 52\n<section class=\"bc-history\" id=\"sect3\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 52\n</dt>\n<dd> Disabled in the Firefox 52 Extended Support Release (ESR).</dd>\n</dl></section>\n</td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 11</td>\n<td class=\"bc-supports-yes\"> 7.0</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 8.0.0</td>\n</tr></tbody>\n</table>\n</div>  <h2 id=\"See_also\">See also</h2> <ul> <li>\n<a href=\"https://developer.mozilla.org/en-US/docs/WebAssembly\">WebAssembly</a> overview page</li> <li><a href=\"https://developer.mozilla.org/en-US/docs/WebAssembly/Concepts\">WebAssembly concepts</a></li> <li><a href=\"https://developer.mozilla.org/en-US/docs/WebAssembly/Using_the_JavaScript_API\">Using the WebAssembly JavaScript API</a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Table/set$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Table/set\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Table/set</a>\n  </p>\n</div>\n","global_objects/webassembly/global/prototype":"<h1>WebAssembly.global.prototype</h1> <p>The <code><strong>WebAssembly.Global</strong></code><code>.prototype</code> property represents the prototype for the <a href=\"../global\"><code>WebAssembly.Global()</code></a> constructor.</p> <div class=\"_table\"><table class=\"standard-table\"> <thead> <tr> <th colspan=\"2\" class=\"header\">Property attributes of <code>WebAssembly.Global.prototype</code>\n</th> </tr> </thead> <tbody> <tr> <td>Writable</td> <td>no</td> </tr> <tr> <td>Enumerable</td> <td>no</td> </tr> <tr> <td>Configurable</td> <td>no</td> </tr> </tbody> </table></div> <h2 id=\"Description\">Description</h2> <p>All <a href=\"../global\"><code>WebAssembly.Global</code></a> instances inherit from <code>Global.prototype</code>. The prototype object of the <a href=\"../global\"><code>WebAssembly.Global()</code></a> constructor can be modified to affect all <a href=\"../global\"><code>WebAssembly.Global</code></a> instances.</p> <h2 id=\"Properties\">Properties</h2> <dl> <dt><code>Global.prototype.constructor</code></dt> <dd>Returns the function that created this object's instance. By default this is the <a href=\"../global\"><code>WebAssembly.Global()</code></a> constructor.</dd> <dt><code>Global.prototype[@@toStringTag]</code></dt> <dd>The initial value of the <a href=\"../../symbol/tostringtag\">@@toStringTag</a> property is the String value \"WebAssembly.Global\".</dd> <dt><code>Global.prototype.value</code></dt> <dd>The value contained inside the global variable — this can be used to directly set and get the global's value.</dd> </dl> <h2 id=\"Methods\">Methods</h2> <dl> <dt><code>Global.prototype.valueOf()</code></dt> <dd>Old-style method that returns the value contained inside the global variable.</dd> </dl> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <thead> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> </thead> <tbody> <tr> <td><a href=\"https://webassembly.github.io/spec/js-api/#globals\" hreflang=\"en\">WebAssembly JavaScript Interface<br><small>The definition of 'WebAssembly.Global()' in that specification.</small></a></td> <td><span class=\"spec-WD\">Working Draft</span></td> <td>Initial draft definition.</td> </tr> </tbody> </table></div> <h2 name=\"Browser_compatibility\" id=\"Browser_compatibility\">Browser compatibility</h2>   <p>No compatibility data found. Please contribute data for \"javascript.builtins.WebAssembly.Global.prototype\" (depth: 1) to the <a href=\"https://github.com/mdn/browser-compat-data\">MDN compatibility data repository</a>.</p>     <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"../global\"><code>WebAssembly.Global()</code></a></li> </ul> <div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Global/prototype$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Global/prototype\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Global/prototype</a>\n  </p>\n</div>\n","global_objects/webassembly/table/get":"<h1>WebAssembly.table.get</h1> <p>The <code><strong>get()</strong></code> prototype method of the <a href=\"../table\"><code>WebAssembly.Table()</code></a> object retrieves a function reference stored at a given index.</p> <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\">var funcRef = table.get(<em>index</em>);\n</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><em>index</em></dt> <dd>The index of the function reference you want to retrieve.</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p>A function reference — this is an <a href=\"https://developer.mozilla.org/en-US/docs/WebAssembly/Exported_functions\">exported WebAssembly function</a>, a JavaScript wrapper for an underlying wasm function.</p> <h3 id=\"Exceptions\">Exceptions</h3> <p>If <em>index</em> is greater than or equal to <a href=\"length\"><code>Table.prototype.length</code></a>, a <a href=\"../../rangeerror\"><code>RangeError</code></a> is thrown.</p> <h2 id=\"Examples\">Examples</h2> <p>The following example (see <a href=\"https://github.com/mdn/webassembly-examples/blob/master/js-api-examples/table.html\">table.html</a> on GitHub, and <a href=\"https://mdn.github.io/webassembly-examples/js-api-examples/table.html\">view it live</a> also) compiles and instantiates the loaded table.wasm byte code using the <a href=\"../instantiatestreaming\"><code>WebAssembly.instantiateStreaming()</code></a> method. It then retrieves the references stored in the exported table.</p> <pre data-language=\"js\">WebAssembly.instantiateStreaming(fetch('table.wasm'))\n.then(function(obj) {\n  var tbl = obj.instance.exports.tbl;\n  console.log(tbl.get(0)());  // 13\n  console.log(tbl.get(1)());  // 42\n});</pre> <p>Note how you've got to include a second function invocation operator at the end of the accessor to actually retrieve the value stored inside the reference (e.g. <code>get(0)()</code> rather than <code>get(0)</code>) — it is a function rather than a simple value.</p> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <thead> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> </thead> <tbody> <tr> <td><a href=\"https://webassembly.github.io/spec/js-api/#webassemblytableprototypeget\" hreflang=\"en\">WebAssembly JavaScript Interface<br><small>The definition of 'get()' in that specification.</small></a></td> <td><span class=\"spec-WD\">Working Draft</span></td> <td>Initial draft definition.</td> </tr> </tbody> </table></div> <h2 name=\"Browser_compatibility\" id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>   <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 57</td>\n<td class=\"bc-supports-yes\"> 16</td>\n<td class=\"bc-supports-yes bc-has-history\"> 52\n<section class=\"bc-history\" id=\"sect1\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 52\n</dt>\n<dd> Disabled in the Firefox 52 Extended Support Release (ESR).</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 44</td>\n<td class=\"bc-supports-yes\"> 11</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 57</td>\n<td class=\"bc-supports-yes\"> 57</td>\n<td class=\"bc-supports-yes bc-has-history\"> Yes<div class=\"bc-icons\">Disabled </div>\n<section class=\"bc-history\" id=\"sect2\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> Yes<div class=\"bc-icons\">Disabled </div>\n</dt>\n<dd>Disabled This feature is behind the <code>Experimental JavaScript Features</code> preference.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-yes bc-has-history\"> 52\n<section class=\"bc-history\" id=\"sect3\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 52\n</dt>\n<dd> Disabled in the Firefox 52 Extended Support Release (ESR).</dd>\n</dl></section>\n</td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 11</td>\n<td class=\"bc-supports-yes\"> 7.0</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 8.0.0</td>\n</tr></tbody>\n</table>\n</div>  <h2 id=\"See_also\">See also</h2> <ul> <li>\n<a href=\"https://developer.mozilla.org/en-US/docs/WebAssembly\">WebAssembly</a> overview page</li> <li><a href=\"https://developer.mozilla.org/en-US/docs/WebAssembly/Concepts\">WebAssembly concepts</a></li> <li><a href=\"https://developer.mozilla.org/en-US/docs/WebAssembly/Using_the_JavaScript_API\">Using the WebAssembly JavaScript API</a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Table/get$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Table/get\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Table/get</a>\n  </p>\n</div>\n","global_objects/webassembly/table/grow":"<h1>WebAssembly.table.grow</h1> <p>The <code><strong>grow()</strong></code> prototype method of the <a href=\"../table\"><code>WebAssembly.Table</code></a> object increases the size of the Table instance by a specified number of elements.</p> <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\">table.grow(<em>number</em>);\n</pre> <h3 id=\"Parameters\">Parameters</h3> <dl> <dt><em>number</em></dt> <dd>The number of elements you want to grow the table by.</dd> </dl> <h3 id=\"Return_value\">Return value</h3> <p>The previous length of the table.</p> <h3 id=\"Exceptions\">Exceptions</h3> <p>If the <code>grow()</code> operation fails for whatever reason, a <a href=\"../../rangeerror\"><code>RangeError</code></a> is thrown.</p> <h2 id=\"Examples\">Examples</h2> <p>The following example creates a new WebAssembly Table instance with an initial size of 2 and a maximum size of 10.</p> <pre data-language=\"js\">var table = new WebAssembly.Table({ element: \"anyfunc\", initial: 2, maximum: 10 });</pre> <p>You can then grow the table by 1 with the following:</p> <pre data-language=\"js\">console.log(table.length);   // \"2\"\nconsole.log(table.grow(1));  // \"2\"\nconsole.log(table.length);   // \"3\"\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <thead> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> </thead> <tbody> <tr> <td><a href=\"https://webassembly.github.io/spec/js-api/#webassemblytableprototypegrow\" hreflang=\"en\">WebAssembly JavaScript Interface<br><small>The definition of 'grow()' in that specification.</small></a></td> <td><span class=\"spec-WD\">Working Draft</span></td> <td>Initial draft definition.</td> </tr> </tbody> </table></div> <h2 name=\"Browser_compatibility\" id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>   <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 57</td>\n<td class=\"bc-supports-yes\"> 16</td>\n<td class=\"bc-supports-yes bc-has-history\"> 52\n<section class=\"bc-history\" id=\"sect1\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 52\n</dt>\n<dd> Disabled in the Firefox 52 Extended Support Release (ESR).</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 44</td>\n<td class=\"bc-supports-yes\"> 11</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 57</td>\n<td class=\"bc-supports-yes\"> 57</td>\n<td class=\"bc-supports-yes bc-has-history\"> Yes<div class=\"bc-icons\">Disabled </div>\n<section class=\"bc-history\" id=\"sect2\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> Yes<div class=\"bc-icons\">Disabled </div>\n</dt>\n<dd>Disabled This feature is behind the <code>Experimental JavaScript Features</code> preference.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-yes bc-has-history\"> 52\n<section class=\"bc-history\" id=\"sect3\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 52\n</dt>\n<dd> Disabled in the Firefox 52 Extended Support Release (ESR).</dd>\n</dl></section>\n</td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 11</td>\n<td class=\"bc-supports-yes\"> 7.0</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 8.0.0</td>\n</tr></tbody>\n</table>\n</div>  <h2 id=\"See_also\">See also</h2> <ul> <li>\n<a href=\"https://developer.mozilla.org/en-US/docs/WebAssembly\">WebAssembly</a> overview page</li> <li><a href=\"https://developer.mozilla.org/en-US/docs/WebAssembly/Concepts\">WebAssembly concepts</a></li> <li><a href=\"https://developer.mozilla.org/en-US/docs/WebAssembly/Using_the_JavaScript_API\">Using the WebAssembly JavaScript API</a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Table/grow$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Table/grow\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Table/grow</a>\n  </p>\n</div>\n","global_objects/webassembly/table/length":"<h1>WebAssembly.table.length</h1> <p>The <code><strong>length</strong></code> prototype property of the <a href=\"../table\"><code>WebAssembly.Table</code></a> object returns the length of the table, i.e. the number of elements in the table.</p> <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\">table.length;\n</pre> <h2 id=\"Examples\">Examples</h2> <p>The following example creates a new WebAssembly Table instance with an initial size of 2 and a maximum size of 10.</p> <pre data-language=\"js\">var table = new WebAssembly.Table({ element: \"anyfunc\", initial: 2, maximum: 10 });</pre> <p>You can then grow the table by 1 with the following:</p> <pre data-language=\"js\">console.log(table.length);   // \"2\"\nconsole.log(table.grow(1));  // \"2\"\nconsole.log(table.length);   // \"3\"\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <thead> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> </thead> <tbody> <tr> <td><a href=\"https://webassembly.github.io/spec/js-api/#webassemblytableprototypelength\" hreflang=\"en\">WebAssembly JavaScript Interface<br><small>The definition of 'length' in that specification.</small></a></td> <td><span class=\"spec-WD\">Working Draft</span></td> <td>Initial draft definition.</td> </tr> </tbody> </table></div> <h2 name=\"Browser_compatibility\" id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>   <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 57</td>\n<td class=\"bc-supports-yes\"> 16</td>\n<td class=\"bc-supports-yes bc-has-history\"> 52\n<section class=\"bc-history\" id=\"sect1\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 52\n</dt>\n<dd> Disabled in the Firefox 52 Extended Support Release (ESR).</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 44</td>\n<td class=\"bc-supports-yes\"> 11</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 57</td>\n<td class=\"bc-supports-yes\"> 57</td>\n<td class=\"bc-supports-yes bc-has-history\"> Yes<div class=\"bc-icons\">Disabled </div>\n<section class=\"bc-history\" id=\"sect2\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> Yes<div class=\"bc-icons\">Disabled </div>\n</dt>\n<dd>Disabled This feature is behind the <code>Experimental JavaScript Features</code> preference.</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-yes bc-has-history\"> 52\n<section class=\"bc-history\" id=\"sect3\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 52\n</dt>\n<dd> Disabled in the Firefox 52 Extended Support Release (ESR).</dd>\n</dl></section>\n</td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 11</td>\n<td class=\"bc-supports-yes\"> 7.0</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 8.0.0</td>\n</tr></tbody>\n</table>\n</div>  <h2 id=\"See_also\">See also</h2> <ul> <li>\n<a href=\"https://developer.mozilla.org/en-US/docs/WebAssembly\">WebAssembly</a> overview page</li> <li><a href=\"https://developer.mozilla.org/en-US/docs/WebAssembly/Concepts\">WebAssembly concepts</a></li> <li><a href=\"https://developer.mozilla.org/en-US/docs/WebAssembly/Using_the_JavaScript_API\">Using the WebAssembly JavaScript API</a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Table/length$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Table/length\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Table/length</a>\n  </p>\n</div>\n","functions/arguments/callee":"<h1>arguments.callee</h1> <p>The <code>arguments.callee</code> property contains the currently executing function.</p> <h2 id=\"Description\">Description</h2> <p><code>callee</code> is a property of the <code>arguments</code> object. It can be used to refer to the currently executing function inside the function body of that function. This is useful when the name of the function is unknown, such as within a function expression with no name (also called \"anonymous functions\").</p> <div class=\"warning\">\n<strong>Warning:</strong> The 5th edition of ECMAScript (ES5) forbids use of <code>arguments.callee()</code> in <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Strict_mode\">strict mode</a>. Avoid using <code>arguments.callee()</code> by either giving function expressions a name or use a function declaration where a function must call itself.</div> <h3 id=\"Why_was_arguments.callee_removed_from_ES5_strict_mode\">Why was <code>arguments.callee</code> removed from ES5 strict mode?</h3> <p>(adapted from <a href=\"http://stackoverflow.com/a/235760/578288\">a Stack Overflow answer by olliej</a>)</p> <p>Early versions of JavaScript did not allow named function expressions, and for this reason you could not make a recursive function expression.</p> <p>For example, this syntax worked:</p> <pre data-language=\"js\">function factorial (n) {\n    return !(n &gt; 1) ? 1 : factorial(n - 1) * n;\n}\n\n[1, 2, 3, 4, 5].map(factorial);</pre> <p>but:</p> <pre data-language=\"js\">[1, 2, 3, 4, 5].map(function(n) {\n    return !(n &gt; 1) ? 1 : /* what goes here? */ (n - 1) * n;\n});</pre> <p>did not. To get around this <code>arguments.callee</code> was added so you could do</p> <pre data-language=\"js\">[1, 2, 3, 4, 5].map(function(n) {\n    return !(n &gt; 1) ? 1 : arguments.callee(n - 1) * n;\n});</pre> <p>However, this was actually a really bad solution as this (in conjunction with other <code>arguments</code>, <code>callee</code>, and <code>caller</code> issues) make inlining and tail recursion impossible in the general case (you can achieve it in select cases through tracing, etc., but even the best code is suboptimal due to checks that would not otherwise be necessary.) The other major issue is that the recursive call will get a different <code>this</code> value, e.g.:</p> <pre data-language=\"js\">var global = this;\n\nvar sillyFunction = function(recursed) {\n    if (!recursed) { return arguments.callee(true); }\n    if (this !== global) {\n        alert('This is: ' + this);\n    } else {\n        alert('This is the global');\n    }\n}\n\nsillyFunction();</pre> <p>ECMAScript 3 resolved these issues by allowing named function expressions. For example:</p> <pre data-language=\"js\">[1, 2, 3, 4, 5].map(function factorial(n) {\n    return !(n &gt; 1) ? 1 : factorial(n - 1)*n;\n});</pre> <p>This has numerous benefits:</p> <ul> <li>the function can be called like any other from inside your code</li> <li>it does not create a variable in the outer scope (<a href=\"http://kangax.github.io/nfe/#example_1_function_expression_identifier_leaks_into_an_enclosing_scope\">except for IE 8 and below</a>)</li> <li>it has better performance than accessing the arguments object</li> </ul> <p>Another feature that was deprecated was <code>arguments.callee.caller</code>, or more specifically <code>Function.caller</code>. Why is this? Well, at any point in time you can find the deepest caller of any function on the stack, and as I said above looking at the call stack has one single major effect: it makes a large number of optimizations impossible, or much much more difficult. For example, if you cannot guarantee that a function <code>f</code> will not call an unknown function, it is not possible to inline <code>f</code>. Basically it means that any call site that may have been trivially inlinable accumulates a large number of guards:</p> <pre data-language=\"js\">function f(a, b, c, d, e) { return a ? b * c : d * e; }</pre> <p>If the JavaScript interpreter cannot guarantee that all the provided arguments are numbers at the point that the call is made, it needs to either insert checks for all the arguments before the inlined code, or it cannot inline the function. Now in this particular case a smart interpreter should be able to rearrange the checks to be more optimal and not check any values that would not be used. However in many cases that's just not possible and therefore it becomes impossible to inline.</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Using_arguments.callee_in_an_anonymous_recursive_function\">Using <code>arguments.callee</code> in an anonymous recursive function</h3> <p>A recursive function must be able to refer to itself. Typically, a function refers to itself by its name. However, an anonymous function (which can be created by a <a href=\"../../operators/function\">function expression</a> or the <a href=\"../../global_objects/function\"><code>Function</code> constructor</a>) does not have a name. Therefore if there is no accessible variable referring to it, the only way the function can refer to itself is by <code>arguments.callee</code>.</p> <p>The following example defines a function, which, in turn, defines and returns a factorial function. This example isn't very practical, and there are nearly no cases where the same result cannot be achieved with <a href=\"../../operators/function\">named function expressions</a>.</p> <pre data-language=\"js\">function create() {\n   return function(n) {\n      if (n &lt;= 1)\n         return 1;\n      return n * arguments.callee(n - 1);\n   };\n}\n\nvar result = create()(5); // returns 120 (5 * 4 * 3 * 2 * 1)</pre> <h3 id=\"A_use_of_arguments.callee_with_no_good_alternative\">A use of <code>arguments.callee</code> with no good alternative</h3> <p>However, in a case like the following, there are not alternatives to <code>arguments.callee</code>, so its deprecation could be a bug (see <a href=\"https://bugzilla.mozilla.org/show_bug.cgi?id=725398\">bug 725398</a>):</p> <pre data-language=\"js\">function createPerson(sIdentity) {\n    var oPerson = new Function('alert(arguments.callee.identity);');\n    oPerson.identity = sIdentity;\n    return oPerson;\n}\n\nvar john = createPerson('John Smith');\n\njohn();</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/publications/files/ECMA-ST-ARCH/ECMA-262,%201st%20edition,%20June%201997.pdf\" hreflang=\"en\">ECMAScript 1st Edition (ECMA-262)</a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition. Implemented in JavaScript 1.2</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/5.1/#sec-10.6\" hreflang=\"en\">ECMAScript 5.1 (ECMA-262)<br><small>The definition of 'Arguments Object' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-arguments-exotic-objects\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Arguments Exotic Objects' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-arguments-exotic-objects\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Arguments Exotic Objects' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> 6</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div>  <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"../../global_objects/function\"><code>Function</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/arguments/callee$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/arguments/callee\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/arguments/callee</a>\n  </p>\n</div>\n","functions/arguments/@@iterator":"<h1>arguments.@@iterator</h1> <p>The initial value of the <code><strong>@@iterator</strong></code> property is the same function object as the initial value of the <a href=\"../../global_objects/array/values\"><code>Array.prototype.values</code></a> property.</p> <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\"><var>arguments</var>[Symbol.iterator]()</pre> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Iteration_using_for...of_loop\">Iteration using <code>for...of</code> loop</h3> <pre data-language=\"js\">function f() {\n  // your browser must support for..of loop\n  // and let-scoped variables in for loops\n  for (let letter of arguments) {\n    console.log(letter);\n  }\n}\nf('w', 'y', 'k', 'o', 'p');\n</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-createunmappedargumentsobject\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of ' CreateUnmappedArgumentsObject' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-createmappedargumentsobject\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of ' CreateMappedArgumentsObject' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-createunmappedargumentsobject\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'CreateUnmappedArgumentsObject' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-createmappedargumentsobject\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'CreateMappedArgumentsObject' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>   <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 52</td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 46</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 9</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> 52</td>\n<td class=\"bc-supports-yes\"> 52</td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 46</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 9</td>\n<td class=\"bc-supports-yes\"> 6.0</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div>  <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"../../global_objects/array/values\"><code>Array.prototype.values()</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/arguments/@@iterator$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/arguments/@@iterator\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/arguments/@@iterator</a>\n  </p>\n</div>\n","functions/arguments/caller":"<h1>arguments.caller</h1> <div class=\"blockIndicator obsolete obsoleteHeader\"><p><strong> Obsolete</strong><br>This feature is obsolete. Although it may still work in some browsers, its use is discouraged since it could be removed at any time. Try to avoid using it.</p></div> <p>The obsolete <code>arguments.caller</code> property used to provide the function that invoked the currently executing function. This property has been removed and no longer works.</p> <h2 id=\"Description\">Description</h2> <p>This property is not available anymore, but you can still use <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/caller\"><code>Function.caller</code></a>.</p> <pre data-language=\"js\">function whoCalled() {\n   if (whoCalled.caller == null)\n      console.log('I was called from the global scope.');\n   else\n      console.log(whoCalled.caller + ' called me!');\n}</pre> <h2 id=\"Examples\">Examples</h2> <p>The following code was used to check the value of <code>arguments.caller</code> in a function, but doesn't work anymore.</p> <pre data-language=\"js\">function whoCalled() {\n   if (arguments.caller == null)\n      console.log('I was called from the global scope.');\n   else\n      console.log(arguments.caller + ' called me!');\n}\n</pre> <h2 id=\"Specifications\">Specifications</h2> <p>Not part of any standard. Implemented in JavaScript 1.1 and removed in <a href=\"https://bugzilla.mozilla.org/show_bug.cgi?id=7224\">bug 7224</a> due to potentially vulnerable for security.</p> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support \n</th>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\">? — 9</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support \n</th>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-no\"> No</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support \n</th>\n<td class=\"bc-supports-no\"> No</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"../../global_objects/function\"><code>Function</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/arguments/caller$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/arguments/caller\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/arguments/caller</a>\n  </p>\n</div>\n","functions/arguments/length":"<h1>arguments.length</h1> <p>The <code>arguments.length</code> property contains the number of arguments passed to the function.</p> <h2 id=\"Syntax\">Syntax</h2> <pre class=\"syntaxbox\">arguments.length</pre> <h2 id=\"Description\">Description</h2> <p>The arguments.length property provides the number of arguments actually passed to a function. This can be more or less than the defined parameter's count (see <a href=\"../../global_objects/function/length\"><code>Function.length</code></a>).</p> <h2 id=\"Examples\">Examples</h2> <h3 id=\"Using_arguments.length\">Using <code>arguments.length</code>\n</h3> <p>In this example we define a function that can add two or more numbers together.</p> <pre data-language=\"js\">function adder(base /*, n2, ... */) {\n  base = Number(base);\n  for (var i = 1; i &lt; arguments.length; i++) {\n    base += Number(arguments[i]);\n  }\n  return base;\n}\n</pre> <div class=\"note\"> <p>Note the difference between <a href=\"../../global_objects/function/length\"><code>Function.length</code></a> and arguments.length</p> </div> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/publications/files/ECMA-ST-ARCH/ECMA-262,%201st%20edition,%20June%201997.pdf\" hreflang=\"en\">ECMAScript 1st Edition (ECMA-262)</a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition. Implemented in JavaScript 1.1</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/5.1/#sec-10.6\" hreflang=\"en\">ECMAScript 5.1 (ECMA-262)<br><small>The definition of 'Arguments Object' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-arguments-exotic-objects\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Arguments Exotic Objects' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-arguments-exotic-objects\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Arguments Exotic Objects' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 1</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 4</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody><tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr></tbody>\n</table>\n</div> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"../../global_objects/function\"><code>Function</code></a></li> <li><a href=\"../../global_objects/function/length\"><code>Function.length</code></a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/arguments/length$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/arguments/length\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/arguments/length</a>\n  </p>\n</div>\n","errors":"<h1>Errors</h1> <p>Below, you'll find a list of errors which are thrown by JavaScript. These errors can be a helpful debugging aid, but the reported problem isn't always immediately clear. The pages below will provide additional details about these errors. Each error is an object based upon the <a href=\"global_objects/error\"><code>Error</code></a> object, and has a <code>name</code> and a <code>message</code>.</p> <p>Errors displayed in the Web console may include a link to the corresponding page below to help you quickly comprehend the problem in your code.</p> <h2 id=\"List_of_errors\">List of errors</h2> <p>In this list, each page is listed by name (the type of error) and message (a more detailed human-readable error message). Together, these two properties provide a starting point toward understanding and resolving the error. For more information, follow the links below!</p> <ul>\n<li><a href=\"errors/property_access_denied\">Error: Permission denied to access property \"x\"</a></li>\n<li><a href=\"errors/too_much_recursion\">InternalError: too much recursion</a></li>\n<li><a href=\"errors/not_a_codepoint\">RangeError: argument is not a valid code point</a></li>\n<li><a href=\"errors/invalid_array_length\">RangeError: invalid array length</a></li>\n<li><a href=\"errors/invalid_date\">RangeError: invalid date</a></li>\n<li><a href=\"errors/precision_range\">RangeError: precision is out of range</a></li>\n<li><a href=\"errors/bad_radix\">RangeError: radix must be an integer</a></li>\n<li><a href=\"errors/resulting_string_too_large\">RangeError: repeat count must be less than infinity</a></li>\n<li><a href=\"errors/negative_repetition_count\">RangeError: repeat count must be non-negative</a></li>\n<li><a href=\"errors/not_defined\">ReferenceError: \"x\" is not defined</a></li>\n<li><a href=\"errors/undeclared_var\">ReferenceError: assignment to undeclared variable \"x\"</a></li>\n<li><a href=\"errors/cant_access_lexical_declaration_before_init\">ReferenceError: can't access lexical declaration`X' before initialization</a></li>\n<li><a href=\"errors/deprecated_caller_or_arguments_usage\">ReferenceError: deprecated caller or arguments usage</a></li>\n<li><a href=\"errors/invalid_assignment_left-hand_side\">ReferenceError: invalid assignment left-hand side</a></li>\n<li><a href=\"errors/undefined_prop\">ReferenceError: reference to undefined property \"x\"</a></li>\n<li><a href=\"errors/deprecated_octal\">SyntaxError: \"0\"-prefixed octal literals and octal escape seq. are deprecated</a></li>\n<li><a href=\"errors/strict_non_simple_params\">SyntaxError: \"use strict\" not allowed in function with non-simple parameters</a></li>\n<li><a href=\"errors/reserved_identifier\">SyntaxError: \"x\" is a reserved identifier</a></li>\n<li><a href=\"errors/json_bad_parse\">SyntaxError: JSON.parse: bad parsing</a></li>\n<li><a href=\"errors/malformed_formal_parameter\">SyntaxError: Malformed formal parameter</a></li>\n<li><a href=\"errors/unexpected_token\">SyntaxError: Unexpected token</a></li>\n<li><a href=\"errors/deprecated_source_map_pragma\">SyntaxError: Using //@ to indicate sourceURL pragmas is deprecated. Use //# instead</a></li>\n<li><a href=\"errors/invalid_for-of_initializer\">SyntaxError: a declaration in the head of a for-of loop can't have an initializer</a></li>\n<li><a href=\"errors/delete_in_strict_mode\">SyntaxError: applying the 'delete' operator to an unqualified name is deprecated</a></li>\n<li><a href=\"errors/invalid_for-in_initializer\">SyntaxError: for-in loop head declarations may not have initializers</a></li>\n<li><a href=\"errors/unnamed_function_statement\">SyntaxError: function statement requires a name</a></li>\n<li><a href=\"errors/identifier_after_number\">SyntaxError: identifier starts immediately after numeric literal</a></li>\n<li><a href=\"errors/illegal_character\">SyntaxError: illegal character</a></li>\n<li><a href=\"errors/bad_regexp_flag\">SyntaxError: invalid regular expression flag \"x\"</a></li>\n<li><a href=\"errors/missing_parenthesis_after_argument_list\">SyntaxError: missing ) after argument list</a></li>\n<li><a href=\"errors/missing_parenthesis_after_condition\">SyntaxError: missing ) after condition</a></li>\n<li><a href=\"errors/missing_colon_after_property_id\">SyntaxError: missing : after property id</a></li>\n<li><a href=\"errors/missing_semicolon_before_statement\">SyntaxError: missing ; before statement</a></li>\n<li><a href=\"errors/missing_initializer_in_const\">SyntaxError: missing = in const declaration</a></li>\n<li><a href=\"errors/missing_bracket_after_list\">SyntaxError: missing ] after element list</a></li>\n<li><a href=\"errors/missing_formal_parameter\">SyntaxError: missing formal parameter</a></li>\n<li><a href=\"errors/missing_name_after_dot_operator\">SyntaxError: missing name after . operator</a></li>\n<li><a href=\"errors/no_variable_name\">SyntaxError: missing variable name</a></li>\n<li><a href=\"errors/missing_curly_after_function_body\">SyntaxError: missing } after function body</a></li>\n<li><a href=\"errors/missing_curly_after_property_list\">SyntaxError: missing } after property list</a></li>\n<li><a href=\"errors/redeclared_parameter\">SyntaxError: redeclaration of formal parameter \"x\"</a></li>\n<li><a href=\"errors/bad_return_or_yield\">SyntaxError: return not in function</a></li>\n<li><a href=\"errors/equal_as_assign\">SyntaxError: test for equality (==) mistyped as assignment (=)?</a></li>\n<li><a href=\"errors/unterminated_string_literal\">SyntaxError: unterminated string literal</a></li>\n<li><a href=\"errors/no_properties\">TypeError: \"x\" has no properties</a></li>\n<li><a href=\"errors/unexpected_type\">TypeError: \"x\" is (not) \"y\"</a></li>\n<li><a href=\"errors/not_a_constructor\">TypeError: \"x\" is not a constructor</a></li>\n<li><a href=\"errors/not_a_function\">TypeError: \"x\" is not a function</a></li>\n<li><a href=\"errors/no_non-null_object\">TypeError: \"x\" is not a non-null object</a></li>\n<li><a href=\"errors/read-only\">TypeError: \"x\" is read-only</a></li>\n<li><a href=\"errors/is_not_iterable\">TypeError: 'x' is not iterable</a></li>\n<li><a href=\"errors/more_arguments_needed\">TypeError: More arguments needed</a></li>\n<li><a href=\"errors/reduce_of_empty_array_with_no_initial_value\">TypeError: Reduce of empty array with no initial value</a></li>\n<li><a href=\"errors/dead_object\">TypeError: can't access dead object</a></li>\n<li><a href=\"errors/cant_access_property\">TypeError: can't access property \"x\" of \"y\"</a></li>\n<li><a href=\"errors/cant_define_property_object_not_extensible\">TypeError: can't define property \"x\": \"obj\" is not extensible</a></li>\n<li><a href=\"errors/non_configurable_array_element\">TypeError: can't delete non-configurable array element</a></li>\n<li><a href=\"errors/cant_redefine_property\">TypeError: can't redefine non-configurable property \"x\"</a></li>\n<li><a href=\"errors/in_operator_no_object\">TypeError: cannot use 'in' operator to search for 'x' in 'y'</a></li>\n<li><a href=\"errors/cyclic_object_value\">TypeError: cyclic object value</a></li>\n<li><a href=\"errors/invalid_right_hand_side_instanceof_operand\">TypeError: invalid 'instanceof' operand 'x'</a></li>\n<li><a href=\"errors/array_sort_argument\">TypeError: invalid Array.prototype.sort argument</a></li>\n<li><a href=\"errors/typed_array_invalid_arguments\">TypeError: invalid arguments</a></li>\n<li><a href=\"errors/invalid_const_assignment\">TypeError: invalid assignment to const \"x\"</a></li>\n<li><a href=\"errors/cant_delete\">TypeError: property \"x\" is non-configurable and can't be deleted</a></li>\n<li><a href=\"errors/getter_only\">TypeError: setting getter-only property \"x\"</a></li>\n<li><a href=\"errors/var_hides_argument\">TypeError: variable \"x\" redeclares argument</a></li>\n<li><a href=\"errors/malformed_uri\">URIError: malformed URI sequence</a></li>\n<li><a href=\"errors/bad_octal\">Warning: 08/09 is not a legal ECMA-262 octal constant</a></li>\n<li><a href=\"errors/already_has_pragma\">Warning: -file- is being assigned a //# sourceMappingURL, but already has one</a></li>\n<li><a href=\"errors/deprecated_tolocaleformat\">Warning: Date.prototype.toLocaleFormat is deprecated</a></li>\n<li><a href=\"errors/for-each-in_loops_are_deprecated\">Warning: JavaScript 1.6's for-each-in loops are deprecated</a></li>\n<li><a href=\"errors/deprecated_string_generics\">Warning: String.x is deprecated; use String.prototype.x instead</a></li>\n<li><a href=\"errors/deprecated_expression_closures\">Warning: expression closures are deprecated</a></li>\n<li><a href=\"errors/stmt_after_return\">Warning: unreachable code after return statement</a></li>\n<li><a href=\"errors/called_on_incompatible_type\">X.prototype.y called on incompatible type</a></li>\n</ul> <h2 id=\"See_also\">See also</h2> <ul> <li>\n<a href=\"https://developer.mozilla.org/en-US/docs/Learn/JavaScript/First_steps/What_went_wrong\">What went wrong? Troubleshooting JavaScript</a>: Beginner's introductory tutorial on fixing JavaScript errors.</li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors</a>\n  </p>\n</div>\n","classes":"<h1>Classes</h1> <p>JavaScript classes, introduced in ECMAScript 2015, are primarily syntactical sugar over JavaScript's existing prototype-based inheritance. The class syntax <em>does not</em> introduce a new object-oriented inheritance model to JavaScript.</p> <h2 id=\"Defining_classes\">Defining classes</h2> <p>Classes are in fact \"special <a href=\"functions\">functions</a>\", and just as you can define <a href=\"operators/function\">function expressions</a> and <a href=\"statements/function\">function declarations</a>, the class syntax has two components: <a href=\"operators/class\">class expressions</a> and <a href=\"statements/class\">class declarations</a>.</p> <h3 id=\"Class_declarations\">Class declarations</h3> <p>One way to define a class is using a <strong>class declaration</strong>. To declare a class, you use the <code>class</code> keyword with the name of the class (\"Rectangle\" here).</p> <pre data-language=\"js\">class Rectangle {\n  constructor(height, width) {\n    this.height = height;\n    this.width = width;\n  }\n}</pre> <h4 id=\"Hoisting\">Hoisting</h4> <p>An important difference between <strong>function declarations</strong> and <strong>class declarations</strong> is that function declarations are <a href=\"https://developer.mozilla.org/en-US/docs/Glossary/Hoisting\">hoisted</a> and class declarations are not. You first need to declare your class and then access it, otherwise code like the following will throw a <a href=\"global_objects/referenceerror\"><code>ReferenceError</code></a>:</p> <pre data-language=\"js\">const p = new Rectangle(); // ReferenceError\n\nclass Rectangle {}\n</pre> <h3 id=\"Class_expressions\">Class expressions</h3> <p>A <strong>class expression</strong> is another way to define a class. Class expressions can be named or unnamed. The name given to a named class expression is local to the class's body. (it can be retrieved through the class's (not an instance's) <a href=\"global_objects/function/name\"><code>name</code></a> property, though).</p> <pre data-language=\"js\">// unnamed\nlet Rectangle = class {\n  constructor(height, width) {\n    this.height = height;\n    this.width = width;\n  }\n};\nconsole.log(Rectangle.name);\n// output: \"Rectangle\"\n\n// named\nlet Rectangle = class Rectangle2 {\n  constructor(height, width) {\n    this.height = height;\n    this.width = width;\n  }\n};\nconsole.log(Rectangle.name);\n// output: \"Rectangle2\"\n</pre> <div class=\"note\"> <p><strong>Note:</strong> Class <strong>expressions</strong> are subject to the same hoisting restrictions as described in the <a href=\"#Class_declarations\">Class declarations</a> section.</p> </div> <h2 id=\"Class_body_and_method_definitions\">Class body and method definitions</h2> <p>The body of a class is the part that is in curly brackets <code>{}</code>. This is where you define class members, such as methods or constructor.</p> <h3 id=\"Strict_mode\">Strict mode</h3> <p>The body of a class is executed in <a href=\"strict_mode\">strict mode</a>, i.e., code written here is subject to stricter syntax for increased performance, some otherwise silent errors will be thrown, and certain keywords are reserved for future versions of ECMAScript.</p> <h3 id=\"Constructor\">Constructor</h3> <p>The <code><a href=\"classes/constructor\">constructor</a></code> method is a special method for creating and initializing an object created with a <code>class</code>. There can only be one special method with the name \"constructor\" in a class. A <a href=\"global_objects/syntaxerror\"><code>SyntaxError</code></a> will be thrown if the class contains more than one occurrence of a <code>constructor</code> method.</p> <p>A constructor can use the <code>super</code> keyword to call the constructor of the super class.</p> <h3 id=\"Prototype_methods\">Prototype methods</h3> <p>See also <a href=\"functions/method_definitions\">method definitions</a>.</p> <pre data-language=\"js\">class Rectangle {\n  constructor(height, width) {\n    this.height = height;\n    this.width = width;\n  }\n  // Getter\n  get area() {\n    return this.calcArea();\n  }\n  // Method\n  calcArea() {\n    return this.height * this.width;\n  }\n}\n\nconst square = new Rectangle(10, 10);\n\nconsole.log(square.area); // 100</pre> <h3 id=\"Static_methods\">Static methods</h3> <p>The <code><a href=\"classes/static\">static</a></code> keyword defines a static method for a class. Static methods are called without <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Introduction_to_Object-Oriented_JavaScript#The_object_(class_instance)\">instantiating </a>their class and <strong>cannot </strong>be called through a class instance. Static methods are often used to create utility functions for an application.</p> <pre data-language=\"js\">class Point {\n  constructor(x, y) {\n    this.x = x;\n    this.y = y;\n  }\n\n  static distance(a, b) {\n    const dx = a.x - b.x;\n    const dy = a.y - b.y;\n\n    return Math.hypot(dx, dy);\n  }\n}\n\nconst p1 = new Point(5, 5);\nconst p2 = new Point(10, 10);\n\nconsole.log(Point.distance(p1, p2)); // 7.0710678118654755</pre> <h3 id=\"Boxing_with_prototype_and_static_methods\">Boxing with prototype and static methods</h3> <p>When a static or prototype method is called without a value for <em>this</em>, the <em>this</em> value will be <code>undefined</code> inside the method. This behavior will be the same even if the <code>\"use strict\"</code> directive isn't present, because code within the <code>class</code> body's syntactic boundary is always executed in strict mode.</p> <pre data-language=\"js\">class Animal { \n  speak() {\n    return this;\n  }\n  static eat() {\n    return this;\n  }\n}\n\nlet obj = new Animal();\nobj.speak(); // Animal {}\nlet speak = obj.speak;\nspeak(); // undefined\n\nAnimal.eat() // class Animal\nlet eat = Animal.eat;\neat(); // undefined</pre> <p>If the above is written using traditional function-based syntax, then autoboxing in method calls will happen in non–strict mode based on the initial <em>this</em> value. If the initial value is <code>undefined</code>, <em>this</em> will be set to the global object.</p> <p>Autoboxing will not happen in strict mode, the <em>this</em> value remains as passed.</p> <pre data-language=\"js\">function Animal() { }\n\nAnimal.prototype.speak = function() {\n  return this;\n}\n\nAnimal.eat = function() {\n  return this;\n}\n\nlet obj = new Animal();\nlet speak = obj.speak;\nspeak(); // global object\n\nlet eat = Animal.eat;\neat(); // global object\n</pre> <h3 id=\"Instance_properties\">Instance properties</h3> <p>Instance properties must be defined inside of class methods:</p> <pre data-language=\"js\">class Rectangle {\n  constructor(height, width) {    \n    this.height = height;\n    this.width = width;\n  }\n}</pre> <p>Static class-side properties and prototype data properties must be defined outside of the ClassBody declaration:</p> <pre data-language=\"js\">Rectangle.staticWidth = 20;\nRectangle.prototype.prototypeWidth = 25;\n</pre> <h3 id=\"Field_declarations\">Field declarations</h3> <div class=\"warning\"> <p>Public and private field declarations are an <a href=\"https://github.com/tc39/proposal-class-fields\">experimental feature (stage 3)</a> proposed at <a href=\"https://tc39.github.io/beta/\">TC39</a>, the JavaScript standards committee. Support in browsers is limited, but the feature can be used through a build step with systems like <a href=\"https://babeljs.io/\">Babel</a>.</p> </div> <h4 id=\"Public_field_declarations\">Public field declarations</h4> <p>With the JavaScript field declaration syntax, the above example can be written as:</p> <pre data-language=\"js\">class Rectangle {\n  height = 0;\n  width;\n  constructor(height, width) {    \n    this.height = height;\n    this.width = width;\n  }\n}\n</pre> <p>By declaring fields up-front, class definitions become more self-documenting, and the fields are always present.</p> <p>As seen above, the fields can be declared with or without a default value.</p> <h4 id=\"Private_field_declarations\">Private field declarations</h4> <p>Using private fields, the definition can be refined as below.</p> <pre data-language=\"js\">class Rectangle {\n  #height = 0;\n  #width;\n  constructor(height, width) {    \n    this.#height = height;\n    this.#width = width;\n  }\n}\n</pre> <p>It's an error to reference private fields from outside of the class; they can only be read or written within the class body. By defining things which are not visible outside of the class, you ensure that your classes' users can't depend on internals, which may change version to version.</p> <div class=\"note\"> <p>Private fields can only be declared up-front in a field declaration.</p> </div> <p>Private fields cannot be created later through assigning to them, the way that normal properties can.</p>  <h2 id=\"Sub_classing_with_extends\">Sub classing with <code>extends</code>\n</h2> <p>The <code><a href=\"classes/extends\">extends</a></code> keyword is used in <em>class declarations</em> or <em>class expressions</em> to create a class as a child of another class.</p> <pre data-language=\"js\">class Animal { \n  constructor(name) {\n    this.name = name;\n  }\n  \n  speak() {\n    console.log(this.name + ' makes a noise.');\n  }\n}\n\nclass Dog extends Animal {\n  constructor(name) {\n    super(name); // call the super class constructor and pass in the name parameter\n  }\n\n  speak() {\n    console.log(this.name + ' barks.');\n  }\n}\n\nlet d = new Dog('Mitzie');\nd.speak(); // Mitzie barks.\n</pre> <p>If there is a constructor present in the subclass, it needs to first call super() before using \"this\".</p> <p>One may also extend traditional function-based \"classes\":</p> <pre data-language=\"js\">function Animal (name) {\n  this.name = name;  \n}\n\nAnimal.prototype.speak = function () {\n  console.log(this.name + ' makes a noise.');\n}\n\nclass Dog extends Animal {\n  speak() {\n    console.log(this.name + ' barks.');\n  }\n}\n\nlet d = new Dog('Mitzie');\nd.speak(); // Mitzie barks.\n</pre> <p>Note that classes cannot extend regular (non-constructible) objects. If you want to inherit from a regular object, you can instead use <a href=\"global_objects/object/setprototypeof\"><code>Object.setPrototypeOf()</code></a>:</p> <pre data-language=\"js\">const Animal = {\n  speak() {\n    console.log(this.name + ' makes a noise.');\n  }\n};\n\nclass Dog {\n  constructor(name) {\n    this.name = name;\n  }\n}\n\n// If you do not do this you will get a TypeError when you invoke speak\nObject.setPrototypeOf(Dog.prototype, Animal);\n\nlet d = new Dog('Mitzie');\nd.speak(); // Mitzie makes a noise.\n</pre> <h2 id=\"Species\">Species</h2> <p>You might want to return <a href=\"global_objects/array\"><code>Array</code></a> objects in your derived array class <code>MyArray</code>. The species pattern lets you override default constructors.</p> <p>For example, when using methods such as <a href=\"global_objects/array/map\"><code>map()</code></a> that returns the default constructor, you want these methods to return a parent <code>Array</code> object, instead of the <code>MyArray</code> object. The <a href=\"global_objects/symbol/species\"><code>Symbol.species</code></a> symbol lets you do this:</p> <pre data-language=\"js\">class MyArray extends Array {\n  // Overwrite species to the parent Array constructor\n  static get [Symbol.species]() { return Array; }\n}\n\nlet a = new MyArray(1,2,3);\nlet mapped = a.map(x =&gt; x * x);\n\nconsole.log(mapped instanceof MyArray); // false\nconsole.log(mapped instanceof Array);   // true\n</pre> <h2 id=\"Super_class_calls_with_super\">Super class calls with <code>super</code>\n</h2> <p>The <code><a href=\"operators/super\">super</a></code> keyword is used to call corresponding methods of super class. This is one advantage over prototype-based inheritance.</p> <pre data-language=\"js\">class Cat { \n  constructor(name) {\n    this.name = name;\n  }\n  \n  speak() {\n    console.log(`${this.name} makes a noise.`);\n  }\n}\n\nclass Lion extends Cat {\n  speak() {\n    super.speak();\n    console.log(`${this.name} roars.`);\n  }\n}\n\nlet l = new Lion('Fuzzy');\nl.speak(); \n// Fuzzy makes a noise.\n// Fuzzy roars.\n</pre> <h2 id=\"Mix-ins\">Mix-ins</h2> <p>Abstract subclasses or <em>mix-ins</em> are templates for classes. An ECMAScript class can only have a single superclass, so multiple inheritance from tooling classes, for example, is not possible. The functionality must be provided by the superclass.</p> <p>A function with a superclass as input and a subclass extending that superclass as output can be used to implement mix-ins in ECMAScript:</p> <pre data-language=\"js\">let calculatorMixin = Base =&gt; class extends Base {\n  calc() { }\n};\n\nlet randomizerMixin = Base =&gt; class extends Base {\n  randomize() { }\n};\n</pre> <p>A class that uses these mix-ins can then be written like this:</p> <pre data-language=\"js\">class Foo { }\nclass Bar extends calculatorMixin(randomizerMixin(Foo)) { }</pre> <h2 id=\"Specifications\">Specifications</h2> <div class=\"_table\"><table class=\"standard-table\"> <tbody> <tr> <th scope=\"col\">Specification</th> <th scope=\"col\">Status</th> <th scope=\"col\">Comment</th> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/6.0/#sec-class-definitions\" hreflang=\"en\">ECMAScript 2015 (6th Edition, ECMA-262)<br><small>The definition of 'Class definitions' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td>Initial definition.</td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/7.0/#sec-class-definitions\" hreflang=\"en\">ECMAScript 2016 (ECMA-262)<br><small>The definition of 'Class definitions' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://www.ecma-international.org/ecma-262/8.0/#sec-class-definitions\" hreflang=\"en\">ECMAScript 2017 (ECMA-262)<br><small>The definition of 'Class definitions' in that specification.</small></a></td> <td><span class=\"spec-Standard\">Standard</span></td> <td> </td> </tr> <tr> <td><a href=\"https://tc39.github.io/ecma262/#sec-class-definitions\" hreflang=\"en\">ECMAScript Latest Draft (ECMA-262)<br><small>The definition of 'Class definitions' in that specification.</small></a></td> <td><span class=\"spec-Draft\">Draft</span></td> <td> </td> </tr> </tbody> </table></div> <h2 id=\"Browser_compatibility\">Browser compatibility<a href=\"https://github.com/mdn/browser-compat-data\" class=\"bc-github-link\">Update compatibility data on GitHub</a>\n</h2>  <div class=\"_table\">\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"6\">Desktop</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Chrome</th>\n<th>Edge</th>\n<th>Firefox</th>\n<th>Internet Explorer</th>\n<th>Opera</th>\n<th>Safari</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes bc-has-history\"> 49\n<section class=\"bc-history\" id=\"sect1\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 49\n</dt>\n<dd> From Chrome 42 to 48 strict mode is required. Non-strict mode support can be enabled using the flag \"Enable Experimental JavaScript\".</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-yes\"> 13</td>\n<td class=\"bc-supports-yes\"> 45</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 36</td>\n<td class=\"bc-supports-yes\"> 9</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Classes/constructor\"><code>constructor</code></a></th>\n<td class=\"bc-supports-yes bc-has-history\"> 49\n<section class=\"bc-history\" id=\"sect3\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 49\n</dt>\n<dd> From Chrome 42 to 48 strict mode is required. Non-strict mode support can be enabled using the flag \"Enable Experimental JavaScript\".</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-yes\"> 13</td>\n<td class=\"bc-supports-yes\"> 45</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 36</td>\n<td class=\"bc-supports-yes\"> 9</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Classes/extends\"><code>extends</code></a></th>\n<td class=\"bc-supports-yes bc-has-history\"> 49\n<section class=\"bc-history\" id=\"sect5\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 49\n</dt>\n<dd> From Chrome 42 to 48 strict mode is required. Non-strict mode support can be enabled using the flag \"Enable Experimental JavaScript\".</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-yes\"> 13</td>\n<td class=\"bc-supports-yes\"> 45</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 36</td>\n<td class=\"bc-supports-yes\"> 9</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Classes/static\"><code>static</code></a></th>\n<td class=\"bc-supports-yes bc-has-history\"> 49\n<section class=\"bc-history\" id=\"sect7\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 49\n</dt>\n<dd> From Chrome 42 to 48 strict mode is required. Non-strict mode support can be enabled using the flag \"Enable Experimental JavaScript\".</dd>\n</dl></section>\n</td>\n<td class=\"bc-supports-yes\"> 13</td>\n<td class=\"bc-supports-yes\"> 45</td>\n<td class=\"bc-supports-no\"> No</td>\n<td class=\"bc-supports-yes\"> 36</td>\n<td class=\"bc-supports-yes\"> 9</td>\n</tr>\n</tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"7\">Mobile</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Android webview</th>\n<th>Chrome for Android</th>\n<th>Edge Mobile</th>\n<th>Firefox for Android</th>\n<th>Opera for Android</th>\n<th>iOS Safari</th>\n<th>Samsung Internet</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 13</td>\n<td class=\"bc-supports-yes\"> 45</td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 9</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Classes/constructor\"><code>constructor</code></a></th>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 13</td>\n<td class=\"bc-supports-yes\"> 45</td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 9</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Classes/extends\"><code>extends</code></a></th>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 13</td>\n<td class=\"bc-supports-yes\"> 45</td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 9</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Classes/static\"><code>static</code></a></th>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> Yes</td>\n<td class=\"bc-supports-yes\"> 13</td>\n<td class=\"bc-supports-yes\"> 45</td>\n<td> ? </td>\n<td class=\"bc-supports-yes\"> 9</td>\n<td class=\"bc-supports-yes\"> Yes</td>\n</tr>\n</tbody>\n</table>\n<table class=\"bc-table bc-table-js\">\n<thead>\n<tr class=\"bc-platforms\">\n<th></th>\n<th colspan=\"1\">Server</th>\n</tr>\n<tr class=\"bc-browsers\">\n<th></th>\n<th>Node.js</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<th scope=\"row\">Basic support</th>\n<td class=\"bc-supports-yes bc-has-history\"> 6.0.0\n<section class=\"bc-history\" id=\"sect2\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 6.0.0\n</dt>\n\n<dt class=\"bc-supports-yes bc-supports\"> 4.0.0<div class=\"bc-icons\">Disabled </div>\n</dt>\n<dd>Disabled From version 4.0.0: this feature is behind the <code>--use_strict</code> runtime flag.</dd>\n<dt class=\"bc-supports-yes bc-supports\"> 5.0.0<div class=\"bc-icons\">Disabled </div>\n</dt>\n<dd>Disabled From version 5.0.0: this feature is behind the <code>--harmony</code> runtime flag.</dd>\n</dl></section>\n</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Classes/constructor\"><code>constructor</code></a></th>\n<td class=\"bc-supports-yes bc-has-history\"> 6.0.0\n<section class=\"bc-history\" id=\"sect4\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 6.0.0\n</dt>\n\n<dt class=\"bc-supports-yes bc-supports\"> 4.0.0<div class=\"bc-icons\">Disabled </div>\n</dt>\n<dd>Disabled From version 4.0.0: this feature is behind the <code>--use_strict</code> runtime flag.</dd>\n<dt class=\"bc-supports-yes bc-supports\"> 5.0.0<div class=\"bc-icons\">Disabled </div>\n</dt>\n<dd>Disabled From version 5.0.0: this feature is behind the <code>--harmony</code> runtime flag.</dd>\n</dl></section>\n</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Classes/extends\"><code>extends</code></a></th>\n<td class=\"bc-supports-yes bc-has-history\"> 6.0.0\n<section class=\"bc-history\" id=\"sect6\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 6.0.0\n</dt>\n\n<dt class=\"bc-supports-yes bc-supports\"> 4.0.0<div class=\"bc-icons\">Disabled </div>\n</dt>\n<dd>Disabled From version 4.0.0: this feature is behind the <code>--use_strict</code> runtime flag.</dd>\n<dt class=\"bc-supports-yes bc-supports\"> 5.0.0<div class=\"bc-icons\">Disabled </div>\n</dt>\n<dd>Disabled From version 5.0.0: this feature is behind the <code>--harmony</code> runtime flag.</dd>\n</dl></section>\n</td>\n</tr>\n<tr>\n<th scope=\"row\"><a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Classes/static\"><code>static</code></a></th>\n<td class=\"bc-supports-yes bc-has-history\"> 6.0.0\n<section class=\"bc-history\" id=\"sect8\"><dl>\n<dt class=\"bc-supports-yes bc-supports\"> 6.0.0\n</dt>\n\n<dt class=\"bc-supports-yes bc-supports\"> 4.0.0<div class=\"bc-icons\">Disabled </div>\n</dt>\n<dd>Disabled From version 4.0.0: this feature is behind the <code>--use_strict</code> runtime flag.</dd>\n<dt class=\"bc-supports-yes bc-supports\"> 5.0.0<div class=\"bc-icons\">Disabled </div>\n</dt>\n<dd>Disabled From version 5.0.0: this feature is behind the <code>--harmony</code> runtime flag.</dd>\n</dl></section>\n</td>\n</tr>\n</tbody>\n</table>\n</div> <h2 id=\"Running_in_Scratchpad\">Running in Scratchpad</h2> <p>A class can't be redefined. If you're playing with code in Scratchpad (Firefox menu Tools &gt; Web Developer &gt; Scratchpad) and you 'Run' a definition of a class with the same name twice, you'll get a confusing SyntaxError: redeclaration of let &lt;class-name&gt;.</p> <p>To re-run a definition, use Scratchpad's menu Execute &gt; Reload and Run.<br> Please vote for bug <a href=\"https://bugzilla.mozilla.org/show_bug.cgi?id=1428672\">#1428672</a>.</p> <h2 id=\"See_also\">See also</h2> <ul> <li><a href=\"functions\">Functions</a></li> <li><a href=\"statements/class\"><code>class</code> declaration</a></li> <li><a href=\"operators/class\"><code>class</code> expression</a></li> <li><a href=\"operators/super\"><code>super</code></a></li> <li><a href=\"https://hacks.mozilla.org/2015/07/es6-in-depth-classes/\">Blog post: \"ES6 In Depth: Classes\"</a></li> <li><a href=\"https://github.com/tc39/proposal-class-fields\">Fields and public/private class properties proposal (stage 3)</a></li> </ul><div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes$edit\" class=\"_attribution-link\">Edit this page on MDN</a>\n  </p>\n</div>\n<div class=\"_attribution\">\n  <p class=\"_attribution-p\">\n    &copy; 2005&ndash;2018 Mozilla Developer Network and individual contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>\n    <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes\" class=\"_attribution-link\">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes</a>\n  </p>\n</div>\n"}