- 回调函数
- 事件监听
- 发布/订阅
- Promise 对象
git pull 强制
1 | git fetch --all |
回调
1 | a('1.json',function(d){console.log(d);}) |
promise
1 | a('1.json') |
generator
···
function* gen(x){
var y = yield x + 2;
return y;
}
var g = gen(100);
g.next() // { value: 102, done: false }
g.next() // { value: undefined, done: true }
···
function* gen(){
var rs = yield fetch(‘1.json’,function(d){
console.log(111,d);
console.log(222,d.data);
});
console.log(rs);
}
var g = gen();
console.log(g);
g.next();
console.log(g);
fetch(‘1.json’)
.then((response) => {
return response.json();
})
.then((data) => {
console.log(data);
});