You cannot change the source of a function. If you want to change the behavior of this function, you have options:
Override the function with your own. It is easy if the function is autonomous. Then you can simply define
function Person(name) { this.name = name; }
after determining the original function. But if prototypes and inheritance are involved, it can be difficult to get a link to the original prototype (due to how function declarations are evaluated).
Set up a wrapper function that creates and creates instances and removes properties you don't need:
function PersonWrapper(name) { var p = new Person(name); delete p.greet; return p; }
This approach is also limited as you can only change what is accessible from the outside. In the above example, it would be enough for you.
source share