3 ms·
Why is this?
by regularfry 16y ago
Why is this?
- praptak 16y agoThat's the default on any function you create in JS. This prints 'true': var f = function() {}; document.write(f.prototype.constructor == f); This alone isn't perhaps a very important reason to keep this invariant, but it makes some basic reflection possible. This is (among other things) useful for debugging. It's just sometimes useful to be able to check the problematic object's "class", or at least something as close to class as you can get in a classless language.