Is the JavaScript RegExp implicit method deprecated?
Posted
by Eric
on Stack Overflow
See other posts from Stack Overflow
or by Eric
Published on 2010-06-17T00:02:44Z
Indexed on
2010/06/17
0:12 UTC
Read the original article
Hit count: 277
JavaScript
|regex
So everyone knows what I mean by "implicit methods"? They're like those default properties from the Windows COM days of yore, where you could type something like
val = obj(arguments)
and it would be interpreted as
val = obj.defaultMethod(arguments)
I just found out JavaScript has the same thing: the default method of a RegExp object appears to be 'exec', as in
/(\w{4})/('yip jump man')[1]
==> jump
This even works when the RegExp object is assigned to a variable, and even when
it's created with the RegExp constructor, instead of /.../
, which is good news
to us fans of referential transparency.
Where is this documented, and/or is it deprecated?
© Stack Overflow or respective owner