Master technical and career interviews with structured answers—short definition, real examples, pitfalls, and how to answer in 60–90 seconds.
Short answer: Method Returns Chainable Use Case forEach () undefin ed ❌ No Iteration map() New array ✅ Yes Transformation Example: [1,2,3].map(x => x*2); // [2,4,6] Example code Method Returns Chainable Use Case forEa…
Short answer: Arrow functions are a shorter syntax for writing functions. They don’t have their own this. Example: const sum = (a, b) => a + b; Follow me on LinkedIn: Example code Arrow functions are a shorter syntax…
Short answer: It hints the browser that an element will soon change, so the browser can optimize rendering ahead of time. Example code .box { will-change: transform, opacity; } Key Takeaway: Improves animation performanc…
Short answer: z-index controls stacking order of overlapping elements. Example code .box1 { z-index: 1; } .box2 { z-index: 10; } Higher values appear on top. Key Takeaway: Only works on positioned elements (position ≠ st…
Short answer: It links human-readable text with a machine-readable value — useful for analytics or scripts. Follow me on LinkedIn: Example code <p>Price: <data value="499">₹499</data></p>…
Short answer: <ol> = Ordered List (numbered) <ul> = Unordered List (bulleted) <dl> = Description List (term–definition pairs) Example: <ol> <li>HTML</li> <li>CSS</li> </…
Short answer: Returns the type of a variable. Example: typeof "hello"; // "string" typeof 42; // "number" Example code Returns the type of a variable. Example: typeof "hello"; // &…
Short answer: Instead of attaching listeners to every element, attach one listener to a parent — it captures events from its children using bubbling. Example code document.querySelector('#list').addEventListener('click',…
Short answer: == : Equality operator (converts type before comparing) === : Strict equality (no type conversion, checks type + value) Example: 5 == '5'; // true 5 === '5'; // false Example code == : Equality operator (co…
Short answer: contain tells the browser which aspects of an element’s rendering are independent from the rest of the document — reducing reflows and repaints. Example code .card { Follow me on LinkedIn: contain: layout p…
Short answer: id is unique and used for a single element. class can be used for multiple elements. Example code <div id="main-header"></div> <div class="card"></div> <div cl…
Short answer: .container: Fixed width, adjusts at each breakpoint. .container-fluid: Always spans 100% width. Real-world example (ShopNest) ShopNest’s browser cart uses modern JavaScript: fetch APIs with async/await, mod…
Short answer: Logical properties adapt layouts for different writing directions (LTR, RTL, vertical text). Physical Logical margin-le ft margin-inline-s tart padding-t op padding-block-s tart Example code p { padding-inl…
Short answer: A function is a block of reusable code that performs a task or returns a value. Example: function greet(name) { return `Hello, ${name}!`; } console.log(greet("Sandeep")); Example code A function i…
Short answer: Both create objects, but: {} is simpler and faster. new Object() is less common and can be overridden. Example: const a = {}; // Preferred const b = new Object(); // Not preferred Example code Both create o…
Short answer: An event listener waits for user actions (like clicks or keypresses) and runs a function when the event occurs. Example code button.addEventListener("click", () => alert("Clicked!"));…
Short answer: Controls what happens when content exceeds the container’s size. Values: visible (default) hidden scroll auto Example code div { overflow: auto; } Key Takeaway: overflow: auto adds scrollbars only when need…
Short answer: It collects user input and sends it to a server or script for processing. Example code <form action="/submit" method="POST"> <input type="text" name="username&quo…
Short answer: Variables declared inside a function are accessible only within that function. Example code function demo() { let x = 10; console.log(x); // 10 } console.log(x); // ReferenceError Real-world example (ShopNe…
Short answer: ssigned Follow me on LinkedIn: Real-world example (ShopNest) ShopNest’s browser cart uses modern JavaScript: fetch APIs with async/await, modules, and clear error handling. Say this in the interview Define…
Short answer: Type Meaning null Intentional absence of value undefin ed Variable declared but not assigned Follow me on LinkedIn: Real-world example (ShopNest) ShopNest’s browser cart uses modern JavaScript: fetch APIs w…
Short answer: Property Location Affects Background? Padding Inside border ✅ Yes Margin Outside border ❌ No Example code div { Follow me on LinkedIn: margin: 10px; padding: 20px; } Key Takeaway: Padding = inner spacing, M…
Short answer: <picture> allows serving different image versions depending on device, screen size, or media type. Example code <picture> <source srcset="photo-large.jpg" media="(min-width: 80…
Short answer: <head> holds metadata (title, styles, scripts). <header> defines the visible top section of the page (logo, navigation, heading). Example code <head> <title>My Portfolio</title>…
Short answer: Variables declared with let or const inside curly braces {} are accessible only within that block. Example: if (true) { let y = 20; const z = 30; } // console.log(y, z); // ReferenceError Example code Varia…
JavaScript JavaScript Tutorial · JavaScript
Short answer: Method Returns Chainable Use Case forEach () undefin ed ❌ No Iteration map() New array ✅ Yes Transformation Example: [1,2,3].map(x => x*2); // [2,4,6]
Method Returns Chainable Use Case forEach () undefin ed ❌ No Iteration map() New array ✅ Yes Transformation Example: [1,2,3].map(x => x*2); // [2,4,6]
JavaScript JavaScript Tutorial · JavaScript
Short answer: Arrow functions are a shorter syntax for writing functions. They don’t have their own this. Example: const sum = (a, b) => a + b; Follow me on LinkedIn:
Arrow functions are a shorter syntax for writing functions. They don’t have their own this. Example: const sum = (a, b) => a + b; 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: It hints the browser that an element will soon change, so the browser can optimize rendering ahead of time.
.box { will-change: transform, opacity; } Key Takeaway: Improves animation performance but use carefully — too many can waste memory.
ShopNest’s browser cart uses modern JavaScript: fetch APIs with async/await, modules, and clear error handling.
JavaScript JavaScript Tutorial · JavaScript
Short answer: z-index controls stacking order of overlapping elements.
.box1 { z-index: 1; } .box2 { z-index: 10; } Higher values appear on top. Key Takeaway: Only works on positioned elements (position ≠ static).
ShopNest’s browser cart uses modern JavaScript: fetch APIs with async/await, modules, and clear error handling.
JavaScript JavaScript Tutorial · JavaScript
Short answer: It links human-readable text with a machine-readable value — useful for analytics or scripts. Follow me on LinkedIn:
<p>Price: <data value="499">₹499</data></p> Key Takeaway: <data> helps embed structured data inside readable content.
ShopNest’s browser cart uses modern JavaScript: fetch APIs with async/await, modules, and clear error handling.
JavaScript JavaScript Tutorial · JavaScript
Short answer: <ol> = Ordered List (numbered) <ul> = Unordered List (bulleted) <dl> = Description List (term–definition pairs) Example: <ol> <li>HTML</li> <li>CSS</li> </ol> <ul> <li>Apple</li> <li>Banana</li> </ul> Follow me on LinkedIn: <dl> <dt>HTML</dt> <dd>HyperText Markup Language</dd> </dl> Key Takeaway: Choose list type based on how you want to present data.
ShopNest’s browser cart uses modern JavaScript: fetch APIs with async/await, modules, and clear error handling.
JavaScript JavaScript Tutorial · JavaScript
Short answer: Returns the type of a variable. Example: typeof "hello"; // "string" typeof 42; // "number"
Returns the type of a variable. Example: typeof "hello"; // "string" typeof 42; // "number"
ShopNest’s browser cart uses modern JavaScript: fetch APIs with async/await, modules, and clear error handling.
JavaScript JavaScript Tutorial · JavaScript
Short answer: Instead of attaching listeners to every element, attach one listener to a parent — it captures events from its children using bubbling.
document.querySelector('#list').addEventListener('click', e => { if (e.target.tagName === 'LI') console.log(e.target.textContent); }); Follow me on LinkedIn: ✅ Improves performance and memory usage.
ShopNest’s browser cart uses modern JavaScript: fetch APIs with async/await, modules, and clear error handling.
JavaScript JavaScript Tutorial · JavaScript
Short answer: == : Equality operator (converts type before comparing) === : Strict equality (no type conversion, checks type + value) Example: 5 == '5'; // true 5 === '5'; // false
== : Equality operator (converts type before comparing) === : Strict equality (no type conversion, checks type + value) Example: 5 == '5'; // true
5 === '5'; // false
ShopNest’s browser cart uses modern JavaScript: fetch APIs with async/await, modules, and clear error handling.
JavaScript JavaScript Tutorial · JavaScript
Short answer: contain tells the browser which aspects of an element’s rendering are independent from the rest of the document — reducing reflows and repaints.
.card { Follow me on LinkedIn: contain: layout paint; } Key Takeaway: Containment isolates elements for performance optimization.
ShopNest’s browser cart uses modern JavaScript: fetch APIs with async/await, modules, and clear error handling.
JavaScript JavaScript Tutorial · JavaScript
Short answer: id is unique and used for a single element. class can be used for multiple elements.
<div id="main-header"></div> <div class="card"></div> <div class="card"></div> Key Takeaway: Use id for specific targeting; class for grouping and styling.
ShopNest’s browser cart uses modern JavaScript: fetch APIs with async/await, modules, and clear error handling.
JavaScript JavaScript Tutorial · JavaScript
Short answer: .container: Fixed width, adjusts at each breakpoint. .container-fluid: Always spans 100% width.
ShopNest’s browser cart uses modern JavaScript: fetch APIs with async/await, modules, and clear error handling.
JavaScript JavaScript Tutorial · JavaScript
Short answer: Logical properties adapt layouts for different writing directions (LTR, RTL, vertical text). Physical Logical margin-le ft margin-inline-s tart padding-t op padding-block-s tart
p { padding-inline-start: 10px; /* Works for both LTR and RTL */ } Key Takeaway: Logical properties make designs multilingual and direction-aware.
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 is a block of reusable code that performs a task or returns a value. Example: function greet(name) { return `Hello, ${name}!`; } console.log(greet("Sandeep"));
A function is a block of reusable code that performs a task or returns a value. Example: function greet(name) { return `Hello, ${name}!`;
} console.log(greet("Sandeep"));
ShopNest’s browser cart uses modern JavaScript: fetch APIs with async/await, modules, and clear error handling.
JavaScript JavaScript Tutorial · JavaScript
Short answer: Both create objects, but: {} is simpler and faster. new Object() is less common and can be overridden. Example: const a = {}; // Preferred const b = new Object(); // Not preferred
Both create objects, but: {} is simpler and faster. new Object() is less common and can be overridden. Example: const a = {}; // Preferred
const b = new Object(); // Not preferred
ShopNest’s browser cart uses modern JavaScript: fetch APIs with async/await, modules, and clear error handling.
JavaScript JavaScript Tutorial · JavaScript
Short answer: An event listener waits for user actions (like clicks or keypresses) and runs a function when the event occurs.
button.addEventListener("click", () => alert("Clicked!"));
ShopNest’s browser cart uses modern JavaScript: fetch APIs with async/await, modules, and clear error handling.
JavaScript JavaScript Tutorial · JavaScript
Short answer: Controls what happens when content exceeds the container’s size. Values: visible (default) hidden scroll auto
div { overflow: auto; } Key Takeaway: overflow: auto adds scrollbars only when needed.
ShopNest’s browser cart uses modern JavaScript: fetch APIs with async/await, modules, and clear error handling.
JavaScript JavaScript Tutorial · JavaScript
Short answer: It collects user input and sends it to a server or script for processing.
<form action="/submit" method="POST"> <input type="text" name="username"> <button type="submit">Submit</button> </form> Key Takeaway: Forms are the foundation of user interaction on the web.
ShopNest’s browser cart uses modern JavaScript: fetch APIs with async/await, modules, and clear error handling.
JavaScript JavaScript Tutorial · JavaScript
Short answer: Variables declared inside a function are accessible only within that function.
function demo() { let x = 10; console.log(x); // 10 } console.log(x); // ReferenceError
In ShopNest’s cart UI, a click handler closes over productId. Use let in loops so each button keeps the correct id.
JavaScript JavaScript Tutorial · JavaScript
Short answer: ssigned 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: Type Meaning null Intentional absence of value undefin ed Variable declared but not assigned 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: Property Location Affects Background? Padding Inside border ✅ Yes Margin Outside border ❌ No
div { Follow me on LinkedIn: margin: 10px; padding: 20px; } Key Takeaway: Padding = inner spacing, Margin = outer spacing.
ShopNest’s browser cart uses modern JavaScript: fetch APIs with async/await, modules, and clear error handling.
JavaScript JavaScript Tutorial · JavaScript
Short answer: <picture> allows serving different image versions depending on device, screen size, or media type.
<picture> <source srcset="photo-large.jpg" media="(min-width: 800px)"> <source srcset="photo-small.jpg" media="(max-width: 799px)"> <img src="photo-default.jpg" alt="Beautiful landscape"> </picture> Key Takeaway: Use <picture> for art direction — showing different images per device or context.
ShopNest’s browser cart uses modern JavaScript: fetch APIs with async/await, modules, and clear error handling.
JavaScript JavaScript Tutorial · JavaScript
Short answer: <head> holds metadata (title, styles, scripts). <header> defines the visible top section of the page (logo, navigation, heading).
<head> <title>My Portfolio</title> </head> <header> <h1>Welcome to My Portfolio</h1> </header> Follow me on LinkedIn: Key Takeaway: <head> = document info; <header> = visible header area.
ShopNest’s browser cart uses modern JavaScript: fetch APIs with async/await, modules, and clear error handling.
JavaScript JavaScript Tutorial · JavaScript
Short answer: Variables declared with let or const inside curly braces {} are accessible only within that block. Example: if (true) { let y = 20; const z = 30; } // console.log(y, z); // ReferenceError
Variables declared with let or const inside curly braces {} are accessible only within that block. Example: if (true) {
let y = 20;
const z = 30;
} // console.log(y, z); // ReferenceError
In ShopNest’s cart UI, a click handler closes over productId. Use let in loops so each button keeps the correct id.