Skip to content

Instantly share code, notes, and snippets.

View designbyadrian's full-sized avatar
⚛️
Reacting

Adrian von Gegerfelt designbyadrian

⚛️
Reacting
View GitHub Profile
@designbyadrian
designbyadrian / JavaScript String StartsWith and EndsWith.js
Last active January 4, 2016 07:19
Easy startsWith/endsWith proto functions for the String object
if (typeof String.prototype.startsWith != 'function') {
String.prototype.startsWith = function (str){
return this.slice(0, str.length) == str;
};
}
if (typeof String.prototype.endsWith != 'function') {
String.prototype.endsWith = function (str){
return this.slice(-str.length) == str;
};
}