How can I use modulo operator (%) in JavaScript? [

2019-01-08 07:47发布

This question already has an answer here:

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

2条回答
神经病院院长
2楼-- · 2019-01-08 08:03

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.

Apparently it is not the same as the modulo operator entirely.

查看更多
倾城 Initia
3楼-- · 2019-01-08 08:09

That would be the modulo operator, which produces the remainder of the division of two numbers.

查看更多
登录 后发表回答