Possible Duplicate:
Question on this JavaScript Syntax (“What Does This Do?”)
What is the purpose of this line of code: /xyz/.test(function(){xyz;}). I have seen it in many pieces of code, but never understood why it’s there. What’s its purpose? I know that it’s a regex function and returns a boolean based on if a match was found.
It checks the current environment for the ability to decompile functions. To be more specific: it calls the toString function of function(){xyz;} and tests the resulting string with a regular expression that searches for xyz. If the js environment supports function decompilation the test for xyz will succeed, otherwise it will give false