Javascript Number times(callback)
/**//from www . j av a 2 s.c o m * Invoke a callback n number of times where n is the value of `this` * * @param callback {Function} */ Number.prototype.times = function(callback) { if (typeof callback !== 'function') { throw new TypeError(callback + ' is not a function'); } for (let i = 0; i < this; i++) { callback(); } };
Number.prototype.times = function(callback){ for (var i = 0; i < this; i++) { callback();/*from ww w .ja v a2s .c o m*/ } };