快手前端秋招面经8.31
迟来的秋招面经分享,最近在准备春招,把之前秋招的面经都分享一下
秋招-快手
一面 8.31 60min
和实习的时候一个部门。。。一个面试官。。。又是手撕四个题。。。好难啊😭
题目一
手写Vue双向数据绑定
题目二
//说输出setTimeout(() => {console.log(1);}, 0);console.log(2);(new Promise((resolve) => {console.log(3);})).then(() => {console.log(4);});console.log(5);//2//3//5//1
题目三
随机生成一个合法的css颜色值 如 #c1c1c1
function solution() { let res = '#'; let num = parseInt(Math.random() * 0xffffff); res += num.toString(16); return res;}console.log(solution());
题目四
多维数组维度Array.prototype.getLevel [1,[1,2,[1]]].getLevel() === 3
Array.prototype.getLevel = function () { let max = 0 const list = this const stack = [list] while(stack.length > 0) { const data = stack.pop() for(let i=0; i<data.length; i++) { let item = data[i] if (Array.isArray(item)) { item.level = (data.level || 1) + 1 max = Math.max(item.level, max) stack.push(item) } } } return max}const a1 = [1, 2, [1], [1, [2, [3]]]]const a2 = [12, 3, [[6], [7, [7, [66]]], [7]], 4, [5]]console.log(a1.getLevel(), '1111111') //4console.log(a2.getLevel(), '2222222') //5