ES7特性

作者: 33jubi | 来源:发表于2020-05-20 15:30 被阅读0次
ES7
  • 没有this
  • 箭头函数
    对比
    ES6
class Human{
  this.gender = ‘male’
  printGender(){
    console.log(this.gender);
  }
}
class Person extends Human{
  constructor(){
    super();
    this.name='max'
    this.gender = 'female'
    
  }
  printMyName(){
    console.log(this.name);
    
  }
  
}

ES7

class Human{
  gender = ‘male’
  printGender=()=>console.log(this.gender);
  
}
class Person extends Human{
  
  name='max'
  gender = 'female'

  printMyName=()=> console.log(this.name);
  
}
Spread & Rest Operator

spread ...
split up arr or obj properties

const newArr = [...oldArr,1,2]
const newObj = {...oldObj,newP:5}

rest ...
merge a list of dunction arguments into an arr

function sortArr(...arg){
  return args.sort()
}
const filter = (...args)=>return args.filter(e=>e===1);
Destructuring

Array destructuring

const n=[1,2,3]
[n1,,n3]=n;//=>n1=1,n3=3

Object destructuring

ob={name:'a',age:22}
{name}=ob
Reference & primitive types refresher 浅拷贝

参考ES6

Reference function

function 不是浅拷贝
object和arr是浅拷贝

import arr functions

1.map()
2.filter()
3.reduce()
4.find()
5.findIndex()
6.concat() 衔接
7.slice() 拆分
8.splice() 插入

相关文章

  • ES7及ES8新特性

    ES7新特性 (ECMAScript2016 新特性) 一、Array 1、Array.prototype.inc...

  • Math方法和es新特性

    es6常用 es7新特性 es8新特性 es9新特性 es10新特性

  • ES7,ES8简单介绍

    ES7新特性: Array.prototype.includes Array.prototype.includes...

  • ES7特性

    1、Array.prototype.includes(value : any) : boolean 常见问题 为什...

  • ES7特性

    ES7 没有this 箭头函数对比ES6 ES7 Spread & Rest Operator spread .....

  • ECMAScript7,8,9

    ES7特性2个 Array.prototype.includes() 指数操作符 ES8特性7个 异步 Objec...

  • ES6~ES7/ES8发生的变化

    ES7新特性 ES7在ES6的基础上添加了三项内容:求幂运算符()、Array.prototype.include...

  • ES8、ES9和ES10新特征

    相信很多人已经用过ES6或者ES7的部分新特性,比如class、promise、解构等等,也对ES6、ES7比较熟...

  • es7新特性-babel配置

    es7 新特性 npx babel-upgrade --write 覆盖 preset-stage-0 配置 ba...

  • js记录

    异步回调 es7新特性Array.prototype.includes() includes() 方法用来判断一个...

网友评论

      本文标题:ES7特性

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