Whether to use a constructor in angular?


Warning: count(): Parameter must be an array or an object that implements Countable in /home/styllloz/public_html/qa-theme/donut-theme/qa-donut-layer.php on line 274
0 like 0 dislike
14 views
Hello.
There are 2 kinds of code:
public links: Link[]; constructor() { this.links = []; }

public links: Link[] = [];
What code to use desirable and why?
by | 14 views

1 Answer

0 like 0 dislike
If links need to record an empty array or any other that does not depend on the parameters in the constructor, then it is obvious that the second option
by

Related questions

0 like 0 dislike
1 answer
0 like 0 dislike
1 answer
0 like 0 dislike
1 answer
0 like 0 dislike
1 answer
0 like 0 dislike
1 answer
110,608 questions
257,186 answers
0 comments
36,634 users