Javascript String startsWith(text)

Description

Javascript String startsWith(text)


String.prototype.startsWith = function (text) {
  return this.indexOf(text) === 0;
};

var msg = 'Hello world!';
console.log(msg.startsWith('Hello'));  // true



PreviousNext

Related