赋值运算符(=)
简单赋值操作符(=)用于为变量赋值。赋值表达式本身的值为其完成后被赋值的变量的值。为了给多个变量赋一个值,可以链式使用赋值操作符。
The source for this interactive example is stored in a GitHub repository. If you'd like to contribute to the interactive examples project, please clone https://github.com/mdn/interactive-examples and send us a pull request.
语法
Operator: x = y
示例
简单赋值和链式赋值
// 假设已经存在以下变量
// x = 5
// y = 10
// z = 25
x = y // x 为 10
x = y = z // x, y 都为 25
规范
Specification |
---|
ECMAScript (ECMA-262) Assignment operators |
浏览器支持
BCD tables only load in the browser