

Extending Native JavaScript Objects. Evil or Not? - jashkenas
http://perfectionkills.com/extending-built-in-native-objects-evil-or-not/

======
jashkenas
For the record, the reason why Underscore.js is namespaced in the way it is
has everything to do with compatibility and future proofing.

It was extracted from the DocumentCloud codebase, so it had to be possible to
embed directly in the website of any major news organization ... without
conflicting with any of their JavaScript already on the page. For example:

[http://thecaucus.blogs.nytimes.com/2011/07/31/boehner-
outlin...](http://thecaucus.blogs.nytimes.com/2011/07/31/boehner-outlines-
debt-agreement/)

... the embedded doc still works, even though Prototype.js happens to be on
that page, and has already patched in `Array.prototype.each`.

~~~
jdd
@jashkenas I think your example just happened to not have problems.
Underscore.js still has problems
(<https://github.com/documentcloud/underscore/issues/7>) with Prototype.js. I
have made a small test
([http://dl.dropbox.com/u/513327/underscore_prototype_compat.h...](http://dl.dropbox.com/u/513327/underscore_prototype_compat.html))
to show some of the potential issues.

