ëë¨¸ì§ í ë¹ (%=)
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 = 3;
console.log((a %= 2));
// Expected output: 1
console.log((a %= 0));
// Expected output: NaN
console.log((a %= "hello"));
// Expected output: NaN
구문
js
x %= y; // x = x % y
ìì
>ëë¨¸ì§ í ë¹ ì¬ì©í기
js
// bar = 5
// ìì ê°ì ë³ì를 ê°ì í ë
bar %= 2; // 1
bar %= "foo"; // NaN
bar %= 0; // NaN
ëª ì¸
| Specification |
|---|
| ECMAScript® 2027 Language Specification> # sec-assignment-operators> |