I don't mean to be rude by this question, but why would anyone use this instead of arrays? It's just implementing arrays with strings. Which if storage is the concern, JSON is definitely a better, more standardized medium. Is there something I'm missing?
The built in JS array type can be used as a stack by using the built in .push() and .pop() methods. For a queue, you just push to index 0. No problem there if you ask me.
Also if you want more support there are countless libraries out there that cover other data structures.... Without using strings!
I don't mean to be rude by this question, but why would anyone use this instead of arrays? It's just implementing arrays with strings. Which if storage is the concern, JSON is definitely a better, more standardized medium. Is there something I'm missing?
The real WTF for me is a programming language that has no lists. Or queues. Or stacks. Or ...
The built in JS array type can be used as a stack by using the built in
.push()
and.pop()
methods. For a queue, you just push to index 0. No problem there if you ask me.Also if you want more support there are countless libraries out there that cover other data structures.... Without using strings!
But it's still an array, not a stack or a queue. You can't modify random elements in these structures.
A string list might for exampel originate from user input who can't enter arrays in form fields.
But I'm with you. I'd split the string into an array and the work on the array.