DSA #25 - Core Data Structures | Stack Implementation
https://youtu.be/LG5Ehs18DRs
https://youtu.be/LG5Ehs18DRs
YouTube
DSA #25 - Core Data Structures | Stack Implementation
DSA Phase-3 Core Data Structures tutorial focusing on Stack implementation using an array in JavaScript.
In this video you will learn how to implement a Stack from scratch, understand push, pop, and peek methods, and add utility methods like isEmpty and size.β¦
In this video you will learn how to implement a Stack from scratch, understand push, pop, and peek methods, and add utility methods like isEmpty and size.β¦
β€1
Now, let's move to the next topic in Web Development Roadmap:
*βοΈ Simple CRUD UI in React*
Now you learn how real apps work.
π CRUD = Create, Read, Update, Delete
Every real application uses CRUD.
Examples
- Add task β Create
- View tasks β Read
- Edit task β Update
- Delete task β Delete
*πΉ What is CRUD in React*
CRUD means managing data using UI.
React handles CRUD using:
β State
β Events
β Components
*π§ Why CRUD is Important*
- Used in dashboards
- Used in admin panels
- Used in e-commerce apps
- Top interview question
If you know CRUD β you can build real apps.
*π§© Example Project: Todo List CRUD*
We will build:
β Add item
β Show item
β Delete item
β Update item
*βοΈ Step 1: Setup State*
State stores list data.
import { useState } from "react";
function App() {
const [items, setItems] = useState([]);
return <div></div>;
}
export default App;
β items β list data
β setItems() β update list
*β Step 2: Create (Add Item)*
Add new item to list.
const [input, setInput] = useState("");
const addItem = () => {
setItems([...items, input]);
setInput("");
};
UI
<input value={input} onChange={(e) => setInput(e.target.value)} />
<button onClick={addItem}>Add</button>
*π Step 3: Read (Show Items)*
Display list using map.
<ul>
{items.map((item, index) => (
<li key={index}>{item}</li>
))}
</ul>
*β Step 4: Delete Item*
Remove item from list.
const deleteItem = (index) => {
const newItems = items.filter((_, i) => i !== index);
setItems(newItems);
};
UI
<button onClick={() => deleteItem(index)}>Delete</button>
*βοΈ Step 5: Update Item (Edit)*
Update existing data.
const updateItem = (index) => {
const newValue = prompt("Update item");
const updated = [...items];
updated[index] = newValue;
setItems(updated);
};
UI
<button onClick={() => updateItem(index)}>Edit</button>
*β Complete CRUD UI Example*
import { useState } from "react";
function App() {
const [items, setItems] = useState([]);
const [input, setInput] = useState("");
const addItem = () => {
if (!input) return;
setItems([...items, input]);
setInput("");
};
const deleteItem = (index) => {
setItems(items.filter((_, i) => i !== index));
};
const updateItem = (index) => {
const newValue = prompt("Update item");
if (!newValue) return;
const updated = [...items];
updated[index] = newValue;
setItems(updated);
};
return (
<div>
<h2>Todo CRUD</h2>
<input value={input} onChange={(e) => setInput(e.target.value)} />
<button onClick={addItem}>Add</button>
<ul>
{items.map((item, index) => (
<li key={index}>
{item}
<button onClick={() => updateItem(index)}>Edit</button>
<button onClick={() => deleteItem(index)}>Delete</button>
</li>
))}
</ul>
</div>
);
}
export default App;
*π§ How CRUD Works Internally*
- User action β event triggers
- State updates
- React re-renders UI
This is Reactβs core workflow.
*β οΈ Common Beginner Mistakes*
- Mutating state directly
- Forgetting key in list
- Not copying arrays before update
- Confusing state updates
*π§ͺ Mini Practice Task*
- Build a simple student list CRUD
- Add student name
- Edit student name
- Delete student
- Show total count
*β Mini Practice Task β Solution βοΈ*
This covers:
β Add student
β Edit student
β Delete student
β Show total count
*π§© Complete Working Example*
import { useState } from "react";
function App() {
const [students, setStudents] = useState([]);
const [input, setInput] = useState("");
// β Add Student
const addStudent = () => {
if (!input.trim()) return;
setStudents([...students, input]);
setInput("");
};
// β Delete Student
const deleteStudent = (index) => {
const updated = students.filter((_, i) => i !== index);
setStudents(updated);
};
// βοΈ Edit Student
const editStudent = (index) => {
const newName = prompt("Enter new name");
if (!newName || !newName.trim()) return;
const updated = [...students];
*βοΈ Simple CRUD UI in React*
Now you learn how real apps work.
π CRUD = Create, Read, Update, Delete
Every real application uses CRUD.
Examples
- Add task β Create
- View tasks β Read
- Edit task β Update
- Delete task β Delete
*πΉ What is CRUD in React*
CRUD means managing data using UI.
React handles CRUD using:
β State
β Events
β Components
*π§ Why CRUD is Important*
- Used in dashboards
- Used in admin panels
- Used in e-commerce apps
- Top interview question
If you know CRUD β you can build real apps.
*π§© Example Project: Todo List CRUD*
We will build:
β Add item
β Show item
β Delete item
β Update item
*βοΈ Step 1: Setup State*
State stores list data.
import { useState } from "react";
function App() {
const [items, setItems] = useState([]);
return <div></div>;
}
export default App;
β items β list data
β setItems() β update list
*β Step 2: Create (Add Item)*
Add new item to list.
const [input, setInput] = useState("");
const addItem = () => {
setItems([...items, input]);
setInput("");
};
UI
<input value={input} onChange={(e) => setInput(e.target.value)} />
<button onClick={addItem}>Add</button>
*π Step 3: Read (Show Items)*
Display list using map.
<ul>
{items.map((item, index) => (
<li key={index}>{item}</li>
))}
</ul>
*β Step 4: Delete Item*
Remove item from list.
const deleteItem = (index) => {
const newItems = items.filter((_, i) => i !== index);
setItems(newItems);
};
UI
<button onClick={() => deleteItem(index)}>Delete</button>
*βοΈ Step 5: Update Item (Edit)*
Update existing data.
const updateItem = (index) => {
const newValue = prompt("Update item");
const updated = [...items];
updated[index] = newValue;
setItems(updated);
};
UI
<button onClick={() => updateItem(index)}>Edit</button>
*β Complete CRUD UI Example*
import { useState } from "react";
function App() {
const [items, setItems] = useState([]);
const [input, setInput] = useState("");
const addItem = () => {
if (!input) return;
setItems([...items, input]);
setInput("");
};
const deleteItem = (index) => {
setItems(items.filter((_, i) => i !== index));
};
const updateItem = (index) => {
const newValue = prompt("Update item");
if (!newValue) return;
const updated = [...items];
updated[index] = newValue;
setItems(updated);
};
return (
<div>
<h2>Todo CRUD</h2>
<input value={input} onChange={(e) => setInput(e.target.value)} />
<button onClick={addItem}>Add</button>
<ul>
{items.map((item, index) => (
<li key={index}>
{item}
<button onClick={() => updateItem(index)}>Edit</button>
<button onClick={() => deleteItem(index)}>Delete</button>
</li>
))}
</ul>
</div>
);
}
export default App;
*π§ How CRUD Works Internally*
- User action β event triggers
- State updates
- React re-renders UI
This is Reactβs core workflow.
*β οΈ Common Beginner Mistakes*
- Mutating state directly
- Forgetting key in list
- Not copying arrays before update
- Confusing state updates
*π§ͺ Mini Practice Task*
- Build a simple student list CRUD
- Add student name
- Edit student name
- Delete student
- Show total count
*β Mini Practice Task β Solution βοΈ*
This covers:
β Add student
β Edit student
β Delete student
β Show total count
*π§© Complete Working Example*
import { useState } from "react";
function App() {
const [students, setStudents] = useState([]);
const [input, setInput] = useState("");
// β Add Student
const addStudent = () => {
if (!input.trim()) return;
setStudents([...students, input]);
setInput("");
};
// β Delete Student
const deleteStudent = (index) => {
const updated = students.filter((_, i) => i !== index);
setStudents(updated);
};
// βοΈ Edit Student
const editStudent = (index) => {
const newName = prompt("Enter new name");
if (!newName || !newName.trim()) return;
const updated = [...students];
updated[index] = newName;
setStudents(updated);
};
return (
<div style={{ padding: "40px", fontFamily: "Arial" }}>
<h2>Student CRUD</h2>
{/* Input Section */}
<input
value={input}
onChange={(e) => setInput(e.target.value)}
placeholder="Enter student name"
/>
<button onClick={addStudent}>Add</button>
{/* Total Count */}
<p>Total Students: {students.length}</p>
{/* Student List */}
<ul>
{students.map((student, index) => (
<li key={index}>
{student}
<button onClick={() => editStudent(index)}>Edit</button>
<button onClick={() => deleteStudent(index)}>Delete</button>
</li>
))}
</ul>
</div>
);
}
export default App;
*π§ What You Learned*
β Managing list using state
β Adding data using spread operator
β Updating array safely
β Filtering data to delete
β Rendering list with .map()
β Showing dynamic count
*β οΈ Interview Insight*
If interviewer asks:
π Why use [...students] before updating?
Answer: Because React state must not be mutated directly. We create a new copy to trigger re-render.
*Double Tap β₯οΈ For More*
setStudents(updated);
};
return (
<div style={{ padding: "40px", fontFamily: "Arial" }}>
<h2>Student CRUD</h2>
{/* Input Section */}
<input
value={input}
onChange={(e) => setInput(e.target.value)}
placeholder="Enter student name"
/>
<button onClick={addStudent}>Add</button>
{/* Total Count */}
<p>Total Students: {students.length}</p>
{/* Student List */}
<ul>
{students.map((student, index) => (
<li key={index}>
{student}
<button onClick={() => editStudent(index)}>Edit</button>
<button onClick={() => deleteStudent(index)}>Delete</button>
</li>
))}
</ul>
</div>
);
}
export default App;
*π§ What You Learned*
β Managing list using state
β Adding data using spread operator
β Updating array safely
β Filtering data to delete
β Rendering list with .map()
β Showing dynamic count
*β οΈ Interview Insight*
If interviewer asks:
π Why use [...students] before updating?
Answer: Because React state must not be mutated directly. We create a new copy to trigger re-render.
*Double Tap β₯οΈ For More*
β€1
NextJS Tutorial #19 - Page & Layout SEO Metadata | Open Graph, Twitter
https://youtu.be/KmSVE47mHFI
https://youtu.be/KmSVE47mHFI
YouTube
NextJS Tutorial #19 - Page & Layout SEO Metadata | Open Graph, Twitter
This video explains how to implement SEO in Next.js using the Metadata API with the App Router.
You will learn how to add page-level metadata, layout-level metadata, and dynamic metadata for SEO-friendly pages. We also cover how to set up Open Graph andβ¦
You will learn how to add page-level metadata, layout-level metadata, and dynamic metadata for SEO-friendly pages. We also cover how to set up Open Graph andβ¦
β€1
Implement Debounce - Javascript Interview #dsa #interview #coding
https://youtube.com/shorts/x3RMM51Twzg?feature=share
https://youtube.com/shorts/x3RMM51Twzg?feature=share
YouTube
Implement Debounce - Javascript Interview #dsa #interview #coding
Implement Debounce in JavaScript with clear output explanation.In this short video, we solve a common frontend interview question:How to control rapid functi...
β€1
DSA #26 - Core Data Structures | Valid Parentheses Using Stack
https://youtu.be/Jz07KyhZK5E
https://youtu.be/Jz07KyhZK5E
YouTube
DSA #26 - Core Data Structures | Valid Parentheses Using Stack
DSA Phase-3 Core Data Structures tutorial focusing on solving the Valid Parentheses problem using Stack.
In this video you will learn how to understand the problem, apply a stack-based approach, and validate parentheses with a clear step-by-step dry run.β¦
In this video you will learn how to understand the problem, apply a stack-based approach, and validate parentheses with a clear step-by-step dry run.β¦
β€1
Now, let's move to the next topic in Web Development Roadmap:
*βοΈ React Hooks (useEffect & useRef)*
π Now you learn how React handles side effects and DOM access. These hooks are heavily used in real projects and interviews.
*π§ What are React Hooks*
Hooks let you use React features inside functional components.
Before hooks β class components required
After hooks β functional components can do everything
β *Common hooks*
- useState β manage data
- useEffect β handle side effects
- useRef β access DOM or store values
*π Hook 1: useEffect (Side Effects)*
β *What is useEffect*
useEffect runs code when:
β Component loads
β State changes
β Props change
β Component updates
Simple meaning π Perform actions outside UI rendering.
π *Why useEffect is needed*
Used for:
- API calls
- Fetch data from server
- Timer setup
- Event listeners
- Page load logic
*βοΈ Basic Syntax*
import { useEffect } from "react";
useEffect(() => {
// code to run
}, []);
*π Run only once (on page load)*
useEffect(() => {
console.log("Component mounted");
}, []);
π Empty dependency array β runs once.
*π Run when state changes*
useEffect(() => {
console.log("Count changed");
}, [count]);
π Runs whenever count updates.
*β±οΈ Real Example β Timer*
import { useState, useEffect } from "react";
function Timer() {
const [time, setTime] = useState(0);
useEffect(() => {
const interval = setInterval(() => {
setTime(t => t + 1);
}, 1000);
return () => clearInterval(interval);
}, []);
return <h2>{time}</h2>;
}
β Runs timer automatically
β Cleans memory using return
*π― Hook 2: useRef (Access DOM / Store Values)*
β *What is useRef*
useRef gives direct access to DOM elements. Also stores values without re-rendering.
Simple meaning π Reference to element or value.
π *Why useRef is used*
- Focus input automatically
- Access DOM elements
- Store previous value
- Avoid re-render
*βοΈ Basic Syntax*
import { useRef } from "react";
const inputRef = useRef();
*π― Example β Focus input automatically*
import { useRef } from "react";
function InputFocus() {
const inputRef = useRef();
const handleFocus = () => {
inputRef.current.focus();
};
return (
<div>
<input ref={inputRef} />
<button onClick={handleFocus}>Focus</button>
</div>
);
}
β Button click focuses input.
*βοΈ useState, useEffect, and useRef β What's the difference?*
- useState: Stores changing data that triggers re-renders.
- useEffect: Runs side effects (e.g., API calls, timers).
- useRef: Accesses DOM elements or stores values without re-rendering.
*β οΈ Common Beginner Mistakes*
- Forgetting dependency array in useEffect
- Infinite loops in useEffect
- Using useRef instead of state
- Not cleaning side effects
*π§ͺ Mini Practice Task*
- Print message when component loads using useEffect
- Create timer using useEffect
- Focus input automatically using useRef
- Store previous value using useRef
*β Mini Practice Task β Solution βοΈ*
*π¦ 1οΈβ£ Print message when component loads (useEffect)*
import { useEffect } from "react";
function App() {
useEffect(() => {
console.log("Component loaded successfully");
}, []); // runs only once
return <h2>Check console</h2>;
}
export default App;
β Runs once when page loads.
*β±οΈ 2οΈβ£ Create timer using useEffect*
import { useState, useEffect } from "react";
function Timer() {
const [time, setTime] = useState(0);
useEffect(() => {
const interval = setInterval(() => {
setTime((t) => t + 1);
}, 1000);
return () => clearInterval(interval); // cleanup
}, []);
return <h2>Time: {time}</h2>;
}
export default Timer;
β Increases every second
β Clears interval to prevent memory leak
*π― 3οΈβ£ Focus input automatically using useRef*
import { useRef } from "react";
function FocusInput() {
const inputRef = useRef();
const handleFocus = () => {
inputRef.current.focus();
};
return (
<div>
<input ref={inputRef} placeholder="Enter text" />
<button onClick={handleFocus}>Focus Input</button>
</div>
);
}
export default FocusInput;
*βοΈ React Hooks (useEffect & useRef)*
π Now you learn how React handles side effects and DOM access. These hooks are heavily used in real projects and interviews.
*π§ What are React Hooks*
Hooks let you use React features inside functional components.
Before hooks β class components required
After hooks β functional components can do everything
β *Common hooks*
- useState β manage data
- useEffect β handle side effects
- useRef β access DOM or store values
*π Hook 1: useEffect (Side Effects)*
β *What is useEffect*
useEffect runs code when:
β Component loads
β State changes
β Props change
β Component updates
Simple meaning π Perform actions outside UI rendering.
π *Why useEffect is needed*
Used for:
- API calls
- Fetch data from server
- Timer setup
- Event listeners
- Page load logic
*βοΈ Basic Syntax*
import { useEffect } from "react";
useEffect(() => {
// code to run
}, []);
*π Run only once (on page load)*
useEffect(() => {
console.log("Component mounted");
}, []);
π Empty dependency array β runs once.
*π Run when state changes*
useEffect(() => {
console.log("Count changed");
}, [count]);
π Runs whenever count updates.
*β±οΈ Real Example β Timer*
import { useState, useEffect } from "react";
function Timer() {
const [time, setTime] = useState(0);
useEffect(() => {
const interval = setInterval(() => {
setTime(t => t + 1);
}, 1000);
return () => clearInterval(interval);
}, []);
return <h2>{time}</h2>;
}
β Runs timer automatically
β Cleans memory using return
*π― Hook 2: useRef (Access DOM / Store Values)*
β *What is useRef*
useRef gives direct access to DOM elements. Also stores values without re-rendering.
Simple meaning π Reference to element or value.
π *Why useRef is used*
- Focus input automatically
- Access DOM elements
- Store previous value
- Avoid re-render
*βοΈ Basic Syntax*
import { useRef } from "react";
const inputRef = useRef();
*π― Example β Focus input automatically*
import { useRef } from "react";
function InputFocus() {
const inputRef = useRef();
const handleFocus = () => {
inputRef.current.focus();
};
return (
<div>
<input ref={inputRef} />
<button onClick={handleFocus}>Focus</button>
</div>
);
}
β Button click focuses input.
*βοΈ useState, useEffect, and useRef β What's the difference?*
- useState: Stores changing data that triggers re-renders.
- useEffect: Runs side effects (e.g., API calls, timers).
- useRef: Accesses DOM elements or stores values without re-rendering.
*β οΈ Common Beginner Mistakes*
- Forgetting dependency array in useEffect
- Infinite loops in useEffect
- Using useRef instead of state
- Not cleaning side effects
*π§ͺ Mini Practice Task*
- Print message when component loads using useEffect
- Create timer using useEffect
- Focus input automatically using useRef
- Store previous value using useRef
*β Mini Practice Task β Solution βοΈ*
*π¦ 1οΈβ£ Print message when component loads (useEffect)*
import { useEffect } from "react";
function App() {
useEffect(() => {
console.log("Component loaded successfully");
}, []); // runs only once
return <h2>Check console</h2>;
}
export default App;
β Runs once when page loads.
*β±οΈ 2οΈβ£ Create timer using useEffect*
import { useState, useEffect } from "react";
function Timer() {
const [time, setTime] = useState(0);
useEffect(() => {
const interval = setInterval(() => {
setTime((t) => t + 1);
}, 1000);
return () => clearInterval(interval); // cleanup
}, []);
return <h2>Time: {time}</h2>;
}
export default Timer;
β Increases every second
β Clears interval to prevent memory leak
*π― 3οΈβ£ Focus input automatically using useRef*
import { useRef } from "react";
function FocusInput() {
const inputRef = useRef();
const handleFocus = () => {
inputRef.current.focus();
};
return (
<div>
<input ref={inputRef} placeholder="Enter text" />
<button onClick={handleFocus}>Focus Input</button>
</div>
);
}
export default FocusInput;
β
Click button β input gets focus.
*π 4οΈβ£ Store previous value using useRef*
import { useState, useEffect, useRef } from "react";
function PreviousValue() {
const [count, setCount] = useState(0);
const prevCount = useRef();
useEffect(() => {
prevCount.current = count;
});
return (
<div>
<h2>Current: {count}</h2>
<h2>Previous: {prevCount.current}</h2>
<button onClick={() => setCount(count + 1)}> Increase </button>
</div>
);
}
export default PreviousValue;
β Stores previous state without re-rendering.
*π§ What You Learned*
β Run code on component load
β Handle side effects safely
β Access DOM using useRef
β Store values without re-render
β Clean up side effects
β‘οΈ *Double Tap β₯οΈ For More*
*π 4οΈβ£ Store previous value using useRef*
import { useState, useEffect, useRef } from "react";
function PreviousValue() {
const [count, setCount] = useState(0);
const prevCount = useRef();
useEffect(() => {
prevCount.current = count;
});
return (
<div>
<h2>Current: {count}</h2>
<h2>Previous: {prevCount.current}</h2>
<button onClick={() => setCount(count + 1)}> Increase </button>
</div>
);
}
export default PreviousValue;
β Stores previous state without re-rendering.
*π§ What You Learned*
β Run code on component load
β Handle side effects safely
β Access DOM using useRef
β Store values without re-render
β Clean up side effects
β‘οΈ *Double Tap β₯οΈ For More*
β€1
DSA #27 - Core Data Structures | Next Greater Element using Stack - Brute Force vs Optimized
https://youtu.be/K9yheNOvRus
https://youtu.be/K9yheNOvRus
YouTube
DSA #27 - Core Data Structures | Next Greater Element using Stack - Brute Force vs Optimized
DSA Phase-3 Core Data Structures tutorial focusing on the Next Greater Element problem using Stack.
In this video you will learn what Next Greater Element is, compare brute force vs optimized approaches, and understand the Monotonic Stack concept.
We willβ¦
In this video you will learn what Next Greater Element is, compare brute force vs optimized approaches, and understand the Monotonic Stack concept.
We willβ¦
β€1
This media is not supported in your browser
VIEW IN TELEGRAM
Happy Holi Everyone π
DSA #28 - Core Data Structures | Queue Data Structure Explained | FIFO
https://youtu.be/2_rC5_TV3wg
https://youtu.be/2_rC5_TV3wg
YouTube
DSA #28 - Core Data Structures | Queue Data Structure Explained | FIFO
DSA Phase-3 Core Data Structures tutorial focusing on the Queue data structure.
In this video you will learn what a Queue is, how the FIFO (First In First Out) principle works, and how to implement queue operations in JavaScript.
We will cover enqueue, dequeueβ¦
In this video you will learn what a Queue is, how the FIFO (First In First Out) principle works, and how to implement queue operations in JavaScript.
We will cover enqueue, dequeueβ¦
π1
Now, let's move to the next topic in Web Development Roadmap:
π *Backend Basics β Node.js & Express*
Now you move from frontend (React) β backend (server side).
Frontend = UI, Backend = Logic + Database + APIs.
π’ *What is Node.js* β
- Node.js is a JavaScript runtime that runs outside the browser.
- Built on Chrome V8 engine, allows JavaScript to run on server.
π§ *Why Node.js is Popular*
- Same language (JS) for frontend + backend
- Fast and lightweight
- Large ecosystem (npm)
- Used in real companies
β‘ *How Node.js Works*
- Single-threaded, event-driven, non-blocking I/O
- Handles many requests efficiently, good for APIs, real-time apps, chat apps
*π¦ What is npm*
- npm = Node Package Manager
- Used to install libraries, manage dependencies, run scripts
Example:
π *What is Express.js* β
- Express is a minimal web framework for Node.js.
- Makes backend development easy, clean routing, easy API creation, middleware support
*π§© Basic Express Server Example*
- Install Express:
const express = require("express");
const app = express();
app.get("/", (req, res) => {
res.send("Hello Backend");
});
app.listen(3000, () => {
console.log("Server running on port 3000");
});
- Creates server, handles GET request, sends response, listens on port 3000
*π What is an API*
- API = Application Programming Interface
- Frontend talks to backend using APIs, usually in JSON format
*π§ Common HTTP Methods (Backend)*
- GET: Fetch data
- POST: Send data
- PUT: Update data
- DELETE: Remove data
*β οΈ Common Beginner Mistakes*
- Forgetting to install express
- Not using correct port
- Not sending response
- Confusing frontend and backend
*π§ͺ Mini Practice Task*
- Create basic Express server
- Create route /about
- Create route /api/user returning JSON
- Start server and test in browser
β *Mini Practice Task β Solution* π
*π’ Step 1οΈβ£ Install Express*
Open terminal inside project folder:
npm init -y
npm install express
β Creates package.json
β Installs Express framework
π *Step 2οΈβ£ Create server.js*
Create a file named server.js and add:
const express = require("express");
const app = express();
// Home route
app.get("/", (req, res) => {
res.send("Welcome to my server");
});
// About route
app.get("/about", (req, res) => {
res.send("This is About Page");
});
// API route returning JSON
app.get("/api/user", (req, res) => {
res.json({ name: "Deepak", role: "Developer", age: 25 });
});
// Start server
app.listen(3000, () => {
console.log("Server running on http://localhost:3000");
});
*βΆοΈ Step 3οΈβ£ Start the Server*
Run in terminal:
node server.js
You should see: Server running on http://localhost:3000
*π Step 4οΈβ£ Test in Browser*
Open these URLs:
- http://localhost:3000/ β Welcome message
- http://localhost:3000/about β About page text
- http://localhost:3000/api/user β JSON response
*Double Tap β₯οΈ For More*
π *Backend Basics β Node.js & Express*
Now you move from frontend (React) β backend (server side).
Frontend = UI, Backend = Logic + Database + APIs.
π’ *What is Node.js* β
- Node.js is a JavaScript runtime that runs outside the browser.
- Built on Chrome V8 engine, allows JavaScript to run on server.
π§ *Why Node.js is Popular*
- Same language (JS) for frontend + backend
- Fast and lightweight
- Large ecosystem (npm)
- Used in real companies
β‘ *How Node.js Works*
- Single-threaded, event-driven, non-blocking I/O
- Handles many requests efficiently, good for APIs, real-time apps, chat apps
*π¦ What is npm*
- npm = Node Package Manager
- Used to install libraries, manage dependencies, run scripts
Example:
npm install express
π *What is Express.js* β
- Express is a minimal web framework for Node.js.
- Makes backend development easy, clean routing, easy API creation, middleware support
*π§© Basic Express Server Example*
- Install Express:
npm init -y, npm install express
- Create server.js:const express = require("express");
const app = express();
app.get("/", (req, res) => {
res.send("Hello Backend");
});
app.listen(3000, () => {
console.log("Server running on port 3000");
});
- Creates server, handles GET request, sends response, listens on port 3000
*π What is an API*
- API = Application Programming Interface
- Frontend talks to backend using APIs, usually in JSON format
*π§ Common HTTP Methods (Backend)*
- GET: Fetch data
- POST: Send data
- PUT: Update data
- DELETE: Remove data
*β οΈ Common Beginner Mistakes*
- Forgetting to install express
- Not using correct port
- Not sending response
- Confusing frontend and backend
*π§ͺ Mini Practice Task*
- Create basic Express server
- Create route /about
- Create route /api/user returning JSON
- Start server and test in browser
β *Mini Practice Task β Solution* π
*π’ Step 1οΈβ£ Install Express*
Open terminal inside project folder:
npm init -y
npm install express
β Creates package.json
β Installs Express framework
π *Step 2οΈβ£ Create server.js*
Create a file named server.js and add:
const express = require("express");
const app = express();
// Home route
app.get("/", (req, res) => {
res.send("Welcome to my server");
});
// About route
app.get("/about", (req, res) => {
res.send("This is About Page");
});
// API route returning JSON
app.get("/api/user", (req, res) => {
res.json({ name: "Deepak", role: "Developer", age: 25 });
});
// Start server
app.listen(3000, () => {
console.log("Server running on http://localhost:3000");
});
*βΆοΈ Step 3οΈβ£ Start the Server*
Run in terminal:
node server.js
You should see: Server running on http://localhost:3000
*π Step 4οΈβ£ Test in Browser*
Open these URLs:
- http://localhost:3000/ β Welcome message
- http://localhost:3000/about β About page text
- http://localhost:3000/api/user β JSON response
*Double Tap β₯οΈ For More*
β€2
NextJS Tutorial #24 - PATCH Method | Backend and Frontend
https://youtu.be/Fn5oHMadoAY
https://youtu.be/Fn5oHMadoAY
YouTube
NextJS Tutorial #24 - PATCH Method | Backend and Frontend
In this video, we learn how to create a PATCH API in Next.js using the App Router to update existing data.
You will understand what a PATCH API is, how the PATCH method works, and how it differs from POST and PUT. We create an API route to update data andβ¦
You will understand what a PATCH API is, how the PATCH method works, and how it differs from POST and PUT. We create an API route to update data andβ¦
β€1
Angular 21 Full Course in Hindi 2026 | 12 Hour Beginner to Advanced + 4 Projects
https://youtu.be/S2yJRqtnM7Y
https://youtu.be/S2yJRqtnM7Y
β€1
Debounce Explained | Search API Optimization | JS Interview #dsa #interview #coding
https://youtube.com/shorts/joyOWGn25f4?feature=share
https://youtube.com/shorts/joyOWGn25f4?feature=share
YouTube
Debounce Explained | Search API Optimization | JS Interview #dsa #interview #coding
Debounce in JavaScript explained with a real browser search input example.In this short video, you will learn how debounce prevents multiple API calls while ...
β€1
*10 Essential Javascript Concepts You Should Know*:
*1οΈβ£ Variables (`let`,
- *`let`*: Block-scoped, used for values that can change.
- *`const`*: Block-scoped, used for values that shouldnβt change.
- *`var`*: Function-scoped (older, avoid in modern JS).
*Real-life analogy*: A
*2οΈβ£ Data Types*
- *Number*: 10, 3.14
- *String*: "Hello"
- *Boolean*: true, false
- *Null*: intentionally empty
- *Undefined*: declared but no value yet
- *Object*:
- *Array*:
*3οΈβ£ Functions*
Functions group code that you can reuse. They accept inputs (parameters) and return outputs.
*4οΈβ£ Conditionals*
Used to make decisions based on logic.
Also includes
*5οΈβ£ Loops*
Used for repeating tasks (e.g., processing every item in a list).
β`js
for (let i = 0; i < 3; i++)
console.log(i); // 0,1,2
β`
*6οΈβ£ Arrays Methods*
Arrays hold multiple values. Common methods:
-
-
-
*7οΈβ£ Objects*
Objects group data in key-value form.
*8οΈβ£ Events*
Used to interact with users (click, input, etc.).
*9οΈβ£ DOM Manipulation*
DOM = HTML elements. JS can read or update them.
*π ES6 Features*
Modern additions to JS:
- *Arrow functions*: Cleaner syntax
- *Destructuring*: Extract values easily
- *Template literals*:
- *Spread/Rest*: Copy or merge arrays/objects
*React β€οΈ if this helped you!*
*1οΈβ£ Variables (`let`,
const, `var`)*- *`let`*: Block-scoped, used for values that can change.
- *`const`*: Block-scoped, used for values that shouldnβt change.
- *`var`*: Function-scoped (older, avoid in modern JS).
let name = "John";
const age = 25;
var city = "Delhi";
*Real-life analogy*: A
const is like your birthdate β it never changes. A let is your location β it may change.*2οΈβ£ Data Types*
- *Number*: 10, 3.14
- *String*: "Hello"
- *Boolean*: true, false
- *Null*: intentionally empty
- *Undefined*: declared but no value yet
- *Object*:
{ key: value } - *Array*:
[item1, item2]
let items = ["pen", "book"];
let user = null;
*3οΈβ£ Functions*
Functions group code that you can reuse. They accept inputs (parameters) and return outputs.
function greet(name) {
return `Hello ${name}`;
}
greet("Amit"); // "Hello Amit"
*4οΈβ£ Conditionals*
Used to make decisions based on logic.
let marks = 80;
if (marks >= 50) {
console.log("Pass");
} else {
console.log("Fail");
}
Also includes
switch for multiple conditions.*5οΈβ£ Loops*
Used for repeating tasks (e.g., processing every item in a list).
β`js
for (let i = 0; i < 3; i++)
console.log(i); // 0,1,2
β`
*6οΈβ£ Arrays Methods*
Arrays hold multiple values. Common methods:
-
push(), pop(): Add/remove-
length: Size-
forEach(), map(), filter(): Iterate/transformlet fruits = ["apple", "banana"];
fruits.push("mango");
*7οΈβ£ Objects*
Objects group data in key-value form.
let car =
brand: "Toyota",
year: 2020
;
console.log(car.brand); // Toyota
*8οΈβ£ Events*
Used to interact with users (click, input, etc.).
document.getElementById("btn").addEventListener("click", () =>
alert("Button clicked!");
);
*9οΈβ£ DOM Manipulation*
DOM = HTML elements. JS can read or update them.
document.getElementById("title").innerText = "Updated Text";
*π ES6 Features*
Modern additions to JS:
- *Arrow functions*: Cleaner syntax
- *Destructuring*: Extract values easily
- *Template literals*:
{} inside strings- *Spread/Rest*: Copy or merge arrays/objects
const add = (a, b) => a + b;
const { brand } = car;
*React β€οΈ if this helped you!*
β€1
DSA #29 - Core Data Structures | Circular Queue Explained | Front & Rear
https://youtu.be/P-7k-5bM7d0
https://youtu.be/P-7k-5bM7d0
YouTube
DSA #29 - Core Data Structures | Circular Queue Explained | Front & Rear
DSA Phase-3 Core Data Structures tutorial focusing on the Circular Queue.
In this video you will learn what a Circular Queue is, why it is needed, and what problems occur with a normal queue implementation.
We will understand front and rear pointer logicβ¦
In this video you will learn what a Circular Queue is, why it is needed, and what problems occur with a normal queue implementation.
We will understand front and rear pointer logicβ¦
β€1
Check Empty Object - Javascript Interview #dsa #interview #coding
https://youtube.com/shorts/O3EGfDC-6Yc?feature=share
https://youtube.com/shorts/O3EGfDC-6Yc?feature=share
YouTube
Check Empty Object - Javascript Interview #dsa #interview #coding
Check if an object is empty in JavaScript using a simple interview-ready approach.In this short video, you will learn how to use Object.keys() to detect whet...
β€1
Now, let's move to the next topic in Web Development Roadmap:
π *REST APIs & Routing in Express*
Now you move from basic server β real backend API structure.
If you understand this topic properly, you can build production-level APIs.
π§ *What is a REST API?*
REST = Representational State Transfer
Simple meaning:
π Backend exposes URLs
π Frontend sends HTTP requests
π Backend returns data (usually JSON)
π₯ *REST API Structure*
REST follows resources-based URLs.
Example resource: users
Instead of:
REST style:
π *HTTP Methods in REST*
GET -> Read data
POST -> Create data
PUT -> Update data
DELETE -> Remove data
These map directly to CRUD.
π§© *Basic REST API Example*
Step 1: Setup Express
const express = require("express");
const app = express();
app.use(express.json()); // middleware for JSON
let users = [
{ id: 1, name: "Amit" },
{ id: 2, name: "Rahul" }
];
π 1οΈβ£ GET β Fetch all users
app.get("/users", (req, res) => {
res.json(users);
});
β 2οΈβ£ POST β Add new user
app.post("/users", (req, res) => {
const newUser = {
id: users.length + 1,
name: req.body.name
};
users.push(newUser);
res.json(newUser);
});
βοΈ 3οΈβ£ PUT β Update user
app.put("/users/:id", (req, res) => {
const id = parseInt(req.params.id);
const user = users.find(u => u.id === id);
if (!user) {
return res.status(404).json({ message: "User not found" });
}
user.name = req.body.name;
res.json(user);
});
β 4οΈβ£ DELETE β Remove user
app.delete("/users/:id", (req, res) => {
const id = parseInt(req.params.id);
users = users.filter(u => u.id !== id);
res.json({ message: "User deleted" });
});
βΆοΈ *Start Server*
app.listen(3000, () => {
console.log("Server running on port 3000");
});
π§ *What is Routing?*
Routing means:
π Matching URL
π Matching HTTP method
π Running correct function
*Example:*
GET /users β fetch users
POST /users β create user
π *Better Folder Structure (Real Projects)*
project/
βββ routes/
β βββ userRoutes.js
βββ controllers/
βββ server.js
Separation of concerns = scalable backend.
β οΈ *Common Beginner Mistakes*
β’ Not using express.json()
β’ Not parsing req.params correctly
β’ Not sending status codes
β’ Not handling missing data
π§ͺ *Mini Practice Task*
β’ Create REST API for products
β’ GET /products
β’ POST /products
β’ PUT /products/:id
β’ DELETE /products/:id
β‘οΈ *Double Tap β₯οΈ For More*
π *REST APIs & Routing in Express*
Now you move from basic server β real backend API structure.
If you understand this topic properly, you can build production-level APIs.
π§ *What is a REST API?*
REST = Representational State Transfer
Simple meaning:
π Backend exposes URLs
π Frontend sends HTTP requests
π Backend returns data (usually JSON)
π₯ *REST API Structure*
REST follows resources-based URLs.
Example resource: users
Instead of:
/addUser
/deleteUser
REST style:
POST /users
PUT /users/:id
DELETE /users/:id
π *HTTP Methods in REST*
GET -> Read data
POST -> Create data
PUT -> Update data
DELETE -> Remove data
These map directly to CRUD.
π§© *Basic REST API Example*
Step 1: Setup Express
const express = require("express");
const app = express();
app.use(express.json()); // middleware for JSON
let users = [
{ id: 1, name: "Amit" },
{ id: 2, name: "Rahul" }
];
π 1οΈβ£ GET β Fetch all users
app.get("/users", (req, res) => {
res.json(users);
});
β 2οΈβ£ POST β Add new user
app.post("/users", (req, res) => {
const newUser = {
id: users.length + 1,
name: req.body.name
};
users.push(newUser);
res.json(newUser);
});
βοΈ 3οΈβ£ PUT β Update user
app.put("/users/:id", (req, res) => {
const id = parseInt(req.params.id);
const user = users.find(u => u.id === id);
if (!user) {
return res.status(404).json({ message: "User not found" });
}
user.name = req.body.name;
res.json(user);
});
β 4οΈβ£ DELETE β Remove user
app.delete("/users/:id", (req, res) => {
const id = parseInt(req.params.id);
users = users.filter(u => u.id !== id);
res.json({ message: "User deleted" });
});
βΆοΈ *Start Server*
app.listen(3000, () => {
console.log("Server running on port 3000");
});
π§ *What is Routing?*
Routing means:
π Matching URL
π Matching HTTP method
π Running correct function
*Example:*
GET /users β fetch users
POST /users β create user
π *Better Folder Structure (Real Projects)*
project/
βββ routes/
β βββ userRoutes.js
βββ controllers/
βββ server.js
Separation of concerns = scalable backend.
β οΈ *Common Beginner Mistakes*
β’ Not using express.json()
β’ Not parsing req.params correctly
β’ Not sending status codes
β’ Not handling missing data
π§ͺ *Mini Practice Task*
β’ Create REST API for products
β’ GET /products
β’ POST /products
β’ PUT /products/:id
β’ DELETE /products/:id
β‘οΈ *Double Tap β₯οΈ For More*
β€1
NextJS Tutorial #25 - PUT Method | Backend and Frontend
https://youtu.be/gkrgnPPVsJM
https://youtu.be/gkrgnPPVsJM
YouTube
NextJS Tutorial #25 - PUT Method | Backend and Frontend
In this video, we learn how to create a PUT API in Next.js using the App Router to perform full data updates.
You will understand what a PUT API is, how it works, and how it differs from POST and PATCH. We explore the API folder structure, create a PUT methodβ¦
You will understand what a PUT API is, how it works, and how it differs from POST and PATCH. We explore the API folder structure, create a PUT methodβ¦
β€1