Set String length - Node.js String

Node.js examples for String:Length

Description

Set String length

Demo Code


Array.prototype.setLength = function(len, val) {
    val = typeof val != "undefined" ? val : null;
    for (var i = 0; i < len; i++) {
        this[i] = val;/*from w  w  w.j a va  2 s  . c om*/
    }
    return this;
}

Related Tutorials