-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathobjects.html
More file actions
33 lines (29 loc) · 883 Bytes
/
objects.html
File metadata and controls
33 lines (29 loc) · 883 Bytes
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
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Object-oriented JavaScript examples</title>
</head>
<body>
<p>Requires commands in JavaScript browser console</p>
</body>
<script>
function Person(first, last, age, gender, interests) {
this.name = {
'first': first,
'last': last
};
this.age = age;
this.gender = gender;
this.interests = interests;
this.bio = function () {
alert(this.name.first + ' ' + this.name.last + ' is ' + this.age + ' years old. He likes ' + this.interests[
0] + ' and ' + this.interests[1] + '.');
};
this.greeting = function () {
alert('Hi! I\'m ' + this.name.first + '.');
};
}
var person1 = new Person('Seth', 'Romanowski', 28, 'male', ['computers', 'baseball']);
</script>
</html>