Nodejs Function Call times(callback)

Here you can find the source of times(callback)

Method Source Code

Number.prototype.times = function(callback){
  for (var s = this - 1; s >= 0; s--){
    callback.call(this,s);/* www . j  ava  2 s .  c  om*/
  };
}

Related

  1. times(action)
    "use strict";
    Number.prototype.times = function(action) {
      var i;
      for (i = 1; i <= this; i++) {
        action();
    };
    (5).times(function () { console.log("OMG!"); });
    
  2. times(action)
    Number.prototype.times = function(action) {
      var counter = this
      while (counter-- > 0)
        action()
    
  3. times(args)
    Number.prototype.times = function(args) {
      var args = Array.prototype.slice.apply(arguments);
      for(var i = 0; i < this; i++) {
          args[0].apply(null, args.slice(1))
    };
    function Bye(num) {console.log(num)};
    function Hello() {console.log("hello");}
    function Something(num, num2) {console.log(num, num2);}
    ...
    
  4. times(blk)
    Number.prototype.times = function(blk){
      for (var i = 0 ; i < this ; ++i){
        blk.apply(i, [i]);
      return this;
    
  5. times(callback)
    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();
    };
    
  6. times(callback)
    Number.prototype.times = function(callback){
        for (var i = 0; i < this; i++) {
          callback();
    };
    
  7. times(callback)
    Number.prototype.times = function(callback) {
      for (var i = 0; i < this; i++) {
        callback.call(this, i);
      return this;
    };
    
  8. times(callback)
    Number.prototype.times = function(callback) {
      var i;
      if(typeof callback === 'undefined') {
        var array = [];
        for(i = 0; i < this; i++) array.push(i);
        return array;
      }  else if(typeof callback === 'function')  {
        for(i = 0; i < this; i++) callback(i);
      } else {
    ...
    
  9. times(cb)
    Number.prototype.times = function (cb) {
      var i = -1;
      while (++i < this) {
        cb(i);
      return +this;
    };