Object.create 的原始定义是什么?
What is the original definition of Object.create?
function Object.create(o) {
function F() {}
F.prototype = o;
return new F();
}
我认为这等同于 Object.create 的当前 ES6 实现。
- 之前的版本是什么(由于
new
关键字不存在,它明显改变了)?原来的那个。这是一个关于Javascript历史的事实问题,可以回答,我不明白为什么之前被删除了,所以我澄清一下。
- 没有
new
的定义和有new
的定义一样吗?
- 如果改变了,还有其他的吗(由 Good Parts 作者或官方)?例如ES5,如果不等同于ES6.
What was the version before (it clearly changed since the new keyword didn't exist)?
没有。 new
一直存在于JavaScript。
Is the definition without new
equivalent to the one with it?
在 Object.create
被添加到 ES5 的标准库之前,没有任何版本没有 new
。 standard version 直接使用给定的原型创建一个对象,而不是必须通过构造函数调用来完成,但除了没有创建不必要的构造函数之外,结果是相同的。
If it changed, were there any others (by the Good Parts author or officially)? e.g. ES5, if it is not equivalent to ES6.
没变。标准版本是在 ES5 中添加的(不是 ES2015/ES6),此后没有发生实质性变化。 (规范的文本已经更改,因为从那时起整个规范发生了相当大的变化,但所采取的基本步骤和结果是相同的。)
function Object.create(o) {
function F() {}
F.prototype = o;
return new F();
}
我认为这等同于 Object.create 的当前 ES6 实现。
- 之前的版本是什么(由于
new
关键字不存在,它明显改变了)?原来的那个。这是一个关于Javascript历史的事实问题,可以回答,我不明白为什么之前被删除了,所以我澄清一下。 - 没有
new
的定义和有new
的定义一样吗? - 如果改变了,还有其他的吗(由 Good Parts 作者或官方)?例如ES5,如果不等同于ES6.
What was the version before (it clearly changed since the new keyword didn't exist)?
没有。 new
一直存在于JavaScript。
Is the definition without
new
equivalent to the one with it?
在 Object.create
被添加到 ES5 的标准库之前,没有任何版本没有 new
。 standard version 直接使用给定的原型创建一个对象,而不是必须通过构造函数调用来完成,但除了没有创建不必要的构造函数之外,结果是相同的。
If it changed, were there any others (by the Good Parts author or officially)? e.g. ES5, if it is not equivalent to ES6.
没变。标准版本是在 ES5 中添加的(不是 ES2015/ES6),此后没有发生实质性变化。 (规范的文本已经更改,因为从那时起整个规范发生了相当大的变化,但所采取的基本步骤和结果是相同的。)