A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Operators/Assignment below:

赋值(=) - JavaScript | MDN

赋值(=)

Baseline Widely available

简单赋值运算符(=)用于给变量赋值。赋值表达式本身的值为要赋值的值。为了将一个值赋给多个变量,可以链式使用赋值运算符。

尝试一下
let x = 2;
const y = 3;

console.log(x);
// Expected output: 2

console.log((x = y + 1)); // 3 + 1
// Expected output: 4

console.log((x = x * y)); // 4 * 3
// Expected output: 12
语法 示例 简单赋值和链式赋值
// 假设已经存在以下变量
//  x = 5
//  y = 10
//  z = 25

x = y; // x 为 10
x = y = z; // x, y 都为 25
规范 浏览器兼容性 参见

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4