Extending JavaScript Natives

Angus Croll's avatarJavaScript, JavaScript...

Most built-in JavaScript types are constructors whose prototypes contain the methods and other properties that define their default behavior:

You can’t delete or replace a native prototype, but you can edit the values of its properties, or create new ones:

Et voila! Our code gets a useful array extension for free. However if you brag about doing this in production code, expect to get pummeled by a wave of fierce disapproval. Some of it carries weight. Let’s sift the danger from the dogma and try to reach an honest conclusion:

View original post 1,946 more words

Leave a comment