module vs std

Edit on GitHub

fill array

Setup

Tests

  • module

    'use strict';
    
    function repeat(ele, num) {
     var arr = new Array(num);
    
     for (var i = 0; i < num; i++) {
      arr[i] = ele;
     }
     return arr;
    }
    
    var f = repeat("yo", 2);
    var g = repeat(12, 2);
    var h = repeat({a:"yo", b: 12}, 2);
  • std

    function repeat(ele, num) {
      return new Array(num).fill(ele);
    }
    
    var f = repeat("yo", 2);
    var g = repeat(12, 2);
    var h = repeat({a:"yo", b: 12}, 2);