DEV Community

Discussion on: Queue Data Structure in Javascript

Collapse
 
ilya_sher_prog profile image
Ilya Sher • Edited

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.

Collapse
 
Sloan, the sloth mascot
Comment deleted
Collapse
 
ilya_sher_prog profile image
Ilya Sher

misleading beginners

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