Skip to content

Commit 79022ca

Browse files
committed
docs(array): combine example blocks into one for consistency
1 parent 85a5f48 commit 79022ca

File tree

1 file changed

+1
-7
lines changed

1 file changed

+1
-7
lines changed

book/content/part02/array.asc

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -41,18 +41,12 @@ const array = [2, 5, 1, 9, 6, 7];
4141
const array2 = [];
4242
array2[3] = 1;
4343
array2[100] = 2;
44-
array2 // [empty × 3, 1, empty × 96, 2]
45-
----
46-
47-
Using the index, you can replace whatever value you want. Also, you don't have to add items next to each other. The size of the array will dynamically expand to accommodate the data. You can reference values in whatever index you like index 3 or even 100! In the `array2` we inserted 2 numbers, but the length is 101, and there are 99 empty spaces.
4844
49-
[source, javascript]
50-
----
5145
console.log(array2.length); // 101
5246
console.log(array2); // [empty × 3, 1, empty × 96, 2]
5347
----
5448

55-
49+
Using the index, you can replace whatever value you want. Also, you don't have to add items next to each other. The size of the array will dynamically expand to accommodate the data. You can reference values in whatever index you like index 3 or even 100! In the `array2` we inserted 2 numbers, but the length is 101, and there are 99 empty spaces.
5650
The runtime for inserting elements using index is always is constant: _O(1)_.
5751

5852
===== Inserting at the beginning of the array

0 commit comments

Comments
 (0)