A constructor function is a function used to create multiple objects with the same structure.
It is like a blue print.
Function name starts with capital letter.
functionPerson(name,age){this.name=name;this.age=age;this.nationality="Tamil";//default valuethis.greet=function(){document.write(`Hi, I am ${this.name}`+"<br>");}}constvarun=newPerson("Varun",6);constArun=newPerson("Arun",6);varun.greet();Arun.greet();document.write(varun.nationality);
Top comments (0)
Subscribe
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Top comments (0)