面试日期:2023.07.11
面试时长:60min
面试工具:迈联会议
Promise.retry = function (fn, times, delay) { return new Promise((resolve, reject) => { const reSend = () => { fn().then(data => { resolve(data) }, (error) => { if (times == 1) { reject(error) } else { times-- setTimeout(() => { reSend() }, delay) } }) } reSend() }) } //用例 当时不会写,总想着发请求 忘记了最基本的东西 const fetchData = () => { return new Promise((resolve, reject) => { const random = Math.random(); if (random > 0.9) { resolve('Data successfully retrieved'); } else { reject('Failed to retrieve data'); } }); }; Promise.retry(fetchData, 5, 1000) .then(data => console.log(data), error => console.error(error))
没问,面试官本来说要有介绍的项目组的工作内容,可能看时间到了也没说,直接和我拜拜了,直觉必凉。
1.整个面试体验其实很好,小哥循循善诱引导思路,奈何我太菜~(太久没看八股了,还要准备秋招!)
#前端##cvte##cvte面试#