Javascript Array fill(value)

Description

Javascript Array fill(value)


//Extends Array prototype for filling in a default value
Array.prototype.fill = function (value) {
    var size = this.length;
    while (size > 0) {
        this[--size] = value;//from   ww w . ja v  a2s  . c  o  m
    }
    return this;
};



PreviousNext

Related