7.1.1.1 OrdinaryToPrimitive ( O, hint )

当使用参数 Ohint 调用抽象操作 OrdinaryToPrimitive 时,将执行以下步骤:

  1. 断言:Type(O) 是 Object 类型。
  2. 断言:Type(hint) 是 String 类型并且它的值是 "string""number"
  3. 如果 hint "string",那么

a. 使 methodNames 变为 « "toString", "valueOf" »。

  1. 否则

a. 使 methodNames 变为 « "valueOf", "toString" »。

5.对于 methodNames 中的每个 name,按列表顺序执行 a. 使 method 变为 ? Get(O, name)。

b. 如果 IsCallable(method) 为 true,那么

i. 使 result 变为 ? Call(method, O)。

ii. 如果 Type(result) 不是 Object,返回 result

6.抛出一个 TypeError 错误。

results matching ""

    No results matching ""