The Curly Braces Object

This lesson explains the creation of objects by using curly braces.

Object literal advantage

TypeScript can create an object using the curly braces – it is an object literal like in JavaScript. The limitation is that you must define every member at initialization time.

The advantage is that it’s a quick way to organize data. It’s also a natural way to organize data coming from a JSON Payload. For example, executing a request to receive a payload will provide you with a literal object.

TypeScript is a structural language and does not need to have a name. This works great for cases where you do not need to map all the data to a type. With a structural type, you can cast the data and have the structure mapped for you without having to instantiate anything.

Get hands-on with 1400+ tech skills courses.