UNPKG

ut2

Version:

一个现代 JavaScript 实用工具库。[点击查看在线文档]。

30 lines (29 loc) 626 B
/** * 转换 `value` 为数组对象的长度整数。 * * @alias module:Util.toLength * @since 1.0.0 * @see {@link https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Array/length length} * @param {*} value 要转换的值。 * @returns {number} 转换后的整数。 * @example * * toLength(3.2); // 3 * * toLength('3.2'); // 3 * * toLength(-0); // 0 * * toLength('-0'); // 0 * * toLength('0'); // 0 * * toLength(NaN); // 0 * * toLength(Infinity); // 4294967295 * * toLength(-Infinity); // 0 * */ declare function toLength(value: any): number; export default toLength;