Using slice method to check string start - Node.js String

Node.js examples for String:String Start

Description

Using slice method to check string start

Demo Code


if (typeof String.prototype.startsWith != 'function') {
  String.prototype.startsWith = function(str) {
    return this.slice(0, str.length) == str;
  };//from   ww w.j  a  v a  2s.c o  m
}

Related Tutorials