Node: using Reflect TypeError: CreateListFromArrayLike called on non-object

Created on 28 Dec 2016  路  2Comments  路  Source: nodejs/node

  • 7.3.0:
  • Mac:
  • Subsystem:


I am not sure whether it's an issue or node new stable version have intention to do this

this codeReflect.apply(Object.prototype.toString, {}) throw the error

TypeError: CreateListFromArrayLike called on non-object

I have to using Reflect.apply(Object.prototype.toString, {}, []) to make it working

Reflect.apply(Object.prototype.toString, {}, [])
'[object Object]'

if i am wrong, correct me, and close the issue!!!

V8 Engine invalid

Most helpful comment

By reading the spec at https://tc39.github.io/ecma262/#sec-reflect.apply, we see that CreateListFromArrayLike is called on the third argument. The second step of this operation is "If Type(obj) is not Object, throw a TypeError exception."
This is what happens with your code so I think node (actually V8) behaves correctly here.

All 2 comments

By reading the spec at https://tc39.github.io/ecma262/#sec-reflect.apply, we see that CreateListFromArrayLike is called on the third argument. The second step of this operation is "If Type(obj) is not Object, throw a TypeError exception."
This is what happens with your code so I think node (actually V8) behaves correctly here.

Thx!!!

Was this page helpful?
0 / 5 - 0 ratings