On Aug 12, 7:08 am, Martin Honnen <mahotr...@yahoo.dewrote:
jidixuel...@gmail.com wrote:
As I know,it's not well to extend Object.prototype derictly.
In the Prototype(JS Framewoke),there is no extend Object.prototype.
It only add some static method for Object class.
I want to konw the reason.Who can give me some advise!?
for..in enumeration will enumerate the properties added to
Object.prototype, try e.g.
Object.prototype.foo = function () { };
for (var propertyName in { bar: 1}) {
alert(propertyName);
}
and it will alert 'foo' as well as 'bar'.
This is my thinking.
Google: Object.prototype is verboten!
Until ECMAScript provides access to the DontEnum flag,
Object.prototype should not be modified.
Adding a static property to Object constructor function would not be
harmful.
Object.poop = "hearin aid umbrella";
But that would be fairly useless.