本文共 818 字,大约阅读时间需要 2 分钟。
javascript运算符
Use the assignment operator =
to assign a value to a variable:
使用赋值运算符=
为变量赋值:
const a = 2let b = 2var c = 2
This operator has several shortcuts for all the arithmetic operators which let you assign to the first operand the result of the operations with the second operand.
该运算符为所有算术运算符提供了几种快捷方式,您可以将第二个操作数的运算结果分配给第一个操作数。
They are:
他们是:
+=
: addition assignment
+=
:附加分配
-=
: subtraction assignment
-=
:减法分配
*=
: multiplication assignment
*=
:乘法分配
/=
: division assignment
/=
:部门分配
%=
: remainder assignment
%=
:剩余分配
**=
: exponentiation assignment
**=
:求幂分配
Examples:
例子:
let a = 0a += 5 //a === 5a -= 2 //a === 3a *= 2 //a === 6a /= 2 //a === 3a %= 2 //a === 1
To be clear, the above operations are executed one after another, so
a
at the end is 1, not 0需要明确的是,上面的操作被执行的一个接一个,所以
a
在端部为1,而不是0
翻译自:
javascript运算符
转载地址:http://laqgb.baihongyu.com/