esmangle icon indicating copy to clipboard operation
esmangle copied to clipboard

change top-level variable declarations with initialiser to assignments

Open michaelficarra opened this issue 11 years ago • 2 comments

var a = 0;

can become

a=0

at program level. Any assignment to a non-computed member access on this at program level can be similarly transformed:

this.a = 0;

can become

a=0

michaelficarra avatar Aug 31 '14 18:08 michaelficarra

When the script is strict code, it becomes ReferenceError.

'use strict';
Hello = 42;  // ReferenceError

So we cannot apply this to strict code, and as the result, I think this optimization rarely works. Do you think about this?

Constellation avatar Sep 01 '14 01:09 Constellation

I'm sure the vast majority of top-level code is not in strict mode.

michaelficarra avatar Sep 01 '14 02:09 michaelficarra