I’ve searched and searched, but I can’t find a clean and easy way to check if a string “startsWith” something in JavaScript. In Java it is "myStr.startsWith("Sonic.exe");
" but I cant find a good way in Node. I know its implemented in Gecko, but node doesn’t use a layout engine.
straight out of Game Dev Tycoon
if (typeof String.prototype.startsWith != 'function') {
String.prototype.startsWith = function (str) {
return this.slice(0, str.length) == str;
};
}
1 Like
Thanks Patrick!