手写三道算法题
1.实现batchRequest(urls: string[], maxCount: number)方法,最多并行maxCount个;
batchRequest(['url1', 'url2', ...., 'url100'], 3)
batchRequest(['url1', 'url2', ...., 'url100'], 3)
运行过程是 [url1,url2,url3] => [url4,url2,url3] => [url4,url2,url5] ........
2.实现show.Toast
3.<div id="root" data-v="3">
<p data-v="1">p1</p>
<span data-v="2">
<span data-v="4">span2</span>
</span>
<p data-v="99">p2</p>
</div>
<p data-v="1">p1</p>
<span data-v="2">
<span data-v="4">span2</span>
</span>
<p data-v="99">p2</p>
</div>
遍历DOM树,拿到每个路径的便签和当前经过的便签的最大data-v的值
["DIV"] 3
["DIV", "P"] 3
["DIV", "SPAN"] 3
["DIV", "SPAN", "SPAN"] 4
["DIV", "P"] 99
traverse(document.getElementById('root'));
["DIV", "P"] 3
["DIV", "SPAN"] 3
["DIV", "SPAN", "SPAN"] 4
["DIV", "P"] 99
traverse(document.getElementById('root'));
是我太菜了😰
全部评论
(1) 回帖