JavaScript BFS 
\nvar connect = function(root) {\n    if(!root) return;\n    const queue = [root];\n    \n    while(queue.length) {\n        const size  = queue.length;\n      
```\nvar connect = function(root) {\n    if(!root) return;\n    const queue = [root];\n    \n    while(queue.length) {\n        const size  = queue.length;\n        const level = queue.slice();\n\n        for(let i = 0; i < size; i++) {\n            const currentNode = queue.shift();\n            currentNode.next  = level[i + 1];\n            if(currentNode.left)  queue.push(currentNode.left);\n            if(currentNode.right) queue.push(currentNode.right);\n        }\n    }\n};\n```
[]