[ Web Proxy ]
URL:
Viewing: https://developer.mozilla.org/ja/docs/Web/JavaScript/Reference/Operators/Addition_assignment [Back]  [Original]

(+=) - JavaScript | MDN

MDN Web Docs

View in English Always switch to English

(+=)

Baseline

20157

(+=) 2

let a = 2;
let b = "hello";

console.log((a += 3)); // 
// : 5

console.log((b += " world")); // 
// : "hello world"

js
x += y

x += y x = x + y x

js
let bar = 5;
bar += 2; // 7

js
let baz = true;
baz += 1; // 2
baz += false; // 2

js
let x = 1n;
x += 2n; // 3n

x += 1; // TypeError: Cannot mix BigInt and other types, use explicit conversions

js
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