3 ms·
This reminds me of a javascript weirdness I found. When passed as `this`, primitives (string, number, boolean) get wrapped in their classes. You can get the 'N
by daurnimator 11y ago
This reminds me of a javascript weirdness I found. When passed as `this`, primitives (string, number, boolean) get wrapped in their classes.
You can get the 'Number' function with:
Number = (function(){return this;}).call(1).constructor
- bartqk 11y agonice trick. You can, but you can't reference `Number` directly, that's the point. `Number` is a part of standard library, so being in JS it's possible use hack that you've shown. But you won't find a reference to let's say `console`, because it's not a part of ECMAScript.
- bartqk 11y agoor just `1..constructor` -> function Number().
- daurnimator 11y ago> or just `1..constructor` -> function Number(). Ah ha. much simpler :)