Skip to content

Commit 1aa701a

Browse files
authored
Merge pull request lydiahallie#735 from aadityabhusal/patch-1
updates the answer reasoning of question 53
2 parents 36ca689 + 05b485f commit 1aa701a

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1646,7 +1646,9 @@ console.log(myCar.make);
16461646

16471647
#### Answer: B
16481648

1649-
When you return a property, the value of the property is equal to the _returned_ value, not the value set in the constructor function. We return the string `"Maserati"`, so `myCar.make` is equal to `"Maserati"`.
1649+
When a constructor function is called with the `new` keyword, it creates an object and sets the `this` keyword to refer to that object. By default, if the constructor function doesn't explicitly return anything, it will return the newly created object.
1650+
1651+
In this case, the constructor function `Car` explicitly returns a new object with `make` set to `"Maserati"`, which overrides the default behavior. Therefore, when `new Car()` is called, the _returned_ object is assigned to `myCar`, resulting in the output being `"Maserati"` when `myCar.make` is accessed.
16501652

16511653
</p>
16521654
</details>

0 commit comments

Comments
 (0)