← ACARA Digital Technologies Years 9–10

Creating an object with new

Creates an object from a class and passes the arguments to the constructor. Store it in a variable, e.g. const rex = new Dog('Rex', 3). Leaving out new causes an error.

Understanding Creating an object with new in ACARA Digital Technologies Years 9–10

What it does: The keyword new comes first, then the class name Dog and the arguments in brackets. If the constructor is constructor(name, age), then 'Rex' goes to name and 3 goes to age. Calling a class without new causes an error (TypeError: Class constructor Dog cannot be invoked without 'new'). Use new to create an object. Without a variable, the object is created but you have no name to reach it again. Storing it in const rex lets you use rex later. Classes must be called with new. Leaving it out stops the program with a TypeError. The class name must match exactly, including the capital letter. Cat is the class, so new Cat(...) is correct.

Common mistakes: The new keyword is missing. Set is a class, so calling it without new causes a TypeError. It should be const unique = new Set(nums);. Class names are case-sensitive. map (lowercase) does not exist, so JavaScript gives a ReferenceError. It should be new Map(pairs).

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 728–742) and word search (Modules 710–742).

Take this worksheet further — free with Cloodit

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

Learning
Duo
Which line correctly creates a Dog object from the Dog class?
const rex = new Dog('Rex', 3);const rex = Dog('Rex', 3);
Matches
const rex = Dog('Rex', 3);
↓
The keyword new is missing. Calling a class without new causes an error, so no object is created.
Applying
Meanings
Term
new ClassName(arguments)
Meaning
Creates an object from a class and passes the arguments to the constructor. Store it in a variable, e.g. const rex = new Dog('Rex', 3). Leaving out new causes an error.
Practice
class Dog {
Testing
Gaps
const rex = Dog('Rex', 3);
Check Answer
Spots
2console.log(nums.length);
3const unique = Set(nums);

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

The 'Giant Isopod' badge — Patient Builder, 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. Which line correctly creates a Dog object from the Dog class?
A. const rex = Dog('Rex', 3);
B. const rex = new Dog('Rex', 3); ✓
Calling a class without new causes an error (TypeError: Class constructor Dog cannot be invoked without 'new'). Use new to create an object.
2. True or false: new Dog('Rex', 3) passes 'Rex' and 3 to the constructor.
A. False
B. True ✓
The arguments in brackets after the class name are handed to the constructor, where they usually set the object's properties.
3. Which line stores the new object so you can use it later?
A. const rex = new Dog('Rex', 3); ✓
B. new Dog('Rex', 3);
Without a variable, the object is created but you have no name to reach it again. Storing it in const rex lets you use rex later.
4. What happens when you run const max = Dog('Max', 5); and Dog is a class?
A. An error, because new is missing ✓
B. A Dog object is created anyway
Classes must be called with new. Leaving it out stops the program with a TypeError.
5. Given class Cat { constructor(name, age) {...} }, which call is correct?
A. const cat1 = new Cat('Mia', 2); ✓
B. const cat1 = new cat('Mia', 2);
The class name must match exactly, including the capital letter. Cat is the class, so new Cat(...) is correct.

Match the Pairs

const rex = new Dog('Rex', 3); → Creates a Dog object, sends 'Rex' and 3 to the constructor, and stores the object in the variable rex
const song = new Track('Wave', 210); → Makes a new Track object using the Track class and saves it in song
Put the keyword new before the class name to create an object from a class → const pet = new Dog('Bella', 5);
The arguments in the brackets are passed to the constructor, in the same order as its parameters → const rex = new Dog('Rex', 3);
const rex = Dog('Rex', 3); → The keyword new is missing. Calling a class without new causes an error, so no object is created.
new Dog('Rex', 3); → The new object is not stored in a variable, so the program has no way to use it again later.

Key Term

new ClassName(arguments)
Creates an object from a class and passes the arguments to the constructor. Store it in a variable, e.g. const rex = new Dog('Rex', 3). Leaving out new causes an error.

Fill in the Blanks

1. const rex = new Dog('Rex', 3);
Hint: Type the keyword that creates an object from a class.
2. const rex = new Dog('Rex', 3);
Hint: Type the name of the class being used to build the object.
3. const rex = new Dog('Rex', 3); console.log(rex.name);
Hint: Type the variable name that stores the new object, matching its use on the next line.
4. const rex = new Dog('Rex', 3);
Hint: Type the keyword that declares a variable which will not be reassigned.
5. let bo = new Dog('Bo', 5); console.log(bo.name);
Hint: Type the variable that holds the object created on the line above.

Spot the Error

Question 1
A const nums = [1, 2, 2, 3];
B console.log(nums.length);
C const unique = Set(nums);
D console.log(unique.size);
Line C — The new keyword is missing. Set is a class, so calling it without new causes a TypeError. It should be const unique = new Set(nums);
Question 2
A const pairs = [['a', 1]];
B const m = new map(pairs);
C console.log(m.get('a'));
Line B — Class names are case-sensitive. map (lowercase) does not exist, so JavaScript gives a ReferenceError. It should be new Map(pairs).
Question 3
A class Dog() {
B constructor(n) {this.n = n}
C }
D const rex = new Dog('Rex');
Line A — A class header has no round brackets. The class never gets defined, so new Dog('Rex') can't work. It should be class Dog {
Question 4
A const d = Date new(2025, 5);
B console.log(d.getMonth());
C console.log(d.getFullYear());
Line A — The new keyword must come directly before the class name. The correct line is const d = new Date(2025, 5);
Question 5
A class Dog {
B constructor(n) {this.n = n}
C }
D const rex = Dog('Rex');
E console.log(rex.n);
Line D — Without new, the Dog constructor is not run and JavaScript throws a TypeError. It should be const rex = new Dog('Rex');

Student with a class code? Join your class →