1. 箭头函数:
    1. 代码:
      let a = (i,j) => {
      return i + j;
      }
    2. 编译为:
      var a = function(i, j) {
      return i + j;
      };
  2. 类:
    class A{
     constructor(){
         console.log(1);
     }
    }
    class B extends A{
     constructor(){
         super();
     }
    }
  3. 字符串模板:
    let name = 'lee';
    let output = `hello ${name}`;
  4. 解构:
    let [a,b,c] = [1,2,3];
    let func = ({name:x}){
     console.log(x);
    }
  5. 获取剩余参数:
    let func = (x,...y){
     console.log(y);
    }
  6. for…of 语法:
    const arr = [1,2,3];
    for(let item of arr){
     console.log(item);
    }
  7. 导入/导出:
    1. 导出:
      export default a;
      export {a,b};
    2. 导入:
      import a from 'test';
      import {a,b} from 'test';
  8. 集合/字典:
    1. 集合:
      let obj = new Set();
      obj.add("hello").add("goodbye").add("hello");
      console.log(obj.size);
      console.log(obj.has('hello'));
    2. 字典:
      let obj = new Map();
      obj.set('num', 1);
      console.log(obj.get('num'));
  9. 字符串/数组/对象:
    let str = 'abc';
    // 1. 判断 str 中是否包含 'c'
    console.log(str.includes('c'));
    // 2. 重复 str 3次
    str.repeat(3);
    console.log(str);
    let arr = new Array(3);
    // 3. 将 arr 填充成 7
    arr.fill(7);
    console.log(arr);
    let obj = {name:'lee'};
    // 4. 往 obj 后面添加对象 {gender:'male'}
    let new_obj = Object.assign(obj,{gender:'male'});
    console.log(new_obj);
文档更新时间: 2020-11-22 20:37   作者:lee