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: book/content/part02/array.asc
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -29,7 +29,7 @@ Arrays are a sequential collection of elements that can be accessed randomly usi
29
29
30
30
==== Insertion
31
31
32
-
Arrays are a built-in part of most languages. In JavaScript, populating an array is simple; elements can either be added at the time of initialization, or after. Below you can find an example of both cases:
32
+
Arrays are a built-in part of most languages. In JavaScript, populating an array is simple; elements can either be added at the time of initialization, or after. See below for examples of both cases:
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.
49
+
Using the index, you can access and/or modify any value you choose. Also, you can reference values in any index you choose. The size of the array will dynamically expand to accommodate the data. For example, in `array2` 2 numbers have been inserted, but the length is 101, and there are 99 empty spaces.
50
50
The runtime for inserting elements using index is always is constant: _O(1)_.
0 commit comments