BFS Iterative JS Solution
\nvar levelOrder = function(root) {\n    if (root == null) return [];\n    let queue = [], values = [];\n    queue.push(root);\n    while (queue.length > 0) {\n
```\nvar levelOrder = function(root) {\n    if (root == null) return [];\n    let queue = [], values = [];\n    queue.push(root);\n    while (queue.length > 0) {\n        let len = queue.length, level = [];\n        for (let i = 0; i < len; i++) {\n            let node = queue.shift();\n            level.push(node.val);\n            if (node.left) queue.push(node.left);\n            if (node.right) queue.push(node.right);\n        }\n        values.push(level);\n    }\n    return values;\n    // Time Complexity: O(n)\n    // Space Complexity: O(n)\n};\n```
['JavaScript']