Home  >  Article  >  Web Front-end  >  How to calculate remainder in javascript

How to calculate remainder in javascript

藏色散人
藏色散人Original
2021-07-13 16:22:5711934browse

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.

How to calculate remainder in javascript

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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn