What is public property?
Property which will be available in the instance of the class
class A {
public test = 1
}It’s equals:
class A {
test = 1
}But it’s better to explicitly show public properties
What is private property?
Property which will be available only in the scope of particular class
class A {
private _test = 1
testSome() {
console.log(this._test)
} }Usually private properties started with _ preffix
What is class implements?
interface ITest {
some: string
}
class A implements ITest {
some: string
}
Helps to type a class to allow it to have some required properties or methods from an interface
What is protected property?
Property which will be available in particular class, or in child classes, but not in instances
class A {
protected a = 1
}
What is static property?
This is a property which is exist only as a property of a class
class A {
static test = 1
}
console.log(A.test)
What is abstract class?
This is a class which can’t create instance, and can be used only for inheritance
abstract class A {
test() {
console.log(123)
}
}
const b = new A() - !!! will throw an error !!!
What is readonly property?
This property cannot be changed
class A {
readonly some: number
}
What is decorators?
Is a function that is applied to a class, method, property, or parameter to change its behavior or add additional functionality.
Started with “@” symbol.
We can add unlimited amount of decorators.
Decorators are initialized from top to bottom. But executed from bottom to top