-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathArrays.html
More file actions
44 lines (38 loc) · 1.34 KB
/
Copy pathArrays.html
File metadata and controls
44 lines (38 loc) · 1.34 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<h1>Arrays</h1>
<pre>
<script>
var marks = [75,34,45,56]; //array of numbers
var stringArray = ["rohit","sai","sri"];
var mixArray = ["java","python",1,2];
document.writeln("Integer array contents : "+marks);
document.writeln("String Array contents : "+stringArray);
document.writeln("Mixed Type Array Contents : "+mixArray);
document.writeln("<hr>");
// access a array element
document.writeln("Accessing array element in 4th position:"+mixArray[3]);
// add element to array in the tail
mixArray.push(500);
document.writeln("Display array after push() :"+mixArray);
// add element to array on the top
mixArray.unshift(222);
document.writeln("Array after unshift : "+mixArray);
document.writeln("Array Contents :")
for(i=0;i<mixArray.length;i++)
{
document.writeln(mixArray[i]);
}
// display size of array using length property
document.writeln("The Size of Integer Array Marks :" +
marks.length);
</script>
</pre>
</body>
</html>