archives

« Bugzilla Issues Index

#2407 — `String.prototype.contains(regex)` should throw for consistency with `endsWith`/`startsWith`


`String.prototype.contains(regex)` should throw for consistency with `endsWith`/`startsWith`.

This is the behavior as per the latest ES6 draft:

'/a/bc'.startsWith(/a/) // throws TypeError
'ab/c/'.endsWith(/c/) // throws TypeError
'a/b/c'.contains(/b/) // `true`

This is needlessly confusing. It seems that `contains` was forgotten about when https://bugs.ecmascript.org/show_bug.cgi?id=498#c3 was fixed.


fixed in rev23 editor's draft


fixed in rev23 draft