JavaScript BFS solution
Just pure BFS\n\njavascript\nvar levelOrder = function(root) {\n    if (!root) {\n        return [];\n    }\n    const stack = [];\n    stack.push(root);\n    c
Just pure BFS\n\n```javascript\nvar levelOrder = function(root) {\n    if (!root) {\n        return [];\n    }\n    const stack = [];\n    stack.push(root);\n    const result = [];\n    while (stack.length > 0) {\n        const size = stack.length;\n        const temp = [];\n        for (let i = 0; i < size; i++) {\n            const node = stack.shift();\n            temp.push(node.val);\n            if (node.left) {\n                stack.push(node.left);\n            }\n            if (node.right) {\n                stack.push(node.right);\n            }\n        }\n        result.push(temp);\n    }\n    return result;\n};\n```
[]