String.contains() has been renamed to includes()

Published: | Categories: JavaScript


The String.prototype.contains method, introduced with ECMAScript 6 and Firefox 18, had caused considerable site compatibility issues, notably with MooTools. The library has already fixed the issue, but in order to be consistent with Array.prototype.includes, which has also renamed from contains due to compatibility issues, the specification has renamed the method to String.prototype.includes. The Firefox implementation has been updated to match the spec. While the deprecated contains method still remains as an alias of includes, it will be removed in the near future.