Javascript Beginner Quick Notes
(Making Webpages interactive)
Prepared by:
Mohammad Asif Ansari
Software Engineer | Full Stack Developer | Trainer
Specialized in Python & Django Development
📘 JavaScript Basics – Trainee Notes
🔹 What is JavaScript?
JavaScript is an object-based, light-weight, Interpreted and Scripting programming
language which is used to make Web Pages interactive.
Key Points to Remember 📝
✔ JavaScript is case-sensitive
✔ Semicolon ; is optional but recommended
✔ Use DOM to control HTML
✔ Use BOM to control browser behavior
👉 Java is different from JavaScript
👉 JavaScript runs inside the browser
📜 History of JavaScript
🔹 Birth of JavaScript
JavaScript was created in 1995 by Brendan Eich while he was working at Netscape
Communications.
👉 The goal was to create a lightweight scripting language that could make web pages
interactive.
🔹 Initial Names of JavaScript
JavaScript went through three names:
1️⃣ Mocha
✅ (Final name)
2️⃣ LiveScript
3️⃣ JavaScript
📌 The name JavaScript was chosen mainly for marketing purposes, as Java was very
popular at that time.
⚠️ Java and JavaScript are completely different languages
🔹 Purpose of JavaScript (Initially)
Initially, JavaScript was used for:
● Form validation
● Button click actions
● Simple calculations
● Alert and confirmation boxes
Example:
alert("Form submitted successfully!");
🔹 Standardization – ECMAScript
To avoid confusion between browsers, JavaScript was standardized by ECMA
International.
👉 The standardized version of JavaScript is called ECMAScript (ES).
Important ECMAScript Versions:
● ES1 (1997) – First standard
● ES5 (2009) – Widely used, stable version
● ES6 (2015) – Major update (Modern JavaScript)
○ let & const
○ Arrow functions
Example (ES6):
let name = "Asif";
[Link](“Welcome “+name);
🔹 JavaScript Growth Over Time
Earlier:
● Only worked in browsers
● Used for small scripts
Now:
● Frontend development (React, Angular, Vue)
● Backend development ([Link])
● Mobile apps
● Desktop apps
● Game development
● AI & automation
👉 JavaScript is now a full-stack language
🔹 JavaScript Today
✔ One of the most popular programming languages
✔ Supported by all modern browsers
✔ Easy to learn for beginners
✔ Powerful for professionals
🔹 Key Interview Points 📝
● JavaScript was created in 1995
● Created by Brendan Eich
● First name was Mocha
● ECMAScript is the standard of JavaScript
● ES6 is called Modern JavaScript
📘 JavaScript Variables & Declaration
Methods
🔹 What is a Variable?
A variable is a container used to store data values in memory.
Example:
let name = "Asif";
let age = 22;
🔹 Rules for Naming Variables
✔ Must start with letter, _ (underscore), or $
✔ Cannot start with a number
✔ No spaces allowed
✔ Case-sensitive (name ≠ Name)
✔ Should be meaningful
❌ 1name
❌ user name
✅ userName
🔹 Methods to Declare Variables in JavaScript
JavaScript provides three ways to declare variables:
1️⃣ var
2️⃣ let
3️⃣ const
🔹 1️⃣ var Keyword
● Introduced in old JavaScript
● Function scoped
● Allows redeclaration and reassignment
Example:
var num = 5;
var num = 10; // ✅ redeclaration allowed
num = 20; // ✅ reassignment allowed
⚠️ Problem with var:
Can cause unexpected bugs due to redeclaration.
🔹 2️⃣ let Keyword (ES6 – Modern JS)
● Block scoped
● ❌ Redeclaration not allowed
● ✅ Reassignment allowed
Example:
let a = 10;
let a = 20; // ❌ error
a = 30; // ✅ allowed
🔹 3️⃣ const Keyword (ES6 – Modern JS)
● Block scoped
● ❌ Redeclaration not allowed
● ❌ Reassignment not allowed
● Used for fixed values
(We are not changing the variable, only the data inside it)
🔹 Scope Difference
Keyword Scope Redeclare Reassign
var Function ✅ Yes ✅ Yes
let Block ❌ No ✅ Yes
const Block ❌ No ❌ No
🔹 Block Scope Example
{
let x = 10;
const y = 20;
}
// x and y ❌ not accessible here
{
var z = 30;
}
[Link](z); // ✅ accessible