1.
Seman c Tags – Types, Defini ons & Examples
<header>: Top sec on of the page, usually contains logo or naviga on. Example:
<header>My Site</header>
<nav>: Contains naviga on links. Example: <nav><a href="#">Home</a></nav>
<main>: Main content of the page. Example: <main>Welcome</main>
<sec on>: Groups related content. Example: <sec on>About Us</sec on>
<ar cle>: Independent content like blog posts. Example: <ar cle>Blog Post</ar cle>
<footer>: Bo om sec on with contact info or links. Example: <footer>Contact Info</footer>
2. Condi on Statements – Types, Defini ons & Examples
if: Runs code if condi on is true. Example: if (x > 0) [Link]("Posi ve");
if-else: Runs one block if true, another if false. Example: if (x > 0) {...} else {...}
else if: Checks mul ple condi ons. Example: if (x > 90) {...} else if (x > 75) {...}
switch: Matches value with cases. Example: switch(day) { case "Mon": ... }
3. Loops – Types, Defini ons & Examples
A loop is a programming construct that repeats a block of code mul ple mes, either a fixed number
of mes or un l a certain condi on is met.
for: Loop with counter. Example: for (let i = 0; i < 3; i++) {...}
while: Runs while condi on is true. Example: while (i < 3) {...}
do...while: Runs at least once. Example: do {...} while (i < 3);
forEach: Loops through array items. Example: [Link](item => [Link](item));
4. Array – Types, Defini ons & Examples
An array is a special variable that can hold mul ple values in a single container. Each value is stored
at a numbered index star ng from 0.
Single-dimensional: Simple list. Example: let nums = [1, 2, 3];
Mul -dimensional: Array inside array. Example: let matrix = [[1,2],[3,4]];
Mixed-type: Different data types in one array. Example: let mix = [1, "text", true];
Common Array Methods
Method Purpose
push() Add to end
pop() Remove from end
shift() Remove from start
unshift() Add to start
Method Purpose
map() Transform each element
filter() Select elements based on condition
reduce() Accumulate values into one
forEach() Loop through each element
5. RegExp – Types, Defini ons & Examples
RegExp (Regular Expression) is a sequence of characters that defines a search pa ern. It's used to
match, search, and replace text in strings.
Types of Regular Expressions
Type Descrip on
Literal RegExp Defined using slashes /pa ern/
Constructor RegExp Created using new RegExp("pa ern")
Global (g) Matches all occurrences
Case-insensi ve (i) Ignores case
Mul line (m) Matches across mul ple lines
Literal: Wri en directly using slashes. Example: /hello/.test("hello world")
Constructor: Created using new RegExp(). Example: new RegExp("hello").test("hello world")
6. Scope – Types, Defini ons & Examples
Scope refers to the accessibility of variables
Global Scope: Accessible everywhere. Example: let x = 10;
Func on Scope: Accessible inside func on. Example: func on test() { let y = 5; }
Block Scope: Accessible inside {} block. Example: { let z = 3; }
7. Func ons – Types, Defini ons & Examples
A func on is a reusable block of code that performs a specific task.
Func on Defini on: Declares a reusable block. Example: func on greet() {...}
Arrow Func on: Short syntax, no own this. Example: const greet = () => {...}
Parameters: Inputs to func on. Example: func on add(a, b) {...}
Invoca on: Calling the func on. Example: add(2, 3);
this Keyword: Refers to calling object. Example: [Link]()
call(): Calls with specific this. Example: [Link](obj)
apply(): Calls with array of arguments. Example: [Link](obj, [])
bind(): Returns new func on with bound this. Example: const bound = [Link](obj)
Closure: Inner func on remembers outer variables. Example: func on outer() { return
func on inner() {...} }
8. Async – Types, Defini ons & Examples
Callback: Func on passed to another. Example: setTimeout(() => {...}, 1000);
Promise: Represents future value. Example: new Promise(resolve => resolve("Done"))
async/await: Cleaner way to handle promises. Example: async func on getData() { await
fetch(...) }
9. Date – Types, Defini ons & Examples
Current Date: Current system date. Example: new Date();
Specific Date: Custom date. Example: new Date("2025-08-05");
Date Methods: Get parts of date. Example: [Link]();
10. Class Methods – Types, Defini ons & Examples
Class methods are func ons defined inside a class that operate on instances of that class or the class
itself.
Constructor: Ini alizes object. Example: constructor(name) {...}
Instance Method: Called on object. Example: greet() {...}
Sta c Method: Called on class directly. Example: sta c info() {...}
11. Inheritance – Types, Defini ons & Examples
Inheritance is an object-oriented programming concept where one class (child) inherits proper es
and methods from another class (parent). It promotes code reuse and hierarchical rela onships.
Types of Inheritance in JavaScript
Type Descrip on
Single Inheritance One class inherits from one parent class
Mul level Inheritance A class inherits from a child class which inherits from another
Prototypal Inheritance Objects inherit directly from other objects using prototypes
Class-based Inheritance Introduced in ES6 using class and extends keywords