Fandom

JavaScript Wiki

Assignment operators

87pages on
this wiki
Add New Page
Talk0 Share

Each entry except the first (and second) is derived as an arithmetic operator combined with the "equals" sign. All assignment operators evaluate to the assigned value.

=Edit

The primary assignment operator, and by far the most important among all the operators, is the lone "equals" sign (=). Syntactically, the "variable" is to the left of the = and the "value" is to the right. Whatever a variable holds before assignment, it is replaced by the value.

variable = value;

+=Edit

"Plus-equals" adds or concatenates the right value to the left variable's value and assigns the result to the left variable.

-=Edit

"Minus-equals" subtracts the right value from the value of the left variable and assigns the result to the left variable.

*=Edit

"Times-equals" multiplies the value of the left variable to the right value and assigns the result to the left variable.

/=Edit

"Over-equals" divides the value of the left variable by the right value and assigns the result to the left variable.

%=Edit

"Percent-equals" finds the remainder of the corresponding division and assigns the result to the left variable.

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.