I was just reading this answer regarding hashing in Javascript, and, while it was definitely faster than the accepted answer, it requires the reduce
function on the Array
prototype.
Checking the existence of the reduce
function is easy enough; but while most checks I do (and have seen) check against the prototype, it just made me wonder: what are the implications of checking against an instance itself? Why does the prototype check seem to be preferred?
// i.e.
if (!!Array.prototype.reduce) { }
// vs
if (!![].reduce)
The instance will definitely need an instance, so that's one thing, but is that it?