overriding a global function in javascript
问题 I am trying to add my own error handling to the JavaScript setTimeout function. The following code works fine in chrome: var oldSetTimeout = window.setTimeout; window.setTimeout = function setTimeout(func, delay) { var args = Array.prototype.slice.call(arguments, 0); args[0] = function timeoutFunction() { var timeoutArgs = Array.prototype.slice.call(arguments, 0); try { func.apply(this,timeoutArgs); } catch (exception) { //Do Error Handling } } return oldSetTimeout.apply(this, args); } But in