Addition (+)
The addition operator (+
) produces the sum of numeric operands or string
concatenation.
Syntax
x + y
Examples
Numeric addition
// Number + Number -> addition
1 + 2 // 3
// Boolean + Number -> addition
true + 1 // 2
// Boolean + Boolean -> addition
false + false // 0
String concatenation
// String + String -> concatenation
'foo' + 'bar' // "foobar"
// Number + String -> concatenation
5 + 'foo' // "5foo"
// String + Boolean -> concatenation
'foo' + false // "foofalse"
Specifications
Specification |
---|
ECMAScript Language Specification # sec-addition-operator-plus |
Browser compatibility
Report problems with this compatibility data on GitHubdesktop | mobile | server | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Addition ( + ) | ChromeFull support1 | EdgeFull support12 | FirefoxFull support1 | Internet ExplorerFull support3 | OperaFull support3 | SafariFull support1 | WebView AndroidFull support1 | Chrome AndroidFull support18 | Firefox for AndroidFull support4 | Opera AndroidFull support10.1 | Safari on iOSFull support1 | Samsung InternetFull support1.0 | DenoFull support1.0 | Node.jsFull support0.10.0 |
Legend
- 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.