Number.isFinite vs Global isFinite
You'll learn how two similarly-named functions check for finite numbers differently—one strictly, one with automatic type conversion.
The Core Difference
JavaScript gives you two ways to check if a value is a finite number:
Number.isFinite()– The strict version that only returnstruefor actual numbers (no type coercion)isFinite()– The global version that converts values to numbers first, then checks
Think of it like security checks at two different doors: one requires you to already have exact credentials, while the other will try to convert whatever you show into credentials before deciding.
How They Behave
Number.isFinite only accepts numbers:
Number.isFinite(42); // true
Number.isFinite(3.14); // true
Number.isFinite(Infinity); // false
Number.isFinite(NaN); // false
Number.isFinite("100"); // false - it's a string!
Number.isFinite(null); // false - not a number
Global isFinite coerces first:
isFinite(42); // true
isFinite("100"); // true - converts "100" to 100
isFinite(null); // true - converts null to 0
isFinite("hello"); // false - converts to NaN
isFinite(Infinity); // false
Notice how isFinite("100") returns true because it secretly runs Number("100") first, while Number.isFinite("100") refuses to budge—it sees a string and immediately returns false.
When to Use Which
Use Number.isFinite() when you want to strictly verify something is already a finite number. Use the global isFinite() only if you explicitly want type coercion behavior.
Key Takeaway: Number.isFinite() is strict and never coerces types, while global isFinite() converts values to numbers first—prefer the stricter Number.isFinite() for clearer, more predictable code.