Dequeue all nodes of current level and Enqueue all nodes of next level
while ( nodeCount > 0 ) { let node = q . shift ( ) ; document . write ( node . data + " " ) ; if ( node . left != null ) q . push ( node . left ) ; if ( node . right != null ) q . push ( node . right ) ; nodeCount -- ; } document . write ( " " ) ; } }