⊗jstsPmDSCO 45 of 55 menu

Complex Objects in TypeScript

Objects can have a structure of any nesting within themselves, and this structure can be described when declaring the object or in the interface.

As an example, let's make an interface like this that describes a user:

interface User { name: string, age: number, parents: { mother: string, father: string } }

Let's make an object that implements this interface:

let user: User = { name: 'john', age: 30, parents: { mother: 'jane', father: 'eric' } }

Given object:

let event = { name: 'my new event', time: { start: '2025-11-01', finish: '2025-12-31' } };

Create an interface that describes the structure of this object.

Given object:

let employee { name: 'andrew', potision: { name: 'programmer' salary: 1000, } addr: { country: 'belarus', city: 'minsk' } };

Create an interface that describes the structure of this object.

English
AfrikaansAzərbaycanБългарскиবাংলাБеларускаяČeštinaDanskDeutschΕλληνικάEspañolEestiSuomiFrançaisहिन्दीMagyarՀայերենIndonesiaItaliano日本語ქართულიҚазақ한국어КыргызчаLietuviųLatviešuМакедонскиMelayuမြန်မာNederlandsNorskPolskiPortuguêsRomânăРусскийසිංහලSlovenčinaSlovenščinaShqipСрпскиSrpskiSvenskaKiswahiliТоҷикӣไทยTürkmenTürkçeЎзбекOʻzbekTiếng Việt
We use cookies for website operation, analytics, and personalization. Data processing is carried out in accordance with the Privacy Policy.
accept all customize decline