javascript - Can anyone explain this regular expression -
i came across 1 article john resig explaining javascript inheritance. http://ejohn.org/blog/simple-javascript-inheritance/
in post there class implementation code starting line has regexp
fntest = /xyz/.test(function(){xyz;}) ? /\b_super\b/ : /.*/; can 1 tell me meaning of this?
the fntest used check whether method uses _super somewhere. that, function implicitly converted string (tostring) , tested against regular look (in // re-create properties on onto new prototype).
however, not implementations yield source code of function when it's tostring method called. test checks whether function(){xyz;} can tested against containing xyz - if not, always-matching /.*/ used instead of /\b_super\b/.
javascript regex
No comments:
Post a Comment