OOP – Classes & Objects, online
Six activities your students do on their own devices. See who's finished, and their scores.
Learning
Understanding
Testing
OOP – Classes & Objects in one minute
What students need to know
class is exactly the keyword used to define this blueprint. new is the keyword that builds a new object from a class.
class defines the shape and behavior that objects will share. JavaScript is case-sensitive, so 'class' must be lowercase.
Mistakes students make
- 'class' must be lowercase - a capital C causes an error.
- This line is missing a semicolon, but that's not required in JS.
- The class body must close with }, not ].
- 'new' must be lowercase - a capital N causes an error.
PREVIOUS · MODULE 46JSON – stringify and parse
YOU ARE HERE · MODULE 47OOP – Classes & Objects
NEXT · MODULE 48OOP – constructor Method
What students will learn in this module
Every question in Module 47
Quick questions
- Does class declare a blueprint for creating objects?AYesBNo
- Does new create an instance of a class?ANoBYes
- Must 'class' be written in lowercase?AYesBNo
- Must 'new' be written in lowercase?AYesBNo
- Is 'Class' with a capital C valid JavaScript syntax?AYesBNo
Key terms
Students type the meaning of:
class
Match the pairs
class Dog { name = "Rex"; }Match it to what it doesnew Dog()Match it to what it doesDeclares a reusable blueprint for creating objectsMatch it to what it doesCreates an instance of a classMatch it to what it doesClass Dog { name = "Rex"; }Match it to what it doeslet d = New Dog();Match it to what it doesFill in the blanks
_____ Dog {Hint: Type the keyword that declares a class.
let myDog = ___ Dog();
Hint: Type the keyword that creates a new instance of a class.
class Cat _
Hint: Type the symbol that opens the class body.
let c = ___ Cat();
Hint: Type the keyword that creates a new instance of a class.
class Bird _
Hint: Type the symbol that opens the class body.
Spot the error
Question 1
AClass Dog {Bname = "Rex";C}
Question 2
Aclass Cat {Bname = "Tom"C}
Question 3
Aclass Bird {Bname = "Tweety";C]
Question 4
Aclass Fish {Bname = "Nemo";C}Dlet f = New Fish();
Question 5
Aclas Dog {Bname = "Rex";C}
