Creates an array of integers from start up to stop. - Node.js Array

Node.js examples for Array:Array Value

Description

Creates an array of integers from start up to stop.

Demo Code

/**/*  www  .  java 2s . c  om*/
 * Creates an array of integers from start up to (but not including) stop.
 */
Util.Array.range = function range(start, stop)
{
  if (arguments.length == 1) {
    stop = start;
    start = 0;
  }
  
  var ret = [];
  for (var i = start; i < stop; i++) {
    ret.push(i);
  }
  return ret;
}

Related Tutorials