We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
/** * 广度遍历优先,获取叶子节点 * @param {*} obj * * let obj = {a:1, b:"sdf", c:{d: 123, e: "vv"}, f:{g:{h:{i:"afs"}, j:4545}, k: 123}, l: 23 } */ function bfsTraverse(obj) { let leafList = [] let stack = [...Object.values(obj)] while (stack.length) { let item = stack.shift() if (item && typeof item != 'object') { leafList.push(item) } else { Object.values(item).forEach((childValue) => { stack.push(childValue) }) } } return leafList }
The text was updated successfully, but these errors were encountered:
No branches or pull requests
树操作
遍历
The text was updated successfully, but these errors were encountered: