In JavaScript, you can use the remainder operator "%" to achieve numerical remainder. The syntax is such as "result = number1 % number2", and the return value is the remainder.
The operating environment of this article: Windows 7 system, javascript1.8.5, Dell G3 computer.
How to calculate the remainder in javascript?
Remainder operator in javascript
Remainder operator (%)
An expression Divides the value of another expression by the value of another expression, returning the remainder.
result = number1 % number2
Parameters
result
Any variable.
number1
Any numerical expression.
number2
Any numerical expression.
Description
The remainder (or remainder) operator divides number1 by number2 (rounding the floating point number to an integer), and then returns only the remainder as the result. For example, in the following expression, A (result) is equal to 5.
A = 19 % 6.7
Recommended study: "javascript Advanced Tutorial"
The above is the detailed content of How to calculate remainder in javascript. For more information, please follow other related articles on the PHP Chinese website!