Discussion on: Queue Data Structure in Javascript

ilya_sher_prog profile image
Ilya Sher

Low code quality. Please do not learn from this.

Does not work as expected - it implements LIFO, not FIFO.

dequeue and front return inconsistent arbitrary values such as "Underflow" and "No elements in Queue", which are indistinguishable from values which could be placed in the queue.

ifs in these functions use {...} inconsistently - one uses while the other one does not, in same situation.

The comment // Functions to be implemented (and on) is just a clutter.

// returns underflow when called -> // returns the string "Underflow" when called

The data field has almost zero semantic meaning. items would be much better for example.

// front function just above the function - clutter with zero additional information, same for // isEmpty function

As whole, this class is very thin wrapper around Array, providing no additional functionality.

aleksandrhovhannisyan profile image
Aleksandr Hovhannisyan

Not to mention the first paragraph of the article is a copy-paste from W3Schools.

Also, who uses the terms "front" and "rear" in practice? They're more commonly referred to as head and tail, respectively.

It's a shame that platforms like Dev.to and Medium, while generally informative, also give a voice to people who are not actually experienced at what they do, and who will only end up misleading beginners.

ilya_sher_prog profile image
Ilya Sher

misleading beginners

That's my main concern. It's pretty bad situation.