Skip to content

Commit 4b3da5f

Browse files
authored
Create day07(Prototype )
1 parent ee5f6e9 commit 4b3da5f

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

day07(Prototype )

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
1. All JavaScript objects inherit properties and methods from a prototype.
2+
Date objects inherit from Date.prototype. Array objects inherit from Array.prototype. Person objects inherit from Person.prototype.
3+
The Object.prototype is on the top of the prototype inheritance chain:
4+
Date objects, Array objects, and Person objects inherit from Object.prototype.
5+
6+
2. The JavaScript prototype property allows you to add new properties to object constructors:
7+
function Person(first, last, age, eyecolor) {
8+
this.firstName = first;
9+
this.lastName = last;
10+
this.age = age;
11+
this.eyeColor = eyecolor;
12+
}
13+
Person.prototype.nationality = "English";
14+
15+
3. The JavaScript prototype property also allows you to add new methods to objects constructors:
16+
Person.prototype.name = function() {
17+
return this.firstName + " " + this.lastName;
18+
};
19+

0 commit comments

Comments
 (0)