I do not ask if everything is in order:
Object.prototype.method = function(){};
This is considered evil by almost everyone, considering it a mess of for(var i in obj) .
Real question
Ignoring
- Incompetent browsers (browsers that do not support
Object.defineProperty ) - Potential for collision of properties or overriding
Assuming you have a useful method unbelievably , is this considered wrong / unethical?
Object.defineProperty(Object.prototype, 'methodOnSteriods',{ value: function(){ }, writable: true, configurable: true, enumerable: false });
If you think the foregoing is unethical, why would they even implement this feature in the first place?
javascript ecmascript-5
William Jul 29 '11 at 17:51 2011-07-29 17:51
source share