如何比较javascript中的2个函数?我不是在谈论内部参考。说
var a = function(){return 1;}; var b = function(){return 1;};
可以比较a和b吗?
a
b
var a = b = function( c ){ return c; }; //here, you can use a === b because they're pointing to the same memory and they're the same type var a = function( c ){ return c; }, b = function( c ){ return c; }; //here you can use that byte-saver Andy E used (which is implicitly converting the function to it's body's text as a String), ''+a == ''+b. //this is the gist of what is happening behind the scences: a.toString( ) == b.toString( )