CKTIS / JavaScript
Assignment operator (=)
The = operator stores an expression's value in a variable or object property and returns the assigned value. It neither compares values nor declares variables.
Version: ECMAScript and Web APIs; exact feature edition and browser support reviewed per entry; Node 24 in repository does not prove browser API support
Syntax
target = expressionThe = operator assigns the right-hand value to the left-hand target. For ordinary assignment, the target is evaluated first, the right-hand expression next, and the write happens last. The target can be a variable or an object property; destructuring patterns are also supported.
Assignment is an expression: after a successful write, it returns the assigned value. It associates right-to-left, so saved = count = 7 means saved = (count = 7). This does not mean that all operands are evaluated right-to-left.
Do not confuse = with the comparison operators == and ===. In the declaration let count = 0, = introduces an initializer; the declaration itself is not an assignment expression. Reassigning a const variable throws TypeError, but its properties may remain mutable, as with box.value in the example.
Declare variables before assignment: writing to an undeclared name in strict mode throws ReferenceError. Assigning an object does not copy it — both variables can refer to the same object.
Examples
"use strict";
let count = 0;
let saved = 0;
const box = { value: 0 };
saved = count = 7;
box.value = count + 1;
console.log(count);
console.log(saved);
console.log(box.value);Result
7 7 8
The displayed code and declared result were verified in an isolated environment using the method recorded in the verification evidence for this exact version.