Nodejs Number Calculate times()

Here you can find the source of times()

Method Source Code

/**/*from w w  w .  j  a va  2s. c  o m*/
 * @example
 * (5).times() => [0,1,2,3,4]
 *
 * @returns {Array}
 */
Number.prototype.times = function () {
    return _.times(this, function (i) {
        return i;
    });
};

Related

  1. plus( num )
    Number.prototype.plus = function ( num ) {
      return this + num;
    };
    Number.prototype.minus = function ( num ) {
      return this - num;
    };
    Number.prototype.multiple = function ( num ) {
      return this * num;
    };
    ...
    
  2. plus()
    Number.prototype.plus = function() {
        if ((arguments.length == 0) || (arguments.length > 1) || isNaN(arguments[0]))return;
        return Number(this.toString()) + Number(arguments[0].toString());
    };
    Number.prototype.minus = function() {
        if ((arguments.length == 0) || (arguments.length > 1) || isNaN(arguments[0]))return;
        return Number(this.toString()) - Number(arguments[0].toString());
    };
    console.log(2);
    ...
    
  3. plus(i)
    function calcfibonacciNumbers() {
      var i,
          nm = [];
      nm[0] = 0;
      for(i=1; i<10; i++) {
        if(i==1) {
          nm[i] = nm[i-1] + 1;
          console.log (nm[i]);
        } else {
    ...
    
  4. plus(num)
    Number.prototype.plus = function(num) {
      return this + num
    };
    Number.prototype.minus = function(num) {
      return this - num
    };
    Number.prototype.multi = function(num) {
      return this * num
    debug((5).plus(3).minus(6))
    debug((5).multi((3).plus(2)))
    debug(6..multi(2..plus(2)))
    function add(x) {
      return function(y) {
        return function(z) {
          return x + y + z
    debug(add(2) + '\n\n')
    debug(add(2)(3) + '\n\n')
    debug(add(2)(3)(5) + '\n\n')
    
  5. times()
    Number.prototype.times = function () {
      var a = [];
      var i = -1;
      while (++i < this) {
        a.push(i);
      return a;
    };
    
  6. timesPlusOne()
    Number.prototype.timesPlusOne = function () {
        return _.map(this.times(), function (i) {
            return i + 1;
        });
    };
    
  7. timesRepeat(f)
    Number.prototype.timesRepeat = function(f){
      for(var i=0; i<this; i++){
        f();
    
  8. timesTwo(x)
    var x = new Number(2);
    console.log(x);
    Number.prototype.timesTwo = function(x){
      return x * 2;
    };
    console.log(x.timesTwo(x));
    console.log(Number.isNaN(x));
    Number.isInteger = Number.isInteger || function(x){
      return typeof x === "number" &&
    ...