Curriculum
Course: JavaScript Basic
Login

Curriculum

JavaScript Basic

JSHome

0/216
Text lesson

The Assignment Operator

In JavaScript, the equal sign (=) functions as an “assignment” operator, rather than as an “equal to” operator, which is distinct from algebra.

The following expression does not hold meaning in algebra:

x = x + 5

In JavaScript, however, the expression is entirely logical: it assigns the result of x + 5 to x.

(This operation calculates the value of x + 5 and assigns the outcome to x. Consequently, the value of x increases by 5.)

Note

In JavaScript, the “equal to” operator is represented as ==.