-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJavaScript2.html
47 lines (47 loc) · 1.22 KB
/
JavaScript2.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
36
37
38
39
40
41
42
43
44
45
46
47
<html>
<head>
<title> JavaScript Demo 2 </title>
</head>
<body>
<p> JavaScript arrays:
<span id=arr> </span>
<br/>
JavaScript objects:
<span id=object> </span>
<br/>
<span id=type1> </span>
<span id=type2> </span>
<span id=primdata> </span>
<br/>
<span id=compdata> </span>
</p>
<script type="text/javascript">
var cars = ["Saab", "Volvo", "BMW"];
var person = {
firstName: "John",
lastName: "Doe",
age: 35,
}
document.getElementById('arr').innerHTML = cars;
// id must be declared beforehand
document.getElementById('object').innerHTML =
person.firstName + " " + person.lastName + " is " +
person.age + " years old.";
document.getElementById ('type1').innerHTML =
"Type of cars array: " + typeof cars + "<br>";
document.getElementById ('type2').innerHTML =
"Type of person object: " + typeof person;
document.getElementById ('primdata').innerHTML =
typeof "john" + "<br>" +
typeof 3.14 + "<br>" +
typeof true + "<br>" +
typeof false + "<br>" +
typeof x;
document.getElementById ('compdata').innerHTML =
typeof {name: 'john', age: 34} + "<br>" +
typeof [1,2,3,4] + "<br>" +
typeof null + "<br>" +
typeof function myFunc () {};
</script>
</body>
</html>