-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path02_array.js
More file actions
36 lines (22 loc) · 1.04 KB
/
02_array.js
File metadata and controls
36 lines (22 loc) · 1.04 KB
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
const marvel_heroes = ["Thor","Ironman", "Spiderman"]
const dc_heroes = ["Superman", "flash","batman"]
// marvel_heroes.push(dc_heroes)
// console.log(marvel_heroes);
// console.log(marvel_heroes[3][1]);
const all_heros = marvel_heroes.concat(dc_heroes)
console.log(all_heros);
// In concat we form new variable and add two or more array
// In push they work In existing array
const new_all_heros = [...marvel_heroes,...dc_heroes] // most common in use to join two array it is called spread method
console.log(new_all_heros);
const another_array = [1,2,3,[4,5,6],7,[6,7],[4,5],6,[1,2]]
const real_another_array = another_array.flat(Infinity)
console.log(real_another_array);
console.log(Array.isArray("Hitesh")); // to ask question var is or not in array
console.log(Array.from("Hitesh")); // convert to string
console.log(Array.from({name: "Hitesh"})); // Intersting result
let score1 = 100
let score2 = 200
let score3 = 300
console.log(Array.of(score1,score2,score3));
// Returns a new array from a set of elements.