es6

作者: 从前慢pearl | 来源:发表于2017-10-09 10:58 被阅读0次

1,constructor && super

图片.png 图片.png 图片.png 图片.png

代码

2,箭头函数 => 拯救 => setTimeout里面的this

图片.png

代码

图片.png

第三种方法箭头函数

 class Animal {
    constructor(){
    this.type = 'animal'
    }
    says(say){
        setTimeout( () => {
        console.log(this.type + ' says ' + say)
        }, 1000)
    }
}
var animal = new Animal()
animal.says('hi')  //animal says hi
图片.png

3,模板字符串 &&模板变量

图片.png

4,解构

图片.png

相关文章

网友评论

      本文标题:es6

      本文链接:https://www.haomeiwen.com/subject/ocbuyxtx.html