I am trying to understand the mystery of comparing functions:
let a=function(){}
let b=function(){}
console.log(a==b) //false
console.log(a===b) //false
console.log(a<b) //false
console.log(a>b) //false
console.log(a<=b) //true !?!
console.log(a>=b) //true !?!
console.log( (+a) < (+b) ) //false
console.log( (+a) > (+b) ) //false
console.log( (+a) <= (+b) ) //false
console.log( (+a) >= (+b) ) //false
In ECMAscript the <= operator is described:
RelationalExpression:RelationalExpression<=ShiftExpression
- Let lref be the result of evaluating RelationalExpression.
- Let lval be ? GetValue(lref).
- Let rref be the result of evaluating ShiftExpression.
- Let rval be ? GetValue(rref).
- Let r be the result of performing Abstract Relational Comparison rval < lval with LeftFirst equal to false.
- ReturnIfAbrupt(r).
- If r is true or undefined, return false. Otherwise, return true.
The Abstract Relational Comparison seems to have special cases for strings and BigInts but I think everything else should be converting to numbers. So I would expect the second set of comparisons to be equivalent to the first and yet it's not. What am I missing?