CVTE前端二面面经
1、项目难点
2、100个http会有多少条TCP连接。
3、http2.0头压缩算法了解不
4、异步编程题
题目一
function queue(list){
// 在这里填写。
}
function task1(next){
setTimeout(function(){
console.log(1);
next();
}, 10000)
}
function task2(next){
console.log(2)
next();
}
function task3(next){
setTimeout(function(){
console.log(3);
next();
}, 200)
}
queue([task1, task2, task3]) // 1 2 3
我自己的参考答案
// 参考答案
function queue(list){
let fn = list.shift();
fn(next);
function next(){
if(list.length === 0) return;
let fn = list.shift();
fn(next);
}
}
题目二
function queue(list, count){
}
function task1(next){
setTimeout(function(){
console.log(1);
next();
}, 1000)
}
function task2(next){
console.log(2)
next();
}
function task3(next){
setTimeout(function(){
console.log(3);
next();
}, 200)
}
queue([task1, task2, task3], 2) // 输出 2 3 1
我自己的参考答案function queue(list, count){
let array = list.splice(0,count);
for(let fn of array) {
fn(next);
}
function next(){
let array = list.splice(0,count);
for(let fn of array) {
fn(next);
}
}
}
后续 ,最后沟通OC了。