获得徽章 5
- 2.17 阿里乌鸫科技凉面:
第三面笔试,四道算法题
1. 设计一个lastPromise,比如搜索场景,当连续搜索时,触发了新的Promise,如果之前有Promise未完成就废弃,返回这个新的Promise
2. 对象扁平化
const input = {
a: 1,
b: [1, 2, { c: true }, [3]],
d: { e: 2, f: 3 },
g: null,
};
function flatten(input) {
}
flatten(input);
// 返回
{
"a": 1,
'b[0]': 1,
'b[1]': 2,
'b[2].c': true,
'b[3][0]': 3,
'd.e': 2,
'd.f': 3,
};
3. 实现一个搜索匹配算法 search('hlw',["hello world","test world"]); 返回["hello world"]
search('hdl',["hello world","test world"]); 返回[];
4. 封装xmlHttpRequest 响应url 与 option 入参的变化 并处理异常返回方便调用的地方使用![[流泪]](//lf-web-assets.juejin.cn/obj/juejin-web/xitu_juejin_web/img/jj_emoji_6.dde0d83.png)
![[流泪]](//lf-web-assets.juejin.cn/obj/juejin-web/xitu_juejin_web/img/jj_emoji_6.dde0d83.png)
展开64
![[思考]](http://lf-web-assets.juejin.cn/obj/juejin-web/xitu_juejin_web/img/jj_emoji_15.f58c082.png)
![[流泪]](http://lf-web-assets.juejin.cn/obj/juejin-web/xitu_juejin_web/img/jj_emoji_6.dde0d83.png)