JavaScript remains one of the most important skills for frontend, backend, and full-stack developers. In technical interviews—especially for experienced professionals—interviewers expect both conceptual clarity and hands-on coding ability.
This blog covers core to advanced JavaScript interview questions, along with commonly asked programs, explained in a clear and structured way.
1. What is JavaScript?
JavaScript is a single-threaded, synchronous, and event-driven programming language. It is widely used to build interactive web applications and now also powers backend services using Node.js.
Key features:
Interpreted (JIT compiled)
Prototype-based
Dynamically typed
Event-driven
2. Difference Between var, let, and const
Feature var let const
Scope Function Block Block
Hoisting Yes (undefined) Yes (TDZ) Yes (TDZ)
Redeclaration Allowed Not allowed Not allowed
Reassignment Allowed Allowed Not allowed
3. What is Hoisting?
Hoisting is JavaScript’s default behavior of moving declarations to the top of the scope before execution.
console.log(a); var a = 10;
Output: undefined
Reason: Declaration is hoisted, not initialization.
4. Temporal Dead Zone (TDZ)
TDZ is the time between entering a scope and declaring a variable using let or const.
console.log(x); let x = 5;
Result: ReferenceError
5. Difference Between == and ===
== performs type coercion
=== checks value and type
5 == "5" // true 5 === "5" // false
6. What is a Closure?
A closure is created when a function remembers variables from its outer scope, even after the outer function has finished executing.
function counter() { let count = 0; return function () { count++; return count; }; } const increment = counter(); increment(); // 1 increment(); // 2
7. What is the Scope Chain?
When a variable is accessed, JavaScript searches:
Local scope
Parent scope
Global scope
8. What is the Event Loop?
The event loop allows JavaScript to perform non-blocking asynchronous operations.
Execution order:
Call Stack
Microtask Queue (Promises)
Macrotask Queue (setTimeout, setInterval)
9. What are Promises?
Promises represent the eventual completion or failure of an asynchronous operation.
const promise = new Promise((resolve, reject) => { resolve("Success"); }); promise.then(result => console.log(result));
10. Async/Await
async/await makes asynchronous code easier to read and write.
async function fetchData() { const response = await fetch("api/data"); const data = await response.json(); return data; }
11. What is Currying?
Currying transforms a function with multiple arguments into nested single-argument functions.
const add = a => b => c => a + b + c; add(1)(2)(3); // 6
12. Debouncing
Debouncing delays function execution until a certain time has passed.
function debounce(fn, delay) { let timer; return function (...args) { clearTimeout(timer); timer = setTimeout(() => fn.apply(this, args), delay); }; }
13. Throttling
Throttling ensures a function runs at most once per interval.
function throttle(fn, limit) { let flag = true; return function (...args) { if (flag) { fn.apply(this, args); flag = false; setTimeout(() => flag = true, limit); } }; }
14. Memoization
Memoization improves performance by caching results.
function memoize(fn) { const cache = {}; return function (n) { if (cache[n]) return cache[n]; return cache[n] = fn(n); }; }
15. call, apply, and bind
| Method | Execution | Arguments |
|---|---|---|
| call | Immediate | Comma separated |
| apply | Immediate | Array |
| bind | Later | Comma separated |
function greet(city) { return `Hello ${this.name} from ${city}`; } greet.call({ name: "John" }, "Delhi");
Common JavaScript Programs
Reverse a String
function reverseString(str) { return str.split('').reverse().join(''); }
Check Palindrome
function isPalindrome(str) { return str === str.split('').reverse().join(''); }
Factorial of a Number
function factorial(n) { return n <= 1 ? 1 : n * factorial(n - 1); }
Remove Duplicates from Array
function removeDuplicates(arr) { return [...new Set(arr)]; }
Find Maximum Number in Array
function findMax(arr) { return Math.max(...arr); }
Flatten an Array
function flattenArray(arr) { return arr.flat(Infinity); }
Sum of Array Elements
function sumArray(arr) { return arr.reduce((a, b) => a + b, 0); }
Deep Clone an Object
function deepClone(obj) { return JSON.parse(JSON.stringify(obj)); }
Tricky JavaScript Output Questions
console.log([] + []);
Output: “”
console.log([] + {});
Output: “[object Object]”
Final Thoughts
For experienced JavaScript developers, interviews focus on:
Execution context
Asynchronous behavior
Performance optimization
Real-world problem solving
Mastering these concepts – and practicing the programs – will significantly boost your confidence.

