ê°ì ì°ì°ì (--)
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ì.
ê°ì(--) ì°ì°ì ë í¼ì°ì°ì를 ê°ì(1ì ëº)ìí¤ê³ ì°ì°ìì ìì¹ì ë°ë¼ ê°ìí기 ì ì´ë íì ê°ì ë°íí©ëë¤.
ìëí´ ë³´ê¸°
let x = 3;
const y = x--;
console.log(`x:${x}, y:${y}`);
// Expected output: "x:2, y:3"
let a = 3;
const b = --a;
console.log(`a:${a}, b:${b}`);
// Expected output: "a:2, b:2"
구문
x--
--x
ì¤ëª
ë§ì½ í¼ì°ì°ì ë¤ì ì°ì°ì를 ë¶ì¬ì ì¬ì©íë¤ë©´ (ì를 ë¤ì´ x--) ê°ì ì°ì°ìë ì를 ê°ììí¤ê³ ê°ìí기 ì ê°ì ë°íí©ëë¤.
ë§ì½ í¼ì°ì°ì ìì ì°ì°ì를 ë¶ì¬ì ì¬ì©íë¤ë©´(ì를 ë¤ì´ --x) ê°ì ì°ì°ìë ì를 ê°ììí¤ê³ ê°ì í ê°ì ë°íí©ëë¤.
ê°ì ì°ì°ìë ì°¸ì¡°ì¸ í¼ì°ì°ì(ë³ì ë° ê°ì²´ ìì±, ë¤ì ë§í´ ì í¨í
í ë¹ ëììë§ ì ì©í ì ììµëë¤.
--x ìì²´ë ì°¸ì¡°ê° ìë ê°ì¼ë¡ íê°ë기 ë문ì ì¬ë¬ ê°ì ì°ì°ì를 ì°ìì ì¼ë¡ ì¬ì©í ì ììµëë¤.
--(--x); // SyntaxError: Invalid left-hand side expression in prefix operation
ìì
>íì ê°ì
let x = 3;
const y = x--;
// x = 2
// y = 3
ì ì ê°ì
let x = 3;
const y = --x;
// x = 2
// y = 2
ëª ì¸
| Specification |
|---|
| ECMAScript® 2027 Language Specification> # sec-postfix-decrement-operator> |