aboutsummaryrefslogtreecommitdiff
path: root/files/ja/web/javascript/reference/operators/remainder_assignment/index.html
blob: ab7d348b8b63b2c8076e6e37a96324e7472ad976 (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
---
title: 剰余代入 (%=)
slug: Web/JavaScript/Reference/Operators/Remainder_assignment
tags:
  - Assignment operator
  - JavaScript
  - Language feature
  - Operator
  - Reference
translation_of: Web/JavaScript/Reference/Operators/Remainder_assignment
---
<div>{{jsSidebar("Operators")}}</div>

<p>剰余代入演算子 (<code>%=</code>) は、変数を右辺のオペランドの値で除算し、剰余を変数に代入します。</p>

<div>{{EmbedInteractiveExample("pages/js/expressions-remainder-assignment.html")}}</div>

<div></div>



<h2 id="構文">構文</h2>

<pre class="syntaxbox notranslate"><strong>Operator:</strong> x %= y
<strong>Meaning:</strong>  x  = x % y</pre>

<h2 id="例"></h2>

<h3 id="剰余代入の使用">剰余代入の使用</h3>

<pre class="brush: js notranslate">// 以下の変数を想定
//  bar = 5

bar %= 2     // 1
bar %= 'foo' // NaN
bar %= 0     // NaN</pre>

<h2 id="仕様">仕様</h2>

<table class="standard-table">
 <tbody>
  <tr>
   <th scope="col">仕様</th>
  </tr>
  <tr>
   <td>{{SpecName('ESDraft', '#sec-assignment-operators', 'Assignment operators')}}</td>
  </tr>
 </tbody>
</table>

<h2 id="ブラウザーの互換性">ブラウザーの互換性</h2>



<p>{{Compat("javascript.operators.remainder_assignment")}}</p>

<h2 id="関連項目">関連項目</h2>

<ul>
 <li><a href="/docs/Web/JavaScript/Guide/Expressions_and_Operators#Assignment">代入演算子</a></li>
 <li><a href="/docs/Web/JavaScript/Reference/Operators/Remainder">剰余演算子</a></li>
</ul>