Skip to main content
9 events
when toggle format what by license comment
Nov 29, 2021 at 7:42 comment added cibercitizen1 Now, ALL function calls can be caught, even if the method being called does not exist. See stackoverflow.com/a/54172062/286335
Mar 25, 2015 at 3:20 comment added Motomotes I wanted to inject an function before another one and I needed to know about this and Function.prototype.call to pass the correct this to my hooked function. developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/…
Aug 14, 2014 at 22:42 comment added Dan It's worth noting that someFunction in your example is the function you wish to intercept/extend. I had it backward when I first tried this but eventually figured out I was reading this wrong. Great example besides that.
Dec 7, 2011 at 21:51 history edited Andy E CC BY-SA 3.0
added 224 characters in body
Aug 4, 2010 at 17:07 vote accept yilmazhuseyin
Aug 4, 2010 at 14:56 comment added yilmazhuseyin yes you are right. function newConstructor(){alert("a");}; Function.prototype.constructor = newConstructor; did not work.
Aug 4, 2010 at 14:49 comment added Andy E @yilmazhuseyin: no, you can't. Changing the Function constructor would only allow you to override functions created with new Function(str).
Aug 4, 2010 at 14:36 comment added yilmazhuseyin Maybe I can change Function.constructor function so every returned function will have your wrapper around it.
Aug 4, 2010 at 14:29 history answered Andy E CC BY-SA 2.5