mirror of
https://github.com/fofolee/uTools-Manuals.git
synced 2025-06-08 23:14:06 +08:00
237 lines
33 KiB
HTML
237 lines
33 KiB
HTML
<article id="wikiArticle">
|
||
<div></div>
|
||
<div>该部分是 Javascript 的资料库。阅读<a href="Reference/About">关于该参考</a>了解更多。</div>
|
||
<h2 id="全局对象">全局对象</h2>
|
||
<div><span class="short_text" id="result_box" lang="zh-CN"><span>本章介绍</span><span>所有的 </span></span><a href="Reference/Global_Objects">JavaScript 标准的内置对象</a><span class="short_text" lang="zh-CN"><span>,</span><span>以及它们的</span><span>方法和属性</span><span>。</span></span></div>
|
||
<div> </div>
|
||
<div></div>
|
||
<h2 id="Statements" name="Statements">语句</h2>
|
||
<div><span class="short_text" id="result_box" lang="zh-CN"><span>本章介绍</span><span>所有的 </span></span><a href="Reference/Statements">JavaScript 语句和声明</a>。</div>
|
||
<div> </div>
|
||
<div></div>
|
||
<h2 id="Operators" name="Operators">表达式和操作符</h2>
|
||
<div><span class="short_text" id="result_box" lang="zh-CN"><span>本章介绍</span><span>所有的 </span></span><a href="Reference/Operators">JavaScript 表达式和操作符</a>。</div>
|
||
<div> </div>
|
||
<div><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="/en-US/docs/Web/JavaScript/Reference/Operators/this" title="A function's this keyword behaves a little differently in JavaScript compared to other languages. It also has some differences between strict mode and non-strict mode."><code>this</code></a></dt>
|
||
<dd>The <code>this</code> keyword refers to a special property of an execution context.</dd>
|
||
<dt><a href="/en-US/docs/Web/JavaScript/Reference/Operators/function" title="The function keyword can be used to define a function inside an expression."><code>function</code></a></dt>
|
||
<dd>The <code>function</code> keyword defines a function expression.</dd>
|
||
<dt><a href="/en-US/docs/Web/JavaScript/Reference/Operators/class" title="The class expression is one way to define a class in ECMAScript 2015. Similar to function expressions, 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."><code>class</code></a></dt>
|
||
<dd>The <code>class</code> keyword defines a class expression.</dd>
|
||
<dt><a href="/en-US/docs/Web/JavaScript/Reference/Operators/function*" title="The function* keyword can be used to define a generator function inside an expression."><code>function*</code></a></dt>
|
||
<dd>The <code>function*</code> keyword defines a generator function expression.</dd>
|
||
<dt><a href="/en-US/docs/Web/JavaScript/Reference/Operators/yield" title="The yield keyword is used to pause and resume a generator function (function* or legacy generator function)."><code>yield</code></a></dt>
|
||
<dd>Pause and resume a generator function.</dd>
|
||
<dt><a href="/en-US/docs/Web/JavaScript/Reference/Operators/yield*" title="The yield* expression is used to delegate to another generator or iterable object."><code>yield*</code></a></dt>
|
||
<dd>Delegate to another generator function or iterable object.</dd>
|
||
<dt><a href="/en-US/docs/Web/JavaScript/Reference/Operators/async_function" title="The async function keyword can be used to define async functions inside expressions."><code>async function</code></a></dt>
|
||
<dd>The <code>async function</code> defines an async function expression.</dd>
|
||
<dt><a href="/en-US/docs/Web/JavaScript/Reference/Operators/await" title="The await operator is used to wait for a Promise. It can only be used inside an async function."><code>await</code></a></dt>
|
||
<dd>Pause and resume an async function and wait for the promise's resolution/rejection.</dd>
|
||
<dt><a href="/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array" title="The JavaScript Array object is a global object that is used in the construction of arrays; which are high-level, list-like objects."><code>[]</code></a></dt>
|
||
<dd>Array initializer/literal syntax.</dd>
|
||
<dt><a href="/en-US/docs/Web/JavaScript/Reference/Operators/Object_initializer" title="Objects can be initialized using new Object(), Object.create(), or using the literal notation (initializer 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></a></dt>
|
||
<dd>Object initializer/literal syntax.</dd>
|
||
<dt><a href="/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp" title="The RegExp constructor creates a regular expression object for matching text with a pattern."><code>/ab+c/i</code></a></dt>
|
||
<dd>Regular expression literal syntax.</dd>
|
||
<dt><a href="/en-US/docs/Web/JavaScript/Reference/Operators/Grouping" title="The grouping operator ( ) controls the precedence of evaluation in expressions."><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="/en-US/docs/Web/JavaScript/Reference/Operators/Property_accessors" title="Property accessors provide access to an object's properties by using the dot notation or the bracket notation.">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="/en-US/docs/Web/JavaScript/Reference/Operators/new" title="The new operator lets developers create an instance of a user-defined object type or of one of the built-in object types that has a constructor function."><code>new</code></a></dt>
|
||
<dd>The <code>new</code> operator creates an instance of a constructor.</dd>
|
||
<dt><a href="/en-US/docs/Web/JavaScript/Reference/Operators/new.target">new.target</a></dt>
|
||
<dd>In constructors, <code>new.target</code> refers to the constructor that was invoked by <a href="/en-US/docs/Web/JavaScript/Reference/Operators/new" title="The new operator lets developers create an instance of a user-defined object type or of one of the built-in object types that has a constructor function."><code>new</code></a>.</dd>
|
||
<dt><a href="/en-US/docs/Web/JavaScript/Reference/Operators/super" title="The super keyword is used to access and call functions on an object's parent."><code>super</code></a></dt>
|
||
<dd>The <code>super</code> keyword calls the parent constructor.</dd>
|
||
<dt><a href="/en-US/docs/Web/JavaScript/Reference/Operators/Spread_syntax" title="Spread syntax 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."><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="/en-US/docs/Web/JavaScript/Reference/Operators/Arithmetic_Operators#Increment" title="Arithmetic operators 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 (/)."><code>A++</code></a></dt>
|
||
<dd>Postfix increment operator.</dd>
|
||
<dt><a href="/en-US/docs/Web/JavaScript/Reference/Operators/Arithmetic_Operators#Decrement" title="Arithmetic operators 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 (/)."><code>A--</code></a></dt>
|
||
<dd>Postfix decrement operator.</dd>
|
||
<dt><a href="/en-US/docs/Web/JavaScript/Reference/Operators/Arithmetic_Operators#Increment" title="Arithmetic operators 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 (/)."><code>++A</code></a></dt>
|
||
<dd>Prefix increment operator.</dd>
|
||
<dt><a href="/en-US/docs/Web/JavaScript/Reference/Operators/Arithmetic_Operators#Decrement" title="Arithmetic operators 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 (/)."><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="/en-US/docs/Web/JavaScript/Reference/Operators/delete" title="The JavaScript delete operator removes a property from an object; if no more references to the same property are held, it is eventually released automatically."><code>delete</code></a></dt>
|
||
<dd>The <code>delete</code> operator deletes a property from an object.</dd>
|
||
<dt><a href="/en-US/docs/Web/JavaScript/Reference/Operators/void" title="The void operator evaluates the given expression and then returns undefined."><code>void</code></a></dt>
|
||
<dd>The <code>void</code> operator discards an expression's return value.</dd>
|
||
<dt><a href="/en-US/docs/Web/JavaScript/Reference/Operators/typeof" title="The typeof operator returns a string indicating the type of the unevaluated operand."><code>typeof</code></a></dt>
|
||
<dd>The <code>typeof</code> operator determines the type of a given object.</dd>
|
||
<dt><a href="/en-US/docs/Web/JavaScript/Reference/Operators/Arithmetic_Operators#Unary_plus" title="Arithmetic operators 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 (/)."><code>+</code></a></dt>
|
||
<dd>The unary plus operator converts its operand to Number type.</dd>
|
||
<dt><a href="/en-US/docs/Web/JavaScript/Reference/Operators/Arithmetic_Operators#Unary_negation" title="Arithmetic operators 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 (/)."><code>-</code></a></dt>
|
||
<dd>The unary negation operator converts its operand to Number type and then negates it.</dd>
|
||
<dt><a href="/en-US/docs/Web/JavaScript/Reference/Operators/Bitwise_Operators#Bitwise_NOT" title="Bitwise operators treat their operands as a sequence of 32 bits (zeroes and ones), rather than as decimal, hexadecimal, or octal numbers. 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."><code>~</code></a></dt>
|
||
<dd>Bitwise NOT operator.</dd>
|
||
<dt><a href="/en-US/docs/Web/JavaScript/Reference/Operators/Logical_Operators#Logical_NOT" title="Logical operators are typically used with Boolean (logical) values. When they are, they return a Boolean value. However, the && and || operators actually return the value of one of the specified operands, so if these operators are used with non-Boolean values, they will return a non-Boolean value."><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="/en-US/docs/Web/JavaScript/Reference/Operators/Arithmetic_Operators#Addition" title="Arithmetic operators 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 (/)."><code>+</code></a></dt>
|
||
<dd>Addition operator.</dd>
|
||
<dt><a href="/en-US/docs/Web/JavaScript/Reference/Operators/Arithmetic_Operators#Subtraction" title="Arithmetic operators 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 (/)."><code>-</code></a></dt>
|
||
<dd>Subtraction operator.</dd>
|
||
<dt><a href="/en-US/docs/Web/JavaScript/Reference/Operators/Arithmetic_Operators#Division" title="Arithmetic operators 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 (/)."><code>/</code></a></dt>
|
||
<dd>Division operator.</dd>
|
||
<dt><a href="/en-US/docs/Web/JavaScript/Reference/Operators/Arithmetic_Operators#Multiplication" title="Arithmetic operators 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 (/)."><code>*</code></a></dt>
|
||
<dd>Multiplication operator.</dd>
|
||
<dt><a href="/en-US/docs/Web/JavaScript/Reference/Operators/Arithmetic_Operators#Remainder" title="Arithmetic operators 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 (/)."><code>%</code></a></dt>
|
||
<dd>Remainder operator.</dd>
|
||
</dl>
|
||
<dl>
|
||
<dt><a href="/en-US/docs/Web/JavaScript/Reference/Operators/Arithmetic_Operators#Exponentiation" title="Arithmetic operators 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 (/)."><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="/en-US/docs/Web/JavaScript/Reference/Operators/in" title="The in operator returns true if the specified property is in the specified object or its prototype chain."><code>in</code></a></dt>
|
||
<dd>The <code>in</code> operator determines whether an object has a given property.</dd>
|
||
<dt><a href="/en-US/docs/Web/JavaScript/Reference/Operators/instanceof" title="The instanceof operator tests whether the prototype property of a constructor appears anywhere in the prototype chain of an object."><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="/en-US/docs/Web/JavaScript/Reference/Operators/Comparison_Operators#Less_than_operator" title="JavaScript has both strict and type–converting comparisons. A strict comparison (e.g., ===) is only true if the operands are of the same type and the contents match. The more commonly-used abstract comparison (e.g. ==) converts the operands to the same type before making the comparison. For relational abstract comparisons (e.g., <=), the operands are first converted to primitives, then to the same type, before comparison."><code><</code></a></dt>
|
||
<dd>Less than operator.</dd>
|
||
<dt><a href="/en-US/docs/Web/JavaScript/Reference/Operators/Comparison_Operators#Greater_than_operator" title="JavaScript has both strict and type–converting comparisons. A strict comparison (e.g., ===) is only true if the operands are of the same type and the contents match. The more commonly-used abstract comparison (e.g. ==) converts the operands to the same type before making the comparison. For relational abstract comparisons (e.g., <=), the operands are first converted to primitives, then to the same type, before comparison."><code>></code></a></dt>
|
||
<dd>Greater than operator.</dd>
|
||
<dt><a href="/en-US/docs/Web/JavaScript/Reference/Operators/Comparison_Operators#Less_than_or_equal_operator" title="JavaScript has both strict and type–converting comparisons. A strict comparison (e.g., ===) is only true if the operands are of the same type and the contents match. The more commonly-used abstract comparison (e.g. ==) converts the operands to the same type before making the comparison. For relational abstract comparisons (e.g., <=), the operands are first converted to primitives, then to the same type, before comparison."><code><=</code></a></dt>
|
||
<dd>Less than or equal operator.</dd>
|
||
<dt><a href="/en-US/docs/Web/JavaScript/Reference/Operators/Comparison_Operators#Greater_than_or_equal_operator" title="JavaScript has both strict and type–converting comparisons. A strict comparison (e.g., ===) is only true if the operands are of the same type and the contents match. The more commonly-used abstract comparison (e.g. ==) converts the operands to the same type before making the comparison. For relational abstract comparisons (e.g., <=), the operands are first converted to primitives, then to the same type, before comparison."><code>>=</code></a></dt>
|
||
<dd>Greater than or equal operator.</dd>
|
||
</dl>
|
||
<div class="note">
|
||
<p><strong>Note: =></strong> is not an operator, but the notation for <a href="/en-US/docs/Web/JavaScript/Reference/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="/en-US/docs/Web/JavaScript/Reference/Operators/Comparison_Operators#Equality" title="JavaScript has both strict and type–converting comparisons. A strict comparison (e.g., ===) is only true if the operands are of the same type and the contents match. The more commonly-used abstract comparison (e.g. ==) converts the operands to the same type before making the comparison. For relational abstract comparisons (e.g., <=), the operands are first converted to primitives, then to the same type, before comparison."><code>==</code></a></dt>
|
||
<dd>Equality operator.</dd>
|
||
<dt><a href="/en-US/docs/Web/JavaScript/Reference/Operators/Comparison_Operators#Inequality" title="JavaScript has both strict and type–converting comparisons. A strict comparison (e.g., ===) is only true if the operands are of the same type and the contents match. The more commonly-used abstract comparison (e.g. ==) converts the operands to the same type before making the comparison. For relational abstract comparisons (e.g., <=), the operands are first converted to primitives, then to the same type, before comparison."><code>!=</code></a></dt>
|
||
<dd>Inequality operator.</dd>
|
||
<dt><a href="/en-US/docs/Web/JavaScript/Reference/Operators/Comparison_Operators#Identity" title="JavaScript has both strict and type–converting comparisons. A strict comparison (e.g., ===) is only true if the operands are of the same type and the contents match. The more commonly-used abstract comparison (e.g. ==) converts the operands to the same type before making the comparison. For relational abstract comparisons (e.g., <=), the operands are first converted to primitives, then to the same type, before comparison."><code>===</code></a></dt>
|
||
<dd>Identity operator.</dd>
|
||
<dt><a href="/en-US/docs/Web/JavaScript/Reference/Operators/Comparison_Operators#Nonidentity" title="JavaScript has both strict and type–converting comparisons. A strict comparison (e.g., ===) is only true if the operands are of the same type and the contents match. The more commonly-used abstract comparison (e.g. ==) converts the operands to the same type before making the comparison. For relational abstract comparisons (e.g., <=), the operands are first converted to primitives, then to the same type, before comparison."><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="/en-US/docs/Web/JavaScript/Reference/Operators/Bitwise_Operators#Left_shift" title="Bitwise operators treat their operands as a sequence of 32 bits (zeroes and ones), rather than as decimal, hexadecimal, or octal numbers. 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."><code><<</code></a></dt>
|
||
<dd>Bitwise left shift operator.</dd>
|
||
<dt><a href="/en-US/docs/Web/JavaScript/Reference/Operators/Bitwise_Operators#Right_shift" title="Bitwise operators treat their operands as a sequence of 32 bits (zeroes and ones), rather than as decimal, hexadecimal, or octal numbers. 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."><code>>></code></a></dt>
|
||
<dd>Bitwise right shift operator.</dd>
|
||
<dt><a href="/en-US/docs/Web/JavaScript/Reference/Operators/Bitwise_Operators#Unsigned_right_shift" title="Bitwise operators treat their operands as a sequence of 32 bits (zeroes and ones), rather than as decimal, hexadecimal, or octal numbers. 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."><code>>>></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="/en-US/docs/Web/JavaScript/Reference/Operators/Bitwise_Operators#Bitwise_AND" title="Bitwise operators treat their operands as a sequence of 32 bits (zeroes and ones), rather than as decimal, hexadecimal, or octal numbers. 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."><code>&</code></a></dt>
|
||
<dd>Bitwise AND.</dd>
|
||
<dt><a href="/en-US/docs/Web/JavaScript/Reference/Operators/Bitwise_Operators#Bitwise_OR" title="Bitwise operators treat their operands as a sequence of 32 bits (zeroes and ones), rather than as decimal, hexadecimal, or octal numbers. 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."><code>|</code></a></dt>
|
||
<dd>Bitwise OR.</dd>
|
||
<dt><a href="/en-US/docs/Web/JavaScript/Reference/Operators/Bitwise_Operators#Bitwise_XOR" title="Bitwise operators treat their operands as a sequence of 32 bits (zeroes and ones), rather than as decimal, hexadecimal, or octal numbers. 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."><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="/en-US/docs/Web/JavaScript/Reference/Operators/Logical_Operators#Logical_AND" title="Logical operators are typically used with Boolean (logical) values. When they are, they return a Boolean value. However, the && and || operators actually return the value of one of the specified operands, so if these operators are used with non-Boolean values, they will return a non-Boolean value."><code>&&</code></a></dt>
|
||
<dd>Logical AND.</dd>
|
||
<dt><a href="/en-US/docs/Web/JavaScript/Reference/Operators/Logical_Operators#Logical_OR" title="Logical operators are typically used with Boolean (logical) values. When they are, they return a Boolean value. However, the && and || operators actually return the value of one of the specified operands, so if these operators are used with non-Boolean values, they will return a non-Boolean value."><code>||</code></a></dt>
|
||
<dd>Logical OR.</dd>
|
||
</dl>
|
||
<h3 id="Conditional_(ternary)_operator">Conditional (ternary) operator</h3>
|
||
<dl>
|
||
<dt><a href="/en-US/docs/Web/JavaScript/Reference/Operators/Conditional_Operator" title="The conditional (ternary) operator is the only JavaScript operator that takes three operands. This operator is frequently used as a shortcut for the if statement."><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="/en-US/docs/Web/JavaScript/Reference/Operators/Assignment_Operators#Assignment" title="An assignment operator assigns a value to its left operand based on the value of its right operand."><code>=</code></a></dt>
|
||
<dd>Assignment operator.</dd>
|
||
<dt><a href="/en-US/docs/Web/JavaScript/Reference/Operators/Assignment_Operators#Multiplication_assignment" title="An assignment operator assigns a value to its left operand based on the value of its right operand."><code>*=</code></a></dt>
|
||
<dd>Multiplication assignment.</dd>
|
||
<dt><a href="/en-US/docs/Web/JavaScript/Reference/Operators/Assignment_Operators#Division_assignment" title="An assignment operator assigns a value to its left operand based on the value of its right operand."><code>/=</code></a></dt>
|
||
<dd>Division assignment.</dd>
|
||
<dt><a href="/en-US/docs/Web/JavaScript/Reference/Operators/Assignment_Operators#Remainder_assignment" title="An assignment operator assigns a value to its left operand based on the value of its right operand."><code>%=</code></a></dt>
|
||
<dd>Remainder assignment.</dd>
|
||
<dt><a href="/en-US/docs/Web/JavaScript/Reference/Operators/Assignment_Operators#Addition_assignment" title="An assignment operator assigns a value to its left operand based on the value of its right operand."><code>+=</code></a></dt>
|
||
<dd>Addition assignment.</dd>
|
||
<dt><a href="/en-US/docs/Web/JavaScript/Reference/Operators/Assignment_Operators#Subtraction_assignment" title="An assignment operator assigns a value to its left operand based on the value of its right operand."><code>-=</code></a></dt>
|
||
<dd>Subtraction assignment</dd>
|
||
<dt><a href="/en-US/docs/Web/JavaScript/Reference/Operators/Assignment_Operators#Left_shift_assignment" title="An assignment operator assigns a value to its left operand based on the value of its right operand."><code><<=</code></a></dt>
|
||
<dd>Left shift assignment.</dd>
|
||
<dt><a href="/en-US/docs/Web/JavaScript/Reference/Operators/Assignment_Operators#Right_shift_assignment" title="An assignment operator assigns a value to its left operand based on the value of its right operand."><code>>>=</code></a></dt>
|
||
<dd>Right shift assignment.</dd>
|
||
<dt><a href="/en-US/docs/Web/JavaScript/Reference/Operators/Assignment_Operators#Unsigned_right_shift_assignment" title="An assignment operator assigns a value to its left operand based on the value of its right operand."><code>>>>=</code></a></dt>
|
||
<dd>Unsigned right shift assignment.</dd>
|
||
<dt><a href="/en-US/docs/Web/JavaScript/Reference/Operators/Assignment_Operators#Bitwise_AND_assignment" title="An assignment operator assigns a value to its left operand based on the value of its right operand."><code>&=</code></a></dt>
|
||
<dd>Bitwise AND assignment.</dd>
|
||
<dt><a href="/en-US/docs/Web/JavaScript/Reference/Operators/Assignment_Operators#Bitwise_XOR_assignment" title="An assignment operator assigns a value to its left operand based on the value of its right operand."><code>^=</code></a></dt>
|
||
<dd>Bitwise XOR assignment.</dd>
|
||
<dt><a href="/en-US/docs/Web/JavaScript/Reference/Operators/Assignment_Operators#Bitwise_OR_assignment" title="An assignment operator assigns a value to its left operand based on the value of its right operand."><code>|=</code></a></dt>
|
||
<dd>Bitwise OR assignment.</dd>
|
||
<dt><a href="/en-US/docs/Web/JavaScript/Reference/Operators/Destructuring_assignment" title="The destructuring assignment syntax is a JavaScript expression that makes it possible to unpack values from arrays, or properties from objects, into distinct variables."><code>[a, b] = [1, 2]</code></a><br/>
|
||
<a href="/en-US/docs/Web/JavaScript/Reference/Operators/Destructuring_assignment" title="The destructuring assignment syntax is a JavaScript expression that makes it possible to unpack values from arrays, or properties from objects, into distinct variables."><code>{a, b} = {a:1, b:2}</code></a></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="/en-US/docs/Web/JavaScript/Reference/Operators/Comma_Operator" title="The comma operator evaluates each of its operands (from left to right) and returns the value of the last operand."><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 id="Non-standard_features" name="Non-standard_features">Non-standard features <span class="icon-only-inline" title="This API has not been standardized."><i class="icon-warning-sign"> </i></span></h3>
|
||
<dl>
|
||
<dt><a href="/en-US/docs/Web/JavaScript/Reference/Operators/Expression_closures" title="Expression closures are a shorthand function syntax for writing simple functions.">Expression closures</a> <span class="icon-only-inline" title="This API has not been standardized."><i class="icon-warning-sign"> </i></span><span class="inlineIndicator obsolete obsoleteInline" title="(Firefox 60 / Thunderbird 60 / SeaMonkey 2.57)">Obsolete since Gecko 60</span></dt>
|
||
<dd>The expression closure syntax is a shorthand for writing simple function.</dd>
|
||
<dt><a href="/en-US/docs/Web/JavaScript/Reference/Operators/Legacy_generator_function" title="The function keyword can be used to define a legacy generator function inside an expression. To make the function a legacy generator, the function body should contain at least one yield expression.">Legacy generator function</a> <span class="icon-only-inline" title="This API has not been standardized."><i class="icon-warning-sign"> </i></span><span class="inlineIndicator obsolete obsoleteInline" title="(Firefox 58 / Thunderbird 58 / SeaMonkey 2.55)">Obsolete since Gecko 58</span></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="/en-US/docs/Web/JavaScript/Reference/Operators/yield" title="The yield keyword is used to pause and resume a generator function (function* or legacy generator function)."><code>yield</code></a> expression.</dd>
|
||
<dt><a href="/en-US/docs/Web/JavaScript/Reference/Operators/Array_comprehensions" title="The array comprehension 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!"><code>[for (x of y) x]</code></a> <span class="icon-only-inline" title="This API has not been standardized."><i class="icon-warning-sign"> </i></span><span class="inlineIndicator obsolete obsoleteInline" title="(Firefox 58 / Thunderbird 58 / SeaMonkey 2.55)">Obsolete since Gecko 58</span></dt>
|
||
<dd>Array comprehensions.</dd>
|
||
<dt><a href="/en-US/docs/Web/JavaScript/Reference/Operators/Generator_comprehensions" title="The generator comprehension syntax was a JavaScript expression which allowed you to quickly assemble a new generator function based on an existing iterable object. However, it has been removed from the standard and the Firefox implementation. Do not use it!"><code>(for (x of y) y)</code></a> <span class="icon-only-inline" title="This API has not been standardized."><i class="icon-warning-sign"> </i></span><span class="inlineIndicator obsolete obsoleteInline" title="(Firefox 58 / Thunderbird 58 / SeaMonkey 2.55)">Obsolete since Gecko 58</span></dt>
|
||
<dd>Generator comprehensions.</dd>
|
||
</dl></div>
|
||
<h2 id="Comments" name="Comments">函数</h2>
|
||
<p><span class="short_text" id="result_box" lang="zh-CN"><span>本章介绍</span></span>如何使用 <a href="Reference/Functions">JavaScript函数</a> 来开发应用程序。</p>
|
||
<ul>
|
||
<li><a href="Reference/Functions/arguments"><code>arguments</code></a></li>
|
||
<li><a href="Reference/Functions/Arrow_functions">箭头函数</a></li>
|
||
<li><a href="Reference/Functions/Default_parameters">默认参数</a></li>
|
||
<li><a href="Reference/Functions/rest_parameters">剩余参数</a></li>
|
||
</ul>
|
||
<h2 id="附加参考页">附加参考页</h2>
|
||
<ul>
|
||
<li><a href="Reference/Lexical_grammar">词法文法</a></li>
|
||
<li><a href="Data_structures">数据类型和数据结构</a></li>
|
||
<li><a href="Reference/Strict_mode">严格模式</a></li>
|
||
<li><a href="Reference/Deprecated_and_obsolete_features">过时的功能</a></li>
|
||
</ul>
|
||
</article> |