Master technical and career interviews with structured answers—short definition, real examples, pitfalls, and how to answer in 60–90 seconds.
Short answer: Functions that execute immediately after being defined. Example code (function() { console.log("Runs instantly!"); })(); Used to create private scopes before let and const. Real-world example (Sho…
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: GPU acceleration is triggered when you use transform, opacity, or will-change. It moves rendering to the GPU, making animations smoother. Example code .box { transform: translateZ(0); Follow me on LinkedIn:…
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: Browsers are forgiving — they use an HTML parser that tries to fix mistakes automatically. For example, missing closing tags are inferred. Example: <p>This is valid Follow me on LinkedIn: <p>Thi…
Short answer: YouTube provides an embed link using <iframe>. Example code <iframe width="560" height="315" src=" allowfullscreen> </iframe> Key Takeaway: Always use the /embed/…
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: Modals are created using the .modal class and toggled with JS or data attributes. <button data-bs-toggle="modal" data-bs-target="#myModal">Open</button> <div class="m…
Short answer: A polyfill is a piece of code that adds a feature missing in older browsers. Follow me on LinkedIn: Example code if (!Array.prototype.includes) { Array.prototype.includes = function(item) { return this.inde…
Short answer: Functions that: Return the same output for the same input. Have no side effects. Example: function add(a, b) { return a + b; // pure } Example code Functions that: Return the same output for the same input.…
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: CSS Houdini is a set of APIs that let developers extend CSS by writing code that hooks directly into the CSS engine. Explain a bit more Examples: Paint API → Custom background drawing. Layout API → Define c…
Short answer: Use the following combination: p { width: 200px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } Key Takeaway: Truncates long text with “…” when it exceeds container width. Real-world exam…
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: Entities display reserved characters (like <, >, &) or symbols not on the keyboard. Example code <p>Use <div> for containers and &amp; for ampersands.</p> Key Takeaway: Entit…
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…
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: Follow me on LinkedIn: Comments are added using: <!-- This is a comment --> Example: <!-- TODO: Add footer here --> Key Takeaway: Comments help others understand your code — they don’t appear on…
Short answer: Reusable UI blocks like buttons, modals, navbars, forms, alerts, etc., that Bootstrap’s design standards. Real-world example (ShopNest) ShopNest’s browser cart uses modern JavaScript: fetch APIs with async/…
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…
JavaScript JavaScript Tutorial · JavaScript
Short answer: Functions that execute immediately after being defined.
(function() { console.log("Runs instantly!"); })(); Used to create private scopes before let and const.
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: GPU acceleration is triggered when you use transform, opacity, or will-change. It moves rendering to the GPU, making animations smoother.
.box { transform: translateZ(0); Follow me on LinkedIn: } Key Takeaway: Use GPU-friendly properties for smoother transitions; avoid triggering layout changes.
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: Browsers are forgiving — they use an HTML parser that tries to fix mistakes automatically. For example, missing closing tags are inferred. Example: <p>This is valid Follow me on LinkedIn: <p>This is auto-closed by browser</p> Key Takeaway: Browsers recover from errors, but writing valid HTML ensures consistent rendering.
JavaScript JavaScript Tutorial · JavaScript
Short answer: YouTube provides an embed link using <iframe>.
<iframe width="560" height="315" src=" allowfullscreen> </iframe> Key Takeaway: Always use the /embed/ URL format for proper YouTube embedding.
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: Modals are created using the .modal class and toggled with JS or data attributes. <button data-bs-toggle="modal" data-bs-target="#myModal">Open</button> <div class="modal fade" id="myModal"> <div class="modal-dialog"><div class="modal-content">...</div></div> </div>
ShopNest’s browser cart uses modern JavaScript: fetch APIs with async/await, modules, and clear error handling.
JavaScript JavaScript Tutorial · JavaScript
Short answer: A polyfill is a piece of code that adds a feature missing in older browsers. Follow me on LinkedIn:
if (!Array.prototype.includes) { Array.prototype.includes = function(item) { return this.indexOf(item) !== -1; }; }
ShopNest’s browser cart uses modern JavaScript: fetch APIs with async/await, modules, and clear error handling.
JavaScript JavaScript Tutorial · JavaScript
Short answer: Functions that: Return the same output for the same input. Have no side effects. Example: function add(a, b) { return a + b; // pure }
Functions that: Return the same output for the same input. Have no side effects. Example: function add(a, b) { return a + b; // pure
}
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: CSS Houdini is a set of APIs that let developers extend CSS by writing code that hooks directly into the CSS engine.
Examples: Paint API → Custom background drawing. Layout API → Define custom layout logic. Properties & Values API → Register custom CSS properties. Example (Paint API): registerPaint('dots', class { paint(ctx, size) { ctx.fillStyle = 'red'; ctx.arc(50, 50, 10, 0, 2 * Math.PI); ctx.fill(); } }); Key Takeaway: Houdini gives developers low-level control over how CSS works under the hood.
ShopNest’s browser cart uses modern JavaScript: fetch APIs with async/await, modules, and clear error handling.
JavaScript JavaScript Tutorial · JavaScript
Short answer: Use the following combination: p { width: 200px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } Key Takeaway: Truncates long text with “…” when it exceeds container width.
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: Entities display reserved characters (like <, >, &) or symbols not on the keyboard.
<p>Use <div> for containers and & for ampersands.</p> Key Takeaway: Entities prevent HTML from confusing symbols with code.
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.
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: Follow me on LinkedIn: Comments are added using: <!-- This is a comment --> Example: <!-- TODO: Add footer here --> Key Takeaway: Comments help others understand your code — they don’t appear on the page.
ShopNest’s browser cart uses modern JavaScript: fetch APIs with async/await, modules, and clear error handling.
JavaScript JavaScript Tutorial · JavaScript
Short answer: Reusable UI blocks like buttons, modals, navbars, forms, alerts, etc., that Bootstrap’s design standards.
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.