0% found this document useful (0 votes)
23 views4 pages

JavaScript Interview Questions 3 To 5 Years

The document provides a comprehensive overview of JavaScript concepts, including definitions and differences between key terms such as variables, functions, and asynchronous programming. It covers topics like closures, promises, event handling, and ES6 features, along with practical programming techniques like currying and memoization. Additionally, it highlights common pitfalls and best practices in JavaScript development.

Uploaded by

Arif Shaikh
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
23 views4 pages

JavaScript Interview Questions 3 To 5 Years

The document provides a comprehensive overview of JavaScript concepts, including definitions and differences between key terms such as variables, functions, and asynchronous programming. It covers topics like closures, promises, event handling, and ES6 features, along with practical programming techniques like currying and memoization. Additionally, it highlights common pitfalls and best practices in JavaScript development.

Uploaded by

Arif Shaikh
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Q1. What is JavaScript and where is it used?

JavaScript is a high-level, interpreted programming language primarily used for building interactive
web applications. It runs in browsers and on servers via environments like [Link].

Q2. Difference between var, let, and const?


var is function-scoped and hoisted, let and const are block-scoped. const prevents reassignment,
while let allows it.

Q3. What is hoisting?


Hoisting is JavaScript's default behavior of moving variable and function declarations to the top of
their scope before execution.

Q4. Explain closures.


A closure is a function that retains access to variables from its lexical scope even after the outer
function has executed.

Q5. What is the event loop?


The event loop handles asynchronous operations by pushing callbacks from the task queue to the
call stack when it is empty.

Q6. Difference between == and ===?


== performs type coercion before comparison, while === checks both value and type strictly.

Q7. What are promises?


Promises represent the eventual completion or failure of an asynchronous operation and help avoid
callback hell.

Q8. Promise vs async/await?


async/await is syntactic sugar over promises, providing cleaner and more readable asynchronous
code.

Q9. What is callback hell?


Callback hell occurs when multiple nested callbacks make code hard to read and maintain.

Q10. Explain arrow functions.


Arrow functions provide a concise syntax and do not bind their own this, inheriting it from the
surrounding scope.

Q11. What is 'this' keyword?


'this' refers to the object that is executing the current function, determined by how the function is
called.

Q12. Explain call, apply, and bind.


They are methods used to explicitly set the value of this for a function invocation.
Q13. What is prototypal inheritance?
JavaScript objects inherit properties from other objects via the prototype chain.

Q14. Difference between null and undefined?


undefined means a variable has been declared but not assigned, null is an intentional absence of
value.

Q15. What is a higher-order function?


A function that takes another function as an argument or returns a function.

Q16. Explain map, filter, reduce.


Array methods used for transforming, filtering, and reducing arrays into single values.

Q17. What is immutability?


Immutability means data cannot be changed after creation; instead, new copies are created.

Q18. Explain shallow vs deep copy.


Shallow copy duplicates references, deep copy duplicates all nested objects.

Q19. What is debounce?


Debounce limits function execution until a specified delay has passed after the last call.

Q20. What is throttle?


Throttle ensures a function executes at most once in a given time interval.

Q21. Explain event delegation.


Event delegation uses event bubbling to handle events at a parent level.

Q22. What are ES6 features?


Includes let/const, arrow functions, destructuring, spread/rest, classes, and modules.

Q23. What is destructuring?


Destructuring extracts values from arrays or objects into variables.

Q24. Explain spread and rest operators.


Spread expands elements, rest collects remaining elements.

Q25. What are modules?


Modules allow code splitting using import and export statements.

Q26. What is strict mode?


Strict mode enforces stricter parsing and error handling.

Q27. What is memory leak?


Occurs when unused memory is not released, often due to lingering references.

Q28. Explain garbage collection.


JavaScript automatically frees memory by removing unreachable objects.

Q29. What is NaN?


NaN stands for Not-a-Number and represents an invalid numeric value.

Q30. Difference between synchronous and asynchronous code?


Synchronous code blocks execution, asynchronous code allows non-blocking operations.

Q31. What is setTimeout vs setInterval?


setTimeout runs once after delay, setInterval runs repeatedly at intervals.

Q32. What is currying?


Transforming a function with multiple arguments into a sequence of functions.

Q33. Explain lexical scope.


Scope determined by the location of variables in source code.

Q34. What is a polyfill?


Polyfills provide modern functionality in older browsers.

Q35. Explain try/catch.


Used to handle runtime errors gracefully.

Q36. What is IIFE?


Immediately Invoked Function Expression executes as soon as defined.

Q37. What is JSON?


A lightweight data-interchange format.

Q38. Explain deep equality.


Checks whether nested objects have equal values.

Q39. What is [Link]()?


Prevents modification of object properties.

Q40. Difference between map and forEach?


map returns a new array, forEach does not.

Q41. What is DOM?


The Document Object Model represents HTML as objects.

Q42. What is BOM?


Browser Object Model provides browser-specific objects like window.

Q43. Explain event bubbling.


Events propagate from child to parent.

Q44. What is shadowing?


Inner variables overriding outer scope variables.

Q45. What is temporal dead zone?


The time between block start and variable declaration where access is forbidden.

Q46. Explain weakMap.


A collection of key-value pairs with weakly referenced keys.

Q47. What is BigInt?


Used for handling integers larger than Number.MAX_SAFE_INTEGER.

Q48. Explain memoization.


Caching results of expensive function calls.

Q49. What is tree shaking?


Removing unused code during build time.

Q50. Common JavaScript pitfalls?


Type coercion issues, this binding, async bugs, memory leaks.

You might also like