0

I try to understand why this happens:

console.log(Boolean(true)); //true
console.log(Boolean({})); //true

but

console.log(true == {}); //false

Is that even comparable?

I've read about type coercion and step by step process but still don't get this case.

Is my way of thinking right? Does coercion work as I wrote below?

true == {}
1 == {}
1 == [object Object]
false

Does JS stop because JS doesn't convert [object Object] to number value, so it returs false?

NetPax
  • 111
  • 1
  • 6

0 Answers0