Using
isFinite function, you can check whether a number is finite (or) not. It treats
all the finite numbers and Boolean values as finite numbers.
<!DOCTYPE html> <html> <head> <title>Check Whether number is finite (or) not</title> </head> <body> <script> var a = 10; var b = Infinity; var c = -Infinity; var d = NaN; var e = "Hello"; var f = true; var g = false; document.write("a = " + a + ", isFinite = " + isFinite(a) + "<br />"); document.write("b = " + b + ", isFinite = " + isFinite(b) + "<br />"); document.write("c = " + c + ", isFinite = " + isFinite(c) + "<br />"); document.write("d = " + d + ", isFinite = " + isFinite(d) + "<br />"); document.write("e = " + e + ", isFinite = " + isFinite(e) + "<br />"); document.write("f = " + f + ", isFinite = " + isFinite(f) + "<br />"); document.write("g = " + g + ", isFinite = " + isFinite(g) + "<br />"); </script> </body> </html>
Open above
page in browser, you can able to see below output.
a = 10,
isFinite = true
b = Infinity,
isFinite = false
c =
-Infinity, isFinite = false
d = NaN,
isFinite = false
e = Hello,
isFinite = false
f = true,
isFinite = true
g = false,
isFinite = true
No comments:
Post a Comment