赋值(=)
Baseline Widely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.
简单赋值运算符(=
)用于给变量赋值。赋值表达式本身的值为要赋值的值。为了将一个值赋给多个变量,可以链式使用赋值运算符。
尝试一下
语法
js
x = y
示例
简单赋值和链式赋值
js
// 假设已经存在以下变量
// x = 5
// y = 10
// z = 25
x = y; // x 为 10
x = y = z; // x, y 都为 25
规范
Specification |
---|
ECMAScript Language Specification # sec-assignment-operators |
浏览器兼容性
BCD tables only load in the browser