I think that undefined
(or window.undefined
) is a constant variable, not a reserved word (like NaN
, Infinity
, unlike null
).
When use UglifyJS to compress a Javascript file which use undefined
frequently, it is good if declare a local variable to hold undefined
.
For example:
function main() {
var undefined;
...
}
UglifyJS will gives me:
function main(){var n;...}
EDIT
Thanks @T.J. Crowder! Now I have my own choice. I'm sure that undefined
, NaN
, Infinity
, and window
is not a reserved word, they just "read-only". So, there're no problem to declare a local undefined
(even if strict mode). I also don't worry about the maintain issues of confusion, I just need to write a // comment
or a /* comment */
to explain what does that means.