-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.js
More file actions
43 lines (27 loc) · 876 Bytes
/
Copy pathmain.js
File metadata and controls
43 lines (27 loc) · 876 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
//REFERENCE TYPE DATATYPES
//ARRAY
let arrayValue = [1,2,3,4,5,6];// array initialization
console.log(arrayValue);
let arrayValue1= []; // initializing array
arrayValue1[0]= 10; // assigning values to each position
arrayValue1[1]= 20;
arrayValue1[2]= 30;
arrayValue1[3]= 40;
console.log(arrayValue1);
let arrayValue2= []; // initializing array
arrayValue2[0]= 10; // assigning values to each position
arrayValue2[1]= 20;
arrayValue2[2]= 30;
arrayValue2[3]= 40;
// it create empty space for position 4 as there is no value assign to it
arrayValue2[5]= 50;
console.log(arrayValue2);// [10, 20, 30, 40, empty, 50]
let arrayValue3 = [1,2,4,6,8,0];
// For loop
for (let counter = 0; counter <= arrayValue3.length-1; counter++) {
console.log(arrayValue3[counter]);
}
//ForEach loop
for(let numValue of arrayValue3){
console.log(numValue);
}