mirror of
https://github.com/ruanyf/es6tutorial.git
synced 2025-05-24 18:32:22 +00:00
Merge branch 'gh-pages' of github.com:ruanyf/es6tutorial into gh-pages
This commit is contained in:
commit
a0249e7506
@ -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);
|
||||
|
@ -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) {
|
||||
|
@ -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());
|
||||
}
|
||||
|
@ -528,7 +528,7 @@ $traceurRuntime.ModuleStore.getAnonymousModule(function() {
|
||||
|
||||
### 命令行转换
|
||||
|
||||
作为命令行工具使用时,Traceur 是一个 Node 的模块,首先需要用 Npm 安装。
|
||||
作为命令行工具使用时,Traceur 是一个 Node 的模块,首先需要用 npm 安装。
|
||||
|
||||
```bash
|
||||
$ npm install -g traceur
|
||||
|
Loading…
x
Reference in New Issue
Block a user