有赞前端一面
大概持续了一个小时吧,用的微信面试,没能录音,具体的记不清楚了
1.简单介绍
2.项目相关
3.如果让你来做前端监控,你会怎么做
4.讲下async这个库。
5.编程题(实现函数从而改变对象)
const testData = { a_v: 123, a_y: [1, 2, 3, 4], a_d: { s: 2, s_3: 3 }, a_f: [{ a_g: 5 }], a_a_d: 1 } // a_d => aD // a_a_d =>aAD function underscoreToHump(data, isDeep=true) { //要实现的函数 } const result = underscoreToHump(testData) console.log(result)
我给下我的答案吧
function underscoreToHump(data, isDeep=true) { if(data == null || data == undefined){ return ; } let newObj = {}; if(typeof data !== 'object'){ return data; }else{ if(!Array.isArray(data) ){ for(let key in data){ let keyStr = key.toString(); if(keyStr.indexOf("_")>-1){ //转换属性名 let tmp = keyStr.split("_"); let first = tmp[0]; tmp = tmp.map(i => i.toUpperCase()); tmp[0] = first; let newKey = tmp.join(""); //赋值 newObj[newKey] = underscoreToHump(data[key], isDeep); }else{ //赋值 newObj[key] = underscoreToHump(data[key], isDeep); } } }else{ let len = data.length; for(let i = 0; i< len; i++){ data[i] = underscoreToHump(data[i], isDeep); } return data; } } return newObj; }
#有赞##前端工程师##面经##内推##秋招##提前批#