| [ Web Proxy ] |
| Viewing: https://developer.mozilla.org/ja/docs/Web/JavaScript/Reference/Operators/Addition_assignment | [Back] [Original] |
Get to know MDN better
let a = 2;
let b = "hello";
console.log((a += 3)); //
// : 5
console.log((b += " world")); //
// : "hello world"
x += y
x += y x = x + y x
let bar = 5;
bar += 2; // 7
let baz = true;
baz += 1; // 2
baz += false; // 2
let x = 1n;
x += 2n; // 3n
x += 1; // TypeError: Cannot mix BigInt and other types, use explicit conversions
let foo = "foo";
foo += false; // "foofalse"
foo += "bar"; // "foofalsebar"
let bar = 5;
bar += "foo"; // "5foo"
| ECMAScript 2027 LanguageSpecification # sec-assignment-operators |
| Web Proxy Viewer | New URL | Original Page |