记录开发中的使用 js 减少重复操作的优良代码
生成有序数组
1 | orderedArray=(n)=>[...new Array(n).keys()] |
计算对象+=每个值得长度
中英文都计算为一个字符长度
1 | let test = { a: "hhh", dd: "ddd", e: { f: "哈哈哈" } }; |
对象转为 table 显示的树状带 children 结构(可能带 bug)
data 测试数据集合
1 | module.exports = { |
index.js
1 | const data = require("./data.js"); |
输出
1 | [ |