← ACARA Digital Technologies Years 9–10

Changing and adding object properties

Assigning to object.property with = changes an existing property or adds a new one if it is not there yet. Reading a property that does not exist gives undefined.

Understanding Changing and adding object properties in ACARA Digital Technologies Years 9–10

What it does: JavaScript does not throw an error for a missing property; reading it just gives undefined. Writing object.newName = value adds the property named newName with that value. A single = assigns a value. Double == only compares values and changes nothing. const stops you reassigning the variable itself, but the properties inside the object can still be changed. The assignment added points to the object, so reading it afterwards gives 10. A double equals checks equality and leaves the object unchanged, so the property is not updated.

Common mistakes: Inside an object literal, each property is written as name: value with a colon. It should be { age: 15 }. The = sign is only used when assigning with dot notation after the object exists. Property names are case-sensitive. The property was added as age, so pet.Age does not exist and gives undefined. It should be pet.age.

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
const student = { name: 'Ava', age: 15 }; student.age = 16; What is student.age now?
1615
Matches
student.age == 16;
↓
== compares values instead of assigning. It does not change age. Use a single = to assign.
Applying
Meanings
Term
student.age = 16
Meaning
Assigning to object.property with = changes an existing property or adds a new one if it is not there yet. Reading a property that does not exist gives undefined.
Practice
const student = { name: "Ava", age: 15 };
Testing
Gaps
student.age 16;
Check Answer
Spots
1const student = { age = 15 };
2student.age = 16;

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

The 'Elephant' badge — OOP Heavyweight, 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. const student = { name: 'Ava', age: 15 }; student.age = 16; What is student.age now?
A. 16 ✓
B. 15
Assigning with = replaces the old value of an existing property, so age changes from 15 to 16.
2. Which line changes the age property of student to 16?
A. student.age = 16; ✓
B. student.age == 16;
A single = assigns a value. Double == only compares values and changes nothing.
3. const student = { name: 'Liam' }; student.house = 'Blue'; What happens?
A. A new house property is added to student ✓
B. An error is thrown because house did not exist
Assigning to a property that does not exist yet adds it to the object.
4. const pet = { name: 'Rex' }; console.log(pet.age); What is printed?
A. An error message
B. undefined ✓
Reading a property that does not exist gives undefined. It does not crash the program.
5. True or false: you can change a property of an object that was declared with const.
A. False
B. True ✓
const stops you reassigning the variable itself, but the properties inside the object can still be changed.

Match the Pairs

student.age = 16; → Changes the existing age property of student to 16
student.house = "Red"; → Adds a new house property to student if it was not there before
Reading a property that was never added gives undefined → console.log(student.email); // undefined
Use dot notation and = to give an object a new property → student.points = 50;
student.age == 16; → == compares values instead of assigning. It does not change age. Use a single = to assign.
student = 16; → This assigns to the whole variable, not the age property. It should be student.age = 16;

Key Term

student.age = 16
Assigning to object.property with = changes an existing property or adds a new one if it is not there yet. Reading a property that does not exist gives undefined.

Fill in the Blanks

1. let student = { name: "Ava", age: 15 }; student.age = 16; console.log(student.age);
Hint: Type the operator that stores a new value in the age property.
2. let student = { name: "Ava", age: 15 }; student.age = 16; console.log(student.age);
Hint: Type the name of the object whose property is being changed.
3. let student = { name: "Ava" }; student.age = 16; console.log(student.age);
Hint: Type the name of the new property that was just added, so it can be read back.
4. let student = { name: "Ava" }; console.log(student.age); // prints undefined
Hint: Type the value JavaScript gives when you read a property that does not exist.
5. let student = { name: "Ava", age: 15 }; student.age += 1; // age is now 16
Hint: Type the operator that adds to the current property value and saves the result.

Spot the Error

Question 1
A const student = { age = 15 };
B student.age = 16;
C console.log(student.age);
Line A — Inside an object literal, each property is written as name: value with a colon. It should be { age: 15 }. The = sign is only used when assigning with dot notation after the object exists.
Question 2
A const pet = { name: 'Rex' };
B pet.age = 3;
C pet.age = 4;
D console.log(pet.Age);
Line D — Property names are case-sensitive. The property was added as age, so pet.Age does not exist and gives undefined. It should be pet.age.
Question 3
A const car = { speed: 0 };
B car.speed = 50;
C car.colour == 'red';
D console.log(car.colour);
Line C — A double == compares values; it does not add or change a property. Use a single = to assign: car.colour = 'red'; adds the new colour property.
Question 4
A const dog = { name, 'Max' };
B dog.age = 2;
C console.log(dog.age);
Line A — A property name and its value are separated by a colon, not a comma. It should be { name: 'Max' }.
Question 5
A const book = { pages: 100 };
B book.pages = 120;
C book.title: 'Maps';
D console.log(book.title);
Line C — A colon is only used inside the curly braces of an object literal. To add a property afterwards, use assignment with =: book.title = 'Maps';

Student with a class code? Join your class →