Objects and Dynamism
Explore the core concept of objects in JavaScript, including how to dynamically add properties and how constructors function to create object instances. This lesson helps you understand the dynamic nature of JavaScript objects and prepares you for more advanced programming concepts.
In previous code examples you could already see that JavaScript works with primitive types, such as numbers or strings.
However, when you worked with the DOM in the previous chapter, you saw that the language works with objects representing the document loaded into the browser or a collection of objects that represent HTML elements.
Objects are the most important concept in the language.
Everything is either an object in JavaScript, or a primitive type’s instance that can work like an object.
Objects can have zero, one, or more properties with their associated values, and— wait for it! — they can be extended with properties dynamically at run-time.
The Listing below ...