File tree Expand file tree Collapse file tree 1 file changed +19
-0
lines changed Expand file tree Collapse file tree 1 file changed +19
-0
lines changed Original file line number Diff line number Diff line change
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
+
You can’t perform that action at this time.
0 commit comments