JavaScript queue data structure