摘要: flat 数组扁平化,第三种和第四种主要用于面试问题。 // 递归实现 function flat1(arr) { let res = []; for (const item of arr) { if (Array.isArray(item)) { res = res.concat(flat1(it 阅读全文
posted @ 2020-09-11 10:31 alohaplat 阅读(235) 评论(0) 推荐(0)
摘要: Promise 并发限制 并发请求限制,n个请求,每次最多只能同时存在limit个请求,剩余的在队列中等待。 promiseAll 实现并发请求,n个请求,每次最多同时请求limit个,所有请求完成后处理数据。 并发请求限制 思路: 定义一个请求池,run 函数每次将等待队列中任务加入到请求池中,直 阅读全文
posted @ 2020-09-10 10:14 alohaplat 阅读(2164) 评论(0) 推荐(0)
摘要: ### Margin 塌陷问题 ```html box1 box2 ``` > 想要得到的效果 ![](https://img2020.cnblogs.com/blog/2107786/202008/2107786-20200803211423044-42850... 阅读全文
posted @ 2020-08-03 21:09 alohaplat 阅读(63) 评论(0) 推荐(0)
摘要: ## 防抖与节流 --- - 函数防抖是指在事件被触发 n 秒后再执行回调,如果在这 n 秒内事件又被触发,则重新计时。这可以使用在一些点击请求的事件上,避免因为用户的多次点击向后端发送多次请求。 - 函数节流是指规定一个单位时间,在这个单位时间内,只能有一次触发事件的回调函数执行,如果在同一个单位时间内某事件被触发多次,只有一次能生效。节流可以使用在 scroll 函数的事件监听上,通过事... 阅读全文
posted @ 2020-08-02 22:20 alohaplat 阅读(93) 评论(0) 推荐(0)
摘要: ### 原型链1 求代码结果```function Foo() { Foo.getValue = function() { console.log(1); } this.getValue = function() { console.log(2); }} Foo.prototype.getValue = function() { console.log(3)}Foo.getV... 阅读全文
posted @ 2020-07-29 20:52 alohaplat 阅读(121) 评论(0) 推荐(0)