加算演算子 (+
) は、数値オペランドまたは文字列連結の合計を生成します。
The source for this interactive example is stored in a GitHub repository. If you'd like to contribute to the interactive examples project, please clone https://github.com/mdn/interactive-examples and send us a pull request.
構文
Operator: x + y
例
数値加算
// 数値 + 数値 -> 加算
1 + 2 // 3
// ブール値 + 数値 -> 加算
true + 1 // 2
// ブール値 + ブール値 -> 加算
false + false // 0
文字列連結
// 文字列 + 文字列 -> 連結
'foo' + 'bar' // "foobar"
// 数値 + 文字列 -> 連結
5 + 'foo' // "5foo"
// 文字列 + ブール値 -> 連結
'foo' + false // "foofalse"
仕様
ブラウザーの互換性
BCD tables only load in the browser
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.