main.js
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
var Human = {
	hands: 2,
	foots: 2,
	head: 1,
	about: function() {
		return `I have ${this.head} head with ${this.hands} hands and ${this.foots} foots`;
	}
};
console.log('Human',Human);
console.log(Human.about());
console.log(Array(60).join('-'));

var Man = Object.create(Human);
Man.gender = 'male';
console.log(Man.about());
console.log(Array(60).join('-'));

var twoHeadedMan = Object.create(Human);
twoHeadedMan.gender = 'female';
twoHeadedMan.head = 2;
twoHeadedMan.about = function() {
	return `I am very happy cos i have ${this.head} heads!`;	
};
console.log(twoHeadedMan.about());

Human.tellHands = function() {
	return `I have exactly ${this.hands} hands`;	
};
console.log(Array(60).join('-'));
console.log('Adding new method to Human object');
console.log(Human.tellHands());
console.log(Man.tellHands());
console.log(twoHeadedMan.tellHands());
Native Browser JavaScript