MENU
Number Static Methods
Number.isNaN()
Determine whether the passed value is NaN.
Number.isFinite()
Determine whether the passed value is a finite number.
Number.isInteger()
Determine whether the passed value is an integer.
Number.isSafeInteger()
Determine whether the passed value is a safe integer (a number between -(253 - 1) and 253 - 1).
Number.parseFloat()
Convert a string or a number to a float.
Number.parseInt()
Convert a string or a number to an integer.
Note that isNan(), isFinite(), parseFloat(), and parseInt() also exist as global functions.
RESETRUNFULL
RESETRUNFULL
<!DOCTYPE html><html><body><script>
<!DOCTYPE html><html><body><script>
console.log(isNaN(NaN)); // true
console.log(Number.isNaN(NaN)); // true
console.log(isFinite(100)); // true
console.log(Number.isFinite(100)); // true // console.log(isInteger(100.0)); // ReferenceError
console.log(Number.isInteger(100.0)); // true // console.log(isSafeInteger(100.0)); // ReferenceError
console.log(Number.isSafeInteger(100.0)); // true
console.log(parseFloat(10)); // 10
console.log(Number.parseFloat(10)); // 10
console.log(parseInt("100abc123")); // 100
console.log(Number.parseInt(100.9)); // 100
console.log(parseInt('10a',2)); // base 2 --> 10 --> 2
console.log(parseInt('10A',15)); // base 15 --> 235</script></body></html>
</script></body><html><!DOCTYPE html><html><body><script>
function isNumeric(n) {
return !isNaN(parseFloat(n)) && isFinite(n);}
</script></body><html>RESETRUNFULL
<!DOCTYPE html><html><body><script>
Here, 1/0 -> “Inifinity" -> 18nifity -> 18
</script></body><html><!DOCTYPE html><html><body><script>
<!DOCTYPE html><html><body><script>
console.log(parseInt(1/0, 19)); // 18</script></body></html>
</script></body><html>