Operators

Remainder operator (%)

Try the free JavaScript compiler

The remainder operator computes the remainder after truncating the quotient toward zero. For finite Number operands a nonzero remainder has the dividend's sign. It is not a percentage or generally a mathematical modulo operation. BigInt division by zero throws RangeError.

Formal Syntax & Structure

javascript syntaxjavascript
left % right

Parameters & Attributes

NameTypeDescription
leftexpressionDividend.
rightexpressionDivisor.

Return Value

number | bigint

Remainder in the applicable numeric type.

Working Example

Example Snippetjavascript
console.log(17 % 5);console.log(-17 % 5);
JavaScript Reference