Which operator assigns a value to a variable?

The story behind the answer

The JavaScript operator that assigns a value to a variable is `=`.

The single equals sign is the basic assignment operator. In an expression such as `let score = 10`, it evaluates the value on the right and stores that value in the variable on the left. Assignment is an operation, so it can itself produce a value and may appear in larger expressions, although separate statements are usually clearer.

JavaScript also provides compound assignment operators, including `+=`, `-=`, `*=`, `/=`, and `%=`. These combine an operation with assignment: `score += 5` is broadly equivalent to `score = score + 5`. Modern JavaScript additionally includes operators such as `**=` for exponentiation assignment and logical assignment forms such as `||=`.

The most common confusion is between assignment and comparison. `==` performs loose equality comparison, while `===` performs strict equality comparison without the same type coercion. `!=` tests loose inequality. Thus `x = 3` changes or initializes a variable, whereas `x === 3` asks whether its current value and type match 3.

Source: Wikipedia · fact-checked Aug. 2026

Add question to a list

Choose a list to keep this question in: