📜  Lodash _.isFinite() 方法

📅  最后修改于: 2022-05-13 01:56:22.988000             🧑  作者: Mango

Lodash _.isFinite() 方法

Lodash _.isFinite() 方法检查给定值是否是原始有限数并返回相应的布尔值。

句法:

_.isFinite( value )

参数:此方法接受上面提到的单个参数,如下所述:

  • value:此参数保存要检查的原始有限数的值。

返回值:此方法返回一个布尔值(如果给定值是有限数则返回真,否则返回假)。

示例 1:

Javascript
// Defining Lodash variable 
const _ = require('lodash'); 
  
// Checking for Finite Value 
console.log("The Value is Finite : "
        +_.isFinite(10));


Javascript
// Defining Lodash variable 
const _ = require('lodash'); 
  
// Checking for Finite Value 
console.log("The Value is Finite : "
        +_.isFinite(Infinity));


Javascript
// Defining Lodash variable 
const _ = require('lodash'); 
  
// Checking for Finite Value 
console.log("The Value is Finite : "
        + _.isFinite("gfg"));


Javascript
// Defining Lodash variable 
const _ = require('lodash'); 
  
// Checking for Finite Value 
console.log("The Value is Finite : "
    +_.isFinite(Number.MAX_VALUE));


输出:

The Value is Finite : true

示例 2:对于 Infinity,它返回 false。

Javascript

// Defining Lodash variable 
const _ = require('lodash'); 
  
// Checking for Finite Value 
console.log("The Value is Finite : "
        +_.isFinite(Infinity));

输出:

The Value is Finite : false 

示例 3:对于字符串,它返回 false。

Javascript

// Defining Lodash variable 
const _ = require('lodash'); 
  
// Checking for Finite Value 
console.log("The Value is Finite : "
        + _.isFinite("gfg"));

输出:

The Value is Finite : false 

示例 4:

Javascript

// Defining Lodash variable 
const _ = require('lodash'); 
  
// Checking for Finite Value 
console.log("The Value is Finite : "
    +_.isFinite(Number.MAX_VALUE));

输出:

The Value is Finite : true