« Bugzilla Issues Index
#2407 — `String.prototype.contains(regex)` should throw for consistency with `endsWith`/`startsWith`
- bug_id:
2407
- creation_ts:
2013-12-23 00:22:00 -0800
- short_desc:
`String.prototype.contains(regex)` should throw for consistency with `endsWith`/`startsWith`
- delta_ts:
2014-04-06 11:30:50 -0700
- product:
Draft for 6th Edition
- component:
technical issue
- version:
Rev 22: January 20, 2014 Draft
- rep_platform:
All
- op_sys:
All
- bug_status:
RESOLVED
- resolution:
FIXED
- see_also:
https://bugs.ecmascript.org/show_bug.cgi?id=498
- priority:
Normal
- bug_severity:
major
- everconfirmed:
true
- reporter:
Mathias Bynens
- assigned_to:
Allen Wirfs-Brock
- cc:
["jorendorff", "mathias"]
- commentid:
6955
- comment_count:
0
- who:
Mathias Bynens
- bug_when:
2013-12-23 00:22:19 -0800
`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.
- commentid:
7321
- comment_count:
1
- who:
Allen Wirfs-Brock
- bug_when:
2014-02-15 17:51:06 -0800
fixed in rev23 editor's draft
- commentid:
7575
- comment_count:
2
- who:
Allen Wirfs-Brock
- bug_when:
2014-04-06 11:30:50 -0700
fixed in rev23 draft