Javascript Array fill(dim, init)

Description

Javascript Array fill(dim, init)

Array.prototype.fill = (dim, init) => {
  console.log(this);//from w  w w  . j  av a  2  s . c om
  for (var i = 0; i < dim; i++) {
    this.push(init);
  }
  return this;
}

function log(x) {
  console.log(x);
}

log.method('test', () => console.log('test'))
a = [];
a.fill(3, 4)



PreviousNext

Related