할당 연산자 (=)
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.
Please take two minutes to fill out our short survey.
할당(=
) 연산자는 변수에 값을 대입하는 데 사용됩니다. 할당 연산은 할당된 값으로 평가됩니다. 할당 연산자를
연결하여 사용하면 단일 값을 여러 변수에 할당할 수 있습니다.
시도해 보기
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® 2026 Language Specification # sec-assignment-operators |