es6新特性

es6的新特性

    1.新的变量         let、const

    2.箭头函数         ()=>{}

    3.模板字符串      let b = `<h1>${a}</h1>`;

    4.解构赋值         { a,b,c } = { a : 1,b = 2,c = 3 }  

    5.函数默认参数  function add( x=20,y=20 ){  console.log(x + y)  } add();  //在没有传参的情况下输出40

    6.展开运算符   const arr = [ 1,2,3 ]; console.log( ...arr );  //输出123

    7.对象字面量   提供一种简写方式,当一个对象内键对应的值是一个变量a,例如 let a = 0;{   a :a   },可以简写为 {  a  }

    8.class

    9.extends     继承

    10.for of        循环

    11.includes() /*  返回布尔值,是否找到该字符串  */    startsWith() endWith   /*   返回布尔值,该字符串是否在要寻找的字符串头部尾部  */

    12.repeat()    将原字符串重复n次

    13.trimStart() trimEnd 消除字符串空白

    14.Array.form()  将对象转换为数组

    15.Array.of()   将一组值转换为数组

    16.includes()    查看数组是否有该指定的值

    17.flat()     数组降维 [1,2,3,[4,5]].flat(1);   //[1,2,3,4,5]

    18.Symbol()   第七种数据类型,独一无二的

    19.Set()      数组去重

    20.Map()    

    21.Promise()  异步

原文地址:https://www.cnblogs.com/wayaoyao/p/10960901.html