Generator函数
控制函数的执行过程,手工暂停,继续
案例二
function* getStockPrice(stock){
while(true){
yield Math.random()*100;
}
}
var priceGenerator = getStockPrice()
var limitPrice = 15;
var price = 100;
while(price > limitPrice){
price = priceGenerator.next().value;
console.log(`the generator reutrn ${price}`);
}
console.log(`buying at ${price}`)
解构复制
箭头表达式