function Book title pubYear price this title title this pubYear pubYea

 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
function Book (title, pubYear, price) {
this.title = title;
this.pubYear = pubYear;
this.price = price;
}
Book.prototype.show = function () {
console.log(this.title);
console.log(this.price);
}
var book1 = new Book('book1', 2014, 1300);
book1.show();
function Dictionary (config) {
for (var item in config) {
this[item] = config[item];
}
this.get = function(name) {
return this[name];
}
this.set = function(name, value) {
this[name] = value;
}
}
var users = new Dictionary({'john':'admin'});
var johnRole = users.get('john');
users.set('mike', 'manager');
console.log(users);
console.log(johnRole);