-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathobjects.js
More file actions
28 lines (24 loc) · 849 Bytes
/
Copy pathobjects.js
File metadata and controls
28 lines (24 loc) · 849 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
var car1 = {color: "red", wheels: 4};
function Car(color, wheels) {
this.color = color;
this.wheels = wheels;
}
var car2 = new Car("red", 4);
console.log(car1.color);
console.log(car2["color"]);
function FamilyMember(first, last, age) {
this.firstName = first;
this.lastName = last;
this.age = age;
this.name = function(){return this.firstName + " " + this.lastName;};
}
var myFather = new FamilyMember("John", "Doe", 50);
var myMother = new FamilyMember("Jane", "Doe", 48);
console.log(myFather.firstName);
console.log(myMother["lastName"]);
console.log(myMother.age);
console.log(myFather.name());
FamilyMember.prototype.nationality = "English";
FamilyMember.prototype.nameUpper = function(){return (this.firstName + " " + this.lastName).toUpperCase()};
console.log(myMother.nationality);
console.log(myFather.nameUpper());