Created
April 6, 2018 13:27
-
-
Save jimfloss/af12de9d5c2d003d1bf921b449486f7a to your computer and use it in GitHub Desktop.
Polyfill to make ES6 Includes work in IE 11
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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