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

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(){ /* ... */}
}
主站蜘蛛池模板: 四子王旗| 苏州市| 嘉兴市| 新兴县| 方城县| 郸城县| 平舆县| 河西区| 玉树县| 边坝县| 大竹县| 县级市| 江安县| 绥芬河市| 林西县| 天津市| 五河县| 从江县| 明水县| 临沭县| 红原县| 湘西| 汝阳县| 改则县| 大埔区| 山东省| 普格县| 仙居县| 开平市| 高尔夫| 南城县| 恭城| 双江| 丰镇市| 微山县| 蒙山县| 若尔盖县| 红原县| 宜黄县| 平遥县| 张家口市|