Determines whether a number is prime.
A number within the safe integer range.
true if the absolute value of n is prime; otherwise false.
true
n
false
Negative numbers are judged by their absolute value. Non-integers are never prime.
TypeError If n is not a number.
TypeError
RangeError If n is NaN, infinite, or larger in magnitude than Number.MAX_SAFE_INTEGER.
RangeError
Number.MAX_SAFE_INTEGER
1.0.0
isPrime(97); // trueisPrime(-7); // trueisPrime(10.5); // false Copy
isPrime(97); // trueisPrime(-7); // trueisPrime(10.5); // false
Determines whether a number is prime.