NextGen Knowledge Center

Assignment Operators

These operators are used to assign values to JavaScript variables. In this table, the x-variable has a value of 10, and the y-variable has a value of 5 to explain the JavaScript Assignment operators:

OperatorDescriptionExampleSame AsResult
=assignx=yx=y (5)x=5
+=add and assignx+=yx=x+y (10+5)x=15
-=subtract and assignx-=yx=x-y (10-5)x=5
*=multiply and assignx*=yx=x*y (10*5)x=50
/=divide and assignx/=yx=x/y (10/5)x=2
%=modulus (division remainder) and assignx%=yx=x%y (remainder is 0 for the equation 10/2)x=0