JavaScript(JS) built-in method - isfinite

www.igif‮edit‬a.com

The isFinite() method in JavaScript is a built-in function that determines whether a passed value is a finite number. It returns a Boolean value indicating whether the provided value is finite.

The isFinite() function takes one parameter, which is the value to be tested. If the value is a number, isFinite() returns true if the value is a finite number (i.e., not NaN, Infinity or -Infinity) and false otherwise. If the value is not a number, isFinite() coerces it to a number and then performs the test.

Here's an example of using the isFinite() method:

isFinite(42); // true
isFinite(Infinity); // false
isFinite(-Infinity); // false
isFinite("42"); // true
isFinite("Hello"); // false

In the example above, we use the isFinite() method to check if the given values are finite numbers. The first call to isFinite() returns true because 42 is a finite number. The second and third calls return false because Infinity and -Infinity are not finite. The fourth call returns true because the string "42" can be converted to the finite number 42. The fifth call returns false because the string "Hello" cannot be converted to a number.