拼xx前端一二面面经
一面
自我介绍
实习的收获
项目工程化怎么做的
代码冲突怎么解决
1、vue数据双向绑定原理,2.0和3.0的区别
2、事件循环,宏任务、微任务包括哪些
3、下面这个输出是精确的吗,为什么
setInterval(()=>{
console.log("data:" + new Date())
},3000) 4、跨域的原因,解决方案 5、用XhrHttpReuqest实现一个ajax跨域请求,可以支持自定义Headers,返回的是一个promise
const request = (
url: string,
params: {
method: Get,
body: string;
headers:{
[index]:string
}
}
):promise{
//TODO
} 没写出来,面试官让讲一下promise 6、然后又出了个简单的promise写
const setPromiseConsole = ()=>{
//TODO promise实现每隔3秒输出时间
return new Promise((resolve,reject)=>{
setTimeout(()=>{
resolve(+new Date())
},3000)
})
}
setPromiseConsole().then(result=>{
console.log('result',result)
}) 反问
二面
自我介绍
1、
let a = [1,2,3]
let d = {}
function b(c,d){
c = []
d.b = 2
d = {a:1}
}
b(a,d)
console.log(a)
console.log(d) 求大佬给解答下这题啊。。。
2、 var a = function(){}
var b = [1,a]
console.log(JSON.stringify(a))
console.log(JSON.stringify({a}))
console.log(JSON.stringify(b)) 3、 Promise.reject(7).then( ()=>console.log(1), undefined ).then( ()=>console.log(2), (err)=>console.log(err,3) )4、写一个函数,它支持传入一个32位正整数,返回该正整数的按位反转。
例如:
输入12,二进制为0000 0000 0000 0000 0000 0000 0000 1100
输出805306368,二进制为0011 0000 0000 0000 0000 0000 0000 0000
5、模态框样式是:背景色#eee,填满整个屏幕,模态框内容区长400px,宽400px,上下左右均居中对齐
业务方调用该API时,仅传入模态框的内容
如果多次调用renderAlert,后一个模态框要覆盖住前一个
<html>
<body>
<button id="btn">点我弹alert</button>
</body>
<script>
function renderAlert(xxx){
//TODO
}
var currentAlert = 0
document.getElementById('btn').addEventListener('click',()=>{
renderAlert('<div>我是第' + currentAlert + '个模态框</div>')
})
</script>
</html>
6、用react或vue写一个显示系统时间的组件
查看16道真题和解析