ES6 要点梳理

模板字符串、多行字符串

函数默认值、解构函数

集成原型新方式:object.create

箭头函数

promise

变量的声明方式:let const

类的声明:class , 继承关键字: extends

module import export 用法

Generatro 异步函数  *  jield  异步操作同步化表达,执行权交替来实现异步编程

function* main() {

  var result = yield request("http://some.url");

  var resp = JSON.parse(result);

console.log(resp.value);

}

function request(url) {

  makeAjaxCall(url, function(response){

it.next(response);

  });

}

var it = main();

it.next();

//参考:https://www.jianshu.com/p/c7f4129d7794

function* longRunningTask(value1) {

  try {

var value2 = yield step1(value1);

var value3 = yield step2(value2);

var value4 = yield step3(value3);

var value5 = yield step4(value4);

// Do something with value4

  } catch (e) {

// Handle any error from step1 through step4

  }

}

scheduler(longRunningTask(initialValue));

function scheduler(task) {

  var taskObj = task.next(task.value);

  // 如果Generator函数未结束,就继续调用

  if (!taskObj.done) {

task.value = taskObj.value

scheduler(task);

  }

}

你可能感兴趣的:(ES6 要点梳理)