YouTip LogoYouTip

Jsref Isfinite Number

\\ [![Image 1: Number objectReference Manual](#) JavaScript Number object](#)\\ \\ ## Examples (Example)\\ \\ Checks whether the parameter is infinite (Detect whether the parameter is infinite):\\ \\ Number.isFinite(123)Number.isFinite(-1.23)Number.isFinite(5-2)Number.isFinite(0)Number.isFinite('123')Number.isFinite('Hello')Number.isFinite('2005/12/12')Number.isFinite(Infinity)Number.isFinite(-Infinity)Number.isFinite(0 / 0)\\ \\ [Try it Β»](#)\\ \\ * * *\\ \\ ## Definition and Usage (Definition and Usage)\\ \\ Number.isFinite() is JavaScript A built-in method used to determine whether a value is a finite number (i.e., whether it is a normal number, rather than Infinity, -Infinity, or NaN). (Number.isFinite() is a built-in method in JavaScript used to determine whether a value is a finite number (i.e., whether it is a normal number, not Infinity, -Infinity, or NaN).)\\ \\ isFinite() is Number objectpart of, used to ensure the value is a valid, finite number value type. (isFinite() is part of the Number object, used to ensure the value is a valid, finite numeric type.)\\ \\ **Tip:** Returns false if the number is NaN (Not-a-Number), or positive/negative infinity. (**Tip:** If number is NaN (Not-a-Number), or positive/negative infinity, it returns false.)\\ \\ Number.isFinite() Unlike the global [isFinite()](#) function,`Number.isFinite()` Does not perform type conversion, whereas is strictly judges `value` iswhether it is a finite number. In contrast,`isFinite()` Methodfirst converts its parameter to a number before evaluating. (Number.isFinite() differs from the global [isFinite()](#) function. `Number.isFinite()` does not perform type conversion, but strictly checks whether `value` is a finite number. In contrast, the `isFinite()` method first converts its parameter to a number before making a determination.)\\ \\ ### 1、Basic usage (1. Basic Usage)\\ \\ ## Examples (Example)\\ \\ console.log(Number.isFinite(2));// true: 2 isfinite number (true: 2 is a finite number)\\ \\ console.log(Number.isFinite(3.14));// true: 3.14 isfinite number (true: 3.14 is a finite number)\\ \\ console.log(Number.isFinite(-100));// true: -100 isfinite number (true: -100 is a finite number)\\ \\ console.log(Number.isFinite(1/0));// false: Infinity is not a finite number (false: Infinity is not a finite number)\\ \\ console.log(Number.isFinite(-1/0));// false: -Infinity is not a finite number (false: -Infinity is not a finite number)\\ \\ console.log(Number.isFinite(NaN));// false: NaN is not a finite number (false: NaN is not a finite number)\\ \\ console.log(Number.isFinite('2'));// false: '2' isStrings,not a number (false: '2' is a string, not a number)\\ \\ ### 2、Number.isFinite() vs isFinite() (2. Number.isFinite() vs isFinite())\\ \\ ## Examples (Example)\\ \\ console.log(isFinite(2));// true: Global isFinite converts types (true: global isFinite converts type)\\ \\ console.log(isFinite('2'));// true: Strings '2' is converted to the number 2 (true: string '2' is converted to number 2)\\ \\ console.log(Number.isFinite(2));// true: 2 isfinite number (true: 2 is a finite number)\\ \\ console.log(Number.isFinite('2'));// false: Strings '2' is not of number type (false: string '2' is not a number type)\\ \\ ### 3、NaN and Infinity (3. NaN and Infinity)\\ \\ ## Examples (Example)\\ \\ console.log(Number.isFinite(NaN));// false: NaN is not a finite number (false: NaN is not a finite number)\\ \\ console.log(Number.isFinite(Infinity));// false: Infinity is not a finite number (false: Infinity is not a finite number)\\ \\ console.log(Number.isFinite(-Infinity));// false: -Infinity is not a finite number (false: -Infinity is not a finite number)\\ \\ ### 4、Typeconversion (4. Type Conversion)\\ \\ Number.isFinite() MethodIt does not automatically convert the passed value to a number, so it is strict in its evaluation. For values of other types, it directly returns false. (The Number.isFinite() method does not automatically convert the passed value to a number, so it is strict in its judgment. For other types of values, it directly returns false.)\\ \\ ## Examples (Example)\\ \\ console.log(Number.isFinite(true));// false: Boolean value true is not a number (false: boolean true is not a number)\\ \\ console.log(Number.isFinite(undefined));// false: undefined is not a number (false: undefined is not a number)\\ \\ console.log(Number.isFinite(null));// false: null is not a number (false: null is not a number)\\ \\ * * *\\ \\ ## Browser Support (Browser Support)\\ \\ | Method (Method) | | | | | |\\ | --- | --- | --- | --- | --- | --- |\\ | Number.isFinite() | 19 | 12.0 | 16 | 9 | 22 |\\ \\ * * *\\ \\ ## Syntax (Syntax)\\ \\ Number.isFinite(value)\\ ## ParameterValue (Parameter Values)\\ \\ | Parameter (Parameter) | Description (Description) |\\ | --- | --- |\\ | _value_ | The value to be evaluated, which can be of any data type (e.g., number, string, object, boolean, etc.). (The value to be checked, can be any type of data (e.g., number, string, object, boolean, etc.).) |\\ \\ ## Return Value (Return Value)\\ \\ | Type (Type) | Description (Description) |\\ | --- | --- |\\ | Boolean (Boolean) | Returns true if the value is a finite number. Returns false if the value is not a finite number (e.g., NaN, Infinity, -Infinity, or non-number types). (Returns true if value is a finite number. Returns
← Ts UnionTs If Statement β†’