![](https://img-blog.csdnimg.cn/20201014180756927.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
递归
文章平均质量分 67
lihefei_coder
这个作者很懒,什么都没留下…
展开
-
递归获取祖先id集合
function getAncestors(result, id, arr) { arr.some(item => { if (item.id === id) { result.unshift(item.parentId); getAncestors(result, item.parentId, arr); return true; } }); return result;原创 2020-06-22 16:30:54 · 538 阅读 · 0 评论 -
商品规格SKU笛卡尔积计算
typeScript 版function cartesianProductOf(...args: any[]) { return args.reduce( (total: any, current: any) => { let ret = [] as any[]; total.forEach((a: any) => { current.forEach((b: any) => {原创 2020-06-10 16:18:42 · 2304 阅读 · 0 评论 -
reduce实现递归查找多层级对象的属性
let peoples = { zhangsan: { name: '张三', height: 170, child: { name: '张小小' }, }, lisi: { name: '李四', weight: 200, wife: { name: '杨玉环' }, }, wagnwu: {原创 2020-05-14 18:39:47 · 1531 阅读 · 0 评论 -
artTemplate的用法
<!DOCTYPE html><html><head> <meta charset="utf-8"> <meta http-equiv="X-原创 2019-01-28 11:59:36 · 761 阅读 · 0 评论