I'm stuck with this problem. Need to check if the 2 functions are the same or refer to the same. So the scenario is kind of like this : fn1 function are anonymous.
function fnName(args) {
if(this.fn1 === this.json1.fn1)
//this is true
else
//this is false
}
here both this.fn1 and this.json1.fn1 points to the same function definition. Is there a way to find out if they are pointing the same or not ?
I have tried using function.toString() but this gives the same output for any function i.e;
function() { [native code] }
and on this being compared it gives true as the output for any 2 function that are not even same.
On comparing === It's not considering them as same. On debugging it shows that it is pointing to the function at the same line.
On doing Object.is(this.fn1,this.json1.fn1); is returning false , which means they are not the same object.
How these functions are set to the attribute are through using the bind function such as :
fn1 = fn1.bind(this);
json1["fn1"] = fn1.bind(this)
So now we know these are 2 different Objects