-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path10_arrays.js
More file actions
47 lines (31 loc) · 813 Bytes
/
10_arrays.js
File metadata and controls
47 lines (31 loc) · 813 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
const myArr = [0, 1, 2, 3, 4, 5]
console.log(myArr[0]);
const myArrOne = [0, 1, 2, 3, 4, 5, true, "chetan"]
const myHeros = ["Jetha", "Iyer"]
const myArr2 = new Array(1, 2, 3, 4)
// Array methods
myArr.push(6)
console.log(myArr);
myArr.push(7)
console.log(myArr);
myArr.pop()
console.log(myArr);
myArr.unshift(9)
console.log(myArr);
myArr.shift()
console.log(myArr);
console.log(myArr.includes(9));
console.log(myArr.indexOf(9));
console.log(myArr.indexOf(3));
const newArr = myArr.join()
console.log(myArr);
console.log(typeof newArr);
console.log(newArr);
// slice, splice
console.log("A ", myArr);
const myn1 = myArr.slice(1, 3)
console.log(myn1);
console.log("B", myArr);
const myn2 = myArr.splice(1, 3)
console.log("C", myArr);
console.log(myn2);