// let date = '晚上';
// let centent = `${date}吃什么`
// console.log(centent)
// let name = 'yht'
// let cen = 'hhh'
// const list = {
// name,
// cen
// }
// console.log(list)
// let name = m => m*m
// console.log(name(9))
// let ad = document.getElementById('add')
// ad.addEventListener("click",function(){
// // this.style.background = 'red'
// let _this = this
// setTimeout(()=>{
// this.style.background = 'red'
// },1000)
// })
// const list = [23,15,10,9,6,21]
// const ret = list.filter(itemr => itemr % 3 == 0)
// console.log(ret)
// let dainying = ['三体','电影','126']
// for(let a in dainying){
// console.log(a)
// }
// let list = {
// name:'三体',
// stu:['三体','电影','126'],
// [Stmbol.iterator(){
// let index = 0;
// return {
// nex
// }
// }]
// }
// for(let a of list.stu){
// console.log(a)
// }
// -----------生成器函数声明及调用--------------------------------
// 生成器
// 异步编译,纯回调函数, node fs ajax mongodb
// yield:函数代码的分隔符
// function * gan(){
// yield 'hhhhhh',
// yield 'ddddd',
// yield 'xxxxxxx'
// }
// let aa = gan();
// console.log(aa.next());
// console.log(aa.next());
// console.log(aa.next());
// console.log(aa.next());
// 遍历
// for(let a of gan()){
// console.log(a)
// }
// -----------生成器参数传递------------------------------
// --------------生成器函数实例---------------------------
// 异步编程 文件操作 网络操作(ajax,request) 数据库操作
// 定时执行
// function one (){
// setTimeout(()=>{
// console.log(111)
// aa.next();
// },1000)
// }
// function two (){
// setTimeout(()=>{
// console.log(222)
// aa.next();
// },2000)
// }
// function three(){
// setTimeout(()=>{
// console.log(333)
// aa.next();
// },3000)
// }
// function * gan(){
// yield one();
// yield two();
// yield three();
// }
// // 调用生成器函数
// let aa = gan();
// aa.next()
// 模拟用户数据操作
function getData(){
setTimeout(()=>{
let data = '用户数据'
iterator.next(data)
},1000)
}
function getOrder(){
setTimeout(()=>{
let data = '商品列表'
iterator.next(data)
},1000)
}
function getOrderData(){
setTimeout(()=>{
let data = '商品数据'
iterator.next(data)
},1000)
}
function * gan(){
let user = yield getData();
console.log(user)
let list = yield getOrder();
console.log(list)
let data = yield getOrderData();
console.log(data)
}
// 调用生成函数
let iterator = gan();
iterator.next();
// 利用数组方法定时执行
// let data = [{
// txt:'111',
// itme:1000
// },{
// txt:'222',
// itme:3000
// },{
// txt:'333',
// itme:7000
// }]
// for(let a of data){
// setTimeout(()=>{
// console.log(a.txt)
// console.log(a.itme)
// },a.itme)
// }
<div style="width: 50px;
height: 50px;
background: pink;" id="add"></div>