You are probably used to thinking about functions, methods, and class constructors as three distinct things if you are experienced with object-oriente...
Global variables are defined outside of functions or alongside window objects for use throughout the program
What is the difference between constructor and ngOnInit?
Learn the difference between constructor and ngOnInit in this informative article. Find out how each method works and when to use them in Angular.