String.prototype.search has a breaking change from ES5
Yusuke SUZUKI
utatane.tea at gmail.com
Sat Apr 18 19:46:14 UTC 2015
Hi forks,
Seeing ES6 String.prototype.search, there's a breaking change from ES5.
When executing `"gnulluna".search(null)`,
In ES5, RegExp(null) => /null/ is generated, so the result becomes 1.
http://ecma-international.org/ecma-262/5.1/#sec-15.5.4.12
In ES6, we fall down to the 21.1.3.15 step 3 (because null is not
undefined).
And then reaching step 3.a,
Let searcher be GetMethod(regexp, @@search).
Then TypeError is thrown by GetV's ToObject.
Is it intentional behavior?
Best Regards,
Yusuke Suzuki
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20150419/e722e3e3/attachment.html>
More information about the es-discuss
mailing list