题解 | #加粗文字#
加粗文字
http://www.nowcoder.com/practice/919c502e497f4c53a3f7c336beec7cb4
{"css":"","js":"let p=document.getElementsByTagName('p')[0];\nlet s=\"<strong>牛客网</strong>,程序员必备求职神器\";\np.innerHTML=s","html":"<p>牛客网,程序员必备求职神器</p>","libs":[]}
加粗文字
http://www.nowcoder.com/practice/919c502e497f4c53a3f7c336beec7cb4
相关推荐
球球与墩墩:这不是前端常考的对象扁平化吗,面试官像是前端出来的
const flattern = (obj) => {
const res = {};
const dfs = (curr, path) => {
if(typeof curr === 'object' && curr !== null) {
const isArray = Array.isArray(curr);
for(let key in curr) {
const newPath = path ? isArray ? `${path}[${key}]` : `${path}.${key}` : key;
dfs(curr[key], newPath);
}
} else {
res[path] = curr
}
}
dfs(obj);
return res;
}
查看3道真题和解析