English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
Javascript providesisFinite()method to check if the given entity is a valid number. If the given entity is a number, then regardless of the string " 123"What is, this method will causeboolean value true, otherwise returnsfalse. Let's discuss it briefly.
isFinite(value);
This method takes a value as a parameter and returns a boolean value true if the passed value is a number, otherwise it returns a boolean value false.
In the following example,number sent as a parameter to the methodisFinite()In this case, the result is displayed in the output.
<html> <body> <p id="number"></p> <script> var a = isFinite(567) + "</br>"; var b = isFinite(-9.23) + "</br>"; var c = isFinite(0) + "</br>"; var d = isFinite(6-7) + "</br>"; var bol = a + b + c + d; document.getElementById("number").innerHTML = bol; </script> </body> </html>
Output Result
true true true true
In the following example,String andDate This method accepts a numeric string as a number and returns true as the output.
<html> <body> <p id="number"></p> <script> 123) + "<br>"; var y = isFinite("string") + "<br>"; var z = isFinite("2019/08/06); var res = x + y + z ; document.getElementById("number").innerHTML = res; </script> </body> </html>
Output Result
true false false