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: concepts/arrays/about.md
+118-1Lines changed: 118 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,7 @@
1
1
# About
2
2
3
-
In Javascript, an array is actually just a regular object where the elements are properties of that object. It includes the `length` property and also lots of [useful methods][array-docs] for traversing and mutating the array.
3
+
In Javascript, an array is actually a regular `object` where the elements are properties of that object.
4
+
It includes the `length` property and also lots of [useful methods][array-docs] for traversing and mutating the array.
4
5
5
6
Declaring an array and accessing an element:
6
7
@@ -10,4 +11,120 @@ names[1];
10
11
// => Laura
11
12
```
12
13
14
+
Arrays cannot use `strings` as element indexes, but must use integers ([`number`][concept-numbers]).
15
+
Setting or accessing via non-integers using bracket notation (or dot notation) will not set or retrieve an element from the array list itself, but will set or access a variable associated with that array's object property collection.
16
+
The array's object properties and list of array elements are separate, and the array's traversal and mutation operations cannot be applied to these named properties.
17
+
18
+
```javascript
19
+
constnames= ['Jack', 'Laura', 'Paul', 'Megan'];
20
+
names.length;
21
+
// => 3
22
+
23
+
// Properties can be set on arrays using bracket ['property'] or dot .property
24
+
// notation, and this will affect the length, as shown below.
25
+
26
+
names.magician='Elyse';
27
+
names.length;
28
+
// => 4
29
+
30
+
// The property shows up when logging the array, making it seem that the
Copy file name to clipboardExpand all lines: concepts/arrays/introduction.md
+2-1Lines changed: 2 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,7 @@
1
1
# Introduction
2
2
3
-
In Javascript, an array is a list-like structure with no fixed length which can hold any type of primitives or ojects, even mixed types. The array elements can be accesed by their index.
3
+
In Javascript, an array is a list-like structure with no fixed length which can hold any type of primitives or objects, even mixed types.
4
+
The array elements can be accessed by their index.
4
5
5
6
Example of an array declaration and accessing an element by index:
Copy file name to clipboardExpand all lines: exercises/concept/elyses-enchantments/.docs/introduction.md
+2-1Lines changed: 2 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,7 @@
1
1
# Introduction
2
2
3
-
In Javascript, an array is a list-like structure with no fixed length which can hold any type of primitives or ojects, even mixed types. The array elements can be accesed by their index.
3
+
In Javascript, an array is a list-like structure with no fixed length which can hold any type of primitives or objects, even mixed types.
4
+
The array elements can be accessed by their index.
4
5
5
6
Example of an array declaration and accessing an element by index:
0 commit comments