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

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(){ /* ... */}
}
主站蜘蛛池模板: 泰来县| 临沂市| 揭东县| 奉新县| 泊头市| 乐陵市| 泌阳县| 嘉义县| 绿春县| 铜鼓县| 静乐县| 启东市| 额敏县| 射洪县| 泾源县| 靖边县| 正镶白旗| 萝北县| 舒兰市| 遂宁市| 本溪| 兴山县| 青铜峡市| 张家口市| 大连市| 桐梓县| 卢湾区| 河源市| 贡觉县| 仁怀市| 沅陵县| 鄂伦春自治旗| 德保县| 柳河县| 航空| 会理县| 尖扎县| 博野县| 清涧县| 沙河市| 新沂市|