美团 食杂零售 前端一面
暑期考察基础比较多。
(1)数组和链表的区别
读取 和 删除 的时间复杂度
(2)什么是TCP和UDP
它们之间有什么区别?
(3)什么是进程与线程?
(4)HTTP和HTTPS 区别是啥?
(5)Array上有什么方法
比如 map, push
(6)
<div id="B">
<div id="A"></div>
</div>
document.getElementById('A').addEventListener('click', () => { console.log('A') })
document.getElementById('B').addEventListener('click', () => { console.log('B') })
鼠标点击A元素内,此时输出?(事件冒泡)
(7)跨域的原因及方案、如何解决跨域
cookie、localStorage、sessionStorage有什么区别
(8)
[a][b][c]
a,b,c {
display: inline-block,
width: 100px,
height: 100px,
}
b {
position: absolute,
top: 50px,
}
说下元素的排列情况
(9)setState是同步还是异步?具体做了什么?
代码:
树形结构取值
{ id: 1, children: [ { id:2, children: [ {id:4, children: []} ], }, { id:3, children: null } ] } 输入4,输出[1,2,4] 输入3,输出[1,3] 输入5,输出[]
代码输出题
async function async1() { console.log('async1 start') await async2() console.log('async1 end') } async function async2() { console.log('async2') } console.log('start') async1() setTimeout(() => { console.log('timer1') Promise.resolve().then(function () { console.log('promise1') }) }, 0) Promise.resolve().then(function () { console.log('promise2') }) new Promise(resolve => { console.log('Promise3') resolve() }).then(() => { console.log('Promise3 then') }) console.log('end') //start、async1 start、async2、Promise3、end、async1 end、promise2、Promise3 then timer1 promise1#面经#