Leadgq

Results 2 comments of Leadgq

// 我更喜欢这种,因为在真是业务场景中,应该保留原始解构 // 只是把深层的children拿出来放到第一层 个人想法 function treeToList(data) { if (!Array.isArray(data) && data.length === 0) return; // 方式1 return data.reduce((prev, cur) => { const {children} = cur; return Array.isArray(children) && children.length...

Array.prototype._flat = function (depth = Infinity) { if (!Array.isArray(this) && this.length === 0) return; depth--; return this.reduce((prev, cur) => { if (Array.isArray(cur) && depth >= 0) { prev = [...prev,...