Check if a string starts with a string and deal with null value - Node.js String

Node.js examples for String:String Start

Description

Check if a string starts with a string and deal with null value

Demo Code

String.prototype.startsWith = function(str) {
    if (this == void 0) {throw new Error("Illegal argument error.");}
    return this.substr(0, str.length) == str;
}

Related Tutorials