A constructor is a function that creates an instance of a class which is typically called an “object”. In JavaScript, a constructor gets called when you declare an object using the new keyword. The purpose of a constructor is to create an object and set values if there are any object properties present .
Read moreDo you need a constructor in JavaScript?
Creating and using constructors A constructor is useful when you want to create multiple similar objects with the same properties and methods . It’s a convention to capitalize the name of constructors to distinguish them from regular functions.24 Eyl 2015
Read more