← JavaScript

throw Statement

Creates a custom error and immediately stops the current code from running further.

Understanding throw Statement in JavaScript

What it does: throw is exactly the keyword that does this. A thrown error inside try can be handled by catch. throw raises an error that can be handled elsewhere. Execution stops immediately at the point throw is called. JavaScript is case-sensitive, so 'throw' must be lowercase. Error is a built-in object and must be capitalized. The correct spelling is 'throw', not 'trow'. throw can raise any value, including a plain string.

Common mistakes: 'throw' must be lowercase - a capital T causes an error. 'Error' must start with a capital E, not lowercase.

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 throw create a custom error?
YesNo
Matches
Throw new Error("Bad");
↓
Wrong - 'throw' must be lowercase
Applying
Meanings
Term
throw
Meaning
Creates a custom error and immediately stops the current code from running further.
Practice
try {
Testing
Gaps
new Error("Something broke");
Check Answer
Spots
1Throw new Error("Bad");
2console.log("after");

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

The 'Ermine' badge — Tundra Streak, 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 throw create a custom error?
A. Yes ✓
B. No
throw raises an error that can be handled elsewhere.
2. Does throw stop the current code from running further?
A. No
B. Yes ✓
Execution stops immediately at the point throw is called.
3. Can a thrown error be caught by a catch block?
A. Yes ✓
B. No
If throw happens inside try, catch can handle the error.
4. Must 'throw' be written in lowercase?
A. No
B. Yes ✓
JavaScript is case-sensitive, so 'throw' must be lowercase.
5. Must 'Error' start with a capital E when using new Error()?
A. Yes ✓
B. No
Error is a built-in object and must be capitalized.

Match the Pairs

throw new Error("Something broke"); → Raises a custom error and stops execution at that point
throw new Error("Bad age"); → Raises an error describing an invalid age
Creates and raises a custom error → throw
Can be caught by a matching catch block → try { throw new Error("X"); } catch (e) { ... }
Throw new Error("Bad"); → Wrong - 'throw' must be lowercase
throw new error("Bad"); → Wrong - 'Error' must start with a capital E

Key Term

throw
Creates a custom error and immediately stops the current code from running further.

Fill in the Blanks

1. throw new Error("Something broke");
Hint: Type the keyword that raises a custom error.
2. throw new Error("Invalid input");
Hint: Type the built-in type used to create an error.
3. throw new Error("No data found");
Hint: Type the keyword that raises a custom error.
4. if (age < 0) { throw new Error("Bad age"); }
Hint: Type the keyword that raises a custom error.
5. throw new Error("Out of range");
Hint: Type the built-in type used to create an error.

Spot the Error

Question 1
A Throw new Error("Bad");
B console.log("after");
C let x = 1;
Line A — 'throw' must be lowercase - a capital T causes an error.
Question 2
A throw new error("Bad");
B console.log("after");
C let x = 1;
Line A — 'Error' must start with a capital E, not lowercase.
Question 3
A let a = 1;
B throw "Bad";
C console.log(a);
Line B — This line is actually correct - throw can raise a plain string too.
Question 4
A let b = 2;
B trow new Error("Bad");
C console.log(b);
Line B — 'throw' is misspelled as 'trow'.
Question 5
A try {
B throw new Error("Oops");
C } catch (e) {
D console.log(e.message)
E }
Line D — This line is missing a semicolon, but that's not required in JS.

Student with a class code? Join your class →