Class Concept Check
Concept Check Medium
Question
What does the `constructor` method do in an ES6 class?
Hint
constructor runs when you call new ClassName().
Explanation
The constructor is a special method that runs automatically when a class is instantiated with new. It initializes the instance's properties. If you don't define one, a default empty constructor is used. Only one constructor is allowed per class. constructor receives the arguments passed to new ClassName(...).
Related Resources
Related Lessons
- JavaScript Objects
Learn about classes.
Look up unfamiliar terms
A beginner-friendly glossary explains jargon in plain English — variables, functions, DOM, Promise, and more.
Decode error messages
Plain-English explanations of common errors — what they mean, why they happen, and how to fix them.
Build real projects
Apply what you learned by building guided projects with starter code and solutions.