TIL14 - JS - Mathematical Assignment Operators

Peter D Lee·2020년 8월 26일
0

JavaScript

목록 보기
3/19

1. Mathematical Assignment Operators

  • +=
  • -=
  • *=
  • /=

These assignment operators update and assign with a single operator

ex)

let x = 10;
x += 2;
console.log(x);
// Prints 12.

*In the above example, the initial variable x with value 10 is added by 2 and this new value is assigned as the updated value for the variable x

2. Increment/Decrement Operators

  • ++
  • --

These work similarly to the 4 mathematical assignment operators
The variable value is increased by 1 or decreased by 1 and this is assgined as the new value

ex)

let x = 10;
x ++;
console.log(x);
// Prints 11

0개의 댓글