Interface Interface In Functions Class Array Class Methods Class Constant Data Class Get Set Back
Logo image

Defining Interface

You can think of Typescript interface as "data structure" that describes the properties of an object.

Suppose you want a Stock object that takes in name & quantity thereafter add to an array for some processing.

Copy the code below to run on an online typescript compiler.


Here we created an Stock interface that holds the properties of name and qty. Loaded it with some default constant data thereafter added two new data to the array & added filtering functions.