Wednesday, 11 September 2013

Restriction of "new" keyword in Javascript

Restriction of "new" keyword in Javascript

I have this JS code:
var A = {};
A.new = function(n) { return new Array(n); }
It works well in all browsers, but when I try to obfuscate it with
obfuscator, it shows an error.
Is it a valid JS code? I looked into specification, but didn't find
anything. I know, that browsers sometimes accept syntactically wrong code,
but I want to write syntactically correct code.

No comments:

Post a Comment