官术网_书友最值得收藏!

Interface

As we start building complex apps, there will be a common need for a certain type of structure to be repeated throughout the app, which follows certain rules. This is where an interface comes into the picture. Interfaces provide structural subtyping or duck typing to check the type and shape of entities.

For instance, if we are working with an app that deals with cars, every car will have a certain common structure that needs to be adhered to when used within the app. Hence we create an interface named ICar. Any class working with cars will implement this interface as follows:

Interface ICar { 
engine : String;
color: String;
price : Number;
}

class CarInfo implements ICar{
engine : String;
color: String;
price : Number;

constructor(){ /* ... */}
}
主站蜘蛛池模板: 苏尼特左旗| 北京市| 崇义县| 墨玉县| 台南县| 普洱| 南投市| 凤山县| 乐安县| 镶黄旗| 九龙城区| 蓝田县| 鱼台县| 兖州市| 师宗县| 武城县| 交口县| 洛隆县| 喀喇沁旗| 绥宁县| 洪洞县| 会同县| 莎车县| 樟树市| 商水县| 黔西县| 新竹县| 高平市| 白山市| 合山市| 叙永县| 昭觉县| 手游| 银川市| 五台县| 三河市| 紫阳县| 布尔津县| 贵阳市| 界首市| 张家港市|