This page was translated from English by the community. Learn more and join the MDN Web Docs community.

View in English Always switch to English

๋นผ๊ธฐ ํ• ๋‹น (-=)

Baseline Widely available

This feature is well established and works across many devices and browser versions. Itโ€™s been available across browsers since โจ2015๋…„ 7์›”โฉ.

๋นผ๊ธฐ ํ• ๋‹น ์—ฐ์‚ฐ์ž(-=)๋Š” ์˜ค๋ฅธ์ชฝ ํ”ผ์—ฐ์‚ฐ์ž์˜ ๊ฐ’์„ ๋ณ€์ˆ˜์—์„œ ๋บ€ ๊ฒฐ๊ณผ๋ฅผ ๋‹ค์‹œ ๋ณ€์ˆ˜์— ํ• ๋‹นํ•ฉ๋‹ˆ๋‹ค.

์‹œ๋„ํ•ด ๋ณด๊ธฐ

let a = 2;

console.log((a -= 3));
// Expected output: -1

console.log((a -= "Hello"));
// Expected output: NaN

๊ตฌ๋ฌธ

js
x -= y; // x = x - y

์˜ˆ์ œ

๋นผ๊ธฐ ํ• ๋‹น ์‚ฌ์šฉํ•˜๊ธฐ

js
// bar = 5
// ์œ„์™€ ๊ฐ™์€ ๋ณ€์ˆ˜๋ฅผ ๊ฐ€์ •ํ•  ๋•Œ

bar -= 2; // 3
bar -= "foo"; // NaN

๋ช…์„ธ

Specification
ECMAScriptยฎ 2026 Language Specification
# sec-assignment-operators

๋ธŒ๋ผ์šฐ์ € ํ˜ธํ™˜์„ฑ

๊ฐ™์ด ๋ณด๊ธฐ