Skip to content

Instantly share code, notes, and snippets.

@jimfloss
Created April 6, 2018 13:27
Show Gist options
  • Save jimfloss/af12de9d5c2d003d1bf921b449486f7a to your computer and use it in GitHub Desktop.
Save jimfloss/af12de9d5c2d003d1bf921b449486f7a to your computer and use it in GitHub Desktop.
Polyfill to make ES6 Includes work in IE 11
//Includes Polyfill
if (!String.prototype.includes) {
String.prototype.includes = function(search, start) {
'use strict';
if (typeof start !== 'number') {
start = 0;
}
if (start + search.length > this.length) {
return false;
} else {
return this.indexOf(search, start) !== -1;
}
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment