할당 연산자 (=)
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.
할당(=
) 연산자는 변수에 값을 대입하는 데 사용됩니다. 할당 연산은 할당된 값으로 평가됩니다. 할당 연산자를
연결하여 사용하면 단일 값을 여러 변수에 할당할 수 있습니다.
시도해보기
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
구문
js
x = y
예제
간단한 대입과 연결하여 사용
js
let x = 5;
let y = 10;
let z = 25;
x = y; // x 는 10입니다.
x = y = z; // x, y, z 는 모두 25입니다.
명세
Specification |
---|
ECMAScript® 2025 Language Specification # sec-assignment-operators |
브라우저 호환성
Report problems with this compatibility data on GitHubdesktop | mobile | server | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Assignment ( x = y ) |
Legend
Tip: you can click/tap on a cell for more information.
- Full support
- Full support
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.