DEV Community

Discussion on: Stacks vs. Queues In JavaScript

Collapse
 
geompse profile image
Geompse

It is interesting but not true : stacks and queues are native to Javascript under the Array class. While both your classes may have a more readable usage, they have a larger memory footprint and may be slower than the native one. You might be better off extending the Array prototype and creating aliases...

Collapse
 
diek profile image
diek

Well, it is not native as we should understand native.

She is sweetening the usage of queues and stacks, people creating sugar versions of native implementations it's not only an awesome training but necessary to the community to grow.

Collapse
 
geompse profile image
Geompse

I agree but when I read "JavaScript doesn’t provide a native stack data structure, so we have to build our own with an array and a closure or a class." I do not understand "Let's make vanilla Javascript easier for beginners and learn more about it.".

It was meant to be constructive, much love.

PS: The fact that in an other contexts (java...) stacks are "more native" is true aswell (and can also be detailled)