Nodejs Array Range range(start, count)

Here you can find the source of range(start, count)

Method Source Code

Array.range  = function(start, count) {
  var arr = [],/*from   w w  w  .j a va  2s .  c  o m*/
      val = start;
  while(count > 0) {
    arr.push(val);
    count--;
    val++;
  }
  return arr;
}

console.log(Array.range(-1,4).sum());

Related

  1. range()
    Array.prototype.range = function() {
      var min = null,
        max = null,
        sum = null,
        i, len;
      for (i = 0, len = this.length; i < len; ++i) {
        var elem = this[i];
        sum += elem;
        if (min === null || min > elem) min = elem;
    ...
    
  2. range(end, step)
    Array.range = function (end, step) {
      var array = [];
      for (var i = step; i <= end; i += step) {
        array.push(i);
      return array;
    
  3. range(first, second)
    Array.prototype.range = function(first, second) {
      var range = []
      console.log(typeof second)
      if (typeof second === 'undefined') {
        for (var i = 0; i < first; i++) {
          range.push(i)
        return range
      for (var i = first; i < second; i++) {
        range.push(i)
      return range
    
  4. range(from, to)
    Array.prototype.range = function(from, to) {
      var result = []
      while (from <= to)
        result.push(from++)
      return result
    
  5. range(from, to)
    Array.prototype.range = function(from, to) {
      var i, result = [];
      for (i = from; i<= to; i++) {
        result.push(i);
      return result;
    };
    console.log([].range(1, 10));
    
  6. range(start, end)
    Array.range = function (start, end) {
      var a = [], i;
      for (i = start; i < end; i += 1) {
        a[i] = i;
      return a;
    
  7. range(start, end)
    Array.prototype.range = function(start, end) {
        var result = [];
        for (var i = start; i <= end; i++) {
            result.push(i);
        return result;
    
  8. range(start,end)
    Array.prototype.range = function(start,end){
      return Array.apply(null, Array(end-start+1)).map(function (_, i){
          return start+i;
      });
    };
    
  9. range(start,end,step)
    Array.prototype.range = (start,end,step)=>{
        const stepVal = step || 1
        const set = new Set()
        for (var i=start;i<=end;i=i+stepVal){
            set.add(i)
        return [...set]
    Set.prototype.union = function (set) {
    ...