Unit 1: JavaScript Foundations & SyntaxLesson #1 / 10

Lesson 1: JavaScript Basics, Variables & Data Types

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

1. Introduction to Modern JavaScript

JavaScript is the programming language of the web. It drives client-side interactivity, asynchronous APIs, DOM modifications, and server-side runtimes via Node.js.

  • High-Level Interpreted Language: Executes directly inside browser engines (V8 in Google Chrome & Edge) and Node.js.
  • Dynamic Typing: Variables hold values with types, but the variable itself is not locked to a static type.
  • Modern ES6+ Standards: Uses block-scoped const and let instead of legacy function-scoped var.
  • HTML5 Web Code (index.html)
    <!DOCTYPE html>
    <html lang="en">
    <head>
    <meta charset="UTF-8">
    <title>JavaScript Basics</title>
    </head>
    <body style="background:#17181c; color:#fff; font-family:Arial; padding:30px;">
    <h2>JavaScript Console Output</h2>
    <p id="output-text">Check browser DevTools console (F12) or see below:</p>
    <div id="demo-box" style="padding:15px; background:#1f2029; border-left:4px solid #04AA6D; margin-top:15px;"></div>
    <script>
    // 1. Variable Declarations
    const platformName = "Nextsem Academy";
    let activeStudents = 1500;
    const isFree = true;
    // 2. Logging and Displaying
    console.log("Welcome to " + platformName + "!");
    console.log("Active learners:", activeStudents);
    // 3. Injecting to UI
    document.getElementById("demo-box").innerHTML =
    "<strong>Platform:</strong> " + platformName + "<br>" +
    "<strong>Students:</strong> " + activeStudents + "<br>" +
    "<strong>100% Free:</strong> " + isFree;
    </script>
    </body>
    </html>

    2. Primitive vs Non-Primitive Data Types

    Data TypeExampleDescription
    String"Nextsem", 'Code'Text sequences enclosed in quotes
    Number42, 3.14159Integers and floating-point decimals
    Booleantrue / falseLogical condition flags
    NullnullIntentional absence of any object value
    UndefinedundefinedVariable declared but not assigned
    Object{ name: "Dev" }Key-value mapping collection
    Array[1, 2, 3]Ordered index-based list

    Interactive Knowledge Check

    Test your understanding of Lesson #1 concepts

    Which keyword should you use by default in modern JavaScript for variables whose value reference does not change?