MSK Institute LogoMSK.Institute
HomeCourses
Book Free Demo➔Sign In
Free Demo➔
MSK Institute LogoMSK.Institute

Leading computer training academy in Shikohabad for software engineering, Python, web development, and digital literacy.

ISO 9001:2015 Certified Center
Follow & Connect
4.9

Programs & Admissions

  • All CoursesCatalog
  • Learning PathsRoadmaps
  • Student ProjectsShowcase
  • Live Classes & ScheduleLive
  • Upcoming Batches
  • Campuses & LocationsHub
  • Verify Certificates
  • Book Free Demo Class

Resources & Tools

  • Free Online Mock TestsAll Tests
  • NIELIT CCC Mock TestFree
  • Course & Career FinderQuiz
  • Study Material Hub
  • All MSK ToolsHub
  • Keyboard ShortcutsNew
  • TypeQuest Speed LabTyping
  • MSK Code PlaygroundCode
  • Interactive Tutorials
  • Quick Cheatsheets

Institute & Contact

  • About MSK Institute
  • Careers & InternshipsHiring
  • Publications & Blogs
  • Gali No. 3, Near Gyan Jyoti Public School,
    Adarsh Nagar, Shikohabad, Uttar Pradesh 283135
  • +91 83930 42166
  • mskshikohabad@gmail.com
  • Hours:Mon – Sat: 8:00 AM – 7:00 PM | Sun: 10:00 AM – 2:00 PM
  • 4.9 ★(38 Google Reviews)
© 2026 MSK Institute. All rights reserved.•Privacy Policy•Terms of Service•Disclaimer•Contact Us

Shikohabad's Leading Computer & Coding Academy

Home
Courses
Live
Material
Object Basics and Properties0%
Study Materials
JavaScript for BeginnersProgress 0%
1.1What is JavaScript?1.2How JavaScript Works in Browser1.3Setting up Environment: VSCode, Live Server
8.1Array Basics and Methods8.2Object Basics and Properties8.3Iterating over Arrays and Objects
HomeTutorialsJavaScript for BeginnersObject Basics and Properties
Iterating over Arrays and Objects

Object Basics and Properties

Beginner12 min read•Updated: 2026-09-15•By Er. Sumit Kumar (MSK Institute)
Study Materials

If arrays are ordered lists, Objects are structured dictionaries. Objects in JavaScript allow you to group related state and behavior into a single data structure composed of key-value pairs (also called properties and methods).


1. Creating Objects: Object Literal Syntax

The simplest and most common way to create an object is using curly braces { ... }:

1const student = {
2 // Properties (key: value)
3 firstName: "Sumit",
4 lastName: "Sharma",
5 age: 24,
6 isEnrolled: true,
7 skills: ["HTML", "CSS", "JavaScript"],
8 address: {
9 city: "New Delhi",
10 country: "India"
11 },
12 
13 // Method (function inside an object)
14 getFullName: function() {
15 return `${this.firstName} ${this.lastName}`;
16 }
17};

2. Accessing and Modifying Properties

JavaScript offers two ways to access object properties:

A. Dot Notation (object.property)

Clean, standard, and easy to read:

1console.log(student.firstName); // "Sumit"
2console.log(student.address.city); // "New Delhi"
3 
4// Calling a method:
5console.log(student.getFullName()); // "Sumit Sharma"

B. Bracket Notation (object["property"])

Mandatory in two critical scenarios:

  1. 1
    When property names contain spaces or hyphens:
1 const config = { "api-version": "v2", "max retries": 3 };
2 console.log(config["api-version"]); // Valid! config.api-version would fail!
  1. 1
    When the property key is stored in a dynamic variable:
1 const keyToLookUp = "age";
2 console.log(student[keyToLookUp]); // 24!
3 // student.keyToLookUp would look literally for a property named 'keyToLookUp'!

3. Adding, Updating, and Deleting Properties

Objects in JavaScript are dynamic:

1const course = {
2 title: "Full-Stack Development",
3 duration: "6 months"
4};
5 
6// 1. Updating an existing property:
7course.duration = "12 months";
8 
9// 2. Adding a brand new property:
10course.instructor = "Sumit Sir";
11course.rating = 4.9;
12 
13// 3. Deleting a property using the 'delete' keyword:
14delete course.rating;
15 
16console.log(course);
17// { title: "Full-Stack Development", duration: "12 months", instructor: "Sumit Sir" }

4. Checking if a Property Exists

1const user = { name: "Aarav", email: "aarav@gmail.com" };
2 
3// 1. The 'in' operator:
4console.log("email" in user); // true
5console.log("phoneNumber" in user); // false
6 
7// 2. Object.hasOwn() (Modern ES2022 standard):
8console.log(Object.hasOwn(user, "name")); // true

5. The this Keyword Inside Object Methods

When a function is called as a method of an object, this refers to the object itself:

1const car = {
2 brand: "Tesla",
3 speed: 60,
4 accelerate() {
5 this.speed += 20;
6 console.log(`${this.brand} is now moving at ${this.speed} km/h.`);
7 }
8};
9 
10car.accelerate(); // "Tesla is now moving at 80 km/h."

Interactive Quiz• Knowledge Check

Practice Quiz

Question 1
What data structure does a JavaScript object use to store data?
Question 2
When MUST you use bracket notation (obj[key]) instead of dot notation (obj.key)?
Question 3
What keyword is used to remove a property from an object in JavaScript?
Question 4
Inside an object method, what does the this keyword refer to when invoked normally?
Question 5
What is the modern ES2022 method to safely check if an object owns a specific property key?
Next Lesson

Iterating over Arrays and Objects

Continue learning with hands-on practice, examples, and exercises in the upcoming topic.

Related Lessons

Previous LessonNext Lesson
Array Basics and MethodsIterating over Arrays and Objects

Practice Quiz

Test your understanding of this lesson with 5 questions. Each question has one correct answer.

Mentor-Led Practical Training

Master JavaScript for Beginners with Hands-On Projects

Practice in live mentor-led sessions with real projects, mock tests, and verifiable certification at MSK Institute.

View Full CourseBook Free Demo
PreviousNext
PreviousPrevNext