WeCodeAcademy

Object Types

Describe the shape of an object by listing its properties and their types.

Exampletypescript
Open in editor »

Missing or extra properties are errors, and so are typos.

Exampletypescript
Open in editor »

Add ? to make a property optional.

Exampletypescript
Open in editor »
Quick check

What does `nickname?: string` mean?

Your turn: write the code

Give user an object type with a name (string) and an age (number), then print Ada is 36.

Finish the quick check (and any code exercise) to complete this lesson, or mark it done yourself.

Tip: use the left and right arrow keys to move between lessons.