From fb129cca2082cbc57f93025a2e46797e5fb4a0f3 Mon Sep 17 00:00:00 2001 From: Masahiro FUJIMOTO Date: Sun, 26 Sep 2021 01:32:15 +0900 Subject: 代入演算子の文書を更新 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 2021/07/21 時点の英語版に更新 --- .../operators/addition_assignment/index.md | 59 +++++++++------------- 1 file changed, 23 insertions(+), 36 deletions(-) (limited to 'files/ja/web/javascript/reference/operators/addition_assignment') diff --git a/files/ja/web/javascript/reference/operators/addition_assignment/index.md b/files/ja/web/javascript/reference/operators/addition_assignment/index.md index 3a3645d2ab..fabea99ceb 100644 --- a/files/ja/web/javascript/reference/operators/addition_assignment/index.md +++ b/files/ja/web/javascript/reference/operators/addition_assignment/index.md @@ -7,72 +7,59 @@ tags: - 言語機能 - 演算子 - Reference +browser-compat: javascript.operators.addition_assignment translation_of: Web/JavaScript/Reference/Operators/Addition_assignment --- {{jsSidebar("Operators")}} -加算代入演算子 (`+=`) は、右辺のオペランドの値を変数に加算し、結果を変数に代入します。 2つのオペランドの型は、加算代入演算子の動作を決定します。加算もしくは連結が可能です。 +加算代入演算子 (`+=`) は、右オペランドの値を変数に加算し、結果を変数に代入します。2 つのオペランドの型が加算代入演算子の動作を決定します。加算もしくは連結が可能です。 {{EmbedInteractiveExample("pages/js/expressions-addition-assignment.html")}} -
- - - ## 構文 -
Operator: x += y
-Meaning:  x  = x + y
+```js +x += y // x = x + y +``` ## 例 -

加算代入の使用

+### 加算代入の使用 -
// 以下の変数を想定
+```js
+// 以下の変数を想定
 //  foo = 'foo'
 //  bar = 5
 //  baz = true
 
-// 数値 + 数値 -> 加算
+// 数値 + 数値 -> 加算
 bar += 2 // 7
 
-// ブール値 + 数値 -> 加算
+// 論理値 + 数値 -> 加算
 baz += 1 // 2
 
-// ブール値 + ブール値 -> 加算
+// 論理値 + 論理値 -> 加算
 baz += false // 1
 
-// 数値 + 文字列 -> 連結
+// 数値 + 文字列 -> 連結
 bar += 'foo' // "5foo"
 
-// 文字列 + ブール値 -> 連結
+// 文字列 + 論理値 -> 連結
 foo += false // "foofalse"
 
-// 文字列 + 文字列 -> 連結
-foo += 'bar' // "foobar"
- -

仕様

- - - - - - - - - - -
仕様
{{SpecName('ESDraft', '#sec-assignment-operators', 'Assignment operators')}}
+// 文字列 + 文字列 -> 連結 +foo += 'bar' // "foobar" +``` -

ブラウザーの互換性

+## 仕様書 +{{Specifications}} +## ブラウザーの互換性 -{{Compat("javascript.operators.addition_assignment")}} +{{Compat}} -

関連項目

+## 関連情報 - +- [JavaScript ガイドの代入演算子](/ja/docs/Web/JavaScript/Guide/Expressions_and_Operators#assignment) +- [加算演算子](/ja/docs/Web/JavaScript/Reference/Operators/Addition) -- cgit v1.2.3-54-g00ecf