JS इंटरव्यू सवाल
In this page:
Basic Interview Questions
आम शुरुआती interview questions var/let/const के बीच फर्क, == === से कैसे अलग है, और undefined और null का असल में क्या मतलब है जैसी fundamentals जांचते हैं, क्योंकि ये दिखाते हैं कि किसी की basics पर पकड़ असल में कितनी मजबूत है।
उदाहरण: Basic Interview Questions
console.log(typeof undefined, typeof null); // classic var/let/const & null-vs-undefined question
console.log(1 == "1", 1 === "1");
Functions और Scope
Function और scope के सवाल अक्सर आपसे closures, hoisting, या अलग-अलग call contexts में this क्या refer करता है यह समझाने को कहते हैं — ऐसे क्षेत्र जहाँ JavaScript का व्यवहार कई developers को हैरान कर देता है।
उदाहरण: Functions and Scope
function outer() {
let count = 0;
return () => ++count; // closures question
}
const counter = outer();
console.log(counter(), counter());
Arrays और Objects
Array और object के सवाल आमतौर पर map/filter/reduce से data manipulate करने, shallow बनाम deep copies समझाने, या reference बनाम value semantics वाले output का अंदाज़ा लगाने से जुड़े होते हैं।
उदाहरण: Arrays and Objects
const nums = [1, 2, 3];
const doubled = [...nums].map(n => n * 2); // shallow copy question
console.log(nums, doubled);
Async JavaScript
Async JavaScript के सवाल आमतौर पर event loop, microtasks और macrotasks के बीच फर्क, और callback-based या Promise-chain code को async/await में बदलने को कवर करते हैं।
उदाहरण: Async JavaScript
console.log("1");
setTimeout(() => console.log("2 - macrotask"), 0);
Promise.resolve().then(() => console.log("3 - microtask"));
console.log("4"); // classic event loop ordering question
Coding Interview Practice
इन concepts को मिलाने वाली timed coding problems की practice करना — सिर्फ उनके बारे में पढ़ना नहीं — असल में वह speed और confidence बनाता है जो एक live interview में चाहिए होता है।
उदाहरण: Coding Interview Practice
// Define the function `getValue` taking `cb`
// Define the function `getValue` taking `cb`
function getValue(cb) { setTimeout(() => cb(42), 100); }
// Define the asynchronous function `getValueAsync` with no parameters
// Define the asynchronous function `getValueAsync` with no parameters
async function getValueAsync() {
// Return `new Promise(resolve => setTimeout(() => resolve(42), 100))` from this function
// Return `new Promise(resolve => setTimeout(() => resolve(42), 100))` from this function
return new Promise(resolve => setTimeout(() => resolve(42), 100));
}
// Call `getValueAsync().then(v => console.log(v))`
// Call `getValueAsync().then(v => console.log(v))`
getValueAsync().then(v => console.log(v));
- यह कहना कि
typeof null"null"है, जबकि यह"object"है, एक well-known quirk। - type coercion explain किए बिना यह answer देना कि
==और===अलग हैं, जैसे"5" == 5काtrueहोना। - closures या
thisकी definition रट लेना बिना कोई छोटा example दिखा पाने के।
Chapter Quiz — Complete all 9 topics to unlock
0/9 topics done
Complete these topics first: