-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathobj.js
More file actions
47 lines (36 loc) · 1.01 KB
/
obj.js
File metadata and controls
47 lines (36 loc) · 1.01 KB
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
console.log("hello");
function Player(name, marker) {
this.name = name
this.marker = marker
this.sayName = function () {
console.log(name)
}
}
const player1 = new Player('steve', 'X')
const player2 = new Player('also steve', 'O')
player1.sayName() // logs 'steve'
player2.sayName() // logs 'also steve'
function Book(title, autor, pages, isRead) {
this.title = title
this.autor = autor
this.pages = pages
this.isRead = isRead
}
Book.prototype.sayBook = function () {
console.log(this.title + " is a book written by " + this.autor);
if (this.isOld) {
console.log("es un libro viejo");
} else {
console.log("es un libro nuevo");
}
}
function LibroAntiguo(name, autorrrr) {
this.title = name;
this.autor = autorrrr;
this.isOld= true;
}
LibroAntiguo.prototype = Object.create(Book.prototype)
const book2 = new LibroAntiguo("La Odisea" , "Homero")
book2.sayBook()
const book1 = new Book('hobbit', "JRR Tolkien ", 342, false)
book1.sayBook()