isfinite in javascript code example
Example 1: IFFI in js
// This function will be invoked right away we don't have to call it
(function () {
console.log("This is an IIFE");
})();
Example 2: isfinite javascript
function div(x) {
if (isFinite(1000 / x)) {
return 'Number is NOT Infinity.';
}
return 'Number is Infinity!';
}
console.log(div(0));
// expected output: "Number is Infinity!""
console.log(div(1));
// expected output: "Number is NOT Infinity."