New Object

This lesson goes over the creation of an object with the keyword new.

Instantiating a class into an object

TypeScript can create an object by instantiating a class using the keyword new. The scope of this lesson does not cover all object-oriented possibilities but in a nutshell, TypeScript lets you use the full set of object-oriented features, even ECMAScript before 2015, which does not contain Object or literal object.

This means that if you want to use polymorphism, have multiple instances of a type, use a decorator, be able to use a pattern like the dependency of injection or even just be able to mock specific functions of an object, the use of a class is mandatory. Creating an object with new creates an instance of an object which inherits all characteristics of the uppercase Object.

Get hands-on with 1200+ tech skills courses.