3 ms·
Which is better `undefinedVar === void 0` or `typeof undefinedVar === 'undefined'`? here says: http://www.2ality.com/2013/04/check-undefined.html http://www.2a
by ttty 12y ago
Which is better `undefinedVar === void 0` or `typeof undefinedVar === 'undefined'`?
here says: http://www.2ality.com/2013/04/check-undefined.html http://www.2ality.com/2013/04/check-undefined.html void 0 is safe.
- ekmartin 12y agoI think minifiers use the former because it's shorter, and thus requires less space.
- kibibu 12y agoI was curious too, so here's a jsPerf: http://jsperf.com/check-for-undefined-argument http://jsperf.com/check-for-undefined-argument On Chrome 35, looks like comparing to void 0 is a bit faster. Would love some more samples though.