← JavaScript

OOP – constructor Method

A special method inside a class that runs automatically when a new instance is created.

Understanding OOP – constructor Method in JavaScript

What it does: this points to the instance the constructor is building. This is exactly what the constructor method does. constructor() fires as soon as new ClassName() is called. JavaScript is case-sensitive, so 'constructor' must be lowercase. Parameters passed to new ClassName() flow into the constructor. This assigns the parameter's value to a property on the instance. Properties are always accessed as this.propertyName, with a dot. new triggers the constructor with "Rex" as the argument.

Common mistakes: 'constructor' must be lowercase - a capital C causes an error. Missing 'this.' before name - it should be this.name.

Class: _____________________  ·  Name: _____________________  ·  Date: _________

Free printable worksheet with full answer key — or add this module to a class and your students practise it interactively.

This module's key terms are also in a printable crossword (Modules 41–52) and word search (Modules 21–52).

Take this worksheet further — free with Cloodit

Each concept is reinforced from every angle — learned, then applied, then tested.

Learning
Duo
Does constructor() run automatically when a new instance is created?
YesNo
Matches
Constructor(name) { this.name = name; }
↓
Wrong - 'constructor' must be lowercase
Applying
Meanings
Term
constructor
Meaning
A special method inside a class that runs automatically when a new instance is created.
Practice
class Dog {
Testing
Gaps
(name) {
Check Answer
Spots
1Constructor(name) {
2this.name = name;

Cloodit turns curriculum-aligned coding content into journeys students work through one biome at a time.

The 'Cosmic Owl' badge — Comprehension Guru, one of Cloodit's 106 collectible badges
Students earn collectable badges

Over 100 of them, across seven natural biomes.

Study Buddy
Students build a real study resource

Turns their work into revision material ready for Flash Cards and Exam study.

Diamond Dash — one of Cloodit's live, competitive Sprint games
Students lock in with Sprints

Live, competitive practice for the start of the lesson or a teacher-led lesson finisher.

A Cloodit certificate of achievement, ready to personalise and print
Custom printable certificates

Honour your top performers, or encourage a student who's trying hard — ready to print in seconds.

Quick Questions

1. Does constructor() run automatically when a new instance is created?
A. Yes ✓
B. No
constructor() fires as soon as new ClassName() is called.
2. Does 'this' refer to the instance being created inside constructor()?
A. No
B. Yes ✓
this points to the new object that new is building.
3. Is 'Constructor' with a capital C valid JavaScript syntax?
A. No ✓
B. Yes
JavaScript is case-sensitive, so 'constructor' must be lowercase.
4. Must 'new' be written in lowercase?
A. Yes ✓
B. No
JavaScript is case-sensitive, so 'new' must be lowercase.
5. Can a constructor accept parameters like name or age?
A. No
B. Yes ✓
Parameters passed to new ClassName() flow into the constructor.

Match the Pairs

constructor(name) { this.name = name; } → Runs automatically when a new Dog is created, setting name
new Dog("Rex") → Creates a new Dog instance and calls its constructor
Refers to the new object being created inside a constructor → this
Runs automatically whenever a class is instantiated with new → constructor(name) { ... }
Constructor(name) { this.name = name; } → Wrong - 'constructor' must be lowercase
let d = New Dog(5); → Wrong - 'new' must be lowercase

Key Term

constructor
A special method inside a class that runs automatically when a new instance is created.

Fill in the Blanks

1. constructor(name) {
Hint: Type the special method that runs when a new instance is created.
2. this.name = name;
Hint: Type the parameter name being assigned to this.name.
3. let myDog = new Dog("Rex");
Hint: Type the string argument passed to the constructor.
4. constructor(color) {
Hint: Type the special method that runs when a new instance is created.
5. this.color = color;
Hint: Type the parameter name being assigned to this.color.

Spot the Error

Question 1
A Constructor(name) {
B this.name = name;
C }
Line A — 'constructor' must be lowercase - a capital C causes an error.
Question 2
A constructor(name) {
B name = name;
C }
Line B — Missing 'this.' before name - it should be this.name.
Question 3
A constructor(name) {
B this.name = name;
C ]
Line C — The block must close with }, not ].
Question 4
A Constructor(age) {
B this.age = age;
C }
D let d = new Dog(5);
Line A — 'constructor' must be lowercase - a capital C causes an error.
Question 5
A constructor(age) {
B this.age = age;
C }
D let d = New Dog(5);
Line D — 'new' must be lowercase - a capital N causes an error.

Student with a class code? Join your class →