如何在 JavaScript 中使用模运算符 (%)?

2022-01-12 00:00:00 char character javascript

如何在 JavaScript 项目的数字计算中使用模运算符 (%)?

How can I use modulo operator (%) in calculation of numbers for JavaScript projects?

推荐答案

是余数运算符,用于取整数除法后的余数.很多语言都有.例如:

It's the remainder operator and is used to get the remainder after integer division. Lots of languages have it. For example:

10 % 3 // = 1 ; because 3 * 3 gets you 9, and 10 - 9 is 1.

显然它与 模运算符完全不同.

相关文章