From the course: JavaScript on the Go: Objects
Unlock this course with a free trial
Join today to access over 25,500 courses taught by industry experts.
Define an object using a constructor function - JavaScript Tutorial
From the course: JavaScript on the Go: Objects
Define an object using a constructor function
- [Instructor] In JavaScript there are two ways to create and store data in an object. The object literal is the simplest and most common way to create objects. The other way is using a constructor function. So now let's explore what constructors are and how developers use them to describe an object structure and behavior with just a single function. That way the next time you come across the term constructor or constructor function, you'll be more equipped with the basics of how they're used. A constructor is a special function that you call using JavaScript's new keyword. Think of a constructor function as a template for creating one or multiple objects with similar properties and behavior. When you call a constructor it creates and initializes a new object. And there are two main ways to create objects with constructor functions. One is with JavaScripts built in object constructor and the other is with a custom…
Contents
-
-
-
Inheritance in JavaScript3m 26s
-
(Locked)
The object literal3m 9s
-
(Locked)
Define an object using a constructor function4m 42s
-
(Locked)
Create objects using an existing object as the prototype2m 58s
-
(Locked)
Merge two or more JavaScript objects into a new object3m 52s
-
(Locked)
Common ways to iterate over objects3m 25s
-
(Locked)
JavaScript classes4m 17s
-
(Locked)
Class-based vs. prototype-based inheritance2m 52s
-
-