大家好,欢迎来到IT知识分享网。
139
_.isFinite(value)
_.isFinite使用原生提供的全局方法isFinite()判断一个值是否是无限的数字
参数
value (*): 需要检查的值
返回值
(boolean): 如果value是无限的数字返回true,否则false
例子
_.isFinite(3); // => true _.isFinite(Number.MIN_VALUE); // => true _.isFinite(Infinity); // => false _.isFinite('3'); // => false
源代码
/** * lodash (Custom Build) <https://lodash.com/> * Build: `lodash modularize exports="npm" -o ./` * Copyright jQuery Foundation and other contributors <https://jquery.org/> * Released under MIT license <https://lodash.com/license> * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE> * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors */ /** Detect free variable `global` from Node.js. */ //探测nodejs环境下global对象 var freeGlobal = typeof global == 'object' && global && global.Object === Object && global; /** Detect free variable `self`. */ //探测self对象 var freeSelf = typeof self == 'object' && self && self.Object === Object && self; /** Used as a reference to the global object. */ //返回全局对象的引用 var root = freeGlobal || freeSelf || Function('return this')(); /* Built-in method references for those with the same name as other `lodash` methods. */ //使用原生的全局方法isFinite() var nativeIsFinite = root.isFinite; /** * Checks if `value` is a finite primitive number. * * **Note:** This method is based on * [`Number.isFinite`](https://mdn.io/Number/isFinite). * * @static * @memberOf _ * @since 0.1.0 * @category Lang * @param {*} value The value to check. * @returns {boolean} Returns `true` if `value` is a finite number, else `false`. * @example * * _.isFinite(3); * // => true * * _.isFinite(Number.MIN_VALUE); * // => true * * _.isFinite(Infinity); * // => false * * _.isFinite('3'); * // => false */ function isFinite(value) {//使用原生提供的全局方法isFinite()判断 return typeof value == 'number' && nativeIsFinite(value); } module.exports = isFinite;
免责声明:本站所有文章内容,图片,视频等均是来源于用户投稿和互联网及文摘转载整编而成,不代表本站观点,不承担相关法律责任。其著作权各归其原作者或其出版社所有。如发现本站有涉嫌抄袭侵权/违法违规的内容,侵犯到您的权益,请在线联系站长,一经查实,本站将立刻删除。 本文来自网络,若有侵权,请联系删除,如若转载,请注明出处:https://yundeesoft.com/28285.html