JavaScript isFinite number is used to tell whether the number is finite number. See the code snippet:
Javascript isFinite function Example - 1
<!DOCTYPE html>
<html>
<head>
<title>Welcome to LearnKode - A code learning platform</title>
</head>
<body>
<p>Click the button to check whether a number is a finite number.</p>
<button onclick="isFiniteNumber()">Click it</button>
<p id="sample"></p>
<script>
function isFiniteNumber() {
var a = isFinite(4) + "<br>";
var b = isFinite(-4) + "<br>";
var c = isFinite(4-2) + "<br>";
var d = isFinite(0) + "<br>";
var e = isFinite("145") + "<br>";
var f = isFinite("LearnKode") + "<br>";
var result = a + b + c + d + e + f ;
document.getElementById("sample").innerHTML = result;
}
</script>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<title>Welcome to LearnKode - A code learning platform</title>
</head>
<body>
<p>Click the button to check whether a number is a finite</p>
<button onclick="isFiniteNumber()">Click it</button>
<p id="sample"></p>
<script>
function isFiniteNumber() {
var a = Number.isFinite(Infinity) + "<br>";
var b = Number.isFinite(NaN) + "<br>";
var c =Number.isFinite(2e64) + "<br>";
result = a+b+c;
document.getElementById("sample").innerHTML = result;
}
</script>
</body>
</html>