For example
console.log({} >= null)
console.log([] >= null)
give as
false
true
Why exactly? MDN define 6 coersion type:
primitive
object
numeric
number
boolean
string
other
there are a lot of very strange result, for example
console.log(Boolean("false") > Boolean());
console.log(Boolean("false") > Boolean(undefined));
console.log(Boolean([]).valueOf(), Boolean({}).valueOf());
console.log(Symbol().valueOf >= Function())
console.log(Symbol().valueOf >= [])
console.log(Symbol>= function(){})
console.log(Symbol() >= function(){})
give us
true
true
true true
true
true
false
TypeError: Cannot convert a Symbol value to a number
or sometimes we receive even more strange result.
Is there simple direct logic, something simple rules for Javascript developer that we can understand and quickly predict result of similar operations?