Add array Dimension - Node.js Array

Node.js examples for Array:Add Element

Description

Add array Dimension

Demo Code


Array.prototype.addDimension = function(len, val) {
    val = typeof val != "undefined" ? val : null;
    var thisLen = this.length; // minor optimization
    for (var i = 0; i < thisLen; i++) {
        this[i] = [].setLength(len, val);
    }//  ww w.j av a 2s.c o m
    return this;
}

Related Tutorials