I came across one article by john resig explaining JavaScript Inheritance.
http://ejohn.org/blog/simple-javascript-inheritance/
In this post there is a Class implementation code where the starting line has a regexp
fnTest = /xyz/.test(function(){xyz;}) ? /\b_super\b/ : /.*/;
Can any one tell me what is the meaning of this?
The
fnTestis used to check whether a method uses_supersomewhere. To do that, the function is implicitly converted to a string (toString) andtested against the regular expression (in// Copy the properties over onto the new prototype).However, not all implementations really yield the source code of a function when it’s
toStringmethod is called. So this test checks whether thefunction(){xyz;}can be tested against containingxyz– if not, the always-matching/.*/is used instead of/\b_super\b/.