前端算法学习路径——【算法】浅谈前端算法
前端处理数据也可以很简单
更优更简洁的生成树和操作树算法

李银城-我接触过的前端数据结构与算法
Effective前端24-学习常用的前端算法与数据结构
为什么我认为数据结构与算法对前端开发很重要?

图形算法(邻接矩阵)在前端领域的应用
javascript将扁平的数据转为树形结构
==》 antd 优秀源码库里的index.js

  1. /**
  2. * Convert an array to a tree-structured array.
  3. * @param {array} array The Array need to Converted.
  4. * @param {string} id The alias of the unique ID of the object in the array.
  5. * @param {string} parentId The alias of the parent ID of the object in the array.
  6. * @param {string} children The alias of children of the object in the array.
  7. * @return {array} Return a tree-structured array.
  8. */
  9. export function arrayToTree(
  10. array,
  11. id = 'id',
  12. parentId = 'pid',
  13. children = 'children'
  14. ) {
  15. const result = []
  16. const hash = {}
  17. const data = cloneDeep(array)
  18. data.forEach((item, index) => {
  19. hash[data[index][id]] = data[index]
  20. })
  21. data.forEach(item => {
  22. const hashParent = hash[item[parentId]]
  23. if (hashParent) {
  24. !hashParent[children] && (hashParent[children] = [])
  25. hashParent[children].push(item)
  26. } else {
  27. result.push(item)
  28. }
  29. })
  30. return result
  31. }

深度剖析:如何实现一个 Virtual DOM 算法
JavaScript基于时间的动画算法

JavaScript设计模式与开发实践

前端图表聚合函数(借鉴sql的语法实现前端的数据处理)

扩展阅读:
破解前端面试系列(3):如何搞定纸上代码环节?

前言

列举涉及的知识点:

  • 递归
    • 使用递归实现不堵塞多串行请求
    • 递归查DOM
    • 递归查DOM非递归实现
    • 查找下个结点
    • 复杂选择器的查DOM (给定id和class 找出相应dom)
  • 重复值处理
    • set、map的实现
    • 引申—数组去重
  • 堆和栈
  • 节流
  • 图像处理与图形算法

一句惊醒梦中人的话:



前端遇到的数据处理算法 - 图1

参考资料

笔记来源:

  • 《高效前端—web高效编程与优化实践》