How to test for equality of functions in Javascript [duplicate]

You could check whether the content of two functions is exactly the same by comparing the result of calling toString on them

 var foo = function() {
    a = 1;
 }; 

 var bar = function() {
    a = 1;
 }; 

alert(foo.toString() == bar.toString());​

That will, however, fail if there is but one character that is different. Checking to see if two functions do the same thing, on the other hand, is pretty much impossible.

Leave a Comment

tech