Javascript metaprogramming: get the name of the current executable function that has been dynamically rewritten

I rewrite one of the main javascript methods:

Element.prototype._removeChild = Element.prototype.removeChild;
Element.prototype.removeChild = function(){
    callback();
    this._removeChild.apply(this,arguments);
}

I want to dynamically get the method name (in this case "removeChild") from within the dynamically rewritten function. I use arguments.callee.name, but it seems to return nothing, thinking it is just an anonymous function. How to get the name of the function to which the anonymous function is assigned?

+5
source share
1 answer

. Element.prototype.removeChild, . , , .

, arguments.callee.name:

Element.prototype.removeChild = function removeChild() {
    ....
}
+5

All Articles