-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjs-3.html
39 lines (29 loc) · 955 Bytes
/
js-3.html
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
<!DOCTYPE html>
</html>
<head>
<meta charset="utf-8">
<title>JS-3</title>
<script type="text/javascript">
// Create an array by declaring a variable
// and assign an array literal
var letters = ["A", "B", "C", "D"];
// Print out an array
console.log(letters); // ["A", "B", "C", "D"]
// A JavaScript Array is actually an object
console.log(typeof letters); // object
// Length of the array via .length property
console.log(letters.length); // 4
// A JavaScript array can contain mixed types
var mixed = [1, 2.3, "YOU", false];
console.log(mixed); // [1, 2.3, "abc", false]
console.log(mixed.length); // 4
// Dynamically allocated
var animals = []; // begins with an emtpy array
console.log(animals); // []
console.log(animals.length); // 0
</script>
</head>
<body>
<p>Welcome to JavaScript!</p>
</body>
</html>