Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
如何在 JavaScript 项目的数字计算中使用模运算符 (%)?
它是余数运算符,用于获取整数除法后的余数。很多语言都有。例如:
10 % 3 // = 1 ; because 3 * 3 gets you 9, and 10 - 9 is 1.
显然,它与模运算符完全不同。
那将是模运算符,它产生两个数字相除的余数。