⊗jstsPmDSAIO 43 of 55 menu

Arrays in Objects in TypeScript

Objects can contain not only primitives, but also arrays in their field values. For example, let's say we have an object with a product, containing its name and an array of available colors:

let prod: { name: string, colors: string[] };

Let's write an object of the specified structure into a variable:

prod = { name: 'notebook', colors: ['red', 'black', 'gray'] }

Make a country object that contains the page title and an array of its cities.

enru