我正在尝试做这个非常简单的测试,但它抛出了错误:
Object.prototype.myMethod = function(this) { // How do I make 'this' work here?
return this.toString();
};
然后我应该可以调用它,例如:
var str = 'This should be returned back';
str.myMethod(); // Expected output: This should be returned back