您正位于 MDN Web 文档的可编辑版本

以 MDN Web 文档用户身份查看: https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Operators/Assignment

这篇翻译不完整。请帮忙从英语翻译这篇文章

简单赋值操作符(=)用于为变量赋值。赋值表达式本身的值为其完成后被赋值的变量的值。为了给多个变量赋一个值,可以链式使用赋值操作符。

语法

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

浏览器支持

Update compatibility data on GitHub
DesktopMobileServer
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidFirefox for AndroidOpera for AndroidSafari on iOSSamsung InternetNode.js
Assignment (x = y)Chrome Full support 1Edge Full support 12Firefox Full support 1IE Full support 3Opera Full support 3Safari Full support 1WebView Android Full support 1Chrome Android Full support 18Firefox Android Full support 4Opera Android Full support 10.1Safari iOS Full support 1Samsung Internet Android Full support 1.0nodejs Full support 0.1.100

Legend

Full support  
Full support

相关链接

文档标签和贡献者

此页面的贡献者: longfangsong, hellorayza, yemao, Linuocc
最后编辑者: longfangsong,