Introduction to JavaScript

Objects in JavaScript

Objects are complex data structures in JavaScript that store key-value pairs. They allow developers to represent real-world entities and organize related data into a single unit.

Creating Objects

Objects are created using curly braces {}. A colon separates each key-value pair, and commas separate multiple pairs.

let person = {

name: 'John Doe',

age: 30,

isStudent: true,

};

Accessing Object Properties

Object properties can be accessed using dot notation or square brackets.

console.log(person.name); // Output: 'John Doe'

console.log(person['age']); // Output: 30

Modifying Object Properties

Object properties can be modified by reassigning their values.

person.age = 31;

console.log(person.age); // Output: 31

Nested Objects

Objects can contain other objects as values, creating nested data structures.

let student = {

 name: 'Alice',

 age: 25,

 address: {

  city: 'New York',

  zipCode: '10001',

 },

};

console.log(student.address.city); // Output: 'New York'

Whenever you're ready

There are 4 ways we can help you become a great backend engineer:

The MB Platform

Join 1000+ backend engineers learning backend engineering. Build real-world backend projects, learn from expert-vetted courses and roadmaps, track your learnings and set schedules, and solve backend engineering tasks, exercises, and challenges.

The MB Academy

The “MB Academy” is a 6-month intensive Advanced Backend Engineering BootCamp to produce great backend engineers.

Join Backend Weekly

If you like post like this, you will absolutely enjoy our exclusive weekly newsletter, Sharing exclusive backend engineering resources to help you become a great Backend Engineer.

Get Backend Jobs

Find over 2,000+ Tailored International Remote Backend Jobs or Reach 50,000+ backend engineers on the #1 Backend Engineering Job Board