🚀 JavaScript Interview Quick Revision Q. What is the difference between localStorage and sessionStorage? Answer: Persistence duration — localStorage persists indefinitely; sessionStorage clears on tab close. Q. What is the difference between document.ready and window.onload? Answer: document.ready triggers when DOM is ready; window.onload when all assets load. Q. What are JavaScript timers? Answer: Functions like setTimeout and setInterval to schedule code execution. Q. What is debouncing? Answer: Technique to limit how often a function is called. Q. What is throttling? Answer: Technique to make sure a function is called at most once per interval. 📘 These are part of my 3000+ JavaScript Interview Questions & Answers book. If you're preparing for frontend interviews, structured revision matters. Comment “JS” if you want the book link.
JavaScript Interview Revision: localStorage, sessionStorage, Timers & More
More Relevant Posts
-
JavaScript Interview Question: What is a Promise in JavaScript? Answer: A Promise is an object that represents the eventual completion or failure of an asynchronous operation. A Promise can be in three states: 1. pending 2. fulfilled 3. rejected Example: 𝘤𝘰𝘯𝘴𝘵 𝘱𝘳𝘰𝘮𝘪𝘴𝘦 = 𝘯𝘦𝘸 𝘗𝘳𝘰𝘮𝘪𝘴𝘦((𝘳𝘦𝘴𝘰𝘭𝘷𝘦, 𝘳𝘦𝘫𝘦𝘤𝘵) => { 𝘴𝘦𝘵𝘛𝘪𝘮𝘦𝘰𝘶𝘵(() => 𝘳𝘦𝘴𝘰𝘭𝘷𝘦("𝘋𝘰𝘯𝘦"), 1000) }) Explanation: Promises allow developers to handle asynchronous operations without deeply nested callbacks. They make async code easier to read and manage. Follow-up Interview Question: Why were Promises introduced in JavaScript? Answer: To solve problems like callback hell and better manage asynchronous workflows. #javascript #promises #AsyncProgramming #WebDevelopment
To view or add a comment, sign in
-
🔥 Top 10 JavaScript Interview Questions You Must Know 🔥 (These decide your JS fundamentals) 1️⃣ var vs let vs const var → function scoped let / const → block scoped 👉 const is preferred by default. 2️⃣ What is Hoisting? Variables and functions are moved to the top during execution. 👉 let and const are hoisted but not initialized. 3️⃣ What is Closure? A function remembers variables from its outer scope. 👉 Very common and very important. 4️⃣ == vs === == → compares value (type conversion) === → compares value + type 👉 Always prefer ===. 5️⃣ What is the Event Loop? It handles async operations like callbacks and promises. 👉 Explains how JS is non-blocking. 6️⃣ Promise vs Callback Promise → cleaner, chainable, better error handling Callback → can cause callback hell 👉 Promises improved async code. 7️⃣ What is this keyword? this depends on how a function is called. 👉 Context matters, not where it’s written. 8️⃣ What is Debouncing and Throttling? Debouncing → delays execution Throttling → limits execution rate 👉 Used for performance optimization. 9️⃣ What is Spread vs Rest operator? Spread → expands values Rest → collects values 👉 Same syntax, different use. 🔟 What is Prototype in JavaScript? Objects inherit properties via prototype chain. 👉 Core concept behind JS inheritance. 💡 JavaScript interviews test concepts, not syntax. 💪 One goal – SELECTION #javascript #Interview #questions #mostasking #important #save
To view or add a comment, sign in
-
JavaScript Interview Question: What is Promise.all()? Answer: Promise.all() runs multiple promises in parallel and resolves when all succeed. Example: 𝘗𝘳𝘰𝘮𝘪𝘴𝘦.𝘢𝘭𝘭([𝘧𝘦𝘵𝘤𝘩𝘜𝘴𝘦𝘳𝘴(), 𝘧𝘦𝘵𝘤𝘩𝘗𝘰𝘴𝘵𝘴()]) .𝘵𝘩𝘦𝘯(([𝘶𝘴𝘦𝘳𝘴, 𝘱𝘰𝘴𝘵𝘴]) => { 𝘤𝘰𝘯𝘴𝘰𝘭𝘦.𝘭𝘰𝘨(𝘶𝘴𝘦𝘳𝘴, 𝘱𝘰𝘴𝘵𝘴) }) Explanation: If any Promise fails, Promise.all() immediately rejects. Follow-up Interview Question: When should you use Promise.all()? Answer: When multiple independent async tasks can run simultaneously. #javascript #promises #AsyncProgramming #FrontendDevelopment
To view or add a comment, sign in
-
🚀 5 Advanced JavaScript Interview Questions Every Developer Should Know JavaScript interviews often go beyond basics. Understanding core concepts helps you write cleaner and more efficient code. Here are 5 advanced JavaScript questions with simple explanations: 1️⃣ What is Closures in JavaScript? A closure occurs when a function remembers variables from its outer scope even after the outer function has finished executing. 2️⃣ What is the Event Loop? The event loop allows JavaScript to handle asynchronous operations like API calls and timers by managing the call stack and callback queue. 3️⃣ What is the difference between == and ===? • == → Compares values after type conversion • === → Strict comparison (value + type) 4️⃣ What is Hoisting in JavaScript? Hoisting means variable and function declarations are moved to the top of their scope during compilation. 5️⃣ What are Promises in JavaScript? Promises handle asynchronous operations and have three states: Pending → Fulfilled → Rejected. 💡 Understanding these concepts helps developers build scalable and reliable applications. #JavaScript #WebDevelopment #Frontend #MERN #Programming #CodingInterview #Developer #JS
To view or add a comment, sign in
-
💻 JavaScript Interview Question Write a function that takes a string input, and returns the first character that is not repeated anywhere in the string. For example, if given the input "stress", the function should return 't', since the letter t only occurs once in the string, and occurs first in the string. If a string contains only repeating characters, return an empty string (""); function firstNonRepeatingLetter(s) { let mySet = new Set(); //stress for(let c of s) { if(mySet.has(c.toLowerCase())) { mySet.delete(c.toLowerCase()); } else if(mySet.has(c.toUpperCase())) { mySet.delete(c.toUpperCase()); } else { mySet.add(c); } } const setAsArray = Array.from(mySet); if(setAsArray.length == 0) return (""); return (setAsArray[0]); } #javaScript #CodingInterview #WebDevelopment #Frontend #React
To view or add a comment, sign in
-
🚀 20 Advanced JavaScript Interview Questions Every Developer Should Know If you're preparing for interviews or want to test your JavaScript depth, try answering these without Googling. Let’s see how many you get right 👇 1️⃣ What is the difference between shallow copy and deep copy in JavaScript? 2️⃣ How does the JavaScript event loop work? 3️⃣ What is a closure, and how is it useful in real-world applications? 4️⃣ What is the difference between call(), apply(), and bind()? 5️⃣ What is currying in JavaScript? 6️⃣ What is the difference between Promise.all(), Promise.allSettled(), Promise.race(), and Promise.any()? 7️⃣ What is hoisting in JavaScript, and how does it affect var, let, and const? 8️⃣ What is the difference between microtasks and macrotasks in the event loop? 9️⃣ What are prototypes and the prototype chain in JavaScript? 🔟 What is debouncing vs throttling, and when should each be used? 1️⃣1️⃣ What is the difference between null and undefined? 1️⃣2️⃣ What is type coercion in JavaScript? 1️⃣3️⃣ What are pure functions in JavaScript? 1️⃣4️⃣ What is the difference between synchronous and asynchronous JavaScript? 1️⃣5️⃣ What is the difference between map(), filter(), and reduce()? 1️⃣6️⃣ What is the difference between Object.freeze() and Object.seal()? 1️⃣7️⃣ What are generators in JavaScript? 1️⃣8️⃣ What is the difference between ES Modules and CommonJS? 1️⃣9️⃣ What is memoization in JavaScript? 2️⃣0️⃣ How does garbage collection work in JavaScript? #javascript #webdevelopment #frontend #coding #softwareengineering #developers
To view or add a comment, sign in
-
JavaScript Interview Question (Confusing but Important 🤯) What will be the output? console.log([] == []); console.log([] === []); console.log({} == {}); console.log({} === {}); 👉 Answer: All will be false Why? Arrays and objects in JavaScript are stored in memory by reference, not by value. Each [] or {} creates a new object with a different memory address, and JavaScript compares references — not structure or content. Same shape ≠ same reference 📌 This is one of the most common JavaScript interview traps. #JavaScript #InterviewQuestions #WebDevelopment #Frontend #Backend #CodingTips
To view or add a comment, sign in
-
🚀 Day 23/100 – #100DaysOfCode JavaScript Interview Questions (Advanced Concepts) Continuing with JavaScript fundamentals, today I reviewed some important interview questions that test a deeper understanding of how JavaScript works under the hood. 🔹 Hoisting Hoisting is JavaScript’s behavior where variable and function declarations are moved to the top of their scope before execution. var is hoisted with undefined, while let and const are hoisted but remain in the temporal dead zone. 🔹 Callback Function A callback is a function passed as an argument to another function, which is executed later. Commonly used in: -Asynchronous operations (API calls) -Event handling 🔹 Closure A closure is a function that remembers variables from its lexical scope even after the outer function has finished execution. This is heavily used in: -Data encapsulation -Maintaining private variables 🔹 Pass by Value vs Pass by Reference Pass by Value: A copy of the value is passed (Primitive types) Pass by Reference: A reference to the original object is passed (Objects, Arrays) Changes in reference types affect the original data, while primitive changes do not. Understanding these concepts is critical because they often separate beginners from intermediate developers in interviews. 23 days down, 77 more to go. #Day23 #100DaysOfCode #JavaScript #FrontendDevelopment #WebDevelopment #CodingInterview #MERN
To view or add a comment, sign in
-
💡 One of the Most Asked JavaScript Closure Questions in Interviews Closures are one of the most frequently tested concepts in JavaScript interviews. A classic output-based question looks like this: function createFunctions() { var arr = []; for (var i = 0; i < 3; i++) { arr.push(function () { console.log(i); }); } return arr; } const functions = createFunctions(); functions[0](); functions[1](); functions[2](); ❓ What will be the output? 3 3 3 🤔 Why does this happen? Because of closures. Each function inside the array does not capture the value of i. Instead, it captures the reference to the same variable i. By the time the functions are executed, the loop has already finished and i becomes 3. So every function prints: 3 ✅ How to fix it? Use let instead of var: for (let i = 0; i < 3; i++) { arr.push(function () { console.log(i); }); } Now the output will be: 0 1 2 Because let creates a new block-scoped variable for each iteration. 📌 Interview Tip Whenever closures are used inside loops: • var → Same variable shared • let → New variable per iteration Understanding this difference can help you solve many tricky JavaScript interview questions. 💬 Quick challenge: Without using let, how would you modify the code to print 0 1 2? Comment your solution 👇 #JavaScript #FrontendDevelopment #WebDevelopment #Closures #JavaScriptInterview
To view or add a comment, sign in
-
JavaScript Event Loop — Interview Important One of the most frequently asked JavaScript interview topics is the Event Loop. JavaScript is single-threaded, but it handles asynchronous tasks efficiently using: • Call Stack • Web APIs • Callback Queue • Event Loop How it works (simple explanation): 1️⃣ Synchronous code runs first (Call Stack). 2️⃣ Async tasks (setTimeout, fetch, promises) go to Web APIs. 3️⃣ Once completed, they move to the Callback Queue. 4️⃣ The Event Loop pushes them back to the Call Stack when it’s empty. Understanding this helps you answer questions like: • Why does setTimeout sometimes run later than expected? • How do Promises work internally? • What is the difference between microtasks and macrotasks? Mastering the Event Loop shows strong JavaScript fundamentals — and interviewers notice that. #JavaScript #InterviewPreparation #FrontendDeveloper #WebDevelopment
To view or add a comment, sign in
Explore related topics
Explore content categories
- Career
- Productivity
- Finance
- Soft Skills & Emotional Intelligence
- Project Management
- Education
- Technology
- Leadership
- Ecommerce
- User Experience
- Recruitment & HR
- Customer Experience
- Real Estate
- Marketing
- Sales
- Retail & Merchandising
- Science
- Supply Chain Management
- Future Of Work
- Consulting
- Writing
- Economics
- Artificial Intelligence
- Employee Experience
- Workplace Trends
- Fundraising
- Networking
- Corporate Social Responsibility
- Negotiation
- Communication
- Engineering
- Hospitality & Tourism
- Business Strategy
- Change Management
- Organizational Culture
- Design
- Innovation
- Event Planning
- Training & Development