3 ms·
new Function() parses the JavaScript code stored in a string into a function object, which can then be called. It cannot access local variables because the code
by babablacksheep 12y ago
new Function() parses the JavaScript code stored in a string into a function object, which can then be called. It cannot access local variables because the code runs in a separate scope.
- LunaSea 12y agoFunction constructor as well as setInterval() and setTimeout() with stringyfied functions are almost as insecure as eval(). Until now I don't think that I have ever encountered a case where any of these were the absolute only solution.