2018-10-16 21:32:40 +05:30

23 lines
494 B
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

---
title: Finding a Remainder in JavaScript
localeTitle: 在JavaScript中查找剩余内容
---
_余数运算符_ `%`给出了两个数的除法的余数。
## 例
```
5 % 2 = 1 because
Math.floor(5 / 2) = 2 (Quotient)
2 * 2 = 4
5 - 4 = 1 (Remainder)
```
## 用法
在数学中通过检查数字除法的余数为2可以检查偶数或奇数。
```
17 % 2 = 1 (17 is Odd)
48 % 2 = 0 (48 is Even)
```
**注意**不要将它与_模数_ `%`混淆,否则与负数不兼容。