Storing objects in an array
Makes a new Student object and adds it to the end of the students array. You can then loop over the array and call each object's methods.
Understanding Storing objects in an array in ACARA Digital Technologies Years 9–10
What it does: The loop visits each object and adds its points property to the running total. Objects made from a class need the new keyword. Without new, a class constructor can't be called and JavaScript throws a TypeError. for...of loops over the array (students), not over the class name. Student is the blueprint, not the list of objects. === compares values. A single = assigns, which would overwrite every name with 'Ava' instead of testing it. First pick the object with its index, students[0], then read its property with .name. push() adds to the end of the array, and new Student(...) builds the object that gets added.
Common mistakes: Student is a class, so you must use the new keyword to make an object before pushing it. It should be list.push(new Student("Zoe"));. for...in gives the index positions ("0", "1"...), not the Student objects, so s.points is undefined and the total becomes NaN. Use for...of to visit each object.
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 743–781) and word search (Modules 743–809).
Take this worksheet further — free with Cloodit
Each concept is reinforced from every angle — learned, then applied, then tested.
Cloodit turns curriculum-aligned coding content into journeys students work through one biome at a time.
Over 100 of them, across seven natural biomes.
Turns their work into revision material ready for Flash Cards and Exam study.
Live, competitive practice for the start of the lesson or a teacher-led lesson finisher.
Honour your top performers, or encourage a student who's trying hard — ready to print in seconds.
Quick Questions
Match the Pairs
Key Term
students.push(new Student('Ava', 7));Fill in the Blanks
Spot the Error
Student with a class code? Join your class →