Course Content
Data types and Values
0/1
Object-oriented programming in JavaScript
0/1
Error handling and debugging in JavaScript
0/1
JavaScript functions for string and array manipulation
0/1
JavaScript Libraries and Frameworks
0/1
JavaScript
About Lesson

JavaScript objects and properties

In JavaScript, objects are a fundamental data type that allow you to group related data and behavior together into a single entity. Objects are composed of one or more key-value pairs, where the key is a string (or symbol) and the value can be any JavaScript data type, including other objects.

Here’s an example of an object literal in JavaScript:

let person = {

  name: “John”,

  age: 30,

  address: {

    street: “123 Main St”,

    city: “Anytown”,

    state: “CA”

  },

  sayHello: function() {

    console.log(“Hello, my name is ” + this.name);

  }

};

You can access properties of an object using dot notation or bracket notation.

You can also add or modify properties of an object using dot notation or bracket notation.