DEV Community

Discussion on: Writing a queue in JS (using a Linked List)

Collapse
scarvps profile image
ScaRvps

I would recommend adding a tail as well. That way you don’t need loop to add. Right now, add is O(n). With tail, it will be O(1). Hope this helps.