Addition (+)
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.
L'opérateur d'addition (+
) produit la somme de deux opérandes numériques ou la concaténation de deux chaînes de caractères.
Exemple interactif
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"
Syntaxe
js
Opérateur: x + y;
Exemples
Addition numérique
js
// Number + Number -> addition
1 + 2; // 3
// Boolean + Number -> addition
true + 1; // 2
// Boolean + Boolean -> addition
false + false; // 0
Concaténation de chaînes de caractères
js
// String + String -> concatenation
"toto" + "truc"; // "tototruc"
// Number + String -> concatenation
5 + "toto"; // "5toto"
// String + Boolean -> concatenation
"toto" + false; // "totofalse"
Spécifications
Specification |
---|
ECMAScript® 2025 Language Specification # sec-addition-operator-plus |
Compatibilité des navigateurs
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.