-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path01_arrays.js
More file actions
38 lines (24 loc) · 785 Bytes
/
01_arrays.js
File metadata and controls
38 lines (24 loc) · 785 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
//Arrays
const myArr = [0, 1, 2, 3, 4]
const myHeros = ["IronMan", "Thor"]
const myArr2 = new Array(1, 2, 3, 4)
// console.log(myArr[1])
// Array methods
// myArr.push(5);
// myArr.push(6); // New elements to add to the array
// myArr.pop(); // remove the last element in array
// myArr.unshift(9); //insert element at the start in array
// myArr.shift();
// console.log(myArr.includes(9));
// console.log(myArr.indexOf(9));
const newArr = myArr.join()
// console.log(myArr);
// 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);