@@ -14,8 +14,8 @@ names[1];
14
14
Arrays can also be created using the constructor syntax, but for most uses, the array literal syntax is recommended.
15
15
16
16
``` javascript
17
- const names = new Array ()
18
- names .push (' Jack' , ' Laura' , ' Paul' , ' Megan' )
17
+ const names = new Array ();
18
+ names .push (' Jack' , ' Laura' , ' Paul' , ' Megan' );
19
19
20
20
names[1 ];
21
21
// => Laura
@@ -30,22 +30,24 @@ const names = ['Jack', 'Laura', 'Paul', 'Megan'];
30
30
names .length ;
31
31
// => 3
32
32
33
- // Properties can be set on arrays using bracket ['property'] or dot .property
34
- // notation, and this will affect the length, as shown below.
33
+ // Properties can be set on arrays using bracket ['property'] or
34
+ // dot .property notation, and this will affect the length, as
35
+ // shown below.
35
36
36
37
names .magician = ' Elyse' ;
37
38
names .length ;
38
39
// => 4
39
40
40
- // The property shows up when logging the array, making it seem that the
41
- // property is somehow incorporated in the array.
41
+ // The property shows up when logging the array, making it seem
42
+ // that the property is somehow incorporated in the array.
42
43
43
44
names;
44
45
// => ["Jack", "Laura", "Paul", "Megan", magician: "Elyse"]
45
46
46
- // However, be aware. Properties added via non-numeric keys are NOT part of the
47
- // array's internal list, and are not traversed or mutated when using one of
48
- // the traversal or mutation operations.
47
+ // However, be aware. Properties added via non-numeric keys are
48
+ // NOT part of the array's internal list, and are not traversed
49
+ // or mutated when using one of the traversal or mutation
50
+ // operations.
49
51
50
52
names .forEach ((name ) => console .log (name));
51
53
// => Jack
0 commit comments