@@ -3654,7 +3654,7 @@ const game = {
3654
3654
// SLICE Method
3655
3655
3656
3656
// With the slice method, we can extract part of any array without changing the original array.
3657
- // So essentially, we can take a slice of an array. And so that's why it's called slice.
3657
+ // Basically we take a slice of an array and that's why it's called slice.
3658
3658
3659
3659
console . log ( arr . slice ( 2 ) ) ; // (3) ["c", "d", "e"];
3660
3660
console . log ( arr . slice ( 2 , 4 ) ) ; // (2) ["c", "d"];
@@ -3668,10 +3668,10 @@ const game = {
3668
3668
// starting from index 1, it extracts everything except the last two elements
3669
3669
console . log ( arr . slice ( 1 , - 2 ) ) ; // (2) ["b", "c"];
3670
3670
3671
- // we can also use the slice method to simply create a shallow copy of any array
3671
+ // important: we can also use the slice method to simply create a shallow copy of any array
3672
3672
console . log ( arr . slice ( ) ) ; // (5) ["a", "b", "c", "d", "e"];
3673
3673
3674
- // spread operator does the same. its up to you to chose which
3674
+ // important: spread operator does the same. its up to you to chose which
3675
3675
console . log ( [ ...arr ] ) ; // (5) ["a", "b", "c", "d", "e"];
3676
3676
3677
3677
@@ -3698,14 +3698,16 @@ const game = {
3698
3698
// So it's actually not the begin parameter.
3699
3699
// It works a little bit different than in the slice method.
3700
3700
3701
+ // arr = ["a", "b", "c", "d"];
3701
3702
arr . splice ( 1 , 2 ) ;
3702
3703
console . log ( arr ) ; // (2) ["a", "d"];
3703
3704
3704
3705
3705
3706
// REVERSE Method
3706
3707
3707
- // The reverse() method reverses an array in place. The first array element becomes the last, and the last array element becomes the first.
3708
- // important: But now what's important to note here is the fact that the reverse method does actually mutate the original array.
3708
+ // The reverse() method reverses an array in place.
3709
+ // The first array element becomes the last, and the last array element becomes the first.
3710
+ // important: What's important to note is the fact that the reverse method mutates the original array.
3709
3711
3710
3712
arr = [ 'a' , 'b' , 'c' , 'd' , 'e' ] ;
3711
3713
const arr2 = [ 'j' , 'i' , 'h' , 'g' , 'f' ] ;
0 commit comments