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