Javascript Tutorial
Chapter 1: Introduction to JavaScript (Complete Deep Dive)
What is JavaScript?
JavaScript is a high-level, interpreted programming language used to make websites
interactive and dynamic. It runs inside the browser and can also run on servers using
environments like [Link].
👉 Without JavaScript, websites are static (like plain text pages).
👉 With JavaScript, you can create:
Interactive forms
Real-time updates
Games
Web apps like Instagram,Amazon
🧠 History of JavaScript
Created by Brendan Eich in 1995
Initially called Mocha → LiveScript → JavaScript
Standardized as ECMAScript (ES)
Modern JavaScript versions:
ES5 (2009)
ES6 (2015) → Major update (let, const, arrow functions)
ES2020+ → Modern features (optional chaining, etc.)
⚙️ How JavaScript Works?
JavaScript runs in the browser using a JavaScript engine:
Chrome → V8 Engine
Firefox → SpiderMonkey
Execution Flow:
Browser loads HTML
CSS applied
JavaScript runs
Page becomes interactive
🧩 Ways to Add JavaScript
1. Inline Js
<button onclick="alert('Hello')">Click</button>
2. Internal Js
<script>
[Link]("Hello World");
</script>
3. External Js
<script src="[Link]"></script>
First JavaScript Program
[Link]("Hello World");
👉 Output will be shown in browser console.
🔍 Console Methods
[Link]("Message");
[Link]("Error");
[Link]("Warning");
Keywords in JavaScript
Reserved words like: let, const, if, else, function cannot be used as variable names.
JavaScript Features
Lightweight & Fast
Interpreted (no compilation needed)
Event-driven
Object-oriented
Asynchronous (handles tasks without blocking)
Common Beginner Mistakes
Forgetting semicolons (optional but recommended)
Using var instead of let/const
Writing JS before HTML loads
🧪 Practice Exercises (Level Wise)
🟢 Beginner
Print your name in console
Print your age
Print numbers from 1 to 20
🟡 Intermediate
Print even numbers from 1–50
Print multiplication table of 7
Create a program to print square of numbers
🔴 Advanced
Print Fibonacci series (first 10 numbers)
Reverse a number (e.g., 123 → 321)
Check if number is prime
Interview Questions (Must Know)
Basic
1. What is JavaScript?
2. Is JavaScript compiled or interpreted?
3. Where is JavaScript used?
Intermediate
1. What is ECMAScript?
2. Difference between JavaScript and TypeScript?
3. What are JavaScript engines?
Advanced
1. How JavaScript executes code internally?
2. What is single-threaded language?
3. What is synchronous vs asynchronous?
Mini Project (Chapter 1)
🧩 Task: Console Based Greeting App
👉 Requirement:
Ask user name (prompt)
Print greeting message
let name = prompt("Enter your name:");
[Link]("Hello " + name + " Welcome to JavaScript!");
Chapter 2 - Variables & Data Types (Complete Deep Dive)
What are Variables?
Variables are containers used to store data values in a program.
👉 Think of a variable like a box where you store information.
let name = "Vikash";
const age = 20;
Types of Variable Declarations
1. let (Recommended)
Block scoped
Can be updated
Cannot be re-declared in same scope
2. const (Best for constants)
Block scoped
Cannot be updated or re-declared
3. var (Avoid using)
Function scoped
Can be re-declared
Causes bugs due to hoisting