Master technical and career interviews with structured answers—short definition, real examples, pitfalls, and how to answer in 60–90 seconds.
Short answer: Follow me on LinkedIn: Debouncing: Executes a function after a delay of no activity. Throttling: Executes a function at regular intervals. Example (debounce): function debounce(fn, delay) { let timer; retur…
Short answer: Static typing: Variable types are known at compile-time (e.g., TypeScript, Java). Dynamic typing: Types are determined at runtime (JavaScript). Example: let x = 10; // number Example code x = "text&quo…
Short answer: NaN stands for “Not-a-Number”, representing an invalid numeric operation. Example: console.log("hello" / 2); // NaN Example code NaN stands for “Not-a-Number”, representing an invalid numeric oper…
Short answer: Defines how images or videos resize within their container. Follow me on LinkedIn: Example code img { width: 100%; height: 300px; object-fit: cover; } Key Takeaway: cover fills the box; contain fits the who…
Short answer: Call stack: Where function execution happens (synchronous). Task queue: Holds async callbacks (processed after stack is empty). Example code console.log("1"); setTimeout(() => console.log("…
Short answer: Used to find the type of a variable. typeof "Hello"; // "string" typeof 10; // "number" typeof null; // "object" (bug) Example code Used to find the type of a variabl…
Short answer: Targets elements with a specific class attribute. Example code .card { background-color: lightgray; } <div class="card">Profile</div> Follow me on LinkedIn: Key Takeaway: Classes are r…
Short answer: When an event occurs in a nested element: Bubbling: Event moves upward (child → parent). Capturing: Event moves downward (parent → child). Example code element.addEventListener('click', handler, true); // c…
Short answer: Feature Regular Function Arrow Function this Dynamic Lexical (inherits from parent) Syntax function f(){} (a,b)=>a+b Can be used as constructor ✅ ❌ Example code Feature Regular Function Arrow Function th…
Short answer: A style where functions are pure, stateless, and composable. Example: const double = x => x * 2; const square = x => x * x; const result = square(double(3)); // 36 Example code A style where functions…
Short answer: Type Description Shallow Copy Copies top-level properties only Deep Copy Copies all nested objects too Follow me on LinkedIn: Example: const obj = { a: { b: 1 } }; Example code const shallow = { ...obj }; /…
Short answer: Unit Relative To Example em Parent’s font size 2em = 2 × parent font-size rem Root (<html>) font size 2rem = 2 × root font-size Example code html { font-size: 16px; } p { font-size: 2rem; } /* = 32px…
Short answer: The alt attribute provides alternative text when an image fails to load and is read by screen readers. Example code Follow me on LinkedIn: <img src="team.jpg" alt="Our development team&quo…
Short answer: A function that accepts another function as a parameter or returns a function. Example: function multiplyBy(factor) { return x => x * factor; } const double = multiplyBy(2); console.log(double(5)); // 10…
Short answer: Promise chaining allows multiple async tasks to run sequentially. Example code fetch('/data') .then(res => res.json()) .then(data => console.log(data)) .catch(err => console.error(err)); Real-world…
Short answer: DOM (Document Object Model) represents the structure of an HTML document as a tree of objects, allowing JavaScript to access and manipulate elements dynamically. Follow me on LinkedIn: Real-world example (S…
Short answer: <b> only makes text bold visually. <strong> adds semantic meaning (important text). Example: <b>Warning:</b> Incorrect password.<br> <strong>Warning:</strong> Incor…
Short answer: A function passed as an argument to another function to be executed later. Example: function greet(name, callback) { console.log(`Hello, ${name}`); callback(); } Example code greet("Sandeep", () =…
Short answer: Provides consistent button styling: <button class="btn btn-primary">Click</button> Real-world example (ShopNest) ShopNest’s browser cart uses modern JavaScript: fetch APIs with async/a…
Short answer: JSON (JavaScript Object Notation) is a lightweight format for storing and transferring data. Example: let obj = { name: "Bob" }; let json = JSON.stringify(obj); // Convert to JSON string Example c…
Short answer: <i> makes text italic for style only. <em> gives emphasis that can change meaning. Example: <i>Book titles</i> are italicized. Please <em>do not</em> touch that. Follow m…
Short answer: A function that: Always returns the same output for the same input Has no side effects (doesn’t modify external variables) Example: function sum(a, b) { return a + b; Real-world example (ShopNest) ShopNest’…
Short answer: Method Mutates Original? Purpose slice(start, end) ❌ No Extracts portion Follow me on LinkedIn: splice(start, count, ...items) ✅ Yes Adds/removes items Real-world example (ShopNest) ShopNest’s browser cart…
Short answer: localStorage stores key-value pairs in the browser permanently (until cleared). Example code localStorage.setItem("user", "Alice"); console.log(localStorage.getItem("user")); /…
Short answer: float moves elements to the left or right — allowing text and inline elements to wrap around. Example code img { float: right; margin: 10px; } Key Takeaway: Used for text wrapping, but Flexbox/Grid is bette…
JavaScript JavaScript Tutorial · JavaScript
Short answer: Follow me on LinkedIn: Debouncing: Executes a function after a delay of no activity. Throttling: Executes a function at regular intervals. Example (debounce): function debounce(fn, delay) { let timer; return (...args) => { clearTimeout(timer); timer = setTimeout(() => fn(...args), delay); }; }
ShopNest’s browser cart uses modern JavaScript: fetch APIs with async/await, modules, and clear error handling.
JavaScript JavaScript Tutorial · JavaScript
Short answer: Static typing: Variable types are known at compile-time (e.g., TypeScript, Java). Dynamic typing: Types are determined at runtime (JavaScript). Example: let x = 10; // number
x = "text"; // allowed
JavaScript JavaScript Tutorial · JavaScript
Short answer: NaN stands for “Not-a-Number”, representing an invalid numeric operation. Example: console.log("hello" / 2); // NaN
NaN stands for “Not-a-Number”, representing an invalid numeric operation. Example: console.log("hello" / 2); // NaN
ShopNest’s browser cart uses modern JavaScript: fetch APIs with async/await, modules, and clear error handling.
JavaScript JavaScript Tutorial · JavaScript
Short answer: Defines how images or videos resize within their container. Follow me on LinkedIn:
img { width: 100%; height: 300px; object-fit: cover; } Key Takeaway: cover fills the box; contain fits the whole image inside.
ShopNest’s browser cart uses modern JavaScript: fetch APIs with async/await, modules, and clear error handling.
JavaScript JavaScript Tutorial · JavaScript
Short answer: Call stack: Where function execution happens (synchronous). Task queue: Holds async callbacks (processed after stack is empty).
console.log("1"); setTimeout(() => console.log("2"), 0); console.log("3"); // Output: 1, 3, 2 Follow me on LinkedIn:
ShopNest’s browser cart uses modern JavaScript: fetch APIs with async/await, modules, and clear error handling.
JavaScript JavaScript Tutorial · JavaScript
Short answer: Used to find the type of a variable. typeof "Hello"; // "string" typeof 10; // "number" typeof null; // "object" (bug)
Used to find the type of a variable. typeof "Hello"; // "string" typeof 10; // "number" typeof null; // "object" (bug)
ShopNest’s browser cart uses modern JavaScript: fetch APIs with async/await, modules, and clear error handling.
JavaScript JavaScript Tutorial · JavaScript
Short answer: Targets elements with a specific class attribute.
.card { background-color: lightgray; } <div class="card">Profile</div> Follow me on LinkedIn: Key Takeaway: Classes are reusable; use them for consistent styling across elements.
ShopNest’s browser cart uses modern JavaScript: fetch APIs with async/await, modules, and clear error handling.
JavaScript JavaScript Tutorial · JavaScript
Short answer: When an event occurs in a nested element: Bubbling: Event moves upward (child → parent). Capturing: Event moves downward (parent → child).
element.addEventListener('click', handler, true); // capturing element.addEventListener('click', handler, false); // bubbling
ShopNest’s browser cart uses modern JavaScript: fetch APIs with async/await, modules, and clear error handling.
JavaScript JavaScript Tutorial · JavaScript
Short answer: Feature Regular Function Arrow Function this Dynamic Lexical (inherits from parent) Syntax function f(){} (a,b)=>a+b Can be used as constructor ✅ ❌
Feature Regular Function Arrow Function this Dynamic Lexical (inherits from parent) Syntax function f(){} (a,b)=>a+b Can be used as constructor ✅ ❌
ShopNest’s browser cart uses modern JavaScript: fetch APIs with async/await, modules, and clear error handling.
JavaScript JavaScript Tutorial · JavaScript
Short answer: A style where functions are pure, stateless, and composable. Example: const double = x => x * 2; const square = x => x * x; const result = square(double(3)); // 36
A style where functions are pure, stateless, and composable. Example: const double = x => x * 2;
const square = x => x * x;
const result = square(double(3)); // 36
ShopNest’s browser cart uses modern JavaScript: fetch APIs with async/await, modules, and clear error handling.
JavaScript JavaScript Tutorial · JavaScript
Short answer: Type Description Shallow Copy Copies top-level properties only Deep Copy Copies all nested objects too Follow me on LinkedIn: Example: const obj = { a: { b: 1 } };
const shallow = { ...obj }; // same reference
const deep = JSON.parse(JSON.stringify(obj)); // new copy
ShopNest’s browser cart uses modern JavaScript: fetch APIs with async/await, modules, and clear error handling.
JavaScript JavaScript Tutorial · JavaScript
Short answer: Unit Relative To Example em Parent’s font size 2em = 2 × parent font-size rem Root (<html>) font size 2rem = 2 × root font-size
html { font-size: 16px; } p { font-size: 2rem; } /* = 32px */ Key Takeaway: Use rem for consistent sizing across the document.
ShopNest’s browser cart uses modern JavaScript: fetch APIs with async/await, modules, and clear error handling.
JavaScript JavaScript Tutorial · JavaScript
Short answer: The alt attribute provides alternative text when an image fails to load and is read by screen readers.
Follow me on LinkedIn: <img src="team.jpg" alt="Our development team"> Key Takeaway: Always include meaningful alt text — it’s good for accessibility and SEO.
ShopNest’s browser cart uses modern JavaScript: fetch APIs with async/await, modules, and clear error handling.
JavaScript JavaScript Tutorial · JavaScript
Short answer: A function that accepts another function as a parameter or returns a function. Example: function multiplyBy(factor) { return x => x * factor; } const double = multiplyBy(2); console.log(double(5)); // 10
A function that accepts another function as a parameter or returns a function. Example: function multiplyBy(factor) { return x => x * factor;
}
const double = multiplyBy(2); console.log(double(5)); // 10
ShopNest’s browser cart uses modern JavaScript: fetch APIs with async/await, modules, and clear error handling.
JavaScript JavaScript Tutorial · JavaScript
Short answer: Promise chaining allows multiple async tasks to run sequentially.
fetch('/data') .then(res => res.json()) .then(data => console.log(data)) .catch(err => console.error(err));
The checkout button uses async/await to call /api/orders, shows a spinner, and catches network errors with a toast.
JavaScript JavaScript Tutorial · JavaScript
Short answer: DOM (Document Object Model) represents the structure of an HTML document as a tree of objects, allowing JavaScript to access and manipulate elements dynamically. Follow me on LinkedIn:
ShopNest’s browser cart uses modern JavaScript: fetch APIs with async/await, modules, and clear error handling.
JavaScript JavaScript Tutorial · JavaScript
Short answer: <b> only makes text bold visually. <strong> adds semantic meaning (important text). Example: <b>Warning:</b> Incorrect password.<br> <strong>Warning:</strong> Incorrect password. Key Takeaway: Use <strong> for emphasis that affects meaning.
ShopNest’s browser cart uses modern JavaScript: fetch APIs with async/await, modules, and clear error handling.
JavaScript JavaScript Tutorial · JavaScript
Short answer: A function passed as an argument to another function to be executed later. Example: function greet(name, callback) { console.log(`Hello, ${name}`); callback(); }
greet("Sandeep", () => console.log("Callback executed"));
ShopNest’s browser cart uses modern JavaScript: fetch APIs with async/await, modules, and clear error handling.
JavaScript JavaScript Tutorial · JavaScript
Short answer: Provides consistent button styling: <button class="btn btn-primary">Click</button>
ShopNest’s browser cart uses modern JavaScript: fetch APIs with async/await, modules, and clear error handling.
JavaScript JavaScript Tutorial · JavaScript
Short answer: JSON (JavaScript Object Notation) is a lightweight format for storing and transferring data. Example: let obj = { name: "Bob" }; let json = JSON.stringify(obj); // Convert to JSON string
JSON (JavaScript Object Notation) is a lightweight format for storing and transferring data. Example: let obj = { name: "Bob" };
let json = JSON.stringify(obj); // Convert to JSON string
ShopNest’s browser cart uses modern JavaScript: fetch APIs with async/await, modules, and clear error handling.
JavaScript JavaScript Tutorial · JavaScript
Short answer: <i> makes text italic for style only. <em> gives emphasis that can change meaning. Example: <i>Book titles</i> are italicized. Please <em>do not</em> touch that. Follow me on LinkedIn: Key Takeaway: <em> adds importance — <i> adds style.
ShopNest’s browser cart uses modern JavaScript: fetch APIs with async/await, modules, and clear error handling.
JavaScript JavaScript Tutorial · JavaScript
Short answer: A function that: Always returns the same output for the same input Has no side effects (doesn’t modify external variables) Example: function sum(a, b) { return a + b;
ShopNest’s browser cart uses modern JavaScript: fetch APIs with async/await, modules, and clear error handling.
JavaScript JavaScript Tutorial · JavaScript
Short answer: Method Mutates Original? Purpose slice(start, end) ❌ No Extracts portion Follow me on LinkedIn: splice(start, count, ...items) ✅ Yes Adds/removes items
ShopNest’s browser cart uses modern JavaScript: fetch APIs with async/await, modules, and clear error handling.
JavaScript JavaScript Tutorial · JavaScript
Short answer: localStorage stores key-value pairs in the browser permanently (until cleared).
localStorage.setItem("user", "Alice"); console.log(localStorage.getItem("user")); // Alice
ShopNest’s browser cart uses modern JavaScript: fetch APIs with async/await, modules, and clear error handling.
JavaScript JavaScript Tutorial · JavaScript
Short answer: float moves elements to the left or right — allowing text and inline elements to wrap around.
img { float: right; margin: 10px; } Key Takeaway: Used for text wrapping, but Flexbox/Grid is better for layout today.
ShopNest’s browser cart uses modern JavaScript: fetch APIs with async/await, modules, and clear error handling.