Tsallaka zuwa abun ciki
Justice Tech School

Objects

An object stores key and value pairs. Read a value with dot notation (user.name) or brackets (user["name"]).

Objects can hold functions too. Those are called methods.

Example
const user = {
  name: "Ada",
  age: 21,
  greet() {
    return "Hi, I am " + this.name;
  },
};
console.log(user.name);
console.log(user["age"]);
console.log(user.greet());

Exercise

Read the city from the object.

const place = { city: "Lagos" };
console.log(place.);

Quiz Test

How do you read the name property of user?

These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.