DEV Community

Discussion on: .includes For Noobs

Collapse
 
avalander profile image
Avalander

Why don't you polyfill .contains and switch to the latest version?

Array.prototype.contains = Array.prototype.contains || Array.prototype.includes

I'm pretty sure you've already considered this, but it seems a reasonable alternative to doing a search and replace to the entire codebase.

Collapse
 
dinsmoredesign profile image
Derek D

Unfortunately, it'd be just as tedious of a task. It's a vendor system we're working with and we extend it by creating small JS plugins. You have to create a "script list" for every plugin you create, as they're self-contained little windows that the system runs in their own iframes. We'd have to go through the code base and find every instance of the .contains() usage and then find the script list associated with all of them and include the polyfill. It's not something we can just add to every instance the software creates, unfortunately, otherwise it'd be a super simple task :(