Unit 3: Objects, DOM & Browser Web APIsLesson #6 / 10

Lesson 6: Objects, Key-Value Pairs & JSON

Er. Manoj Kumar — AuthorEr. Manoj KumarLast Updated: 26 Aug, 2026

1. JavaScript Objects & JSON

Objects store structured key-value data mappings.

  • Dot Notation: user.name
  • Bracket Notation: user["email"]
  • JSON.stringify(obj): Object → JSON String.
  • JSON.parse(str): JSON String → Object.
  • HTML5 Web Code (index.html)
    <!DOCTYPE html>
    <html lang="en">
    <head>
    <meta charset="UTF-8">
    <title>JS Objects & JSON</title>
    </head>
    <body style="background:#17181c; color:#fff; font-family:Arial; padding:30px;">
    <h2>Student Profile Object</h2>
    <pre id="json-view" style="background:#0c0c0c; padding:15px; border-radius:8px; color:#04AA6D;"></pre>
    <script>
    const student = {
    id: 101,
    name: "Manoj Kumar",
    role: "Full Stack Developer",
    skills: ["HTML", "CSS", "JS", "C++"],
    certified: true
    };
    // Serialize to formatted JSON string
    const jsonString = JSON.stringify(student, null, 2);
    document.getElementById("json-view").textContent = jsonString;
    </script>
    </body>
    </html>

    Interactive Knowledge Check

    Test your understanding of Lesson #6 concepts

    Which method serializes a JavaScript object into a JSON string format?