In my daily work, I mainly use C # and sometimes use javascript, so please, javascript Gurus, do not judge my questions rudely!
- The array implements Stack by providing methods
push
, pop
but is peek
missing, why? (yes, trivial to implement, but still) - An array implements a queue, but operations are called
push
- shift
or unshift
- pop
instead of, enqueue
and
dequeue
why name them differently? Is it inspired by Python and Ruby? - Why are the APIs for the array, stack and queue combined into one object instead of separating the interface and having different objects for this? Is it because the implementation is cheap?
- Semantically in many languages (C #, C ++, Java), an array is a continuous block in memory and is not re-significant. On the other hand, a basic collection that allows you to easily add items is a List (ArrayList or LinkedList or the like). Wouldn't it be better if Array were named List in javascript?
- How is Array implemented under the hood? Where can I find a very detailed description?
source
share