# 一面
# 自我介绍
# 介绍一下你经常使用的es6语法,coding出来
# promsie用过吗,介绍一下
# async await介绍一下,打印值是什么?为什么这样打印?
let p = new Promise((resolve, reject) => {
resolve(1)
})
async function print() {
let res = await p
console.log(res)
}
# class用过吗,用class写一个继承看看?
# 反问,前端团队多大?有什么建议或评价?
# 二面
# 自我介绍
# 写一个防抖
function debounce(fn, time) {
let timer
return function {
if(timer) {
clearsettimeout(timer)
}
timer = setTimeout(() => {
fn.call(...arguments)
},time)
}
}
# 写一个数组加法[1,2,3,[1,2,[2,3,[1,6,6],7],8],6,7]
function add(nums) {
let res = 0
function sum(nums) {
nums.forEach(item => {
if(item instanceof Array) {
sum(item)
}
else {
res += item
}
})
}
return res
}
# 写一个日期格式函数,eg:yyyy/mm/dd,yyyy-mm-dd
function fromat(date, formatModel) {
let year = date.getFullYear(),
month = date.getMonth + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth(),
day = date.getDate() < 10 ? '0' + date.getDate : date.getDate()
switch(formModel) {
case 'yyyy/mm/dd':{
return `${year}/${month}/${day}`
};
case 'yyyy-mm-dd':{
return `${year}-${month}-${day}`
}
}
}
# vue的响应式原理
# 聊一聊你知道的设计模式
# 输入url到页面渲染发生了什么?
# 执行到script会阻塞页面为什么?有什么办法?defer 和 async的区别
# 反问业务
# 三面
# coding,如何实现一个接口前一个请求的结果是后一个请求的参数,且超时会fail? 如果不只包含两个请求呢,该如何实现?
// options包含url的数组,timeout超时时间
// 只有两个url的情况
funtion request(options, timeout) {
function req(url, param) {
return new Promise((resolve, reject) => {
let xhr = new XMLRequestHttp(mehtod, url)
xhr.open('get', url, true)
xhr.timeout = timeout
xhr.readychangestate = function () {
if(xhr.readyState === 4 && xhr.status === 200) {
resolve(xhr.responseText)
}
}
xhr.send()
})
}
req(options[0], param).then(res => {
options[1] = `${options[1]}?param=${res}`
req(options[1]).then(() => {})
})
}
# 聊一聊你的项目经验?你用过quill作富文本编辑器,知道它的一些数据格式和api吗?上家公司有个功能涉及到了树结构,你是怎么设计树结构的?
# 知道发布订阅模式吗?观察者模式?它们之间的区别?
# 45分钟面试差不多结束了,反问
# 业务
# 评价和建议,建议多深入了解一些底层