2.react和vue的区别,class和function区别,优缺点
3.项目中很多state,有没有方法对这些state进行管理 (放到一个对象里面),某个state发生变化,如何更新
扩展运算符,后面添加要修改的变量以及内容,为什么要这样做?...是进行浅拷贝
3.typescript中interface和type的不同,interface和class的不同
4.koa的优势,中间件执行两次,为什么还选用Koa
5.浏览器存储, localStorage, sessionStorage, cookie区别
6.cookie每次请求都会携带吗,跨域cookie如何发送
7.要保存多于10M的缓存,如何实现?PC端和移动端对存储大小的限制一样吗?
存储大小是相对于某个域来讲的,放不下可以开一个子域;不一样
8.let, const, var的本质区别,判断输出?
var a = 'abc'; if (true) { a = 123; let a = 4; console.log(a); }
报错,因为暂时性死区
1XX: 2XX:200 3XX:304 4XX:400,401,403,404,405 5XX:200 from disk/from memory (加载图片等静态资源时出现)
200与304的区别
强制缓存和协商缓存
10.算法:标准化输出
let sNodes = [ {id:"1-1",pid:1,name:'第一节'}, {id:"1",pid:0, name:'第一章'}, {id:"2-1",pid:2,name:'第一节'}, {id:"2",pid:0, name:'第二章'} ];
Output:
[{id:"1",pid:0, name:'第一章',children: [{id:"1-1",pid:1,name:'第一节'}]}, {id:"2",pid:0, name:'第二章',children: [{id:"2-1",pid:2,name:'第一节'}]} ];
function transformTozTreeFormat(sNodes) { let res = []; sNodes.sort((a, b) => a.id.length - b.id.length); for (let i = 0; i < sNodes.length; i++) { let cur = sNodes[i]; if (cur.id.length == 1) { res.push(cur); } else { let ids = cur.id.split('-'); for (let j = 0; j < res.length; j++) { if (res[j].id == ids[0]) { if (!res[j].children) { res[j].children = []; } res[j].children.push(cur); } } } } return res; } let sNodes = [ {id:"1-1",pid:1,name:'第一节'}, {id:"1",pid:0, name:'第一章'}, {id:"2-1",pid:2,name:'第一节'}, {id:"2",pid:0, name:'第二章'} ]; let res = transformTozTreeFormat(sNodes); console.log(res);刚开始写的太着急了,以为有深层嵌套,写了个递归,后来面试官姐姐说你调试一下,改好了
错误示范:
function helper(sNodes, res, index){ if (index == sNodes.length) return; for (let i = index; i < sNodes.length; i++) { let cur = sNodes[i]; if (cur.id.length == 1) { res.push(cur); } else { let ids = cur.id.split('-'); for (let j = 0; j < res.length; j++) { if (res[j].id == ids[0]) { if (!res[j].children) { res[j].children = []; } res[j].children.push(cur); } } } helper(sNodes, res, i + 1); } }面试体验98分,极好
全部评论
(5) 回帖