C-Sharp | Java | Python | Swift | GO | WPF | Ruby | Scala | F# | JavaScript | SQL | PHP | Angular | HTML
JavaScript Number isFinite() methodThe JavaScript number isFinite() method determines whether the given value is a finite number. It returns true if the value is a finite number, otherwise it returns false. SyntaxThe isFinite() method is represented by the following syntax: Number.isFinite(num) Parameternum - A number to be checked. ReturnA Boolean value. JavaScript Number isFinite() method exampleHere, we will understand isFinite() method through various examples. Example 1Let's see a simple example of isFinite() method. <script> var x=0; var y=1; var z=-1; document.writeln(Number.isFinite(x)); document.writeln(Number.isFinite(y)); document.writeln(Number.isFinite(z)); </script> Output: true true true Example 2In this example, we will use isFinite() method with negative numbers. <script> function check(x,y) { return x/y; } document.writeln(Number.isFinite(check(0,10))); document.writeln(Number.isFinite(check(10,0))); </script> Output: true false Example 3Let's see isFinite() method with some different test cases. <script> document.writeln(Number.isFinite(Infinity)); document.writeln(Number.isFinite(-Infinity)); document.writeln(Number.isFinite(NaN)); </script> Output: false false false
Next TopicJavaScript Number
|