-
Notifications
You must be signed in to change notification settings - Fork 0
/
testingjs.js
72 lines (53 loc) · 1.32 KB
/
testingjs.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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
function Shape() {
this.x = 0;
this.y = 0;
}
Shape.prototype.move = function(x, y) {
this.x += x;
this.y += y;
console.info("Shape was moved!");
}
Shape.prototype.doSomething = function() {
console.info("I'm doing something here!");
}
function Rectangle() {
Shape.call(this);
}
Rectangle.prototype = Object.create(Shape.prototype);
Rectangle.prototype.constructor = Rectangle;
var rect = new Rectangle();
console.info(rect instanceof Rectangle);
console.info(rect instanceof Shape);
rect.move(1,1);
rect.doSomething();
function Person() {
this.name = "John Doe";
this.age = 0;
this.gender = "N/A";
this.phone = "(000) 000-0000";
}
Person.prototype.show = function() {
console.log(this.name + ", " + this.age + ", " + this.gender + ", " + this.phone);
}
Person.prototype.setName = function(name) {
this.name = name;
console.log("Name has been set to: " + name);
}
function Mariano() {
Person.call(this);
}
function Mariano(name, age, gender, phone) {
this.name = name;
this.age = age;
this.gender = gender;
this.phone = phone;
}
Mariano.prototype = Object.create(Person.prototype);
Mariano.prototype.constructor = Mariano;
var marian = new Mariano();
var marian2 = new Mariano("Bobo", 25, "M", "888-111-2222");
var person = new Person();
person.show();
//marian.setName("Marianito");
marian.show();
marian2.show();