I have been trying to understand Javascript equality. Can you please tell me why the following line returns false?
alert((function a(){}) == (function a(){})) // false
But as you can see from the following cases < returns false but <= returns true, which means == should return true but it is false. Do you have any idea, WHY?
alert((function a(){}) < (function a(){})) // false
alert((function a(){}) > (function a(){})) // false
alert((function a(){}) <= (function a(){})) // true
alert((function a(){}) >= (function a(){})) // true
You are comparing two object using
<,<=, and they are actually compared with string they could covert to."function a(){}" < "function a(){}"is false."function a(){}" <= "function a(){}"is true.EDIT:
Why
(function a(){}) == (function a(){})returns false is because you are compare same type with==, so they don’t need to covert to string or number to compare, they are two different objects.