Nodejs Array Fill fill( size, m, n )

Here you can find the source of fill( size, m, n )

Method Source Code

function randomNumber (m,n)
{
  m = parseInt(m);/*from   w ww.j  av  a 2 s.c  o  m*/
  n = parseInt(n);
  return Math.floor( Math.random() * (n - m + 1) ) + m;
}

Array.prototype.fill = function( size, m, n )
{
 var i;
 for (i = 0;i <= size;i++) {   
  this[i] =  randomNumber(m, n);
 }

 return this;
};

Related

  1. fill( val )
    Array.prototype.fill = function( val ) {
      var len = this.length, i;
      if(val instanceof Array){
        for( i = len-1; i >= 0; i--){
          this.push(val);
      } else {
        for( i = 0; i < len; i++){
          this[i] = val;
    ...
    
  2. fill(first, last, value)
    Array.prototype.fill = function (first, last, value) {
        var i;
        for (i = first; i <= last; i++) {
            this[i] = value;
    
  3. fill(n, get)
    Array.prototype.fill = function(n, get)
        for (var i = 0; i < n; i++)
            this[i] = get(i)
        return this
    
  4. fill(n,v)
    var n = process.argv[2],
      base = process.argv[3],
      decoration = process.argv[4];
    Array.prototype.fill = function(n,v) {
        n = n || this.length;
        for( var i = 0; i < n; i++ )  {
            this[i] = v === undefined ? i : v;
        return this;
    ...