EDITED
Note: I’ve completely edited this because previous problem was solved using another approach and I’ve simplified this question in order to answer myself with my solution to the question and share my conclusion with you.
How to clone a function by avoiding the use of eval(...)?
I need to get an exact copy of some given function and this must be a different object than source one.
That’s functionA != functionCloneOfA, and wrapping “functionA” and calling it from the body of some other isn’t a solution for me.
Finally I didn’t need to clone functions to solve some problem in one of my projects, but I want to share with you what I found in order to truly clone a function:
I’m not absolutely sure this is the best approach around, but it produces an anonymous function which is an exact clone of source function, but both are different objects.
Perhaps uses some kind of “eval” because I’m building a function by using this Function object constructor, but I believe it’s more elegant than an actual use of eval(…).