做__proto__和Object.getPrototype公开的功能完全相同? [英] Do __proto__ and Object.getPrototype of expose exactly the same functionality?

查看:398
本文介绍了做__proto__和Object.getPrototype公开的功能完全相同?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

ES2015中 __ proto __ 的标准化否定了对 Object.getPrototypeOf 的需要?

Does the standardization of __proto__ in ES2015 negate the need for Object.getPrototypeOf?

推荐答案


执行 __ proto __ Object。 getPrototype 显示完全相同的功能?

Do __proto__ and Object.getPrototype of expose exactly the same functionality?

否。 .__ proto __ 仅适用于继承自 Object.prototype 的对象。而 Object.getPrototype 不允许变形原型。

No. .__proto__ only works on objects that inherit from Object.prototype. And Object.getPrototype doesn't allow to mutate the prototype.


ES2015中 __ proto __ 的标准化否定了对 Object.getPrototypeOf 的需要。

Does the standardization of __proto__ in ES2015 negate the need for Object.getPrototypeOf?

你倒退了ES5 Object.getPrototypeOf 和ES6 Object.setPrototypeOf 完全不需要使用 __ proto __

You've got it backwards. ES5 Object.getPrototypeOf and ES6 Object.setPrototypeOf completely negate the need to ever use __proto__.

Object.prototype .__ proto __ accessor属性仅在ES6中进行标准化需要它的实现之间的兼容性和互操作性。它被明确地标记为网络传统功能。检查附件B中的注释( [...] ... [...] [...] [...] [...] [...] [...]程序员在编写新的ECMAScript代码时不应该使用或假设存在[他们],不鼓励ECMAScript实现实现这些功能)

The Object.prototype.__proto__ accessor property is only standardised in ES6 for backwards compatibility and interoperability between implementations that need it. It's explictly marked as a web legacy feature. Check the note on Annex B ("…legacy features [for] web browser based ECMAScript implementations. [They] have […] undesirable characteristics and […] would be removed from this specification [if not used] by large numbers of existing web pages […]. Programmers should not use or assume the existence of [them] when writing new ECMAScript code. ECMAScript implementations are discouraged from implementing these features.")

这篇关于做__proto__和Object.getPrototype公开的功能完全相同?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆