这是摘录。
15.2.2.1 new Object ( [ value ] ) # Ⓣ
When the Object constructor is called with no arguments or with one argument value, the following steps are taken:If value is supplied, then If Type(value) is Object, then
If the value is a native ECMAScript object, do not create a new object but simply return value.
If the value is a host object, then actions are taken and a result is returned in an implementation-dependent manner that may depend on the host object.
我只是想知道传递 native 对象和传递主机对象给对象构造函数有什么不同。换句话说,如果我调用 new Object(document),幕后会发生什么?通过检查返回值我看不出有什么区别。
提前致谢。
最佳答案
对于原生对象:javascript不会创建新对象,只是返回值。
但是对于主机对象:javascript首先创建一个新对象,然后只返回值。
这就是规范所说的。希望您能理解!
关于javascript - ECMAScript 5 中的 "actions are taken"是什么意思?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27055908/