Range error when overriding Object.prototype method with Function constructor
问题 I'm trying to override Object.prototype.toString in a bid to add functionality for additional class descriptions. Here's the initial code: (function(toString){ Object.prototype.toString = function(){ if(this instanceof TestClass) { return '[object TestClass]'; } return toString.apply(this, arguments); } })(Object.prototype.toString); function TestClass(){} var instance_obj = new TestClass(); Object.prototype.toString.call(instance_obj); When I run this in the console, I get the following