JavaScript Objects
Destructure 3 levels down¶
If you know the property will exist
Default Dict¶
new
keyword¶
- Creates a new object 2. type:
object
- It sets this new object's internal, inaccessible, [[prototype]] (proto) property to be the constructor function's external, accessible, prototype object (every function object automatically has a prototype property).
- Variable points to the newly created object.
- Executes the constructor function
- Return the new object
- unless the constructor function returns a non-null object reference.
- In this case, that object reference is returned instead.
How do you know if they used new
?¶
Why Set()
returns an error without new
¶
- without the
new
, the constructor will get called as a regular function - it will use
this
from the caller's context and not fromSet
and it might break
Last update:
2023-04-24