JSFiddle - React, Tailwind, and code Playground
JavaScript
if (!String.prototype.startsWith) {
Object.defineProperty(String.prototype, 'startsWith', {
enumerable: false,
configurable: false,
writable: false,
value: function (searchString, position) {
position = position || 0;
return this.indexOf(searchString, position) === position;
}
});
}
var str = "Pankaj Garg";
alert(str.startsWith("Pankaj")); // true
alert(str.startsWith("Garg")); // false
alert(str.startsWith("Garg", 7));