-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patharray2.js
More file actions
28 lines (22 loc) · 927 Bytes
/
array2.js
File metadata and controls
28 lines (22 loc) · 927 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
const marvelheros=["thor","ironman","spiderman"]
const dcheros=["superman","flash","batman"]
marvelheros.push(dcheros)
console.log(marvelheros)
console.log(marvelheros[3][2]);
marvelheros.pop();
console.log(marvelheros)
const allheros=marvelheros.concat(dcheros)// the concat method in arrays joins two arrays and returns an array in
//which all elements of the two array are separated by comma
console.log(allheros);
const all_new_heros=[...marvelheros,...dcheros]// this method of concatening the array is preferred.
console.log(all_new_heros);
const another_array=[1,2,3,[4,5,6],7,[6,7,[4,5]]]
const b=another_array.flat(Infinity)//
console.log(b);
console.log(Array.isArray("hitesh")) // this method checks whether the given argument is an array or not.
console.log(Array.from("hitesh"))
console.log(Array.from({name:"hitesh"})) // interesting case
let s1=100
let s2=200
let s3=300
console.log(Array.of(s1,s2,s3))