Lodash - toLength 方法

语法

_.toLength(value)

将 value 转换为适合用作类似数组的对象长度的整数。

参数

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

输出

  • (number) − 返回转换后的整数。

示例

var _ = require('lodash');

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

将上述程序保存在tester.js中。运行以下命令执行该程序。

命令

\>node tester.js

输出

3
4294967295

lodash_lang.html