Skip to content

Commit 3af9173

Browse files
committed
more notes
1 parent 9df9daa commit 3af9173

File tree

2 files changed

+13
-8
lines changed

2 files changed

+13
-8
lines changed

session 1/chapters/3. Prototypes.md

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,20 @@ Simply put, whenever you call a property on an object and it doesn’t exist, Ja
99
# Problem with creating objects with the constructor function:
1010

1111
Consider the constructor function below:
12+
1213
```javascript
1314
function Human(firstName, lastName) {
14-
this.firstName = firstName,
15-
this.lastName = lastName,
16-
this.fullName = function() {
17-
return this.firstName + " " + this.lastName;
18-
}
15+
(this.firstName = firstName),
16+
(this.lastName = lastName),
17+
(this.fullName = function () {
18+
return this.firstName + ' ' + this.lastName;
19+
});
1920
}
2021

21-
var person1 = new Human("Virat", "Kohli");
22-
var person2 = new Human("Sachin", "Tendulkar");
23-
```
22+
var person1 = new Human('Virat', 'Kohli');
23+
var person2 = new Human('Sachin', 'Tendulkar');
24+
```
25+
26+
![problemWithObjectConstructor](../images/ProblemWithConstructorrObjectCreation.jpg)
27+
28+
111 KB
Loading

0 commit comments

Comments
 (0)