var arr = [
{ id: 1, canAccess: false },
{ id: 2, canAccess: true },
{ id: 3, canAccess: false, children: [{ id: 4, canAccess: true }] },
{ id: 5, canAccess: false, children: [{ id: 6, canAccess: false, children: [{ id: 7, canAccess: true }] }] },
{
id: 8, canAccess: true, children: [{
id: 9, canAccess: true,
children: [{ id: 10, canAccess: false, children: [{ id: 11, canAccess: true }] }]
}]
}
]
let newArr = []; // 用来接收新id
var findCan = function (V) {
V.forEach(item => { // 把传入的数组循环遍历
if (item.canAccess === true) {
newArr.push(item); // item 为true 把该对象添加到新数组
}
if (item.children) {
// console.log(‘有 children’, item.children); // 有 children 的话就调用自身
findCan(item.children) // 递归调用自身
}
})
}
findCan(arr) // 调用函数
console.log(newArr);
需求:根据传入的树形数组和 id 找出 该id 的一组信息 例如:根据该员工id找到该员工的一组成员
// 例如:根据该员工id找到该员工的一组成员
var array = [
{
id: 1,
children: [{
id: 2,
children: []
}]
},
{
id: 3,
children: []
},
{
id: 4,
children: [{
id: 5,
children: [{
id: 6,
children: []
},
{
id: 7,
children: []
}]
}]
}
]
let newArr;
let findAll = function (v, num) {
v.forEach(e => {
if (e.id === num) { newArr = e } // 某一项的id 等于 传入的id 就把该数组找出来
if (e.children.length > 0) {
findAll(e.children, num)
}
})
ES6
-
列举常用的ES6特性:
-
箭头函数需要注意哪些地方?
-
let、const、var
-
拓展:var方式定义的变量有什么样的bug?
-
Set数据结构
-
拓展:数组去重的方法
-
箭头函数this的指向。
-
手写ES6 class继承。
微信小程序
-
简单描述一下微信小程序的相关文件类型?
-
你是怎么封装微信小程序的数据请求?
-
有哪些参数传值的方法?
-
你使用过哪些方法,来提高微信小程序的应用速度?
-
小程序和原生App哪个好?
-
简述微信小程序原理?
-
分析微信小程序的优劣势
-
怎么解决小程序的异步请求问题?
其他知识点面试
-
webpack的原理
-
webpack的loader和plugin的区别?
-
怎么使用webpack对项目进行优化?
-
防抖、节流
-
浏览器的缓存机制
-
描述一下二叉树, 并说明二叉树的几种遍历方式?
-
项目类问题
-
笔试编程题:
最后
技术栈比较搭,基本用过的东西都是一模一样的。快手终面喜欢问智力题,校招也是终面问智力题,大家要准备一下一些经典智力题。如果排列组合、概率论这些基础忘了,建议回去补一下。