This is the 9th day of my participation in the More text Challenge. For details, see more text Challenge

  • Class: defines the abstract character of everything
  • Object: An instance of a class
  • Object Oriented (OOP) : Three features: encapsulation, inheritance, polymorphism

Three characteristics of object-oriented programming

Encapsulation:

The details of the operation on the data are hidden and only the external interface is exposed. The external caller does not need (and cannot) know the details to access the object through the externally provided interface,

Inheritance:

A child class inherits from a parent class, and in addition to having all the properties of the parent class, a child class also has some more specific properties.

Polymorphism:

Different classes related to inheritance can have different responses to the same method.

Class – the Class

The class member access modifier public modifies properties or methods that are public and can be accessed anywhere. By default, all properties and methods are public

A privately-decorated property or method is private and cannot be accessed outside the class that declares it

A protected property or method is protected. It is similar to private, except that it is also allowed to be accessed in a subclass

Classes and interfaces

Class implements an interface

interface Radio { switchRadio(trigger: boolean): void; } class Car implements Radio { switchRadio(trigger) { return 123 } } class Cellphone implements Radio { switchRadio() { } } interface Battery { checkBatteryStatus(): void; } // To implement multiple interfaces, separate them by commas. class Cellphone implements Radio, Battery { switchRadio() { } checkBatteryStatus() { } }Copy the code

Reference documentation: Typescript Chinese

People are lazy, do not want to picture, are their own blog content (dry goods), hope to help everyone

Public number: xiao He growth, The Buddha department more text, are their own once stepped on the pit or is learned

Interested partners welcome to pay attention to me, I am: He young life. Everybody progress duck together