-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjavascript-object.html
73 lines (52 loc) · 1.12 KB
/
javascript-object.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
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
<!DOCTYPE html>
<html>
<head>
<title>Javascript Objects</title>
</head>
<body>
<h2 id="head2">Personal Data?</h2>
<script type="text/javascript">
//Person
//firstName -> property
//lastName -> property
//age -> property
//eyeColor -> property
//getFullName -> method
var Person = {
firstName: "Mg",
lastName: "Aye",
age: 28,
eyeColor: "blue",
getFullName: function() {
return this.firstName + " " +this.lastName;
}
};
console.log(Person["age"]);
console.log(Person.age);
// document.getElementById("head2").innerHTML = Person.getFullName();
//Car => Object
//- model -> property
//- weight -> property
//- color -> property
//- cartype -> property
//- start -> method
//- drive -> method
//- brake -> method
//- stop -> method
//
// var car = {
// model: "X-Zander",
// weight: "1500",
// color: "white",
// cartype: "Mark II",
// drive: function() {
// return 'Car is driving';
// },
// brake: function() {
// return 'We have braked now!';
// }
// };
// console.log(car.brake());
</script>
</body>
</html>