-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patharrays.html
More file actions
51 lines (42 loc) · 1.94 KB
/
arrays.html
File metadata and controls
51 lines (42 loc) · 1.94 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Learning JavaScript</title>
</head>
<body>
<center><h1>Arrays</h1></center>
<p>They're like collections of variables that can even have different data types. or according to W3schools. An array is a special variable, which can hold more than one value at a time.</p>
<img src="media/1.png" height="150" width="300"> <right><img src="media/Screen%20Shot%202018-10-28%20at%206.19.32%20PM.png" height="150" width="300"></right><right><img src="media/Screen%20Shot%202018-10-28%20at%206.19.50%20PM.png" height="150" width="300"></right><right><img src="media/Screen%20Shot%202018-10-28%20at%206.20.18%20PM.png" height="150" width="300"></right><right><img src="media/Screen%20Shot%202018-10-28%20at%206.20.45%20PM.png" height="150" width="300"></right><right><img src="media/Screen%20Shot%202018-10-28%20at%206.20.37%20PM.png" height="150" width="300"></right>
<right><img src="media/Screen%20Shot%202018-10-28%20at%206.21.04%20PM.png" height="150" width="300"></right>
<h3>Example</h3><br />
<p><strong>// Initialize new array</strong><br />
var names = ['Roopak', 'Brooke', 'David'];<br />
var years = new Array(1992, 1993, 1992);<br />
console.log(names[2]);<br />
console.log(names.length);<br />
<br />
<strong>// Mutate array data</strong><br />
names[1] = 'Sarah';<br />
names[names.length] = 'Ramesh';<br />
console.log(names);<br />
<br />
<strong>// Different data types in array</strong><br />
var john = ['Roopak', 'Kumar', 1992, 'Student', True];<br />
<br />
roopak.push('blue');<br />
roopak.unshift('Mr.');<br />
console.log(roopak);<br />
<br />
roopak.pop();<br />
roopak.pop();<br />
roopak.shift();<br />
console.log(roopak);<br />
</p>
<form action="array_result.html">
<input type="submit" name="Check" value="Check">
<p>click 'Check' to see the answer</p>
</form>
<script src="arrays.js"></script>
</body>
</html>