Calling toString on a javascript function returns source code -


I just found out that when you call strings () on the javascript function, like myFunction. ToString () , the source code of that function is returned back.

If you view it in a firebug or Chrome console, it will also go to formatting for you well, even for at least javascript files.
I do not know what happens to obscure files.

What is the use of this string implementation?

There is some use for debugging, because it lets you see the code of the function. You can check that the function is overwritten, and if one variable points on the correct function

There are some uses of the ObsoBuskated JavaScript code if you want to hard disk in Javascript, then you can convert your entire code into a set of special characters, and you can not leave numbers or letters. . On this technique, which is able to reach to most characters of the alphabet firmly on toString calls everything with + "" (example: (! [] + "") Depending on [+ []] is f ). Some letters like v can be accessed only by calling local code such as []. Sort . The letter v is important for the ambiguous code, because it lets you call eval , which executes anything without using any letter, even so That loop also does. .

Comments