Lodash - toFinite 方法



語法

_.toFinite(value)

將值轉換為有限數字。

引數

  • value (*) − 要轉換的值。

輸出

  • (number) − 返回轉換後的數字。

示例

var _ = require('lodash');

console.log(_.toFinite('3.2'));
console.log(_.toFinite(Infinity));

將以上程式儲存在 tester.js 中。執行以下命令執行此程式。

命令

\>node tester.js

輸出

3.2
1.7976931348623157e+308
lodash_lang.htm
廣告
© . All rights reserved.