-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path02-variables.html
More file actions
94 lines (80 loc) · 2.44 KB
/
02-variables.html
File metadata and controls
94 lines (80 loc) · 2.44 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Variables</title>
<script>
// Variable Type
// Variable Name
// Variable Value -> Data Types
// ----------------------------
// Data Types
// Primitive -> boolean, null, number, string
// Composite -> Objects, Functions, Arrays
var salary;
name = "Zainab"; // String
age = 11; // Number
cnic = null; // Null
isVerified = true; // Boolean
salary = 12000; // Number Also
// document.writeln(typeof(name));
// document.writeln(typeof(age));
// document.writeln(typeof(cnic));
// document.writeln(typeof(isVerified));
studentDetails = {
name: "Arham",
age: 18,
school: "TBISS",
subject: "Computer",
f_phone_number: 923001234567
}
employeeDetails = {
name: "Shah Zubair",
martial_status: "Married",
father_name: "Murtaza Kamal",
position: "Tea Maker",
salary: 14999,
phone_number: "+923347328923",
currency: "PKR"
}
console.log(employeeDetails.father_name);
fruits = [
'Orange',
'Mango',
'Peach',
true,
1200,
null,
false
]
document.write("1. " + fruits[0] + "<br>");
document.write("2. " + fruits[1] + "<br>");
document.write("3. " + fruits[2] + "<br>");
document.write("4. " + fruits[3] + "<br>");
document.write("5. " + fruits[4] + "<br>");
document.write("6. " + fruits[5] + "<br>");
document.write("7. " + fruits[6] + "<br>");
// document.write("Name: " + employeeDetails.name);
// document.write(JSON.stringify(employeeDetails));
// console.log(employeeDetails.name);
// Nested Object
students = {
std1 : {
name: "Arham Chandio",
age: 12,
rollno: 1234
},
std2 : {
name: "Majid Chandio",
age: 12,
rollno: 1234
}
}
document.write(students.std1);
</script>
</head>
<body>
<!-- It will be empty because we are working on JavaScript -->
</body>
</html>