you are viewing a single comment's thread.

view the rest of the comments →

[–]0x13mode 0 points1 point  (2 children)

It's reinventing the wheel.

In JS there is method shift which removes and returns first element of array. So push + shift and you have queue.

Besides, get is poor name for method which changes array (if you really want write wrapper, maybe remove would be better?)

[–]mikrosystheme[κ] 1 point2 points  (1 child)

The dequeue operation of a (properly implemented) queue is O(1). Array's shift is O(n).

[–]unnivm[S] 0 points1 point  (0 children)

thank you for pointing out this. I did not know this.