How to understanding the expression "{} == true"?

I try to understanding the expression {} == true following the section 7.2.12 of doc Ecma-262.

  1. If Type(y) is Boolean, return the result of the comparison x == ToNumber(y)

The result of ToNumber(true) is 1, then

{} == 1

  1. If Type(x) is Object and Type(y) is either String, Number, or Symbol, then return the result of the comparison ToPrimitive(x) == y.

I am confused at the ToPrimitive({}) now.

  1. If hint is "string", then

    a. Let methodNames be «"toString", "valueOf"».

  2. Else,

    a. Let methodNames be «"valueOf", "toString"».

Should ToPrimitive({}) be interpreted as {}.toString() or {}.valueOf()?

Suppose the toString() is called.

If Type(x) is String and Type(y) is Number, return the result of the comparison ToNumber(x) == y

So {} == true could be ToNumber(ToPrimitive({})) == ToNumber(true)?


Click here view more answers http://ift.tt/1RQXrg2