-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patharrays 1.html
More file actions
111 lines (84 loc) · 2.67 KB
/
arrays 1.html
File metadata and controls
111 lines (84 loc) · 2.67 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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
<!-- 1st nrml Array prgrm -->
<script>
let fruits=["oranges","apples","pineapples","mangoes","grapes"];
document.write(fruits[3]);
</script>
<!-- 2nd Finding Length of the Array -->
<script>
let ninjaStorm=["YellowRanger","RedRanger","BlueRanger","GreenRanger","WhiteRanger"];
document.write(ninjaStorm.length);
// output: 5
</script>
<!-- 3rd Array calling with Arrow function-->
<script>
let actress=["pam","nidhi agrawal","tamanna","dimple hayati","sreeleela"];
const arrowFunc=()=>{
document.write(actress[4]);
}
arrowFunc();
// output:sreeleela
</script>
<!-- 3.1 changing an Arrays element in Arrow func -->
<script>
let actress=["pam","nidhi agrawal","tamanna","dimple hayati","sreeleela"];
for(let i in actress){
document.write(actress[i]);
document.write("<br/>");
}
const arrowFunc=()=>{
document.write("<br/>");
document.write("Newly Created Array : <br/>");
actress[0]="ramya Nambeesan";
for(let i in actress){
document.write(actress[i]+"<br/>");
}
}
arrowFunc();
// output: pam
// nidhi agrawal
// tamanna
// dimple hayati
// sreeleela
// Newly Created Array :
// ramya Nambeesan
// nidhi agrawal
// tamanna
// dimple hayati
// sreeleela
</script>
<!-- 4th changing Elements in Arrays with enhanced for loop-->
<script>
let ninjaStorm=["YellowRanger","RedRanger","BlueRanger","GreenRanger","WhiteRanger"];
ninjaStorm[3]="BlackRanger";
document.write("This is the newly added Element into our Array List : "+ninjaStorm[3]);
document.write("<br/>");
document.write("<br/>");
for(let i in ninjaStorm){
document.write(ninjaStorm[i]);
document.write("<br/>");
}
// output: This is the newly added Element into our Array List : BlackRanger
// YellowRanger
// RedRanger
// BlueRanger
// BlackRanger
// WhiteRanger
</script>
<!-- 4.1 changing Elements in Arrays but with normal for loop -->
<script>
let ninjaStorm=["YellowRanger","RedRanger","BlueRanger","GreenRanger","WhiteRanger"];
for(let i=0;i<ninjaStorm.length;i++){
document.write(ninjaStorm[i]+"<br/>");
}
// output:YellowRanger
// RedRanger
// BlueRanger
// GreenRanger
// WhiteRanger
</script>
<!-- in Js Arrays are objects -->
<script>
let success=["hardwork","smartwork","hope","resilience","positive attitude"];
document.write(typeof success);
// output:object
</script>