Thuta Learning
IntermediateProgrammingintermediate

Objects

Relax. We'll talk through this in plain words — no textbook voice.

You can define an object's shape using a type annotation — specifying up front which properties it should have and what type each one is.

typescript
const person: { name: string; age: number } = {
  name: "John Doe",
  age: 30
};

console.log(`${person.name} is ${person.age} years old.`);
You should see
John Doe is 30 years old.