JavaScript Interview Questions (Basic to Advanced)
1. What are the different data types present in JavaScript?
JavaScript provides different data types such as String, Number, BigInt, Boolean, undefined, null,
Symbol, and Object.
2. What is the difference between var, let, and const?
'var' is function-scoped, 'let' and 'const' are block-scoped. 'const' variables cannot be reassigned.
3. What is hoisting in JavaScript?
Hoisting is JavaScript's default behavior of moving declarations to the top of the current scope.
4. What are template literals?
Template literals use backticks (``) and allow embedded expressions using ${expression}.
5. What is the difference between == and ===?
'==' compares values with type coercion, while '===' compares both value and type.
6. What is a closure?
A closure is a function having access to its own scope, the outer function's scope, and the global
scope.
7. What is event delegation?
Event delegation is a technique of handling events efficiently using a single event listener for
multiple child elements.
8. Explain the concept of promises in JavaScript.
A Promise is an object representing the eventual completion or failure of an asynchronous
operation.
9. What are arrow functions?
Arrow functions are a shorter syntax for writing functions using the => arrow. They do not have their
own 'this'.
10. What is the event loop?
The event loop is a mechanism that handles execution of multiple chunks of your program over time
in a non-blocking way.
11. What is the difference between synchronous and asynchronous code?
Synchronous code executes line-by-line; asynchronous code can run independently of the main
thread using callbacks, promises, or async/await.
12. What is 'this' keyword in JavaScript?
'this' refers to the object it belongs to. In strict mode, it is undefined in functions unless explicitly
bound.
13. What is the difference between call, apply, and bind?
'call' and 'apply' invoke functions with a given 'this'. 'bind' returns a new function with 'this' bound.
14. What are higher-order functions?
Functions that take other functions as arguments or return them as results.
15. What is a debounce function?
Debounce limits the rate at which a function is fired by delaying its execution until a certain time has
passed since the last call.