I am looking for correct way to add "static" methods (class level methods) into Object and all its children in JavaScript.
I am trying to do:
Object.prototype.myMethod = function() { ... };
// actually I need only class level method
// but it creates instance method too
I am getting wanted:
function MyClass() {};
var mc = new MyClass();
mc.myMethod();
But I am getting also unwanted:
mc.someProperty = 'val';
for (var k in mc) {
console.log(k);
}
// => myMethod (this is unwanted)
// => someProperty
How to add only class method into Object and all it's children without adding of instance method's?