Trim string and check null - Node.js String

Node.js examples for String:Trim

Description

Trim string and check null

Demo Code


String.prototype.trim = function() {
    if (this == void 0) {throw new Error("Illegal argument error.");}
    return this.replace(/(^\s+)|(\s+$)/g, "");
}

Related Tutorials