Initializers
File Location
We will be working in the following file:
How Objects are Created
To create an object in JavaScript, there are a few different options. From the MDN docs: "Objects can be initialized using new Object()
, Object.create()
, or using the literal notation (initializer notation)." Using the literal notation gives more control and flexibility over what goes inside of it. Most objects you've created so far have been done with the initializer notation.
Below are two ways to create a similar object.
Practice
Create an object using the literal/initializer notation, and create one object using Object()
.
Challenge
Research and create an object using Object.create()
.
Last updated