|
1 | | -const myArr = [0, 1, 2, 3, 4, 5] |
2 | | -const myHeros = ["shaktiman", "naagraj"] |
3 | | -const myArr2 = new Array(1, 2, 3, 4, 5) |
| 1 | +// array |
4 | 2 |
|
5 | | -// access the array value |
6 | | -// console.log(myArr[1] + myArr2[3]); |
| 3 | +const myArr = [0, 1, 2, 3, 4, 5] |
| 4 | +const myHeors = ["shaktiman", "naagraj"] |
7 | 5 |
|
8 | | -console.log(myArr.length); |
| 6 | +const myArr2 = new Array(1, 2, 3, 4) |
| 7 | +// console.log(myArr[1]); |
9 | 8 |
|
10 | 9 | // Array methods |
11 | 10 |
|
12 | 11 | // myArr.push(6) |
13 | 12 | // myArr.push(7) |
14 | 13 | // myArr.pop() |
15 | 14 |
|
16 | | -// myArr.unshift(0) |
| 15 | +// myArr.unshift(9) |
17 | 16 | // myArr.shift() |
18 | | -// console.log(myArr.reverse()); |
19 | 17 |
|
20 | | -// console.log(myArr.includes("3")); |
| 18 | +// console.log(myArr.includes(9)); |
21 | 19 | // console.log(myArr.indexOf(3)); |
22 | | -const newArr = myArr.join() |
23 | | -console.log(typeof newArr); |
24 | 20 |
|
25 | | -// slice splice |
| 21 | +// const newArr = myArr.join() |
| 22 | + |
| 23 | +// console.log(myArr); |
| 24 | +// console.log( newArr); |
| 25 | + |
26 | 26 |
|
27 | | -console.log("A", myArr); |
| 27 | +// slice, splice |
| 28 | + |
| 29 | +console.log("A ", myArr); |
28 | 30 |
|
29 | 31 | const myn1 = myArr.slice(1, 3) |
| 32 | + |
30 | 33 | console.log(myn1); |
31 | | -console.log("B", myArr); |
| 34 | +console.log("B ", myArr); |
| 35 | + |
32 | 36 |
|
33 | 37 | const myn2 = myArr.splice(1, 3) |
| 38 | +console.log("C ", myArr); |
34 | 39 | console.log(myn2); |
35 | | - |
36 | | -console.log("C", myArr); |
|
0 commit comments