R
R
Rag'n' Code Man2021-08-14 14:49:37
typescript
Rag'n' Code Man, 2021-08-14 14:49:37

How does it work and what is the name of such a construction in TS?

constructor(private readonly field1, private readonly field2) {}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry Belyaev, 2021-08-14
@iDmitriyWinX

https://www.typescriptlang.org/docs/handbook/2/cla...
compiles to:

constructor(field1, field2) {
  this.field1 = field1;
  this.field2 = field2;
}
the fields will be inserted immediately after super()if present or at the beginning of the constructor if super()not

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question