Skip to content

Latest commit

 

History

History
45 lines (34 loc) · 2.28 KB

File metadata and controls

45 lines (34 loc) · 2.28 KB

Module 5: Objects

Activity 1: Introduction to objects

  • Understanding the concept of objects and their role in JavaScript.
  • Exploring the syntax for creating objects using object literals.
  • Learning about key-value pairs and accessing object properties.
  • Understanding object methods and their usage.

Activity 2: Creating objects

  • Creating objects using object constructor functions.
  • Using the new keyword to instantiate objects.
  • Initializing object properties in the constructor.
  • Exploring object prototypes and inheritance.

Activity 3: Object properties and methods

  • Working with object properties and accessing them using dot notation and bracket notation.
  • Modifying object properties and adding new properties dynamically.
  • Understanding the concept of this and its usage in object methods.
  • Exploring built-in JavaScript objects and their methods.

Practice Exercises:

  1. Create a person object:

    • Create an object called person with properties for name, age, and occupation.
    • Add a method to the object called introduce that prints a message introducing the person.
    • Call the introduce method on the person object and log the result to the console.
  2. Calculate the area of a rectangle using an object:

    • Create an object called rectangle with properties for width and height.
    • Add a method to the object called calculateArea that calculates the area of the rectangle.
    • Call the calculateArea method on the rectangle object and log the result to the console.
  3. Create a bank account object:

    • Create an object called bankAccount with properties for accountNumber, balance, and ownerName.
    • Add methods to the object for deposit, withdraw, and getBalance.
    • Call the methods on the bankAccount object to perform transactions and log the results to the console.

Estimated time to complete this module is approximately 4-6 hours.

To further enhance your learning, here are some additional resources: