1
0
mirror of https://github.com/ruanyf/es6tutorial.git synced 2025-05-24 18:32:22 +00:00

Update object.md

__proto__属性:第一个例子,注释,ES5,ES6写反了
This commit is contained in:
taxilng 2018-05-22 14:30:21 +08:00 committed by GitHub
parent 76b6bce980
commit 4f5db47055
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -861,13 +861,13 @@ JavaScript 语言的对象继承是通过原型链实现的。ES6 提供了更
`__proto__`属性(前后各两个下划线),用来读取或设置当前对象的`prototype`对象。目前,所有浏览器(包括 IE11都部署了这个属性。 `__proto__`属性(前后各两个下划线),用来读取或设置当前对象的`prototype`对象。目前,所有浏览器(包括 IE11都部署了这个属性。
```javascript ```javascript
// es6 的写法 // es5 的写法
const obj = { const obj = {
method: function() { ... } method: function() { ... }
}; };
obj.__proto__ = someOtherObj; obj.__proto__ = someOtherObj;
// es5 的写法 // es6 的写法
var obj = Object.create(someOtherObj); var obj = Object.create(someOtherObj);
obj.method = function() { ... }; obj.method = function() { ... };
``` ```