Note: It's hard to search for {} == 0
in google
I'm experiencing very exotic behaviour while using node.js:
obj == {}
works, and obviously dumps out false
, but
{} == obj
and
{} === obj
Fails with an error: SyntaxError: expected expression, got '=='
Why aren't we allowed to switch rhs and lhs in this case? Why can't we place {} alone on lhs?
const obj = {};
console.log(obj == {});
console.log({} == obj);
console.log({} === obj);