Javascript Array cleanup()

Description

Javascript Array cleanup()

// remove all "undefined"s from an array
Array.prototype.cleanup = function () {
    var i = 0;//from  w  w w . ja  va  2s  . c  o  m
    while (i < this.length) {
        if (!this[i]) {
            this.splice(i,1);
        } else {
            i++;
        }
    }
}



PreviousNext

Related