01 / 06
Name a shape and you can put [] on it
A register, a product list — real data is nearly always "objects of the same shape, lined up".
You write it just like the arrays in chapter 1: [] after the type of the contents. Item[] means "an array that only holds things shaped like Item".
interface Item { name: string; price: number;}const list: Item[] = [ { name: "apple", price: 120 }, { name: "orange", price: 80 },];console.log(list.length);Result
2