blob: 0bb3edc900524319ebf27859d8cd807883e57269 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
|
---
title: 加算 (+)
slug: Web/JavaScript/Reference/Operators/Addition
tags:
- JavaScript
- 言語機能
- 演算子
- Reference
browser-compat: javascript.operators.addition
translation_of: Web/JavaScript/Reference/Operators/Addition
---
{{jsSidebar("Operators")}}
加算演算子 (`+`) は、数値オペランドの合計または文字列の連結を生成します。
{{EmbedInteractiveExample("pages/js/expressions-addition.html")}}
## 構文
```js
x + y
```
## 例
### 数値の加算
```js
// 数値 + 数値 -> 加算
1 + 2 // 3
// 論理値 + 数値 -> 加算
true + 1 // 2
// 論理値 + 論理値 -> 加算
false + false // 0
```
### 文字列の連結
```js
// 文字列 + 文字列 -> 連結
'foo' + 'bar' // "foobar"
// 数値 + 文字列 -> 連結
5 + 'foo' // "5foo"
// 文字列 + 論理値 -> 連結
'foo' + false // "foofalse"
```
## 仕様書
{{Specifications}}
## ブラウザーの互換性
{{Compat}}
## 関連情報
- [減算演算子](/ja/docs/Web/JavaScript/Reference/Operators/Subtraction)
- [除算演算子](/ja/docs/Web/JavaScript/Reference/Operators/Division)
- [乗算演算子](/ja/docs/Web/JavaScript/Reference/Operators/Multiplication)
- [剰余演算子](/ja/docs/Web/JavaScript/Reference/Operators/Remainder)
- [べき乗演算子](/ja/docs/Web/JavaScript/Reference/Operators/Exponentiation)
- [インクリメント演算子](/ja/docs/Web/JavaScript/Reference/Operators/Increment)
- [デクリメント演算子](/ja/docs/Web/JavaScript/Reference/Operators/Decrement)
- [単項マイナス演算子](/ja/docs/Web/JavaScript/Reference/Operators/Unary_negation)
- [単項プラス演算子](/ja/docs/Web/JavaScript/Reference/Operators/Unary_plus)
|