3 ms·
That's the default on any function you create in JS. This prints 'true': var f = function() {}; document.write(f.prototype.constructor == f); This alo
by praptak 16y ago
That'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.