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

Merge branch 'gh-pages' of github.com:ruanyf/es6tutorial into gh-pages

This commit is contained in:
ruanyf 2017-09-01 22:48:39 +08:00
commit a0249e7506
4 changed files with 4 additions and 4 deletions

View File

@ -399,7 +399,7 @@ Object.setPrototypeOf(B, A);
B.__proto__ = A;
```
这两条继承链,可以这样理解:作为一个对象,子类(`B`)的原型(`__proto__`属性)是父类(`A`);作为一个构造函数,子类(`B`)的原型(`prototype`属性)是父类的实例。
这两条继承链,可以这样理解:作为一个对象,子类(`B`)的原型(`__proto__`属性)是父类(`A`);作为一个构造函数,子类(`B`)的原型对象`prototype`属性)是父类的原型对象(`prototype`属性)的实例。
```javascript
Object.create(A.prototype);

View File

@ -844,7 +844,7 @@ class Foo {
## new.target属性
`new`是从构造函数生成实例的命令。ES6 为`new`命令引入了一个`new.target`属性,该属性一般用在构造函数之中,返回`new`命令作用于的那个构造函数。如果构造函数不是通过`new`命令调用的,`new.target`会返回`undefined`,因此这个属性可以用来确定构造函数是怎么调用的。
`new`是从构造函数生成实例的命令。ES6 为`new`命令引入了一个`new.target`属性,该属性一般用在构造函数之中,返回`new`命令作用于的那个构造函数。如果构造函数不是通过`new`命令调用的,`new.target`会返回`undefined`,因此这个属性可以用来确定构造函数是怎么调用的。
```javascript
function Person(name) {

View File

@ -313,7 +313,7 @@ foo() // ReferenceError: x is not defined
```javascript
let foo = 'outer';
function bar(func = x => foo) {
function bar(func = () => foo) {
let foo = 'inner';
console.log(func());
}

View File

@ -528,7 +528,7 @@ $traceurRuntime.ModuleStore.getAnonymousModule(function() {
### 命令行转换
作为命令行工具使用时Traceur 是一个 Node 的模块,首先需要用 Npm 安装。
作为命令行工具使用时Traceur 是一个 Node 的模块,首先需要用 npm 安装。
```bash
$ npm install -g traceur