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

(+=) - JavaScript | MDN

This page was translated from English by the community. Learn more and join the MDN Web Docs community.

View in English Always switch to English

(+=)

Baseline Widely available

This feature is well established and works across many devices and browser versions. Its been available across browsers since 2015 7.

(+=) . , .

In this article

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

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

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

js
x += y; // x = x + y

js
// foo = 'foo'
// bar = 5
// baz = true
//     

// Number + Number -> 
bar += 2; // 7

// Boolean + Number -> 
baz += 1; // 2

// Boolean + Boolean -> 
baz += false; // 1

// Number + String -> 
bar += "foo"; // "5foo"

// String + Boolean -> 
foo += false; // "foofalse"

// String + String -> 
foo += "bar"; // "foobar"

Specification
ECMAScript 2027 LanguageSpecification
# sec-assignment-operators


Web Proxy Viewer  |  New URL  |  Original Page