longest icon indicating copy to clipboard operation
longest copied to clipboard

use `void 0` to replace 'undefined'

Open newPromise opened this issue 7 years ago • 4 comments

use void 0 to replace 'undefined' for prevent rewrite. image

newPromise avatar Mar 21 '18 09:03 newPromise

I'll need some help understanding this. Please describe the problem first (be specific).

jonschlinkert avatar Mar 23 '18 16:03 jonschlinkert

because when under ES5 , especially in IE browser, identifier undefined can be rewrited, like this example:

var undefined = "hello";
console.log(undefined === "hello"); // true

under Chrome browser or use strict mode no question;

because you use strict mode, so it's well;

so sorry~, my English is not well...

newPromise avatar Mar 30 '18 10:03 newPromise

want to do a pr?

jonschlinkert avatar Mar 30 '18 12:03 jonschlinkert

Please do not do this. It makes the code harder to read and is already done by decent minifiers like closure compiler. If you want smaller code, run the Javascript through a minifier instead of trying to compact the source code.

anonyco avatar Aug 19 '19 17:08 anonyco