Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
1 views

Advanced JavaScript Questions Full

The document contains 50 advanced JavaScript questions along with detailed answers covering key concepts such as variable declarations, closures, the event loop, promises, and asynchronous programming. It explains differences between various JavaScript features like 'var', 'let', and 'const', as well as function declarations versus expressions. Additionally, it discusses advanced topics like memoization, generators, and the use of weak references in data structures.

Uploaded by

sujeetnangare
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
1 views

Advanced JavaScript Questions Full

The document contains 50 advanced JavaScript questions along with detailed answers covering key concepts such as variable declarations, closures, the event loop, promises, and asynchronous programming. It explains differences between various JavaScript features like 'var', 'let', and 'const', as well as function declarations versus expressions. Additionally, it discusses advanced topics like memoization, generators, and the use of weak references in data structures.

Uploaded by

sujeetnangare
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

50 Advanced JavaScript Questions with Detailed Answers

1. What is the difference between var, let, and const?


var is function-scoped and can be redeclared; let is block-scoped and cannot be redeclared; const is
block-scoped and immutable after initialization.

2. What is closure in JavaScript?


A closure is a function that retains access to its lexical scope even when executed outside that
scope.

3. What is the event loop in JavaScript?


The event loop is a mechanism that handles asynchronous operations by pushing callbacks from
the event queue to the call stack.

4. What is hoisting in JavaScript?


Hoisting moves variable and function declarations to the top of their containing scope before
execution.

5. What is the difference between == and === in JavaScript?


== checks for value equality with type coercion, whereas === checks for both value and type
equality.

6. What is a Promise in JavaScript?


A Promise represents a value that may be available now, or in the future, or never, and it has states:
pending, resolved, or rejected.

7. What are async and await in JavaScript?


async makes a function return a Promise, and await pauses execution until the Promise resolves.

8. What are arrow functions, and how are they different from regular functions?
Arrow functions have a shorter syntax and do not have their own this, arguments, or prototype.

9. What is the difference between null and undefined?


null is an assigned value representing no value, whereas undefined means a variable has been
declared but not assigned a value.

10. What is the difference between function declaration and function expression?
Function declarations are hoisted, whereas function expressions are not.

11. What is the difference between call, apply, and bind?


call invokes a function with a specific 'this' and arguments, apply is similar but takes an array of
arguments, and bind returns a new function with 'this' set.

12. What is an IIFE (Immediately Invoked Function Expression)?


An IIFE is a function that executes immediately after its definition, often used to create a local
scope.

13. What is a higher-order function?


A higher-order function is a function that takes another function as an argument or returns a
function.

14. What is the difference between spread and rest operators?


The spread operator (...) expands elements, whereas the rest operator (...) collects them into an
array.

15. What is debouncing and throttling?


Debouncing delays execution until after a pause in activity, whereas throttling limits execution to a
fixed rate.

16. What is the difference between shallow and deep copy?


A shallow copy copies object references, whereas a deep copy clones objects recursively to avoid
reference issues.

17. What are JavaScript generators?


Generators are functions that can be paused and resumed using the 'yield' keyword.

18. What is the difference between synchronous and asynchronous programming?


Synchronous code executes sequentially, whereas asynchronous code allows non-blocking
execution using callbacks, promises, or async/await.

19. What is memoization in JavaScript?


Memoization is an optimization technique that caches function results to improve performance.

20. What are weakMap and weakSet in JavaScript?


WeakMap and WeakSet store weakly referenced keys, allowing garbage collection when keys are
no longer needed.

You might also like