P3.1: JavaScript Basics & Variables

JavaScript is the programming language of the web. It controls the interactive behavior of websites.


1. Declaring Variables

Modern JavaScript uses let and const to store variables:

  • const (Constant): Sourced for variables that should never change.
  • let: Sourced for variables that will be reassigned.
  • Never use var: It has outdated scoping behaviors.
Kyle Simpson

Kyle SimpsonView Profile 🔗

Real-World Developer Case Study
15 Years Exp
RoleAuthor of You Don't Know JS
Salary₹85 Lakhs/yr equivalent
CompanyGetify Solutions
Core Tech Stack
JavaScript CoreScopesClosuresAsync JS

Don't just write code; know how the compiler works. Const signifies that the variable reference will never be reassigned. Use it by default, and change to let only when required.


2. Core Data Types

  • String: "Hello"
  • Number: 42, 3.14
  • Boolean: true / false
  • Null: Represents an intentional empty value.
  • Undefined: Variable declared but not assigned.

🎓 Practice Assignment

  1. Open your browser console.
  2. Create variables representing your name (const), age (let), and student status (const).
  3. Log them to the console.
Advertisement
NS
Ask Nextsem
AI Mode
NS
Home
Course
Playground