breadth-first traversal

using JavaScript’s Array class and its queue/stack-like functionality