mirror of
https://github.com/yangshun/tech-interview-handbook.git
synced 2026-05-01 05:51:56 +08:00
Fix typos (#47)
This commit is contained in:
committed by
Yangshun Tay
parent
f2bcca85a3
commit
7870a58b31
@@ -766,7 +766,7 @@ This question is pretty vague. My best guess at its intention is that it is aski
|
||||
|
||||
`var person = Person()` invokes the `Person` as a function, and not as a constructor. Invoking as such is a common mistake if it the function is intended to be used as a constructor. Typically, the constructor does not return anything, hence invoking the constructor like a normal function will return `undefined` and that gets assigned to the variable intended as the instance.
|
||||
|
||||
`var person = new Person()` creates an instance of the `Person` object using the `new` operator, which inherits from `Person.prototype`. An alterative would be to use `Object.create`, such as: `Object.create(Person.prototype)`.
|
||||
`var person = new Person()` creates an instance of the `Person` object using the `new` operator, which inherits from `Person.prototype`. An alternative would be to use `Object.create`, such as: `Object.create(Person.prototype)`.
|
||||
|
||||
```js
|
||||
function Person(name) {
|
||||
|
||||
Reference in New Issue
Block a user