Lodash - toLength 方法



語法

_.toLength(value)

將值轉換為適用於類陣列物件的長度的整數。

引數

  • value (*) − 要檢查的值。

輸出

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

示例

var _ = require('lodash');

console.log(_.toLength(3.2));
console.log(_.toLength(Infinity));

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

命令

\>node tester.js

輸出

3
4294967295
lodash_lang.htm
廣告
© . All rights reserved.