Сложение (+)
Baseline Widely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.
Оператор сложения (+) создаёт сумму числовых операндов или конкатенацию строк.
Интерактивный пример
console.log(2 + 2);
// Expected output: 4
console.log(2 + true);
// Expected output: 3
console.log("hello " + "everyone");
// Expected output: "hello everyone"
console.log(2001 + ": A Space Odyssey");
// Expected output: "2001: A Space Odyssey"
Синтаксис
js
x + y;
Примеры
Сложение чисел
js
// Number + Number -> addition
1 + 2; // 3
// Boolean + Number -> addition
true + 1; // 2
// Boolean + Boolean -> addition
false + false; // 0
Сложение строк
js
// String + String -> concatenation
"foo" + "bar"; // "foobar"
// Number + String -> concatenation
5 + "foo"; // "5foo"
// String + Boolean -> concatenation
"foo" + false; // "foofalse"
Спецификации
Specification |
---|
ECMAScript® 2025 Language Specification # sec-addition-operator-plus |
Совместимость с браузерами
Report problems with this compatibility data on GitHubdesktop | mobile | server | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Addition ( + ) |
Legend
Tip: you can click/tap on a cell for more information.
- Full support
- Full support
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.