0% found this document useful (0 votes)
2 views9 pages

JS NodeJS ReactJS Interview Notes

This document provides comprehensive interview preparation notes for JavaScript, Node.js, and React.js, covering topics from basic to advanced levels. It includes key concepts, expected interview questions, and quick tips for effective preparation. The notes emphasize understanding core principles, coding practices, and performance optimization techniques relevant to each technology.

Uploaded by

aakanksham79
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views9 pages

JS NodeJS ReactJS Interview Notes

This document provides comprehensive interview preparation notes for JavaScript, Node.js, and React.js, covering topics from basic to advanced levels. It includes key concepts, expected interview questions, and quick tips for effective preparation. The notes emphasize understanding core principles, coding practices, and performance optimization techniques relevant to each technology.

Uploaded by

aakanksham79
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

■ Interview Preparation Notes

JavaScript • [Link] • [Link] | Basics → Advanced

JS JavaScript ■ [Link] ■ [Link]

Basics → Advanced Server Side Mastery UI / Frontend Expert

✏■ Handwritten-Style Quick Revision Notes | Expected Interview Questions

■ JAVASCRIPT — Basics to Advanced

■ BASIC Level

BAS Q: JavaScript kya hai?

JS ek lightweight, interpreted, single-threaded programming language hai jo mainly browsers mein


run hoti hai. Ab [Link] se server pe bhi chalti hai.

BAS Q: var, let, const mein kya fark hai?

• var – function-scoped, hoisted, re-declare kar sakte hain

• let – block-scoped, hoisted but TDZ mein, re-declare nahi

• const – block-scoped, value change nahi (objects mutable hain)

BAS Q: Hoisting kya hota hai?

JS declarations ko code run hone se pehle top par le jaati hai. var hoisted hota hai (undefined se
initialize), function declarations bhi hoist hoti hain. let/const hoist hote hain par Temporal Dead
Zone (TDZ) mein rehte hain.

BAS Q: == vs === kya fark hai?

== type coercion karta hai (2 == '2' → true). === strict equality, type bhi same hona chahiye (2 ===
'2' → false). Hamesha === use karo.
BAS Q: null vs undefined vs NaN?

• null – intentional empty value (developer ne set kiya)

• undefined – variable declare hua but value assign nahi

• NaN – Not a Number, invalid math operation ka result

BAS Q: Data types JavaScript mein?

Primitive: String, Number, Boolean, null, undefined, Symbol, BigInt. Non-Primitive: Object (Array,
Function, Date, RegExp sab object hain).

■ INTERMEDIATE Level

INT Q: Closure kya hota hai?

Jab ek function apne outer function ke variables ko yaad rakhta hai even after outer function
execute ho chuka ho. Example: counter function jo private variable maintain karta hai.

INT Q: Event Loop kya hai? (VERY IMPORTANT)

• JS single-threaded hai – ek time par ek kaam

• Call Stack → Web APIs → Callback Queue → Event Loop

• Microtask Queue (Promise) → Macrotask Queue (setTimeout)

• Event loop call stack khali hone par queue se task uthata hai

INT Q: Promise kya hai? States?

• Promise ek async operation ka future result represent karta hai

• States: Pending → Fulfilled (resolve) ya Rejected (reject)

• .then() fulfilled pe, .catch() rejected pe, .finally() dono pe

• [Link]() – sab resolve hone ka wait, [Link]() – pehla

INT Q: async/await kya hai?

Promises ka syntactic sugar hai. async function hamesha Promise return karta hai. await keyword
ke saamne Promise ka result milta hai. try/catch se error handle karo.

INT Q: Prototype aur Prototype Chain?

Har JS object ka ek hidden [[Prototype]] hota hai. Property nahi mili to upar chain mein dhundha
jaata hai. [Link] chain ka end hai. ES6 class syntax bhi prototype pe based hai.

INT Q: this keyword kya hai?

• Global context mein: window (browser) / global (Node)

• Object method mein: woh object

• Arrow function mein: lexical this (outer scope ka)

• call/apply/bind se manually set kar sakte hain

JS | [Link] | [Link] Interview Notes — Page 2


INT Q: Arrow function vs Regular function?

• Arrow: apna this nahi, arguments object nahi

• Arrow constructor ke taur pe use nahi ho sakti

• Short syntax: const add = (a,b) => a+b

• Regular function: apna this, arguments object hota hai

INT Q: Spread (...) vs Rest (...) operator?

Spread: array/object ko expand karta hai ([...arr1, ...arr2]). Rest: multiple args ko array mein
collect karta hai (function sum(...nums)). Same syntax, alag use.

INT Q: Destructuring kya hai?

Array/object se values directly variables mein nikalna. Array: const [a,b] = [1,2]. Object: const
{name, age} = person. Default values bhi de sakte hain.

■ ADVANCED Level

ADV Q: Debouncing vs Throttling?

• Debounce: function tab call karo jab events band ho jaayein (delay ke baad). Search bar ke liye.

• Throttle: function ek fixed time interval mein ek baar hi call hoga. Scroll event ke liye.

• Dono performance optimization ke liye hain

ADV Q: Deep Copy vs Shallow Copy?

• Shallow: sirf top-level copy, nested objects reference share karte hain. [Link](), spread
operator

• Deep: poori copy, nested objects bhi naye. [Link]([Link](obj)) ya


structuredClone()

• structuredClone() modern aur best way hai

ADV Q: Memory Leaks JS mein?

• Global variables jo clear nahi hote

• Event listeners jo remove nahi hote

• Closures jo bade objects hold karte hain

• SetInterval jo clear nahi kiya

• Use WeakMap/WeakRef for weak references

ADV Q: Generator Functions kya hain?

function* se banate hain. yield se pause karte hain. next() call karne par aage badhte hain. Lazy
evaluation aur infinite sequences ke liye useful hain.

JS | [Link] | [Link] Interview Notes — Page 3


ADV Q: Currying kya hai?

Ek function jo multiple arguments lene ki jagah ek-ek argument leta hai. add(2)(3) === 5. Partial
application aur function reusability ke liye use hota hai.

ADV Q: IIFE kya hai?

Immediately Invoked Function Expression. Banao aur turant execute karo: (function() { ... })().
Scope pollution rokta hai. Purana pattern tha, ab ES modules use karo.

ADV Q: WeakMap vs Map?

WeakMap: keys sirf objects hote hain, garbage collected ho sakte hain, iterable nahi. Map: koi bhi
value key ban sakti hai, size property hai, iterable hai. WeakMap memory leaks rokta hai.

■ [Link] — Server Side Mastery

■ BASIC Level

NODE Q: [Link] kya hai?

[Link] ek JavaScript runtime hai jo V8 engine pe chalti hai (Chrome ka same engine).
Server-side JS run karne ke liye bana. Non-blocking, event-driven architecture use karta hai.

NODE Q: [Link] non-blocking I/O kya matlab?

• Blocking: ek operation ka wait, baaki ruko

• Non-blocking: I/O operation start karo, callback baad mein aayega

• Libuv library thread pool manage karti hai

• Isse ek thread hazaron connections handle kar sakta hai

NODE Q: npm kya hai?

Node Package Manager. packages install karo (npm install), [Link] mein dependencies
manage karo. npm vs npx: npx package run karta hai without global install.

NODE Q: [Link] vs exports?

[Link] woh actual object hai jo require() return karta hai. exports [Link] ka
shorthand hai. Agar exports ko re-assign karo to link toot jaata hai. Hamesha [Link] use
karo safety ke liye.

■ INTERMEDIATE Level

NODE Q: [Link] kya hai?

[Link] ka minimal, unopinionated web framework. Routes define karo, middleware add karo,
HTTP requests handle karo. [Link](), [Link](), [Link]() main methods hain.

JS | [Link] | [Link] Interview Notes — Page 4


NODE Q: Middleware kya hota hai Express mein?

• Request-response cycle ke beech mein function

• Signature: (req, res, next) => {}

• next() call karo agle middleware ko aage badhao

• Error middleware: (err, req, res, next) – 4 params

• Body-parser, cors, auth check sab middleware hain

NODE Q: REST API vs GraphQL?

• REST: fixed endpoints, multiple requests, over/under fetching possible

• GraphQL: ek endpoint, client maange utna hi data mile

• REST simple aur standard, GraphQL complex queries ke liye better

NODE Q: Environment Variables kya hain?

Sensitive config (DB URL, API keys) code se bahar rakhne ke liye. .env file mein store karo.
dotenv package se load karo: require('dotenv').config(). .env ko .gitignore mein add karo!

■ ADVANCED Level

NODE Q: Cluster module kya karta hai?

Multi-core CPUs ka full use karne ke liye. Master process workers spawn karta hai (CPU count ke
barabar). PM2 bhi yahi karta hai internally. Load automatically distribute hota hai.

NODE Q: Streams kya hain Node mein?

• 4 types: Readable, Writable, Duplex, Transform

• Large files memory mein poora load kiye bina process karo

• pipe() method se streams ko connect karo

• [Link]() + pipe(res) – efficient file serving

NODE Q: Event Emitter pattern?

Node ka core pattern. EventEmitter class inherit karo. on() se listen, emit() se trigger. Custom
events bana sakte ho. Sockets, HTTP sab EventEmitter pe based hain.

NODE Q: JWT Authentication kaise kaam karta hai?

• [Link] – 3 parts, base64 encoded

• Server secret se sign karta hai

• Client token store karta hai (localStorage / httpOnly cookie)

• Har request mein Authorization: Bearer bhejo

• Server verify karta hai – stateless auth!

JS | [Link] | [Link] Interview Notes — Page 5


NODE Q: Database Connection Pooling kya hai?

Baar baar naye connections banana expensive hai. Pool pre-created connections maintain karta
hai. Request aane par pool se connection lo, kaam ke baad wapas do. pg-pool, mongoose
connection pooling use karo.

NODE Q: Error Handling best practices Node mein?

• try/catch async/await ke sath

• Express mein centralized error middleware banao

• Operational vs Programming errors alag karo

• [Link]('uncaughtException') crash se pehle log karo

• Never ignore rejected Promises!

■ [Link] — UI / Frontend Expert

■ BASIC

RXJ Q: React kya hai?

Facebook ka open-source UI library hai. Component-based architecture. Virtual DOM use karta
hai for efficient updates. Declarative – kya dikhana hai batao, kaise update hoga React handle
karta hai.

RXJ Q: Virtual DOM kya hai aur kaise kaam karta hai?

• Virtual DOM – actual DOM ka lightweight JS representation

• State change hone par naya Virtual DOM banata hai

• Diffing algorithm: old vs new Virtual DOM compare

• Sirf changed parts ko actual DOM mein update karta hai (Reconciliation)

• Ye real DOM manipulation se faster hai

RXJ Q: JSX kya hai?

JavaScript XML. JS mein HTML jaisa likhne ka syntax. Babel JSX ko [Link]() calls
mein convert karta hai. className use karo (class nahi), camelCase events (onClick, onChange).

RXJ Q: Props vs State?

• Props: parent se child ko data – read-only, immutable

• State: component ka private data – mutable, setState se change

• State change hone par component re-render hota hai

• Props change hone par bhi re-render hota hai

■ HOOKS SECTION

JS | [Link] | [Link] Interview Notes — Page 6


RXJ Q: useState kya hai?

Functional component mein state add karne ke liye. const [count, setCount] = useState(0). Setter
se state update karo – direct mutation mat karo! Lazy initialization bhi possible hai.

RXJ Q: useEffect kya hai? (VERY IMPORTANT)

• Side effects ke liye – API calls, subscriptions, DOM manipulation

• useEffect(() => { ... }, [deps]) – deps change hone par run

• Empty array [] – sirf mount pe run

• No array – har render ke baad run

• Return cleanup function – unmount pe run hogi

• async directly mat likho useEffect mein, andar function banao

RXJ Q: useCallback vs useMemo?

• useCallback: function ko memoize karta hai – same reference maintain

• useMemo: computed value ko memoize karta hai

• Dono dependency array lete hain

• Over-optimization se bachao – sirf jab zarurat ho use karo

• [Link] ke sath useCallback use karo child re-renders rokne ke liye

RXJ Q: useRef kya kaam aata hai?

• DOM elements directly access karne ke liye: [Link]()

• Mutable value store karo jo re-render trigger nahi kare

• Previous value yaad rakhna

• Timers/intervals store karna

• useRef aur useState ka fark – ref change se re-render nahi

RXJ Q: useContext kya hai?

Props drilling se bachne ke liye. [Link]() se context banao. Provider se wrap karo.
useContext(MyContext) se consume karo. Global state (theme, user, language) ke liye.

■ ADVANCED

RXJ Q: useReducer vs useState?

• useReducer complex state logic ke liye better hai

• const [state, dispatch] = useReducer(reducer, initialState)

• Redux jaisi pattern – action dispatch karo, reducer new state return kare

• Multiple related state values ho to useReducer prefer karo

JS | [Link] | [Link] Interview Notes — Page 7


RXJ Q: [Link] kya hai?

Higher Order Component jo component ko memoize karta hai. Agar props same hain to re-render
nahi hoga. Shallow comparison use karta hai. Performance optimization ke liye, unnecessary
renders rokta hai.

RXJ Q: Code Splitting aur Lazy Loading?

• [Link]() + Suspense se dynamic imports karo

• const LazyComp = [Link](() => import('./Component'))

• }> se wrap karo

• Route-based code splitting – initial bundle size kam hoti hai

• Webpack automatically alag chunks banata hai

RXJ Q: React ke performance optimization tricks?

• [Link] – unnecessary re-renders rokta hai

• useCallback/useMemo – functions/values memoize

• Code splitting + lazy loading

• Virtualization – react-window/react-virtual large lists ke liye

• Production build use karo (npm run build)

• Key prop sahi lagao lists mein!

RXJ Q: Controlled vs Uncontrolled Components?

• Controlled: React state form data manage kare – value + onChange

• Uncontrolled: DOM khud data manage kare – useRef se access

• Controlled preferred – predictable, easy to validate

• File inputs always uncontrolled hote hain

RXJ Q: React Router ke main concepts?

• BrowserRouter se app wrap karo

• Route: path match hone par component render

• Link/NavLink: anchor ki jagah (page reload nahi)

• useNavigate: programmatic navigation

• useParams: URL params read karo

• Nested routes, protected routes patterns seekho

JS | [Link] | [Link] Interview Notes — Page 8


RXJ Q: Redux Toolkit kya hai?

• Redux ka official, opinionated toolset

• createSlice: reducer + actions ek jagah

• configureStore: store setup easy

• createAsyncThunk: async operations

• RTK Query: data fetching + caching built-in

• Boilerplate bahut kam ho gayi Redux ki!

■ Interview Ke Liye Quick Tips


■ Event Loop zaroor Ye JS ka sabse common advanced question hai. Call Stack → Web API → Callback
samjho! Queue yaad karo.

■ Promises +
async/await dono Sirf theory nahi, code likhke dekho. Error handling bhi zaroori hai.
practice karo

■ React Hooks ke
use-cases clear useEffect cleanup, useCallback ke sath [Link] – ye sab pooche jaate hain.
rakho

■ 'Explain with
Abstract concepts ko code se explain karo. Closure, Prototype, this – sab example
example' ki practice
ke sath.
karo

■ System Design
REST vs GraphQL, JWT, Database pooling – ye mid-senior level pe aate hain.
basics bhi padho

■ Projects ke baare
Resume mein jo likha hai woh deeply samjho. Performance optimization kahan ki?
mein clear raho

■ All The Best for Your Interview! You've Got This! ■

JS | [Link] | [Link] Interview Notes — Page 9

You might also like