JS: Assignment Operators

By Xah Lee. Date: . Last updated: .

Assignment Operators

var = val
assign val to var, and return val 〔see let Declaration
let zz;
console.log(((zz = 3) + 1) === 4);

Increment / Decrement Assignment

++x
same as x=x+1 (return new value)
--x
same as x=x-1 (return new value)
x++
like x=x+1 but return old value
x--
like x=x-1 but return old value

Compound Assignment Operators

x += y
same as x = x + y
x -= y
same as x = x - y
x *= y
same as x = x * y
x /= y
same as x = x / y
x %= y
same as x = x % y
x **= y
same as x = x ** y

Logical Assignment Operators

JavaScript. Operators

JavaScript. Number