TypeScript Fundamentals TypeScript Fundamentals

Defining & Creating Instances

Check out a free preview of the full TypeScript Fundamentals course:
The "Defining & Creating Instances" Lesson is part of the full, TypeScript Fundamentals course featured in this preview video. Here's what you'd learn in this lesson:

Mike reviews classes in JavaScript including the constructor function used to initialize instances.

Get Unlimited Access Now

Transcript from the "Defining & Creating Instances" Lesson

>> Mike North: The first thing to understand is JavaScript uses prototypes for inheritance. It is more flexible than classical inheritance, right, prototypal inheritance is more flexible. And you just need to know that there are still prototypes involved under the hood. Now there are fewer sharp edges for us to get snagged on, right.

[00:00:29] Fewer things that we can do as developers that will hurt us and make us painfully aware of these prototypes not being classes. But just know that that's still happening under the hood. So if we did something like this, we would be able to logout something that looks like this on the right.

[00:00:52] And this is a lot better than what we get when we define types of objects you may get like square bracket object object or something like that. So at least here we get to know the type of this object and all of the properties that are on it.

[00:01:08] The constructor function is, that is what is used to create a new instance of that object.