What is a constructor in programming?

725 viewsOtherTechnology

I am still trying to wrap my head around the concept I learned in class a while ago. We learned briefly about constructors in JavaScript. Can someone please ELI5? Thank you!

In: Technology

18 Answers

Anonymous 0 Comments

Constructors are programs that will automatically be executed when a new object is created.
Every object can have zero or one constructors attached.
The constructor can only run once per object.
If more objects of the same type are created still each object runs it’s own constructor once.

Therefore the main purpose of the constructor is to initialize certain values within the object before the object is actually used.

You are viewing 1 out of 18 answers, click here to view all answers.