Skip to content

Instantly share code, notes, and snippets.

View daphnesmit's full-sized avatar
👩‍💻
Coding Typescript/GraphQl/NextJS

Daphne daphnesmit

👩‍💻
Coding Typescript/GraphQl/NextJS
View GitHub Profile
@hamiltondanielb
hamiltondanielb / gist:a174bc415fdd71966de1
Last active December 5, 2022 12:52
ES6 String contains, starts with, ends with to ES5
String.prototype.contains = String.prototype.contains || function(str) {
return this.indexOf(str) >= 0;
};
String.prototype.startsWith = String.prototype.startsWith || function(prefix) {
return this.indexOf(prefix) === 0;
};
String.prototype.endsWith = String.prototype.endsWith || function(suffix) {
return this.indexOf(suffix, this.length - suffix.length) >= 0;