FIFO queue in Javascript