Interview Notes
Interview Notes
1) JavaScript Fundamentals
JavaScript single-threaded hoti hai, yani ek waqt mein ek hi kaam main thread par
execute karti hai.
JavaScript ke paas event loop, callback queue, aur browser/Node ke provided APIs hotay
hain jo async operations handle karte hain.
Example:
Interview line:
“JavaScript single-threaded hai, lekin event loop aur async APIs ki help se non-blocking
behavior achieve karti hai.”
1.3 Variables: var, let, const
var
let
• Block-scoped
• Hoist hota hai but Temporal Dead Zone (TDZ) mein hota hai
const
• Block-scoped
• Agar object/array const ho to uske andar ki values change ho sakti hain, lekin
variable reference reassign nahi hota
Example:
• const ko mostly use karte hain jab value/reference reassign nahi karni
Types of scope:
1) Global scope
2) Function scope
Jo variable function ke andar var se declare ho, wo function ke andar hi accessible hota hai.
3) Block scope
Jo variable {} block ke andar let ya const se declare ho, wo sirf us block ke andar accessible
hota hai.
Example:
function test() {
var a = 10;
let b = 20;
const c = 30;
if (true) {
let x = 5;
const y = 6;
}
Yahan x aur y block ke bahar access nahi hongay.
Hoisting ka matlab yeh nahi ke variable physically upar move ho jata hai. Iska matlab yeh
hai ke execution se pehle memory phase mein declarations register ho jati hain.
var hoisting:
[Link](a); // undefined
var a = 10;
var a hoist hota hai aur initial value undefined milti hai.
let/const hoisting:
let aur const bhi hoist hotay hain, lekin Temporal Dead Zone ki wajah se initialization se
pehle access nahi kar sakte.
[Link](x); // ReferenceError
let x = 5;
TDZ woh phase hota hai jab variable memory mein to hota hai, lekin initialize nahi hua hota,
aur us duration mein usay access karne par error aati hai.
Example:
[Link](a); // ReferenceError
let a = 10;
1. String
2. Number
3. Boolean
4. Undefined
5. Null
6. BigInt
7. Symbol
• Object
• Array
• Function
undefined
let a;
[Link](a); // undefined
null
NaN
Number("abc"); // NaN
Primitive
Reference
Example:
let a = 5;
let b = a;
b = 10;
// a still 5
[Link] = "Ahmed";
Interview concept:
Primitives copy by value, objects/arrays copy by reference behavior show karte hain.
1.9 Operators
• Arithmetic: + - * / %
• Assignment: =, +=, -=
== vs ===
==
Sirf values compare karta hai aur type coercion kar sakta hai.
===
5 == "5" // true
Interview line:
“Best practice hai ke mostly strict equality === use ki jaye takay unexpected type coercion
avoid ho.”
JavaScript kabhi kabhi automatically ek type ko doosri type mein convert kar deti hai.
"5" + 1 // "51"
"5" - 1 // 4
Interview point:
JavaScript dynamically typed hai, is liye implicit coercion hoti hai. Isi wajah se strict
comparison aur clean validation important hoti hai.
Function reusable block of code hota hai jo specific task perform karta hai.
Function declaration
function greet(name) {
Function expression
};
Arrow function
};
Function declaration
sayHi();
function sayHi() {
[Link]("Hi");
Function expression
sayHi(); // error
[Link]("Hi");
};
Arrow function:
• Chhoti syntax
Normal function:
“Arrow functions lexical this use karti hain, is liye React aur callbacks mein kaafi
convenient hoti hain.”
1.14 Arrays
• sort() → sorting
Example:
map vs forEach
• map() new array return karta hai
• forEach() sirf iterate karta hai, new array return nahi karta useful way mein
1.15 Objects
const user = {
name: "Sehrish",
age: 22
};
Access:
[Link]
user["age"]
Add/update:
[Link] = "Islamabad";
1.16 Destructuring
Interview point:
Destructuring React props/state aur backend responses handle karne mein bohat use hoti
hai.
1.17 Spread operator ...
function sum(...nums) {
Backticks `
[Link](`Hello ${name}`);
Falsy values:
• false
• 0
• ""
• null
• undefined
• NaN
1.21 Closures
Closure tab hota hai jab inner function outer function ke variables ko yaad rakhta hai even
after outer function execute ho chuka ho.
function outer() {
let count = 0;
count++;
return count;
};
Interview line:
“Closure ka matlab hai function apne lexical scope ko yaad rakhta hai.”
1.22 Callbacks
Callback ek function hota hai jo kisi dusre function ko argument ke طورpar pass kiya jata
hai aur baad mein execute hota hai.
cb();
Examples:
• API requests
• File reading
• Database calls
• Timers
1.24 setTimeout
[Link]("A");
setTimeout(() => {
[Link]("B");
}, 0);
[Link]("C");
Output:
A
C
B
Kyunkay setTimeout callback queue mein jata hai, aur synchronous code pehle execute
hota hai.
1.25 Promises
States:
• pending
• fulfilled
• rejected
Example:
resolve("done");
});
Use:
1.26 async/await
try {
[Link](data);
} catch (error) {
[Link](error);
Interview line:
1.27 try/catch
// risky code
} catch (error) {
[Link]([Link]);
• elements select
• text change
• styles change
[Link]("click", () => {
[Link]("clicked");
});
Jab event child element par hota hai aur parent tak bubble karta hai.
Example:
Interview concept:
localStorage
sessionStorage
Note:
• let / const
• arrow functions
• template literals
• destructuring
• spread/rest
• promises
• modules (import/export)
• default parameters
Q: == aur ===?
== type coercion karta hai, === strict comparison karta hai.
map new array return karta hai, forEach mainly iteration ke liye hota hai.
Agar interviewer pooche “What is closure?” to seedha definition + tiny example do.
Example answer:
“Closure JavaScript ka concept hai jahan inner function apne outer function ke variables ko
access aur remember karta hai, even after outer function execution complete ho jaye. Yeh
data privacy, counters aur factory functions mein useful hota hai.”
2) React Fundamentals
React ek JavaScript library hai jo user interfaces build karne ke liye use hoti hai,
especially single-page applications mein.
• Reusable components
• Better UI structure
• State-driven UI
React app chhote chhote reusable pieces mein break hoti hai jinhein components kehte
hain.
Example:
• Navbar
• Button
• Card
• Product list
• Form
Component types:
Functional components
function Welcome() {
return <h1>Hello</h1>;
JSX ek syntax hai jo HTML jaisa lagta hai, lekin actually JavaScript ke andar likha jata hai.
const element = <h1>Hello</h1>;
Browser directly JSX nahi samajhta; Babel usay JavaScript mein convert karta hai.
Interview line:
“JSX JavaScript XML-like syntax hai jo React components ka UI readable tareeqay se define
karne mein help karti hai.”
Props parent component se child component ko data pass karne ka tareeqa hoti hain.
function UserCard(props) {
return <h1>{[Link]}</h1>;
Ya destructuring ke sath:
return <h1>{name}</h1>;
Important:
Props read-only hoti hain. Child component directly props modify nahi karta.
State component ke andar ka data hota hai jo time ke sath change ho sakta hai aur UI ko
update kar sakta hai.
Example:
• Counter value
• Form input
• Loading state
• API data
2.7 useState hook
function Counter() {
return (
{count}
</button>
);
Samajh:
Interview point:
State ko directly mutate nahi karna, setter function use karna hota hai.
Props
State
<button onClick={handleClick}>Click</button>
Note:
Ya:
{[Link](user => (
<li key={[Link]}>{[Link]}</li>
))}
React ko identify karne mein help milti hai ke kaunsa item change hua, add hua ya remove
hua.
Interview line:
“Key React ko efficient reconciliation aur rendering mein help karti hai.”
2.12 useEffect kya hota hai?
• API call
• event listener
• timer
useEffect(() => {
fetchData();
}, []);
[]
[value]
no dependency array
Class components mein lifecycle methods hoti thin, lekin functional components mein
hum useEffect se mount/update/unmount logic handle kar sakte hain.
Example:
useEffect(() => {
[Link]("mounted");
return () => {
[Link]("cleanup / unmount");
};
}, []);
<input
value={name}
/>
Kyun important?
Jab do sibling components ko same data chahiye ho, to state unke common parent mein
rakh dete hain.
Interview line:
“State ko nearest common parent tak lift kiya jata hai takay multiple components
synchronized data use kar saken.”
• state change ho
• parent re-render ho
React actual DOM ko directly har choti change par update nahi karta. Wo ek virtual DOM
representation banata hai, changes compare karta hai, phir efficiently actual DOM update
karta hai.
Interview line:
“Virtual DOM React ko efficient updates mein help karta hai by minimizing direct DOM
manipulation.”
React mein data generally parent se child jata hai via props. Is se application predictable
hoti hai.
Basic example:
[Link]();
[Link](email);
};
Important:
useEffect(() => {
setUsers(data);
};
fetchUsers();
}, []);
• loading
• error
• data
React Router SPA mein pages/navigation handle karta hai without full page reload.
Concepts:
• Routes
• Route path
• Link
• dynamic params
Example conceptually:
• /login
• /dashboard
• /products/:id
useRef DOM element reference ya mutable value store karne ke liye use hota hai without
causing re-render.
Example uses:
• input focus
• timers
useMemo
useCallback
Interview line:
React performance optimize karne ke liye updates batch kar sakta hai. Is liye turant
updated value console mein na mile.
Props parent se aati hain aur read-only hoti hain; state component ka internal mutable
data hota hai.
Sample answer:
“Maine React ko reusable components banane, forms handle karne, API data fetch karne
aur state manage karne ke liye use kiya. Apne project mein maine pages ko components
mein break kiya, useState aur useEffect use kiye, forms ko controlled inputs se manage
kiya, aur backend APIs se data fetch karke UI render ki.”
Backend application ka wo hissa hota hai jo server side par run karta hai aur handle karta
hai:
• business logic
• database operations
• authentication
• APIs
• data validation
• server responses
“Backend user se aane wali requests ko process karta hai, business logic apply karta hai,
database ke sath interact karta hai aur appropriate response return karta hai.”
Interview line:
“[Link] Chrome V8 engine par based JavaScript runtime hai jo event-driven, non-blocking
I/O model ki wajah se scalable backend applications banane mein help karta hai.”
• Fast development
• Non-blocking I/O
Express [Link] ka lightweight web framework hai jo server banana, routes define karna,
middleware use karna aur APIs develop karna easy banata hai.
Interview line:
“[Link] [Link] ke upar ek minimal framework hai jo routing, middleware aur request-
response handling ko simple banata hai.”
Server ek system/application hota hai jo client ki requests ko receive karta hai aur response
bhejta hai.
Client examples:
• Browser
• mobile app
Request
Response
Example:
Frontend /api/users hit kare → server users ka data response mein bhej de.
GET
POST
PUT / PATCH
DELETE
Interview point:
REST API ek structured way hai jisme frontend aur backend HTTP requests ke through
communicate karte hain.
Example endpoints:
• GET /users
• GET /users/:id
• POST /users
• PUT /users/:id
• DELETE /users/:id
Interview line:
“RESTful API resources ko endpoints ke through expose karti hai aur standard HTTP
methods use karti hai.”
[Link]("Server is running");
});
[Link](5000, () => {
});
Samajh:
Middleware wo function hota hai jo request aur response ke beech execute hota hai.
Common uses:
• authentication check
• logging
• error handling
Example:
[Link]([Link]());
Request body mein agar JSON data aa raha ho to usay parse karke [Link] mein available
karta hai.
3.12 Routing
Routes define karte hain ke kis URL aur method par kya logic chalega.
[Link]("/users", getUsers);
[Link]("/users", createUser);
Better structure:
Model
View
Traditional apps mein UI layer hoti hai; MERN API backend mein kabhi kabhi direct use nahi
hoti as frontend separate hota hai
Controller
Request handle karta hai, logic chalata hai, response bhejta hai
Interview line:
“MVC se code modular aur maintainable hota hai kyun ke concerns separate ho jate hain.”
Controllers route hit hone par actual business logic handle karte hain.
Example:
[Link](users);
};
Tum MERN background ke hisaab se MongoDB mention kar sakti ho, aur agar SQL poocha
jaye to MySQL/PostgreSQL ka basic idea bata sakti ho.
MongoDB ek NoSQL document database hai jahan data JSON-like documents ki form mein
store hota hai.
Terms:
• database
• collection
• document
Example document:
{
"name": "Sehrish",
"email": "abc@[Link]"
Mongoose MongoDB ke sath kaam karne ke liye ODM (Object Data Modeling) library hai
[Link] mein.
• validation
Example:
name: String,
email: String
});
Example mapping:
[Link]
Route params
GET /users/:id
[Link]
[Link]
/users?page=1
[Link]
[Link]
POST /users
[Link]
200
OK
201
Created
400
Bad Request
401
Unauthorized
403
Forbidden
404
Not Found
500
Interview line:
“Proper HTTP status codes dena important hota hai takay frontend ko clear response state
mil sake.”
Agar server/db/API mein issue ho to proper try/catch aur status code ke sath error response
dena chahiye.
try {
[Link](200).json(users);
} catch (error) {
Database calls aur APIs async hoti hain, is liye async/await commonly use hota hai.
try {
[Link](users);
} catch (err) {
});
Authentication
Authorization
Interview line:
“Authentication identity verify karti hai, jab ke authorization permissions determine karti
hai.”
Flow:
Interview point:
“Security ke liye passwords ko hash karke store karna best practice hai.”
Example:
• profile
• dashboard data
• admin actions
Example:
• PORT
• DB URL
• JWT secret
Kyun?
Use cases:
• response dekhna
Interview line:
“Maine backend APIs ko Postman se test kiya, including CRUD endpoints aur auth routes.”
• validation errors
• auth behavior
• edge cases
• wrong/missing fields
• invalid IDs
Example:
• email required hai?
Interview point:
Validation frontend aur backend dono par honi chahiye, lekin backend validation zaroori
hai kyun ke frontend bypass ho sakta hai.
Agar bohat zyada records hon to sab ek sath bhejne ke bajaye chunks mein bhejte hain.
Example:
/users?page=1&limit=10
• category
• status
• date
• keyword
• [Link] / [Link]
• routes/
• controllers/
• models/
• middlewares/
• config/
• utils/
Benefit:
[Link] I/O tasks ko efficient tareeqay se handle karta hai without har request par thread
block kiye. Is liye concurrent requests handle karne mein useful hota hai.
Function that runs during request-response cycle for tasks like parsing, auth, logging, error
handling.
Q: REST API kya hoti hai?
HTTP-based API design jahan resources endpoints aur methods ke through expose hotay
hain.
MongoDB document-based NoSQL hai; SQL relational tables use karta hai.
3.38 Interview mein apne project ko backend angle se kaise explain karna hai
1) Problem statement
“Project ka goal food donation aur distribution process ko manage karna tha.”
2) Tech stack
3) Backend responsibilities
• user authentication
• data store/fetch/update
• form submissions handle karna
• request validation
• protected routes
• dashboard data
4) API examples
• user registration/login
• update status
5) Security / structure
• Postman testing
Sample answer:
“Maine backend mein Express ke through REST APIs banayi jo user registration, login,
donation record management aur data retrieval handle karti thin. MongoDB ko database ke
طورpar use kiya aur Mongoose ke through schemas/models define kiye. API testing ke liye
Postman use kiya, aur jahan zarurat thi wahan validation aur authentication logic
implement ki.”
Answer structure:
Example answer:
“React frontend forms ya user actions ke through API requests send karta hai. Express
backend un requests ko routes/controllers ke through process karta hai, database se data
fetch ya update karta hai, aur phir JSON response return karta hai. Frontend us response ko
state mein store karke UI update karta hai.”
“JavaScript meri core language rahi hai for web development. Mujhe variables, scopes,
functions, arrays/objects, promises, async/await, DOM basics aur ES6 concepts ka
practical understanding hai. React ke through maine frontend development aur
Node/Express ke through backend APIs par bhi kaam kiya hai.”
5.3 “React mein kya kya use kiya?”
“Maine React mein reusable components banaye, useState aur useEffect use kiya, forms
ko controlled inputs ke sath handle kiya, API data fetch kiya aur components ke through UI
structure ki. List rendering, conditional rendering aur props/state flow par bhi kaam kiya.”
“Maine [Link] aur [Link] ke sath REST APIs banayi hain, MongoDB ke sath data
models aur CRUD operations handle kiye hain, Postman se APIs test ki hain, aur project
structure ko routes/controllers/models mein organize karne ki practice ki hai. Mujhe
request-response cycle, middleware, auth basics aur error handling ka understanding hai.”
“I’m not fully sure about the exact low-level detail, but my understanding is that…”
ya
“I haven’t implemented that deeply yet, but from my understanding…”
Yeh better hota hai banisbat ghalat confident answer dene ke.
• JS single-threaded hai
• hoisting + TDZ
• == vs ===
• arrays: map/filter/forEach
• objects, destructuring, spread
• DOM basics
• JSX
• components
• props vs state
• useState
• useEffect
• controlled forms
• conditional rendering
• virtual DOM
• API calls
• [Link] runtime
• Express framework
• REST APIs
• GET/POST/PUT/DELETE
• middleware
• auth vs authorization
• JWT basics
• status codes
• error handling
• Postman testing
Sirf definitions ratna kaafi nahi hota. Har topic ke liye yeh 3 cheezein tayyar rakho:
1) Definition
2) Simple example
3) Project relation
Agar tum har concept ko definition + example + project usage ke format mein prepare kar
lo, to tumhare answers bohat zyada natural aur strong lagenge.
Day 1:
Day 2:
Day 3:
Day 4:
Apna project prepare karo in detail:
• project intro
• features
• tech stack
• frontend flow
• backend flow
• challenges
• kya seekha
Day 5:
Mock interview:
• intro
• strengths
• project explanation
• JS/React/Node questions
Interviewer perfect expert answer expect nahi karta. Wo yeh dekhna chahta hai: