_.now()
93
_.now()
_.now获取从Unix纪元(1970年1月1日)开始一直到现在的经历的时间的毫秒数
参数
返回值
(number): 返回时间戳
例子
_.defer(function(stamp) { console.log(_.now() - stamp); }, _.now()); // => Logs the number of milliseconds it took for the deferred invocation.
源代码:
/** * 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. */ var freeGlobal = typeof global == 'object' && global && global.Object === Object && global; //检查nodejs环境中的global对象 /** Detect free variable `self`. */ var freeSelf = typeof self == 'object' && self && self.Object === Object && self; //检查self对象 /** Used as a reference to the global object. */ var root = freeGlobal || freeSelf || Function('return this')(); //对全局对象的引用 /** * Gets the timestamp of the number of milliseconds that have elapsed since * the Unix epoch (1 January 1970 00:00:00 UTC). * * @static * @memberOf _ * @since 2.4.0 * @category Date * @returns {number} Returns the timestamp. * @example * * _.defer(function(stamp) { * console.log(_.now() - stamp); * }, _.now()); * // => Logs the number of milliseconds it took for the deferred invocation. */ //获取从Unix纪元(1970年1月1日)开始一直到现在的经历的时间的毫秒数 var now = function() { return root.Date.now(); }; module.exports = now;

浙公网安备 33010602011771号