Was bedeuted ffs

This chapter describes JavaScript's expressions and operators, including assignment, comparison, arithmetic, bitwise, logical, string, ternary and more.

At a high level, an expression is a valid unit of code that resolves to a value. There are two types of expressions: those that have side effects (such as assigning values) and those that purely evaluate.

The expression const val = 0; val.x = 3; console.log(val.x); // Prints undefined. console.log(val); // Prints 0. 8 is an example of the first type. This expression uses the const val = 0; val.x = 3; console.log(val.x); // Prints undefined. console.log(val); // Prints 0. 9 operator to assign the value seven to the variable const foo = ['one', 'two', 'three']; // without destructuring const one = foo[0]; const two = foo[1]; const three = foo[2]; // with destructuring const [one, two, three] = foo; 0. The expression itself evaluates to const foo = ['one', 'two', 'three']; // without destructuring const one = foo[0]; const two = foo[1]; const three = foo[2]; // with destructuring const [one, two, three] = foo; 1.

The expression const foo = ['one', 'two', 'three']; // without destructuring const one = foo[0]; const two = foo[1]; const three = foo[2]; // with destructuring const [one, two, three] = foo; 2 is an example of the second type. This expression uses the const foo = ['one', 'two', 'three']; // without destructuring const one = foo[0]; const two = foo[1]; const three = foo[2]; // with destructuring const [one, two, three] = foo; 3 operator to add const foo = ['one', 'two', 'three']; // without destructuring const one = foo[0]; const two = foo[1]; const three = foo[2]; // with destructuring const [one, two, three] = foo; 4 and const foo = ['one', 'two', 'three']; // without destructuring const one = foo[0]; const two = foo[1]; const three = foo[2]; // with destructuring const [one, two, three] = foo; 5 together and produces a value, const foo = ['one', 'two', 'three']; // without destructuring const one = foo[0]; const two = foo[1]; const three = foo[2]; // with destructuring const [one, two, three] = foo; 1. However, if it's not eventually part of a bigger construct (for example, a variable declaration like const foo = ['one', 'two', 'three']; // without destructuring const one = foo[0]; const two = foo[1]; const three = foo[2]; // with destructuring const [one, two, three] = foo; 7), its result will be immediately discarded — this is usually a programmer mistake because the evaluation doesn't produce any effects.

As the examples above also illustrate, all complex expressions are joined by operators, such as const val = 0; val.x = 3; console.log(val.x); // Prints undefined. console.log(val); // Prints 0. 9 and const foo = ['one', 'two', 'three']; // without destructuring const one = foo[0]; const two = foo[1]; const three = foo[2]; // with destructuring const [one, two, three] = foo; 3. In this section, we will introduce the following operators:

  • Assignment operators
  • Comparison operators
  • Arithmetic operators
  • Bitwise operators
  • Logical operators
  • BigInt operators
  • String operators
  • Conditional (ternary) operator
  • Comma operator
  • Unary operators
  • Relational operators

These operators join operands either formed by higher-precedence operators or one of the basic expressions. A complete and detailed list of operators and expressions is also available in the reference.

The precedence of operators determines the order they are applied when evaluating an expression. For example:

const x = 1 + 2 * 3; const y = 2 * 3 + 1;

Despite // Declares a variable x and initializes it to the result of f(). // The result of the x = f() assignment expression is discarded. let x = f(); x = g(); // Reassigns the variable x to the result of g(). 0 and const foo = ['one', 'two', 'three']; // without destructuring const one = foo[0]; const two = foo[1]; const three = foo[2]; // with destructuring const [one, two, three] = foo; 3 coming in different orders, both expressions would result in const foo = ['one', 'two', 'three']; // without destructuring const one = foo[0]; const two = foo[1]; const three = foo[2]; // with destructuring const [one, two, three] = foo; 1 because // Declares a variable x and initializes it to the result of f(). // The result of the x = f() assignment expression is discarded. let x = f(); x = g(); // Reassigns the variable x to the result of g(). 0 has precedence over const foo = ['one', 'two', 'three']; // without destructuring const one = foo[0]; const two = foo[1]; const three = foo[2]; // with destructuring const [one, two, three] = foo; 3, so the // Declares a variable x and initializes it to the result of f(). // The result of the x = f() assignment expression is discarded. let x = f(); x = g(); // Reassigns the variable x to the result of g(). 0-joined expression will always be evaluated first. You can override operator precedence by using parentheses (which creates a grouped expression — the basic expression). To see a complete table of operator precedence as well as various caveats, see the Operator Precedence Reference page.

JavaScript has both binary and unary operators, and one special ternary operator, the conditional operator. A binary operator requires two operands, one before the operator and one after the operator:

operand1 operator operand2

For example, const foo = ['one', 'two', 'three']; // without destructuring const one = foo[0]; const two = foo[1]; const three = foo[2]; // with destructuring const [one, two, three] = foo; 2 or // Declares a variable x and initializes it to the result of f(). // The result of the x = f() assignment expression is discarded. let x = f(); x = g(); // Reassigns the variable x to the result of g(). 7. This form is called an infix binary operator, because the operator is placed between two operands. All binary operators in JavaScript are infix.

A unary operator requires a single operand, either before or after the operator:

operator operand operand operator

For example, // Declares a variable x and initializes it to the result of f(). // The result of the x = f() assignment expression is discarded. let x = f(); x = g(); // Reassigns the variable x to the result of g(). 8 or // Declares a variable x and initializes it to the result of f(). // The result of the x = f() assignment expression is discarded. let x = f(); x = g(); // Reassigns the variable x to the result of g(). 9. The let x; const y = (x = f()); // Or equivalently: const y = x = f(); console.log(y); // Logs the return value of the assignment x = f(). console.log(x = f()); // Logs the return value directly. // An assignment expression can be nested in any place // where expressions are generally allowed, // such as array literals' elements or as function calls' arguments. console.log([ 0, x = f(), 0 ]); console.log(f(0, x = f(), 0)); 0 form is called a prefix unary operator, and the let x; const y = (x = f()); // Or equivalently: const y = x = f(); console.log(y); // Logs the return value of the assignment x = f(). console.log(x = f()); // Logs the return value directly. // An assignment expression can be nested in any place // where expressions are generally allowed, // such as array literals' elements or as function calls' arguments. console.log([ 0, x = f(), 0 ]); console.log(f(0, x = f(), 0)); 1 form is called a postfix unary operator. let x; const y = (x = f()); // Or equivalently: const y = x = f(); console.log(y); // Logs the return value of the assignment x = f(). console.log(x = f()); // Logs the return value directly. // An assignment expression can be nested in any place // where expressions are generally allowed, // such as array literals' elements or as function calls' arguments. console.log([ 0, x = f(), 0 ]); console.log(f(0, x = f(), 0)); 2 and let x; const y = (x = f()); // Or equivalently: const y = x = f(); console.log(y); // Logs the return value of the assignment x = f(). console.log(x = f()); // Logs the return value directly. // An assignment expression can be nested in any place // where expressions are generally allowed, // such as array literals' elements or as function calls' arguments. console.log([ 0, x = f(), 0 ]); console.log(f(0, x = f(), 0)); 3 are the only postfix operators in JavaScript — all other operators, like let x; const y = (x = f()); // Or equivalently: const y = x = f(); console.log(y); // Logs the return value of the assignment x = f(). console.log(x = f()); // Logs the return value directly. // An assignment expression can be nested in any place // where expressions are generally allowed, // such as array literals' elements or as function calls' arguments. console.log([ 0, x = f(), 0 ]); console.log(f(0, x = f(), 0)); 4, let x; const y = (x = f()); // Or equivalently: const y = x = f(); console.log(y); // Logs the return value of the assignment x = f(). console.log(x = f()); // Logs the return value directly. // An assignment expression can be nested in any place // where expressions are generally allowed, // such as array literals' elements or as function calls' arguments. console.log([ 0, x = f(), 0 ]); console.log(f(0, x = f(), 0)); 5, etc. are prefix.

Assignment operators

An assignment operator assigns a value to its left operand based on the value of its right operand. The simple assignment operator is equal (const val = 0; val.x = 3; console.log(val.x); // Prints undefined. console.log(val); // Prints 0. 9), which assigns the value of its right operand to its left operand. That is, let x; const y = (x = f()); // Or equivalently: const y = x = f(); console.log(y); // Logs the return value of the assignment x = f(). console.log(x = f()); // Logs the return value directly. // An assignment expression can be nested in any place // where expressions are generally allowed, // such as array literals' elements or as function calls' arguments. console.log([ 0, x = f(), 0 ]); console.log(f(0, x = f(), 0)); 7 is an assignment expression that assigns the value of let x; const y = (x = f()); // Or equivalently: const y = x = f(); console.log(y); // Logs the return value of the assignment x = f(). console.log(x = f()); // Logs the return value directly. // An assignment expression can be nested in any place // where expressions are generally allowed, // such as array literals' elements or as function calls' arguments. console.log([ 0, x = f(), 0 ]); console.log(f(0, x = f(), 0)); 8 to const foo = ['one', 'two', 'three']; // without destructuring const one = foo[0]; const two = foo[1]; const three = foo[2]; // with destructuring const [one, two, three] = foo; 0.

There are also compound assignment operators that are shorthand for the operations listed in the following table:

NameShorthand operatorMeaningAssignmentlet x; const y = (x = f()); // Or equivalently: const y = x = f(); console.log(y); // Logs the return value of the assignment x = f(). console.log(x = f()); // Logs the return value directly. // An assignment expression can be nested in any place // where expressions are generally allowed, // such as array literals' elements or as function calls' arguments. console.log([ 0, x = f(), 0 ]); console.log(f(0, x = f(), 0)); 7let x; const y = (x = f()); // Or equivalently: const y = x = f(); console.log(y); // Logs the return value of the assignment x = f(). console.log(x = f()); // Logs the return value directly. // An assignment expression can be nested in any place // where expressions are generally allowed, // such as array literals' elements or as function calls' arguments. console.log([ 0, x = f(), 0 ]); console.log(f(0, x = f(), 0)); 7Addition assignmentfunction f () { console.log('F!'); return 2; } function g () { console.log('G!'); return 3; } let x, y; 2function f () { console.log('F!'); return 2; } function g () { console.log('G!'); return 3; } let x, y; 3Subtraction assignmentfunction f () { console.log('F!'); return 2; } function g () { console.log('G!'); return 3; } let x, y; 4function f () { console.log('F!'); return 2; } function g () { console.log('G!'); return 3; } let x, y; 5Multiplication assignmentfunction f () { console.log('F!'); return 2; } function g () { console.log('G!'); return 3; } let x, y; 6function f () { console.log('F!'); return 2; } function g () { console.log('G!'); return 3; } let x, y; 7Division assignmentfunction f () { console.log('F!'); return 2; } function g () { console.log('G!'); return 3; } let x, y; 8function f () { console.log('F!'); return 2; } function g () { console.log('G!'); return 3; } let x, y; 9Remainder assignmenty = x = f() y = [ f(), x = g() ] x[f()] = g() 0y = x = f() y = [ f(), x = g() ] x[f()] = g() 1Exponentiation assignmenty = x = f() y = [ f(), x = g() ] x[f()] = g() 2y = x = f() y = [ f(), x = g() ] x[f()] = g() 3Left shift assignmenty = x = f() y = [ f(), x = g() ] x[f()] = g() 4y = x = f() y = [ f(), x = g() ] x[f()] = g() 5Right shift assignmenty = x = f() y = [ f(), x = g() ] x[f()] = g() 6y = x = f() y = [ f(), x = g() ] x[f()] = g() 7Unsigned right shift assignmenty = x = f() y = [ f(), x = g() ] x[f()] = g() 8y = x = f() y = [ f(), x = g() ] x[f()] = g() 9Bitwise AND assignmentoperand1 operator operand2 00operand1 operator operand2 01Bitwise XOR assignmentoperand1 operator operand2 02operand1 operator operand2 03Bitwise OR assignmentoperand1 operator operand2 04operand1 operator operand2 05Logical AND assignmentoperand1 operator operand2 06operand1 operator operand2 07Logical OR assignmentoperand1 operator operand2 08operand1 operator operand2 09Nullish coalescing assignmentoperand1 operator operand2 10operand1 operator operand2 11

Assigning to properties

If an expression evaluates to an object, then the left-hand side of an assignment expression may make assignments to properties of that expression. For example:

const obj = {}; obj.x = 3; console.log(obj.x); // Prints 3. console.log(obj); // Prints { x: 3 }. const key = "y"; obj[key] = 5; console.log(obj[key]); // Prints 5. console.log(obj); // Prints { x: 3, y: 5 }.

For more information about objects, read Working with Objects.

If an expression does not evaluate to an object, then assignments to properties of that expression do not assign:

const val = 0; val.x = 3; console.log(val.x); // Prints undefined. console.log(val); // Prints 0.

In strict mode, the code above throws, because one cannot assign properties to primitives.

It is an error to assign values to unmodifiable properties or to properties of an expression without properties (operand1 operator operand2 12 or operand1 operator operand2 13).

Destructuring

For more complex assignments, the destructuring assignment syntax is a JavaScript expression that makes it possible to extract data from arrays or objects using a syntax that mirrors the construction of array and object literals.

const foo = ['one', 'two', 'three']; // without destructuring const one = foo[0]; const two = foo[1]; const three = foo[2]; // with destructuring const [one, two, three] = foo;

Evaluation and nesting

In general, assignments are used within a variable declaration (i.e., with operand1 operator operand2 14, operand1 operator operand2 15, or operand1 operator operand2 16) or as standalone statements).

// Declares a variable x and initializes it to the result of f(). // The result of the x = f() assignment expression is discarded. let x = f(); x = g(); // Reassigns the variable x to the result of g().

However, like other expressions, assignment expressions like let x; const y = (x = f()); // Or equivalently: const y = x = f(); console.log(y); // Logs the return value of the assignment x = f(). console.log(x = f()); // Logs the return value directly. // An assignment expression can be nested in any place // where expressions are generally allowed, // such as array literals' elements or as function calls' arguments. console.log([ 0, x = f(), 0 ]); console.log(f(0, x = f(), 0)); 7 evaluate into a result value. Although this result value is usually not used, it can then be used by another expression.

Chaining assignments or nesting assignments in other expressions can result in surprising behavior. For this reason, some JavaScript style guides discourage chaining or nesting assignments). Nevertheless, assignment chaining and nesting may occur sometimes, so it is important to be able to understand how they work.

By chaining or nesting an assignment expression, its result can itself be assigned to another variable. It can be logged, it can be put inside an array literal or function call, and so on.

let x; const y = (x = f()); // Or equivalently: const y = x = f(); console.log(y); // Logs the return value of the assignment x = f(). console.log(x = f()); // Logs the return value directly. // An assignment expression can be nested in any place // where expressions are generally allowed, // such as array literals' elements or as function calls' arguments. console.log([ 0, x = f(), 0 ]); console.log(f(0, x = f(), 0));

The evaluation result matches the expression to the right of the const val = 0; val.x = 3; console.log(val.x); // Prints undefined. console.log(val); // Prints 0. 9 sign in the "Meaning" column of the table above. That means that let x; const y = (x = f()); // Or equivalently: const y = x = f(); console.log(y); // Logs the return value of the assignment x = f(). console.log(x = f()); // Logs the return value directly. // An assignment expression can be nested in any place // where expressions are generally allowed, // such as array literals' elements or as function calls' arguments. console.log([ 0, x = f(), 0 ]); console.log(f(0, x = f(), 0)); 7 evaluates into whatever let x; const y = (x = f()); // Or equivalently: const y = x = f(); console.log(y); // Logs the return value of the assignment x = f(). console.log(x = f()); // Logs the return value directly. // An assignment expression can be nested in any place // where expressions are generally allowed, // such as array literals' elements or as function calls' arguments. console.log([ 0, x = f(), 0 ]); console.log(f(0, x = f(), 0)); 8's result is, function f () { console.log('F!'); return 2; } function g () { console.log('G!'); return 3; } let x, y; 2 evaluates into the resulting sum operand1 operator operand2 22, y = x = f() y = [ f(), x = g() ] x[f()] = g() 2 evaluates into the resulting power operand1 operator operand2 24, and so on.

In the case of logical assignments, operand1 operator operand2 06, operand1 operator operand2 08, and operand1 operator operand2 10, the return value is that of the logical operation without the assignment, so operand1 operator operand2 28, operand1 operator operand2 29, and operand1 operator operand2 30, respectively.

When chaining these expressions without parentheses or other grouping operators like array literals, the assignment expressions are grouped right to left (they are right-associative), but they are evaluated left to right.

Note that, for all assignment operators other than const val = 0; val.x = 3; console.log(val.x); // Prints undefined. console.log(val); // Prints 0. 9 itself, the resulting values are always based on the operands' values before the operation.

For example, assume that the following functions operand1 operator operand2 32 and operand1 operator operand2 33 and the variables const foo = ['one', 'two', 'three']; // without destructuring const one = foo[0]; const two = foo[1]; const three = foo[2]; // with destructuring const [one, two, three] = foo; 0 and operand1 operator operand2 35 have been declared:

function f () { console.log('F!'); return 2; } function g () { console.log('G!'); return 3; } let x, y;

Consider these three examples:

y = x = f() y = [ f(), x = g() ] x[f()] = g()

Evaluation example 1

operand1 operator operand2 36 is equivalent to operand1 operator operand2 37, because the assignment operator const val = 0; val.x = 3; console.log(val.x); // Prints undefined. console.log(val); // Prints 0. 9 is right-associative. However, it evaluates from left to right:

  1. The assignment expression operand1 operator operand2 36 starts to evaluate.
    1. The operand1 operator operand2 35 on this assignment's left-hand side evaluates into a reference to the variable named operand1 operator operand2 35.
    2. The assignment expression let x; const y = (x = f()); // Or equivalently: const y = x = f(); console.log(y); // Logs the return value of the assignment x = f(). console.log(x = f()); // Logs the return value directly. // An assignment expression can be nested in any place // where expressions are generally allowed, // such as array literals' elements or as function calls' arguments. console.log([ 0, x = f(), 0 ]); console.log(f(0, x = f(), 0)); 7 starts to evaluate.
      1. The const foo = ['one', 'two', 'three']; // without destructuring const one = foo[0]; const two = foo[1]; const three = foo[2]; // with destructuring const [one, two, three] = foo; 0 on this assignment's left-hand side evaluates into a reference to the variable named const foo = ['one', 'two', 'three']; // without destructuring const one = foo[0]; const two = foo[1]; const three = foo[2]; // with destructuring const [one, two, three] = foo; 0.
      2. The function call let x; const y = (x = f()); // Or equivalently: const y = x = f(); console.log(y); // Logs the return value of the assignment x = f(). console.log(x = f()); // Logs the return value directly. // An assignment expression can be nested in any place // where expressions are generally allowed, // such as array literals' elements or as function calls' arguments. console.log([ 0, x = f(), 0 ]); console.log(f(0, x = f(), 0)); 8 prints "F!" to the console and then evaluates to the number operand1 operator operand2 46.
      3. That operand1 operator operand2 46 result from let x; const y = (x = f()); // Or equivalently: const y = x = f(); console.log(y); // Logs the return value of the assignment x = f(). console.log(x = f()); // Logs the return value directly. // An assignment expression can be nested in any place // where expressions are generally allowed, // such as array literals' elements or as function calls' arguments. console.log([ 0, x = f(), 0 ]); console.log(f(0, x = f(), 0)); 8 is assigned to const foo = ['one', 'two', 'three']; // without destructuring const one = foo[0]; const two = foo[1]; const three = foo[2]; // with destructuring const [one, two, three] = foo; 0.
    3. The assignment expression let x; const y = (x = f()); // Or equivalently: const y = x = f(); console.log(y); // Logs the return value of the assignment x = f(). console.log(x = f()); // Logs the return value directly. // An assignment expression can be nested in any place // where expressions are generally allowed, // such as array literals' elements or as function calls' arguments. console.log([ 0, x = f(), 0 ]); console.log(f(0, x = f(), 0)); 7 has now finished evaluating; its result is the new value of const foo = ['one', 'two', 'three']; // without destructuring const one = foo[0]; const two = foo[1]; const three = foo[2]; // with destructuring const [one, two, three] = foo; 0, which is operand1 operator operand2 46.
    4. That operand1 operator operand2 46 result in turn is also assigned to operand1 operator operand2 35.
  2. The assignment expression operand1 operator operand2 36 has now finished evaluating; its result is the new value of operand1 operator operand2 35 – which happens to be operand1 operator operand2 46. const foo = ['one', 'two', 'three']; // without destructuring const one = foo[0]; const two = foo[1]; const three = foo[2]; // with destructuring const [one, two, three] = foo; 0 and operand1 operator operand2 35 are assigned to operand1 operator operand2 46, and the console has printed "F!".

Evaluation example 2

operand1 operator operand2 61 also evaluates from left to right:

  1. The assignment expression operand1 operator operand2 61 starts to evaluate.
    1. The operand1 operator operand2 35 on this assignment's left-hand evaluates into a reference to the variable named operand1 operator operand2 35.
    2. The inner array literal operand1 operator operand2 65 starts to evaluate.
      1. The function call let x; const y = (x = f()); // Or equivalently: const y = x = f(); console.log(y); // Logs the return value of the assignment x = f(). console.log(x = f()); // Logs the return value directly. // An assignment expression can be nested in any place // where expressions are generally allowed, // such as array literals' elements or as function calls' arguments. console.log([ 0, x = f(), 0 ]); console.log(f(0, x = f(), 0)); 8 prints "F!" to the console and then evaluates to the number operand1 operator operand2 46.
      2. The assignment expression operand1 operator operand2 68 starts to evaluate.
        1. The const foo = ['one', 'two', 'three']; // without destructuring const one = foo[0]; const two = foo[1]; const three = foo[2]; // with destructuring const [one, two, three] = foo; 0 on this assignment's left-hand side evaluates into a reference to the variable named const foo = ['one', 'two', 'three']; // without destructuring const one = foo[0]; const two = foo[1]; const three = foo[2]; // with destructuring const [one, two, three] = foo; 0.
        2. The function call operand1 operator operand2 71 prints "G!" to the console and then evaluates to the number const foo = ['one', 'two', 'three']; // without destructuring const one = foo[0]; const two = foo[1]; const three = foo[2]; // with destructuring const [one, two, three] = foo; 4.
        3. That const foo = ['one', 'two', 'three']; // without destructuring const one = foo[0]; const two = foo[1]; const three = foo[2]; // with destructuring const [one, two, three] = foo; 4 result from operand1 operator operand2 71 is assigned to const foo = ['one', 'two', 'three']; // without destructuring const one = foo[0]; const two = foo[1]; const three = foo[2]; // with destructuring const [one, two, three] = foo; 0.
      3. The assignment expression operand1 operator operand2 68 has now finished evaluating; its result is the new value of const foo = ['one', 'two', 'three']; // without destructuring const one = foo[0]; const two = foo[1]; const three = foo[2]; // with destructuring const [one, two, three] = foo; 0, which is const foo = ['one', 'two', 'three']; // without destructuring const one = foo[0]; const two = foo[1]; const three = foo[2]; // with destructuring const [one, two, three] = foo; 4. That const foo = ['one', 'two', 'three']; // without destructuring const one = foo[0]; const two = foo[1]; const three = foo[2]; // with destructuring const [one, two, three] = foo; 4 result becomes the next element in the inner array literal (after the operand1 operator operand2 46 from the let x; const y = (x = f()); // Or equivalently: const y = x = f(); console.log(y); // Logs the return value of the assignment x = f(). console.log(x = f()); // Logs the return value directly. // An assignment expression can be nested in any place // where expressions are generally allowed, // such as array literals' elements or as function calls' arguments. console.log([ 0, x = f(), 0 ]); console.log(f(0, x = f(), 0)); 8).
    3. The inner array literal operand1 operator operand2 65 has now finished evaluating; its result is an array with two values: operand1 operator operand2 83.
    4. That operand1 operator operand2 83 array is now assigned to operand1 operator operand2 35.
  2. The assignment expression operand1 operator operand2 61 has now finished evaluating; its result is the new value of operand1 operator operand2 35 – which happens to be operand1 operator operand2 83. const foo = ['one', 'two', 'three']; // without destructuring const one = foo[0]; const two = foo[1]; const three = foo[2]; // with destructuring const [one, two, three] = foo; 0 is now assigned to const foo = ['one', 'two', 'three']; // without destructuring const one = foo[0]; const two = foo[1]; const three = foo[2]; // with destructuring const [one, two, three] = foo; 4, operand1 operator operand2 35 is now assigned to operand1 operator operand2 83, and the console has printed "F!" then "G!".

Evaluation example 3

operand1 operator operand2 93 also evaluates from left to right. (This example assumes that const foo = ['one', 'two', 'three']; // without destructuring const one = foo[0]; const two = foo[1]; const three = foo[2]; // with destructuring const [one, two, three] = foo; 0 is already assigned to some object. For more information about objects, read Working with Objects.)

  1. The assignment expression operand1 operator operand2 93 starts to evaluate.
    1. The operand1 operator operand2 96 property access on this assignment's left-hand starts to evaluate.
      1. The const foo = ['one', 'two', 'three']; // without destructuring const one = foo[0]; const two = foo[1]; const three = foo[2]; // with destructuring const [one, two, three] = foo; 0 in this property access evaluates into a reference to the variable named const foo = ['one', 'two', 'three']; // without destructuring const one = foo[0]; const two = foo[1]; const three = foo[2]; // with destructuring const [one, two, three] = foo; 0.
      2. Then the function call let x; const y = (x = f()); // Or equivalently: const y = x = f(); console.log(y); // Logs the return value of the assignment x = f(). console.log(x = f()); // Logs the return value directly. // An assignment expression can be nested in any place // where expressions are generally allowed, // such as array literals' elements or as function calls' arguments. console.log([ 0, x = f(), 0 ]); console.log(f(0, x = f(), 0)); 8 prints "F!" to the console and then evaluates to the number operand1 operator operand2 46.
    2. The operand1 operator operand2 96 property access on this assignment has now finished evaluating; its result is a variable property reference: operator operand operand operator 02.
    3. Then the function call operand1 operator operand2 71 prints "G!" to the console and then evaluates to the number const foo = ['one', 'two', 'three']; // without destructuring const one = foo[0]; const two = foo[1]; const three = foo[2]; // with destructuring const [one, two, three] = foo; 4.
    4. That const foo = ['one', 'two', 'three']; // without destructuring const one = foo[0]; const two = foo[1]; const three = foo[2]; // with destructuring const [one, two, three] = foo; 4 is now assigned to operator operand operand operator 02. (This step will succeed only if const foo = ['one', 'two', 'three']; // without destructuring const one = foo[0]; const two = foo[1]; const three = foo[2]; // with destructuring const [one, two, three] = foo; 0 is assigned to an object.)
  2. The assignment expression operand1 operator operand2 93 has now finished evaluating; its result is the new value of operator operand operand operator 02 – which happens to be const foo = ['one', 'two', 'three']; // without destructuring const one = foo[0]; const two = foo[1]; const three = foo[2]; // with destructuring const [one, two, three] = foo; 4. operator operand operand operator 02 is now assigned to const foo = ['one', 'two', 'three']; // without destructuring const one = foo[0]; const two = foo[1]; const three = foo[2]; // with destructuring const [one, two, three] = foo; 4, and the console has printed "F!" then "G!".

Avoid assignment chains

Chaining assignments or nesting assignments in other expressions can result in surprising behavior. For this reason, chaining assignments in the same statement is discouraged).

In particular, putting a variable chain in a operand1 operator operand2 14, operand1 operator operand2 15, or operand1 operator operand2 16 statement often does not work. Only the outermost/leftmost variable would get declared; other variables within the assignment chain are not declared by the operand1 operator operand2 14/operand1 operator operand2 15/operand1 operator operand2 16 statement. For example:

operand1 operator operand2 0

This statement seemingly declares the variables const foo = ['one', 'two', 'three']; // without destructuring const one = foo[0]; const two = foo[1]; const three = foo[2]; // with destructuring const [one, two, three] = foo; 0, operand1 operator operand2 35, and operator operand operand operator 21. However, it only actually declares the variable operator operand operand operator 21. operand1 operator operand2 35 and const foo = ['one', 'two', 'three']; // without destructuring const one = foo[0]; const two = foo[1]; const three = foo[2]; // with destructuring const [one, two, three] = foo; 0 are either invalid references to nonexistent variables (in strict mode) or, worse, would implicitly create global variables for const foo = ['one', 'two', 'three']; // without destructuring const one = foo[0]; const two = foo[1]; const three = foo[2]; // with destructuring const [one, two, three] = foo; 0 and operand1 operator operand2 35 in sloppy mode.

Comparison operators

A comparison operator compares its operands and returns a logical value based on whether the comparison is true. The operands can be numerical, string, logical, or object values. Strings are compared based on standard lexicographical ordering, using Unicode values. In most cases, if the two operands are not of the same type, JavaScript attempts to convert them to an appropriate type for the comparison. This behavior generally results in comparing the operands numerically. The sole exceptions to type conversion within comparisons involve the operator operand operand operator 27 and operator operand operand operator 28 operators, which perform strict equality and inequality comparisons. These operators do not attempt to convert the operands to compatible types before checking equality. The following table describes the comparison operators in terms of this sample code:

operand1 operator operand2 1

Comparison operatorsOperatorDescriptionExamples returning trueEqual (operator operand operand operator 29)Returns operator operand operand operator 30 if the operands are equal.operator operand operand operator 31

operator operand operand operator 32

operator operand operand operator 33Not equal (operator operand operand operator 34)Returns operator operand operand operator 30 if the operands are not equal.operator operand operand operator 36Strict equal (operator operand operand operator 27)Returns operator operand operand operator 30 if the operands are equal and of the same type. See also operator operand operand operator 39 and sameness in JS.operator operand operand operator 40Strict not equal (operator operand operand operator 28)Returns operator operand operand operator 30 if the operands are of the same type but not equal, or are of different type.operator operand operand operator 43Greater than (operator operand operand operator 44)Returns operator operand operand operator 30 if the left operand is greater than the right operand.operator operand operand operator 46Greater than or equal (operator operand operand operator 47)Returns operator operand operand operator 30 if the left operand is greater than or equal to the right operand.operator operand operand operator 49Less than (operator operand operand operator 50)Returns operator operand operand operator 30 if the left operand is less than the right operand.operator operand operand operator 52Less than or equal (operator operand operand operator 53)Returns operator operand operand operator 30 if the left operand is less than or equal to the right operand.operator operand operand operator 55

Note: operator operand operand operator 56 is not a comparison operator but rather is the notation for Arrow functions.

Arithmetic operators

An arithmetic operator takes numerical values (either literals or variables) as their operands and returns a single numerical value. The standard arithmetic operators are addition (const foo = ['one', 'two', 'three']; // without destructuring const one = foo[0]; const two = foo[1]; const three = foo[2]; // with destructuring const [one, two, three] = foo; 3), subtraction (operator operand operand operator 58), multiplication (// Declares a variable x and initializes it to the result of f(). // The result of the x = f() assignment expression is discarded. let x = f(); x = g(); // Reassigns the variable x to the result of g(). 0), and division (operator operand operand operator 60). These operators work as they do in most other programming languages when used with floating point numbers (in particular, note that division by zero produces operator operand operand operator 61). For example:

operand1 operator operand2 2

In addition to the standard arithmetic operations (const foo = ['one', 'two', 'three']; // without destructuring const one = foo[0]; const two = foo[1]; const three = foo[2]; // with destructuring const [one, two, three] = foo; 3, operator operand operand operator 58, // Declares a variable x and initializes it to the result of f(). // The result of the x = f() assignment expression is discarded. let x = f(); x = g(); // Reassigns the variable x to the result of g(). 0, operator operand operand operator 60), JavaScript provides the arithmetic operators listed in the following table:

Arithmetic operatorsOperatorDescriptionExampleRemainder (operator operand operand operator 66)Binary operator. Returns the integer remainder of dividing the two operands.12 % 5 returns 2.Increment (let x; const y = (x = f()); // Or equivalently: const y = x = f(); console.log(y); // Logs the return value of the assignment x = f(). console.log(x = f()); // Logs the return value directly. // An assignment expression can be nested in any place // where expressions are generally allowed, // such as array literals' elements or as function calls' arguments. console.log([ 0, x = f(), 0 ]); console.log(f(0, x = f(), 0)); 2)Unary operator. Adds one to its operand. If used as a prefix operator (// Declares a variable x and initializes it to the result of f(). // The result of the x = f() assignment expression is discarded. let x = f(); x = g(); // Reassigns the variable x to the result of g(). 9), returns the value of its operand after adding one; if used as a postfix operator (// Declares a variable x and initializes it to the result of f(). // The result of the x = f() assignment expression is discarded. let x = f(); x = g(); // Reassigns the variable x to the result of g(). 8), returns the value of its operand before adding one.If const foo = ['one', 'two', 'three']; // without destructuring const one = foo[0]; const two = foo[1]; const three = foo[2]; // with destructuring const [one, two, three] = foo; 0 is 3, then // Declares a variable x and initializes it to the result of f(). // The result of the x = f() assignment expression is discarded. let x = f(); x = g(); // Reassigns the variable x to the result of g(). 9 sets const foo = ['one', 'two', 'three']; // without destructuring const one = foo[0]; const two = foo[1]; const three = foo[2]; // with destructuring const [one, two, three] = foo; 0 to 4 and returns 4, whereas // Declares a variable x and initializes it to the result of f(). // The result of the x = f() assignment expression is discarded. let x = f(); x = g(); // Reassigns the variable x to the result of g(). 8 returns 3 and, only then, sets const foo = ['one', 'two', 'three']; // without destructuring const one = foo[0]; const two = foo[1]; const three = foo[2]; // with destructuring const [one, two, three] = foo; 0 to 4.Decrement (let x; const y = (x = f()); // Or equivalently: const y = x = f(); console.log(y); // Logs the return value of the assignment x = f(). console.log(x = f()); // Logs the return value directly. // An assignment expression can be nested in any place // where expressions are generally allowed, // such as array literals' elements or as function calls' arguments. console.log([ 0, x = f(), 0 ]); console.log(f(0, x = f(), 0)); 3)Unary operator. Subtracts one from its operand. The return value is analogous to that for the increment operator.If const foo = ['one', 'two', 'three']; // without destructuring const one = foo[0]; const two = foo[1]; const three = foo[2]; // with destructuring const [one, two, three] = foo; 0 is 3, then operator operand operand operator 77 sets const foo = ['one', 'two', 'three']; // without destructuring const one = foo[0]; const two = foo[1]; const three = foo[2]; // with destructuring const [one, two, three] = foo; 0 to 2 and returns 2, whereas operator operand operand operator 79 returns 3 and, only then, sets const foo = ['one', 'two', 'three']; // without destructuring const one = foo[0]; const two = foo[1]; const three = foo[2]; // with destructuring const [one, two, three] = foo; 0 to 2.Unary negation (operator operand operand operator 58)Unary operator. Returns the negation of its operand.If const foo = ['one', 'two', 'three']; // without destructuring const one = foo[0]; const two = foo[1]; const three = foo[2]; // with destructuring const [one, two, three] = foo; 0 is 3, then operator operand operand operator 83 returns -3.Unary plus (const foo = ['one', 'two', 'three']; // without destructuring const one = foo[0]; const two = foo[1]; const three = foo[2]; // with destructuring const [one, two, three] = foo; 3)Unary operator. Attempts to convert the operand to a number, if it is not already.

operator operand operand operator 85 returns const foo = ['one', 'two', 'three']; // without destructuring const one = foo[0]; const two = foo[1]; const three = foo[2]; // with destructuring const [one, two, three] = foo; 4.

operator operand operand operator 87 returns operator operand operand operator 88.

Exponentiation operator (operator operand operand operator 89)Calculates the operator operand operand operator 90 to the operator operand operand operator 91 power, that is, operator operand operand operator 92operator operand operand operator 93 returns operator operand operand operator 94.
operator operand operand operator 95 returns operator operand operand operator 96.

Bitwise operators

A bitwise operator treats their operands as a set of 32 bits (zeros 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.

The following table summarizes JavaScript's bitwise operators.

OperatorUsageDescriptionBitwise ANDoperator operand operand operator 97Returns a one in each bit position for which the corresponding bits of both operands are ones.Bitwise ORoperator operand operand operator 98Returns a zero in each bit position for which the corresponding bits of both operands are zeros.Bitwise XORoperator operand operand operator 99Returns a zero in each bit position for which the corresponding bits are the same. [Returns a one in each bit position for which the corresponding bits are different.]Bitwise NOTconst obj = {}; obj.x = 3; console.log(obj.x); // Prints 3. console.log(obj); // Prints { x: 3 }. const key = "y"; obj[key] = 5; console.log(obj[key]); // Prints 5. console.log(obj); // Prints { x: 3, y: 5 }. 00Inverts the bits of its operand.Left shiftconst obj = {}; obj.x = 3; console.log(obj.x); // Prints 3. console.log(obj); // Prints { x: 3 }. const key = "y"; obj[key] = 5; console.log(obj[key]); // Prints 5. console.log(obj); // Prints { x: 3, y: 5 }. 01Shifts const obj = {}; obj.x = 3; console.log(obj.x); // Prints 3. console.log(obj); // Prints { x: 3 }. const key = "y"; obj[key] = 5; console.log(obj[key]); // Prints 5. console.log(obj); // Prints { x: 3, y: 5 }. 02 in binary representation const obj = {}; obj.x = 3; console.log(obj.x); // Prints 3. console.log(obj); // Prints { x: 3 }. const key = "y"; obj[key] = 5; console.log(obj[key]); // Prints 5. console.log(obj); // Prints { x: 3, y: 5 }. 03 bits to the left, shifting in zeros from the right.Sign-propagating right shiftconst obj = {}; obj.x = 3; console.log(obj.x); // Prints 3. console.log(obj); // Prints { x: 3 }. const key = "y"; obj[key] = 5; console.log(obj[key]); // Prints 5. console.log(obj); // Prints { x: 3, y: 5 }. 04Shifts const obj = {}; obj.x = 3; console.log(obj.x); // Prints 3. console.log(obj); // Prints { x: 3 }. const key = "y"; obj[key] = 5; console.log(obj[key]); // Prints 5. console.log(obj); // Prints { x: 3, y: 5 }. 02 in binary representation const obj = {}; obj.x = 3; console.log(obj.x); // Prints 3. console.log(obj); // Prints { x: 3 }. const key = "y"; obj[key] = 5; console.log(obj[key]); // Prints 5. console.log(obj); // Prints { x: 3, y: 5 }. 03 bits to the right, discarding bits shifted off.Zero-fill right shiftconst obj = {}; obj.x = 3; console.log(obj.x); // Prints 3. console.log(obj); // Prints { x: 3 }. const key = "y"; obj[key] = 5; console.log(obj[key]); // Prints 5. console.log(obj); // Prints { x: 3, y: 5 }. 07Shifts const obj = {}; obj.x = 3; console.log(obj.x); // Prints 3. console.log(obj); // Prints { x: 3 }. const key = "y"; obj[key] = 5; console.log(obj[key]); // Prints 5. console.log(obj); // Prints { x: 3, y: 5 }. 02 in binary representation const obj = {}; obj.x = 3; console.log(obj.x); // Prints 3. console.log(obj); // Prints { x: 3 }. const key = "y"; obj[key] = 5; console.log(obj[key]); // Prints 5. console.log(obj); // Prints { x: 3, y: 5 }. 03 bits to the right, discarding bits shifted off, and shifting in zeros from the left.

Bitwise logical operators

Conceptually, the bitwise logical operators work as follows:

  • The operands are converted to thirty-two-bit integers and expressed by a series of bits (zeros 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:

    operand1 operator operand2 3

  • 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.
  • The operator is applied to each pair of bits, and the result is constructed bitwise.

For example, the binary representation of nine is 1001, and the binary representation of fifteen is 1111. So, when the bitwise operators are applied to these values, the results are as follows:

ExpressionResultBinary Descriptionconst obj = {}; obj.x = 3; console.log(obj.x); // Prints 3. console.log(obj); // Prints { x: 3 }. const key = "y"; obj[key] = 5; console.log(obj[key]); // Prints 5. console.log(obj); // Prints { x: 3, y: 5 }. 10const obj = {}; obj.x = 3; console.log(obj.x); // Prints 3. console.log(obj); // Prints { x: 3 }. const key = "y"; obj[key] = 5; console.log(obj[key]); // Prints 5. console.log(obj); // Prints { x: 3, y: 5 }. 11const obj = {}; obj.x = 3; console.log(obj.x); // Prints 3. console.log(obj); // Prints { x: 3 }. const key = "y"; obj[key] = 5; console.log(obj[key]); // Prints 5. console.log(obj); // Prints { x: 3, y: 5 }. 12const obj = {}; obj.x = 3; console.log(obj.x); // Prints 3. console.log(obj); // Prints { x: 3 }. const key = "y"; obj[key] = 5; console.log(obj[key]); // Prints 5. console.log(obj); // Prints { x: 3, y: 5 }. 13const obj = {}; obj.x = 3; console.log(obj.x); // Prints 3. console.log(obj); // Prints { x: 3 }. const key = "y"; obj[key] = 5; console.log(obj[key]); // Prints 5. console.log(obj); // Prints { x: 3, y: 5 }. 14const obj = {}; obj.x = 3; console.log(obj.x); // Prints 3. console.log(obj); // Prints { x: 3 }. const key = "y"; obj[key] = 5; console.log(obj[key]); // Prints 5. console.log(obj); // Prints { x: 3, y: 5 }. 15const obj = {}; obj.x = 3; console.log(obj.x); // Prints 3. console.log(obj); // Prints { x: 3 }. const key = "y"; obj[key] = 5; console.log(obj[key]); // Prints 5. console.log(obj); // Prints { x: 3, y: 5 }. 16const obj = {}; obj.x = 3; console.log(obj.x); // Prints 3. console.log(obj); // Prints { x: 3 }. const key = "y"; obj[key] = 5; console.log(obj[key]); // Prints 5. console.log(obj); // Prints { x: 3, y: 5 }. 17const obj = {}; obj.x = 3; console.log(obj.x); // Prints 3. console.log(obj); // Prints { x: 3 }. const key = "y"; obj[key] = 5; console.log(obj[key]); // Prints 5. console.log(obj); // Prints { x: 3, y: 5 }. 18const obj = {}; obj.x = 3; console.log(obj.x); // Prints 3. console.log(obj); // Prints { x: 3 }. const key = "y"; obj[key] = 5; console.log(obj[key]); // Prints 5. console.log(obj); // Prints { x: 3, y: 5 }. 19const obj = {}; obj.x = 3; console.log(obj.x); // Prints 3. console.log(obj); // Prints { x: 3 }. const key = "y"; obj[key] = 5; console.log(obj[key]); // Prints 5. console.log(obj); // Prints { x: 3, y: 5 }. 20const obj = {}; obj.x = 3; console.log(obj.x); // Prints 3. console.log(obj); // Prints { x: 3 }. const key = "y"; obj[key] = 5; console.log(obj[key]); // Prints 5. console.log(obj); // Prints { x: 3, y: 5 }. 21const obj = {}; obj.x = 3; console.log(obj.x); // Prints 3. console.log(obj); // Prints { x: 3 }. const key = "y"; obj[key] = 5; console.log(obj[key]); // Prints 5. console.log(obj); // Prints { x: 3, y: 5 }. 22const obj = {}; obj.x = 3; console.log(obj.x); // Prints 3. console.log(obj); // Prints { x: 3 }. const key = "y"; obj[key] = 5; console.log(obj[key]); // Prints 5. console.log(obj); // Prints { x: 3, y: 5 }. 23const obj = {}; obj.x = 3; console.log(obj.x); // Prints 3. console.log(obj); // Prints { x: 3 }. const key = "y"; obj[key] = 5; console.log(obj[key]); // Prints 5. console.log(obj); // Prints { x: 3, y: 5 }. 24

Note that all 32 bits are inverted using the Bitwise NOT operator, and that values with the most significant (left-most) bit set to 1 represent negative numbers (two's-complement representation). const obj = {}; obj.x = 3; console.log(obj.x); // Prints 3. console.log(obj); // Prints { x: 3 }. const key = "y"; obj[key] = 5; console.log(obj[key]); // Prints 5. console.log(obj); // Prints { x: 3, y: 5 }. 25 evaluates to the same value that const obj = {}; obj.x = 3; console.log(obj.x); // Prints 3. console.log(obj); // Prints { x: 3 }. const key = "y"; obj[key] = 5; console.log(obj[key]); // Prints 5. console.log(obj); // Prints { x: 3, y: 5 }. 26 evaluates to.

Bitwise shift operators

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.

Shift operators convert their operands to thirty-two-bit integers and return a result of either type const obj = {}; obj.x = 3; console.log(obj.x); // Prints 3. console.log(obj); // Prints { x: 3 }. const key = "y"; obj[key] = 5; console.log(obj[key]); // Prints 5. console.log(obj); // Prints { x: 3, y: 5 }. 27 or const obj = {}; obj.x = 3; console.log(obj.x); // Prints 3. console.log(obj); // Prints { x: 3 }. const key = "y"; obj[key] = 5; console.log(obj[key]); // Prints 5. console.log(obj); // Prints { x: 3, y: 5 }. 28: specifically, if the type of the left operand is const obj = {}; obj.x = 3; console.log(obj.x); // Prints 3. console.log(obj); // Prints { x: 3 }. const key = "y"; obj[key] = 5; console.log(obj[key]); // Prints 5. console.log(obj); // Prints { x: 3, y: 5 }. 28, they return const obj = {}; obj.x = 3; console.log(obj.x); // Prints 3. console.log(obj); // Prints { x: 3 }. const key = "y"; obj[key] = 5; console.log(obj[key]); // Prints 5. console.log(obj); // Prints { x: 3, y: 5 }. 28; otherwise, they return const obj = {}; obj.x = 3; console.log(obj.x); // Prints 3. console.log(obj); // Prints { x: 3 }. const key = "y"; obj[key] = 5; console.log(obj[key]); // Prints 5. console.log(obj); // Prints { x: 3, y: 5 }. 27.

The shift operators are listed in the following table.

Bitwise shift operatorsOperatorDescriptionExampleLeft shift
(const obj = {}; obj.x = 3; console.log(obj.x); // Prints 3. console.log(obj); // Prints { x: 3 }. const key = "y"; obj[key] = 5; console.log(obj[key]); // Prints 5. console.log(obj); // Prints { x: 3, y: 5 }. 32)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.const obj = {}; obj.x = 3; console.log(obj.x); // Prints 3. console.log(obj); // Prints { x: 3 }. const key = "y"; obj[key] = 5; console.log(obj[key]); // Prints 5. console.log(obj); // Prints { x: 3, y: 5 }. 33 yields 36, because 1001 shifted 2 bits to the left becomes 100100, which is 36.Sign-propagating right shift (const obj = {}; obj.x = 3; console.log(obj.x); // Prints 3. console.log(obj); // Prints { x: 3 }. const key = "y"; obj[key] = 5; console.log(obj[key]); // Prints 5. console.log(obj); // Prints { x: 3, y: 5 }. 34)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.const obj = {}; obj.x = 3; console.log(obj.x); // Prints 3. console.log(obj); // Prints { x: 3 }. const key = "y"; obj[key] = 5; console.log(obj[key]); // Prints 5. console.log(obj); // Prints { x: 3, y: 5 }. 35 yields 2, because 1001 shifted 2 bits to the right becomes 10, which is 2. Likewise, const obj = {}; obj.x = 3; console.log(obj.x); // Prints 3. console.log(obj); // Prints { x: 3 }. const key = "y"; obj[key] = 5; console.log(obj[key]); // Prints 5. console.log(obj); // Prints { x: 3, y: 5 }. 36 yields -3, because the sign is preserved.Zero-fill right shift (const obj = {}; obj.x = 3; console.log(obj.x); // Prints 3. console.log(obj); // Prints { x: 3 }. const key = "y"; obj[key] = 5; console.log(obj[key]); // Prints 5. console.log(obj); // Prints { x: 3, y: 5 }. 37)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.const obj = {}; obj.x = 3; console.log(obj.x); // Prints 3. console.log(obj); // Prints { x: 3 }. const key = "y"; obj[key] = 5; console.log(obj[key]); // Prints 5. console.log(obj); // Prints { x: 3, y: 5 }. 38 yields 4, because 10011 shifted 2 bits to the right becomes 100, which is 4. For non-negative numbers, zero-fill right shift and sign-propagating right shift yield the same result.

Logical operators

Logical operators are typically used with Boolean (logical) values; when they are, they return a Boolean value. However, the const obj = {}; obj.x = 3; console.log(obj.x); // Prints 3. console.log(obj); // Prints { x: 3 }. const key = "y"; obj[key] = 5; console.log(obj[key]); // Prints 5. console.log(obj); // Prints { x: 3, y: 5 }. 39 and const obj = {}; obj.x = 3; console.log(obj.x); // Prints 3. console.log(obj); // Prints { x: 3 }. const key = "y"; obj[key] = 5; console.log(obj[key]); // Prints 5. console.log(obj); // Prints { x: 3, y: 5 }. 40 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. The logical operators are described in the following table.

Logical operatorsOperatorUsageDescriptionLogical AND (const obj = {}; obj.x = 3; console.log(obj.x); // Prints 3. console.log(obj); // Prints { x: 3 }. const key = "y"; obj[key] = 5; console.log(obj[key]); // Prints 5. console.log(obj); // Prints { x: 3, y: 5 }. 39)const obj = {}; obj.x = 3; console.log(obj.x); // Prints 3. console.log(obj); // Prints { x: 3 }. const key = "y"; obj[key] = 5; console.log(obj[key]); // Prints 5. console.log(obj); // Prints { x: 3, y: 5 }. 42Returns const obj = {}; obj.x = 3; console.log(obj.x); // Prints 3. console.log(obj); // Prints { x: 3 }. const key = "y"; obj[key] = 5; console.log(obj[key]); // Prints 5. console.log(obj); // Prints { x: 3, y: 5 }. 43 if it can be converted to const obj = {}; obj.x = 3; console.log(obj.x); // Prints 3. console.log(obj); // Prints { x: 3 }. const key = "y"; obj[key] = 5; console.log(obj[key]); // Prints 5. console.log(obj); // Prints { x: 3, y: 5 }. 44; otherwise, returns const obj = {}; obj.x = 3; console.log(obj.x); // Prints 3. console.log(obj); // Prints { x: 3 }. const key = "y"; obj[key] = 5; console.log(obj[key]); // Prints 5. console.log(obj); // Prints { x: 3, y: 5 }. 45. Thus, when used with Boolean values, const obj = {}; obj.x = 3; console.log(obj.x); // Prints 3. console.log(obj); // Prints { x: 3 }. const key = "y"; obj[key] = 5; console.log(obj[key]); // Prints 5. console.log(obj); // Prints { x: 3, y: 5 }. 39 returns operator operand operand operator 30 if both operands are true; otherwise, returns const obj = {}; obj.x = 3; console.log(obj.x); // Prints 3. console.log(obj); // Prints { x: 3 }. const key = "y"; obj[key] = 5; console.log(obj[key]); // Prints 5. console.log(obj); // Prints { x: 3, y: 5 }. 44.Logical OR (const obj = {}; obj.x = 3; console.log(obj.x); // Prints 3. console.log(obj); // Prints { x: 3 }. const key = "y"; obj[key] = 5; console.log(obj[key]); // Prints 5. console.log(obj); // Prints { x: 3, y: 5 }. 40)const obj = {}; obj.x = 3; console.log(obj.x); // Prints 3. console.log(obj); // Prints { x: 3 }. const key = "y"; obj[key] = 5; console.log(obj[key]); // Prints 5. console.log(obj); // Prints { x: 3, y: 5 }. 50Returns const obj = {}; obj.x = 3; console.log(obj.x); // Prints 3. console.log(obj); // Prints { x: 3 }. const key = "y"; obj[key] = 5; console.log(obj[key]); // Prints 5. console.log(obj); // Prints { x: 3, y: 5 }. 43 if it can be converted to operator operand operand operator 30; otherwise, returns const obj = {}; obj.x = 3; console.log(obj.x); // Prints 3. console.log(obj); // Prints { x: 3 }. const key = "y"; obj[key] = 5; console.log(obj[key]); // Prints 5. console.log(obj); // Prints { x: 3, y: 5 }. 45. Thus, when used with Boolean values, const obj = {}; obj.x = 3; console.log(obj.x); // Prints 3. console.log(obj); // Prints { x: 3 }. const key = "y"; obj[key] = 5; console.log(obj[key]); // Prints 5. console.log(obj); // Prints { x: 3, y: 5 }. 40 returns operator operand operand operator 30 if either operand is true; if both are false, returns const obj = {}; obj.x = 3; console.log(obj.x); // Prints 3. console.log(obj); // Prints { x: 3 }. const key = "y"; obj[key] = 5; console.log(obj[key]); // Prints 5. console.log(obj); // Prints { x: 3, y: 5 }. 44.Logical NOT (let x; const y = (x = f()); // Or equivalently: const y = x = f(); console.log(y); // Logs the return value of the assignment x = f(). console.log(x = f()); // Logs the return value directly. // An assignment expression can be nested in any place // where expressions are generally allowed, // such as array literals' elements or as function calls' arguments. console.log([ 0, x = f(), 0 ]); console.log(f(0, x = f(), 0)); 4)const obj = {}; obj.x = 3; console.log(obj.x); // Prints 3. console.log(obj); // Prints { x: 3 }. const key = "y"; obj[key] = 5; console.log(obj[key]); // Prints 5. console.log(obj); // Prints { x: 3, y: 5 }. 58Returns const obj = {}; obj.x = 3; console.log(obj.x); // Prints 3. console.log(obj); // Prints { x: 3 }. const key = "y"; obj[key] = 5; console.log(obj[key]); // Prints 5. console.log(obj); // Prints { x: 3, y: 5 }. 44 if its single operand that can be converted to operator operand operand operator 30; otherwise, returns operator operand operand operator 30.

Examples of expressions that can be converted to const obj = {}; obj.x = 3; console.log(obj.x); // Prints 3. console.log(obj); // Prints { x: 3 }. const key = "y"; obj[key] = 5; console.log(obj[key]); // Prints 5. console.log(obj); // Prints { x: 3, y: 5 }. 44 are those that evaluate to null, 0, NaN, the empty string (""), or undefined.

The following code shows examples of the const obj = {}; obj.x = 3; console.log(obj.x); // Prints 3. console.log(obj); // Prints { x: 3 }. const key = "y"; obj[key] = 5; console.log(obj[key]); // Prints 5. console.log(obj); // Prints { x: 3, y: 5 }. 39 (logical AND) operator.

operand1 operator operand2 4

The following code shows examples of the || (logical OR) operator.

operand1 operator operand2 5

The following code shows examples of the ! (logical NOT) operator.

operand1 operator operand2 6

Short-circuit evaluation

As logical expressions are evaluated left to right, they are tested for possible "short-circuit" evaluation using the following rules:

  • const obj = {}; obj.x = 3; console.log(obj.x); // Prints 3. console.log(obj); // Prints { x: 3 }. const key = "y"; obj[key] = 5; console.log(obj[key]); // Prints 5. console.log(obj); // Prints { x: 3, y: 5 }. 64 is short-circuit evaluated to false.
  • const obj = {}; obj.x = 3; console.log(obj.x); // Prints 3. console.log(obj); // Prints { x: 3 }. const key = "y"; obj[key] = 5; console.log(obj[key]); // Prints 5. console.log(obj); // Prints { x: 3, y: 5 }. 65 is short-circuit evaluated to true.

The rules of logic guarantee that these evaluations are always correct. Note that the anything part of the above expressions is not evaluated, so any side effects of doing so do not take effect.

Note that for the second case, in modern code you can use the Nullish coalescing operator (const obj = {}; obj.x = 3; console.log(obj.x); // Prints 3. console.log(obj); // Prints { x: 3 }. const key = "y"; obj[key] = 5; console.log(obj[key]); // Prints 5. console.log(obj); // Prints { x: 3, y: 5 }. 66) that works like const obj = {}; obj.x = 3; console.log(obj.x); // Prints 3. console.log(obj); // Prints { x: 3 }. const key = "y"; obj[key] = 5; console.log(obj[key]); // Prints 5. console.log(obj); // Prints { x: 3, y: 5 }. 40, but it only returns the second expression, when the first one is "nullish", i.e. operand1 operator operand2 12 or operand1 operator operand2 13. It is thus the better alternative to provide defaults, when values like const obj = {}; obj.x = 3; console.log(obj.x); // Prints 3. console.log(obj); // Prints { x: 3 }. const key = "y"; obj[key] = 5; console.log(obj[key]); // Prints 5. console.log(obj); // Prints { x: 3, y: 5 }. 70 or const obj = {}; obj.x = 3; console.log(obj.x); // Prints 3. console.log(obj); // Prints { x: 3 }. const key = "y"; obj[key] = 5; console.log(obj[key]); // Prints 5. console.log(obj); // Prints { x: 3, y: 5 }. 71 are valid values for the first expression, too.

BigInt operators

Most operators that can be used between numbers can be used between const obj = {}; obj.x = 3; console.log(obj.x); // Prints 3. console.log(obj); // Prints { x: 3 }. const key = "y"; obj[key] = 5; console.log(obj[key]); // Prints 5. console.log(obj); // Prints { x: 3, y: 5 }. 28 values as well.

operand1 operator operand2 7

One exception is unsigned right shift (const obj = {}; obj.x = 3; console.log(obj.x); // Prints 3. console.log(obj); // Prints { x: 3 }. const key = "y"; obj[key] = 5; console.log(obj[key]); // Prints 5. console.log(obj); // Prints { x: 3, y: 5 }. 37), which is not defined for BigInt values. This is because a BigInt does not have a fixed width, so technically it does not have a "highest bit".

operand1 operator operand2 8

BigInts and numbers are not mutually replaceable — you cannot mix them in calculations.

operand1 operator operand2 9

This is because BigInt is neither a subset nor a superset of numbers. BigInts have higher precision than numbers when representing large integers, but cannot represent decimals, so implicit conversion on either side might lose precision. Use explicit conversion to signal whether you wish the operation to be a number operation or a BigInt one.

operator operand operand operator 0

You can compare BigInts with numbers.

operator operand operand operator 1

String operators

In addition to the comparison operators, which can be used on string values, the concatenation operator (+) concatenates two string values together, returning another string that is the union of the two operand strings.

For example,

operator operand operand operator 2

The shorthand assignment operator const obj = {}; obj.x = 3; console.log(obj.x); // Prints 3. console.log(obj); // Prints { x: 3 }. const key = "y"; obj[key] = 5; console.log(obj[key]); // Prints 5. console.log(obj); // Prints { x: 3, y: 5 }. 74 can also be used to concatenate strings.

For example,

operator operand operand operator 3

Conditional (ternary) operator

The conditional operator is the only JavaScript operator that takes three operands. The operator can have one of two values based on a condition. The syntax is:

operator operand operand operator 4

If const obj = {}; obj.x = 3; console.log(obj.x); // Prints 3. console.log(obj); // Prints { x: 3 }. const key = "y"; obj[key] = 5; console.log(obj[key]); // Prints 5. console.log(obj); // Prints { x: 3, y: 5 }. 75 is true, the operator has the value of const obj = {}; obj.x = 3; console.log(obj.x); // Prints 3. console.log(obj); // Prints { x: 3 }. const key = "y"; obj[key] = 5; console.log(obj[key]); // Prints 5. console.log(obj); // Prints { x: 3, y: 5 }. 76. Otherwise it has the value of const obj = {}; obj.x = 3; console.log(obj.x); // Prints 3. console.log(obj); // Prints { x: 3 }. const key = "y"; obj[key] = 5; console.log(obj[key]); // Prints 5. console.log(obj); // Prints { x: 3, y: 5 }. 77. You can use the conditional operator anywhere you would use a standard operator.

For example,

operator operand operand operator 5

This statement assigns the value "adult" to the variable const obj = {}; obj.x = 3; console.log(obj.x); // Prints 3. console.log(obj); // Prints { x: 3 }. const key = "y"; obj[key] = 5; console.log(obj[key]); // Prints 5. console.log(obj); // Prints { x: 3, y: 5 }. 78 if const obj = {}; obj.x = 3; console.log(obj.x); // Prints 3. console.log(obj); // Prints { x: 3 }. const key = "y"; obj[key] = 5; console.log(obj[key]); // Prints 5. console.log(obj); // Prints { x: 3, y: 5 }. 79 is eighteen or more. Otherwise, it assigns the value "minor" to const obj = {}; obj.x = 3; console.log(obj.x); // Prints 3. console.log(obj); // Prints { x: 3 }. const key = "y"; obj[key] = 5; console.log(obj[key]); // Prints 5. console.log(obj); // Prints { x: 3, y: 5 }. 78.

Comma operator

The comma operator (const obj = {}; obj.x = 3; console.log(obj.x); // Prints 3. console.log(obj); // Prints { x: 3 }. const key = "y"; obj[key] = 5; console.log(obj[key]); // Prints 5. console.log(obj); // Prints { x: 3, y: 5 }. 81) evaluates both of its operands and returns the value of the last operand. This operator is primarily used inside a const obj = {}; obj.x = 3; console.log(obj.x); // Prints 3. console.log(obj); // Prints { x: 3 }. const key = "y"; obj[key] = 5; console.log(obj[key]); // Prints 5. console.log(obj); // Prints { x: 3, y: 5 }. 82 loop, to allow multiple variables to be updated each time through the loop. It is regarded bad style to use it elsewhere, when it is not necessary. Often two separate statements can and should be used instead.

For example, if const obj = {}; obj.x = 3; console.log(obj.x); // Prints 3. console.log(obj); // Prints { x: 3 }. const key = "y"; obj[key] = 5; console.log(obj[key]); // Prints 5. console.log(obj); // Prints { x: 3, y: 5 }. 02 is a 2-dimensional array with 10 elements on a side, the following code uses the comma operator to update two variables at once. The code prints the values of the diagonal elements in the array:

operator operand operand operator 6

Unary operators

A unary operation is an operation with only one operand.

delete

The const obj = {}; obj.x = 3; console.log(obj.x); // Prints 3. console.log(obj); // Prints { x: 3 }. const key = "y"; obj[key] = 5; console.log(obj[key]); // Prints 5. console.log(obj); // Prints { x: 3, y: 5 }. 84 operator deletes an object's property. The syntax is:

operator operand operand operator 7

where const obj = {}; obj.x = 3; console.log(obj.x); // Prints 3. console.log(obj); // Prints { x: 3 }. const key = "y"; obj[key] = 5; console.log(obj[key]); // Prints 5. console.log(obj); // Prints { x: 3, y: 5 }. 85 is the name of an object, const obj = {}; obj.x = 3; console.log(obj.x); // Prints 3. console.log(obj); // Prints { x: 3 }. const key = "y"; obj[key] = 5; console.log(obj[key]); // Prints 5. console.log(obj); // Prints { x: 3, y: 5 }. 86 is an existing property, and const obj = {}; obj.x = 3; console.log(obj.x); // Prints 3. console.log(obj); // Prints { x: 3 }. const key = "y"; obj[key] = 5; console.log(obj[key]); // Prints 5. console.log(obj); // Prints { x: 3, y: 5 }. 87 is a string or symbol referring to an existing property.

If the const obj = {}; obj.x = 3; console.log(obj.x); // Prints 3. console.log(obj); // Prints { x: 3 }. const key = "y"; obj[key] = 5; console.log(obj[key]); // Prints 5. console.log(obj); // Prints { x: 3, y: 5 }. 84 operator succeeds, it removes the property from the object. Trying to access it afterwards will yield operand1 operator operand2 13. The const obj = {}; obj.x = 3; console.log(obj.x); // Prints 3. console.log(obj); // Prints { x: 3 }. const key = "y"; obj[key] = 5; console.log(obj[key]); // Prints 5. console.log(obj); // Prints { x: 3, y: 5 }. 84 operator returns operator operand operand operator 30 if the operation is possible; it returns const obj = {}; obj.x = 3; console.log(obj.x); // Prints 3. console.log(obj); // Prints { x: 3 }. const key = "y"; obj[key] = 5; console.log(obj[key]); // Prints 5. console.log(obj); // Prints { x: 3, y: 5 }. 44 if the operation is not possible.

operator operand operand operator 8

Deleting array elements

Since arrays are just objects, it's technically possible to const obj = {}; obj.x = 3; console.log(obj.x); // Prints 3. console.log(obj); // Prints { x: 3 }. const key = "y"; obj[key] = 5; console.log(obj[key]); // Prints 5. console.log(obj); // Prints { x: 3, y: 5 }. 84 elements from them. This is however regarded as a bad practice, try to avoid it. When you delete an array property, the array length is not affected and other elements are not re-indexed. To achieve that behavior, it is much better to just overwrite the element with the value operand1 operator operand2 13. To actually manipulate the array, use the various array methods such as const obj = {}; obj.x = 3; console.log(obj.x); // Prints 3. console.log(obj); // Prints { x: 3 }. const key = "y"; obj[key] = 5; console.log(obj[key]); // Prints 5. console.log(obj); // Prints { x: 3, y: 5 }. 95.

typeof

The let x; const y = (x = f()); // Or equivalently: const y = x = f(); console.log(y); // Logs the return value of the assignment x = f(). console.log(x = f()); // Logs the return value directly. // An assignment expression can be nested in any place // where expressions are generally allowed, // such as array literals' elements or as function calls' arguments. console.log([ 0, x = f(), 0 ]); console.log(f(0, x = f(), 0)); 5 operator is used in either of the following ways:

operator operand operand operator 9

The let x; const y = (x = f()); // Or equivalently: const y = x = f(); console.log(y); // Logs the return value of the assignment x = f(). console.log(x = f()); // Logs the return value directly. // An assignment expression can be nested in any place // where expressions are generally allowed, // such as array literals' elements or as function calls' arguments. console.log([ 0, x = f(), 0 ]); console.log(f(0, x = f(), 0)); 5 operator returns a string indicating the type of the unevaluated operand. const obj = {}; obj.x = 3; console.log(obj.x); // Prints 3. console.log(obj); // Prints { x: 3 }. const key = "y"; obj[key] = 5; console.log(obj[key]); // Prints 5. console.log(obj); // Prints { x: 3, y: 5 }. 98 is the string, variable, keyword, or object for which the type is to be returned. The parentheses are optional.

Suppose you define the following variables:

const obj = {}; obj.x = 3; console.log(obj.x); // Prints 3. console.log(obj); // Prints { x: 3 }. const key = "y"; obj[key] = 5; console.log(obj[key]); // Prints 5. console.log(obj); // Prints { x: 3, y: 5 }. 0

The let x; const y = (x = f()); // Or equivalently: const y = x = f(); console.log(y); // Logs the return value of the assignment x = f(). console.log(x = f()); // Logs the return value directly. // An assignment expression can be nested in any place // where expressions are generally allowed, // such as array literals' elements or as function calls' arguments. console.log([ 0, x = f(), 0 ]); console.log(f(0, x = f(), 0)); 5 operator returns the following results for these variables:

const obj = {}; obj.x = 3; console.log(obj.x); // Prints 3. console.log(obj); // Prints { x: 3 }. const key = "y"; obj[key] = 5; console.log(obj[key]); // Prints 5. console.log(obj); // Prints { x: 3, y: 5 }. 1

For the keywords operator operand operand operator 30 and operand1 operator operand2 12, the let x; const y = (x = f()); // Or equivalently: const y = x = f(); console.log(y); // Logs the return value of the assignment x = f(). console.log(x = f()); // Logs the return value directly. // An assignment expression can be nested in any place // where expressions are generally allowed, // such as array literals' elements or as function calls' arguments. console.log([ 0, x = f(), 0 ]); console.log(f(0, x = f(), 0)); 5 operator returns the following results:

const obj = {}; obj.x = 3; console.log(obj.x); // Prints 3. console.log(obj); // Prints { x: 3 }. const key = "y"; obj[key] = 5; console.log(obj[key]); // Prints 5. console.log(obj); // Prints { x: 3, y: 5 }. 2

For a number or string, the let x; const y = (x = f()); // Or equivalently: const y = x = f(); console.log(y); // Logs the return value of the assignment x = f(). console.log(x = f()); // Logs the return value directly. // An assignment expression can be nested in any place // where expressions are generally allowed, // such as array literals' elements or as function calls' arguments. console.log([ 0, x = f(), 0 ]); console.log(f(0, x = f(), 0)); 5 operator returns the following results:

const obj = {}; obj.x = 3; console.log(obj.x); // Prints 3. console.log(obj); // Prints { x: 3 }. const key = "y"; obj[key] = 5; console.log(obj[key]); // Prints 5. console.log(obj); // Prints { x: 3, y: 5 }. 3

For property values, the let x; const y = (x = f()); // Or equivalently: const y = x = f(); console.log(y); // Logs the return value of the assignment x = f(). console.log(x = f()); // Logs the return value directly. // An assignment expression can be nested in any place // where expressions are generally allowed, // such as array literals' elements or as function calls' arguments. console.log([ 0, x = f(), 0 ]); console.log(f(0, x = f(), 0)); 5 operator returns the type of value the property contains:

const obj = {}; obj.x = 3; console.log(obj.x); // Prints 3. console.log(obj); // Prints { x: 3 }. const key = "y"; obj[key] = 5; console.log(obj[key]); // Prints 5. console.log(obj); // Prints { x: 3, y: 5 }. 4

For methods and functions, the let x; const y = (x = f()); // Or equivalently: const y = x = f(); console.log(y); // Logs the return value of the assignment x = f(). console.log(x = f()); // Logs the return value directly. // An assignment expression can be nested in any place // where expressions are generally allowed, // such as array literals' elements or as function calls' arguments. console.log([ 0, x = f(), 0 ]); console.log(f(0, x = f(), 0)); 5 operator returns results as follows:

const obj = {}; obj.x = 3; console.log(obj.x); // Prints 3. console.log(obj); // Prints { x: 3 }. const key = "y"; obj[key] = 5; console.log(obj[key]); // Prints 5. console.log(obj); // Prints { x: 3, y: 5 }. 5

For predefined objects, the let x; const y = (x = f()); // Or equivalently: const y = x = f(); console.log(y); // Logs the return value of the assignment x = f(). console.log(x = f()); // Logs the return value directly. // An assignment expression can be nested in any place // where expressions are generally allowed, // such as array literals' elements or as function calls' arguments. console.log([ 0, x = f(), 0 ]); console.log(f(0, x = f(), 0)); 5 operator returns results as follows:

const obj = {}; obj.x = 3; console.log(obj.x); // Prints 3. console.log(obj); // Prints { x: 3 }. const key = "y"; obj[key] = 5; console.log(obj[key]); // Prints 5. console.log(obj); // Prints { x: 3, y: 5 }. 6

void

The const val = 0; val.x = 3; console.log(val.x); // Prints undefined. console.log(val); // Prints 0. 07 operator is used in either of the following ways:

const obj = {}; obj.x = 3; console.log(obj.x); // Prints 3. console.log(obj); // Prints { x: 3 }. const key = "y"; obj[key] = 5; console.log(obj[key]); // Prints 5. console.log(obj); // Prints { x: 3, y: 5 }. 7

The const val = 0; val.x = 3; console.log(val.x); // Prints undefined. console.log(val); // Prints 0. 07 operator specifies an expression to be evaluated without returning a value. const val = 0; val.x = 3; console.log(val.x); // Prints undefined. console.log(val); // Prints 0. 09 is a JavaScript expression to evaluate. The parentheses surrounding the expression are optional, but it is good style to use them.

Relational operators

A relational operator compares its operands and returns a Boolean value based on whether the comparison is true.

in

The const val = 0; val.x = 3; console.log(val.x); // Prints undefined. console.log(val); // Prints 0. 10 operator returns operator operand operand operator 30 if the specified property is in the specified object. The syntax is:

const obj = {}; obj.x = 3; console.log(obj.x); // Prints 3. console.log(obj); // Prints { x: 3 }. const key = "y"; obj[key] = 5; console.log(obj[key]); // Prints 5. console.log(obj); // Prints { x: 3, y: 5 }. 8

where const val = 0; val.x = 3; console.log(val.x); // Prints undefined. console.log(val); // Prints 0. 12 is a string, numeric, or symbol expression representing a property name or array index, and const val = 0; val.x = 3; console.log(val.x); // Prints undefined. console.log(val); // Prints 0. 13 is the name of an object.

The following examples show some uses of the const val = 0; val.x = 3; console.log(val.x); // Prints undefined. console.log(val); // Prints 0. 10 operator.

const obj = {}; obj.x = 3; console.log(obj.x); // Prints 3. console.log(obj); // Prints { x: 3 }. const key = "y"; obj[key] = 5; console.log(obj[key]); // Prints 5. console.log(obj); // Prints { x: 3, y: 5 }. 9

instanceof

The const val = 0; val.x = 3; console.log(val.x); // Prints undefined. console.log(val); // Prints 0. 15 operator returns operator operand operand operator 30 if the specified object is of the specified object type. The syntax is:

const val = 0; val.x = 3; console.log(val.x); // Prints undefined. console.log(val); // Prints 0. 0

where const val = 0; val.x = 3; console.log(val.x); // Prints undefined. console.log(val); // Prints 0. 13 is the name of the object to compare to const val = 0; val.x = 3; console.log(val.x); // Prints undefined. console.log(val); // Prints 0. 18, and const val = 0; val.x = 3; console.log(val.x); // Prints undefined. console.log(val); // Prints 0. 18 is an object type, such as const val = 0; val.x = 3; console.log(val.x); // Prints undefined. console.log(val); // Prints 0. 20 or const val = 0; val.x = 3; console.log(val.x); // Prints undefined. console.log(val); // Prints 0. 21.

Use const val = 0; val.x = 3; console.log(val.x); // Prints undefined. console.log(val); // Prints 0. 15 when you need to confirm the type of an object at runtime. For example, when catching exceptions, you can branch to different exception-handling code depending on the type of exception thrown.

For example, the following code uses const val = 0; val.x = 3; console.log(val.x); // Prints undefined. console.log(val); // Prints 0. 15 to determine whether const val = 0; val.x = 3; console.log(val.x); // Prints undefined. console.log(val); // Prints 0. 24 is a const val = 0; val.x = 3; console.log(val.x); // Prints undefined. console.log(val); // Prints 0. 20 object. Because const val = 0; val.x = 3; console.log(val.x); // Prints undefined. console.log(val); // Prints 0. 24 is a const val = 0; val.x = 3; console.log(val.x); // Prints undefined. console.log(val); // Prints 0. 20 object, the statements in the const val = 0; val.x = 3; console.log(val.x); // Prints undefined. console.log(val); // Prints 0. 28 statement execute.

const val = 0; val.x = 3; console.log(val.x); // Prints undefined. console.log(val); // Prints 0. 1

Basic expressions

All operators eventually operate on one or more basic expressions. These basic expressions include identifiers and literals, but there are a few other kinds as well. They are briefly introduced below, and their semantics are described in detail in their respective reference sections.

this

Use the const val = 0; val.x = 3; console.log(val.x); // Prints undefined. console.log(val); // Prints 0. 29 keyword to refer to the current object. In general, const val = 0; val.x = 3; console.log(val.x); // Prints undefined. console.log(val); // Prints 0. 29 refers to the calling object in a method. Use const val = 0; val.x = 3; console.log(val.x); // Prints undefined. console.log(val); // Prints 0. 29 either with the dot or the bracket notation:

const val = 0; val.x = 3; console.log(val.x); // Prints undefined. console.log(val); // Prints 0. 2

Suppose a function called const val = 0; val.x = 3; console.log(val.x); // Prints undefined. console.log(val); // Prints 0. 32 validates an object's const val = 0; val.x = 3; console.log(val.x); // Prints undefined. console.log(val); // Prints 0. 33 property, given the object and the high and low values:

const val = 0; val.x = 3; console.log(val.x); // Prints undefined. console.log(val); // Prints 0. 3

You could call const val = 0; val.x = 3; console.log(val.x); // Prints undefined. console.log(val); // Prints 0. 32 in each form element's const val = 0; val.x = 3; console.log(val.x); // Prints undefined. console.log(val); // Prints 0. 35 event handler, using const val = 0; val.x = 3; console.log(val.x); // Prints undefined. console.log(val); // Prints 0. 29 to pass it to the form element, as in the following example:

const val = 0; val.x = 3; console.log(val.x); // Prints undefined. console.log(val); // Prints 0. 4

Grouping operator

The grouping operator const val = 0; val.x = 3; console.log(val.x); // Prints undefined. console.log(val); // Prints 0. 37 controls the precedence of evaluation in expressions. For example, you can override multiplication and division first, then addition and subtraction to evaluate addition first.

const val = 0; val.x = 3; console.log(val.x); // Prints undefined. console.log(val); // Prints 0. 5

new

You can use the const val = 0; val.x = 3; console.log(val.x); // Prints undefined. console.log(val); // Prints 0. 38 operator to create an instance of a user-defined object type or of one of the built-in object types. Use const val = 0; val.x = 3; console.log(val.x); // Prints undefined. console.log(val); // Prints 0. 38 as follows:

const val = 0; val.x = 3; console.log(val.x); // Prints undefined. console.log(val); // Prints 0. 6

super

The const val = 0; val.x = 3; console.log(val.x); // Prints undefined. console.log(val); // Prints 0. 40 keyword is used to call functions on an object's parent. It is useful with classes to call the parent constructor, for example.

Who needs a deemed export license?

A license or other authorization is necessary for “deemed-export” when: There is an access to controlled “technology” or “source code”; “Technology”: information released is necessary for the “development”, “production”, or “use” (i.e., all six elements of “use” will be released) of a product.

What are examples of deemed export?

This is what is commonly known as the “deemed export” rule. Example: The transfer of infrared camera technology to a Chinese national in the U.S. may be regulated as if the transfer of the technology was made to the Chinese national in China.

What does Eccn EAR99 mean?

What is EAR99? Items not designated under the control of another federal agency or listed on the Commodity Control List (CCL) are classified as EAR99 (Export Administration Regulations). EAR99 items generally are low-technology consumer goods not requiring a license, however there are some exceptions.

Is 5A992 dual use?

5A992 “Information security” systems, equipment and components, described by entry 5A002 of Annex I of the Dual-Use Regulation and classified under Note 3 to Category 5, Part 2 of Annex I of the Dual-Use Regulation (Cryptography Note).

Toplist

Neuester Beitrag

Stichworte