2023-5-16 猿辅导 一面 寄

2023-5-16 猿辅导 一面 寄

问题

  1. 项目相关
  2. cookie 和 token 的区别,优势
  3. Script defer,async 的原理,什么钩子
  4. 按需引入(以组件库开发者)
    1. elementUI 按需引入的原理
  5. 浮点数计算机表现形式
  6. 看代码输出
const a = new Promise((resolve, reject) => {
console.log('promise1')
resolve()
}).then(() => {
console.log('promise2')
})

setTimeout(() => {
console.log(‘timeout’)
})

const b = new Promise(async (resolve, reject) => {
await a
console.log('after1')
await b
console.log('after2')
resolve()
})
console.log(‘end’)
  1. 快排思路,桶排序
  2. 深拷贝
function deepcopy(target, map = new Map()) {
if (typeof target !== 'object') return target
if (!target) return target
let constructor = target.constructor
const types = ['Set', 'Map', 'RegExp', 'Symbol', 'BigInt', 'Number']
if (types.includes(constructor.name)) return new constructor(target)
if (map.get(target)) return map.get(target)
map.set(target, true)
let ans = Array.isArray(target) ? [] : {}
for (let key in target) {
if (target.hasOwnProperty(key)) {
ans[key] = deepcopy(target[key], map)
}
}
return ans
}

new Number(123)

反问

  1. 业务做什么
  2. 技术栈
    1. angular