documentcloud/underscore — comment on commit 9e4192729375c8eab68913d36de9fbb8ffbbdfcc
File:  line 0
By jdalton:

@jashkenas

> When I use a library function for iteration, an each, on an object, I expect it to work as a for (key in obj) does

Except `_.each()` doesn't work as simply as you happen to expect. It also requires `hasOwnProperty` checks.

> I do not expect or hope it to enumerate through 7 special keys every time I call each.

Others probably just expect it to work. Devs use libs for convenience and to smooth over cross-browser issues.
These aren't *"special"* keys, in some magic way, they are simply properties of the `Object.prototype` that are non-enumerable and in JScript, pre IE 9, cause own properties of the same name on object literals to be incorrectly set as non-enumerable as well. These 7 keys are also **not** iterated over if the method exits early via a returned `breaker` object.

> While I'm aware that this is the only way to work around IE's DontEnum bug, I would hope that the library I'm using has the sense to forgo this workaround -- as it's not simply not worth the cost

The patch covers issues in IE, **Firefox**, **Opera**, and **Safari**.
The patch **only** iterates over those 7 keys for buggy JScript implementations and **not all browsers**. Again **the patched version is actually faster at iteration**, even with those 7 properties, than the current stable Underscore. It's actually costing devs more by keeping Underscore the way it is ;D
[http://jsperf.com/underscore-dont-enum#chart=bar](http://jsperf.com/underscore-dont-enum#chart=bar)

> Perhaps it can be put better this way. If I were using a library that added this DontEnum fix, and I noticed it, I would probably stop using it's implementation of each immediately, and just write for (key in obj) instead, for nearly all of my code.

You'd still be doing it wrong. As mentioned above, you need those pesky `hasOwnProperty` checks :P

> Underscore's each wants to be useful, not pristine.

Some devs think *"useful"* means having consistent cross-browser behavior ;D