Assignment operator

Assignment operator

-Simple assignment operation, directly assign the right side of the equal sign to the left side of the equal sign (variables, object properties, array values)

-Complex assignment 1: first perform the calculation operation on the right side, and then assign the value to the left side

-Complex assignment 2: Use += -= *= /= %= for assignment

-Assignment statements also have return values, which return the value on the right side of the equal sign

-Can also assign values ​​continuously

var a=1;
var b=1+1;

//递增
a=a+1;
//可以简写为:
a+=3;
console.log(a);//5

//减法运算
var b=3;
b-=2;
console.log(b);//1

//除法运算
var c=8;
c/=2;
console.log(c);//

//乘法运算
var d=3;
d*=2;
console.log(d);//

//取余运算
var e=5;
e%=2;
consoe.log(e);//1

Guess you like

Origin blog.csdn.net/qq_42592823/article/details/115204779