You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: 1-js/05-data-types/04-array/article.md
+6-6Lines changed: 6 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,7 +6,7 @@ But quite often we find that we need an *ordered collection*, where we have a 1s
6
6
7
7
It is not convenient to use an object here, because it provides no methods to manage the order of elements. We can’t insert a new property “between” the existing ones. Objects are just not meant for such use.
8
8
9
-
There exists a special data structure named `Array`, to store ordered collections.
9
+
There exists a special data structure, named `Array`, to store ordered collections.
10
10
11
11
## Declaration
12
12
@@ -136,7 +136,7 @@ A [queue](https://en.wikipedia.org/wiki/Queue_(abstract_data_type)) is one of th
136
136
137
137
Arrays support both operations.
138
138
139
-
In practice we need it very often. For example, a queue of messages that need to be shown on-screen.
139
+
In practice, we need it very often. For example, a queue of messages that need to be shown on-screen.
140
140
141
141
There's another use case for arrays -- the data structure named [stack](https://en.wikipedia.org/wiki/Stack_(abstract_data_type)).
142
142
@@ -145,17 +145,17 @@ It supports two operations:
145
145
-`push` adds an element to the end.
146
146
-`pop` takes an element from the end.
147
147
148
-
So new elements are added or taken always from the "end".
148
+
So new elements are added or taken, always from the "end".
149
149
150
150
A stack is usually illustrated as a pack of cards: new cards are added to the top or taken from the top:
151
151
152
152

153
153
154
154
For stacks, the latest pushed item is received first, that's also called LIFO (Last-In-First-Out) principle. For queues, we have FIFO (First-In-First-Out).
155
155
156
-
Arrays in JavaScript can work both as a queue and as a stack. They allow you to add/remove elements both to/from the beginning or the end.
156
+
Arrays in JavaScript can work both as a queue and as a stack. They allow you to add/remove elements, both to/from the beginning or the end.
157
157
158
-
In computer science the data structure that allows this, is called [deque](https://en.wikipedia.org/wiki/Double-ended_queue).
158
+
In computer science, the data structure that allows this, is called [deque](https://en.wikipedia.org/wiki/Double-ended_queue).
159
159
160
160
**Methods that work with the end of the array:**
161
161
@@ -399,7 +399,7 @@ There is one more syntax to create an array:
399
399
let arr =*!*newArray*/!*("Apple", "Pear", "etc");
400
400
```
401
401
402
-
It's rarely used, because square brackets `[]` are shorter. Also there's a tricky feature with it.
402
+
It's rarely used, because square brackets `[]` are shorter. Also, there's a tricky feature with it.
403
403
404
404
If `new Array` is called with a single argument which is a number, then it creates an array *without items, but with the given length*.
0 commit comments