You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+3-3Lines changed: 3 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2826,7 +2826,7 @@ class Person {
2826
2826
}
2827
2827
}
2828
2828
2829
-
constmember=newPerson("John")
2829
+
constmember=Person("John")
2830
2830
console.log(typeof member)
2831
2831
```
2832
2832
@@ -2838,7 +2838,7 @@ console.log(typeof member)
2838
2838
<details><summary><b>Answer</b></summary>
2839
2839
<p>
2840
2840
2841
-
#### Answer: B
2841
+
#### Answer: C
2842
2842
2843
2843
Classes are syntactical sugar for function constructors. The equivalent of the `Person` class as a function constructor would be:
2844
2844
@@ -2848,7 +2848,7 @@ function Person() {
2848
2848
}
2849
2849
```
2850
2850
2851
-
Which results in the same value. A class is a function under the hood, the `typeof` keyword returns `"function"` for functions. `typeof Person` returns `"function"`.
2851
+
Calling a function constructor with `new` results in the creation of an instance of `Person`, `typeof` keyword returns `"object"` for an instance. `typeof member` returns `"object"`.
0 commit comments