3 ms·
This stack overflow[1] post goes into some more detail about why specifically that syntax. tl;dr is that you can actually redefine the keyword `undefined` sinc
by typicalbender 8y ago
This stack overflow[1] post goes into some more detail about why specifically that syntax.
tl;dr is that you can actually redefine the keyword `undefined` since its actually a global property and not reserved. void 0 will always return you the true value of undefined so it will work in all cases regardless of external shenanigans. Pretty neat.
[1] https://stackoverflow.com/questions/7452341/what-does-void-0-mean https://stackoverflow.com/questions/7452341/what-does-void-0...
- saagarjha 8y ago> you can actually redefine the keyword `undefined` since its actually a global property and not reserved This is horrible :(
- olliej 8y agoUndefined on the global object has been read only since es3.1 I think. However you can still declare variables named undefined that get their own storage and so can have any value. Originally “undefined” didn’t exist in the global scope so many sites had “var undefined” or function f(..., undefined){..} to get a reference to the value.