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

JavaScript Concepts Explained

The document provides an overview of JavaScript concepts including its definition, variable declarations (var, let, const), hoisting, and the differences between equality operators. It also covers advanced topics such as closures, promises, async/await, event loop, and various programming paradigms like OOP, encapsulation, and polymorphism. Additionally, it explains modern features like modules, destructuring, and the Fetch API, highlighting their significance in JavaScript development.

Uploaded by

mrabop007
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)
32 views4 pages

JavaScript Concepts Explained

The document provides an overview of JavaScript concepts including its definition, variable declarations (var, let, const), hoisting, and the differences between equality operators. It also covers advanced topics such as closures, promises, async/await, event loop, and various programming paradigms like OOP, encapsulation, and polymorphism. Additionally, it explains modern features like modules, destructuring, and the Fetch API, highlighting their significance in JavaScript development.

Uploaded by

mrabop007
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

1. What is JavaScript?

JavaScript is a high-level, interpreted programming language that powers dynamic web content. It
can run on browsers and servers ([Link]).

2. Difference between var, let, and const


var: function-scoped, hoisted as undefined, redeclarable. let: block-scoped, hoisted but in temporal
dead zone. const: block-scoped, cannot be reassigned or redeclared.

3. What is Hoisting?
Declarations are moved to the top of their scope during compilation. var is hoisted as undefined,
let/const stay in TDZ.

4. Difference between == and ===


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

5. What are Closures?


Closure is when a function remembers variables from its lexical scope even if called outside that
scope.

6. Explain Event Loop in JavaScript


Event loop continuously checks call stack and callback/microtask queue to handle async code
without blocking execution.

7. What is a Promise?
A promise represents eventual completion or failure of an async task. States: pending, fulfilled,
rejected.

8. What is async/await?
Syntactic sugar over promises that allows writing async code in a synchronous style.

9. What are Higher-Order Functions?


Functions that take other functions as arguments or return them. Example: map, filter, reduce.

10. What are Arrow Functions?


Compact function syntax with lexical this binding. Not suitable for methods requiring their own this.

11. Explain this keyword


this refers to the context object where function is executed. In strict mode can be undefined. Arrow
functions inherit this from enclosing scope.

12. What are JavaScript Modules?


Reusable code units that use import/export to share functionality between files.

13. Explain Debouncing & Throttling


Debounce: execute after user stops triggering events. Throttle: execute at most once per interval.

14. Explain call(), apply(), and bind()


call: [Link](thisArg, arg1,...), apply: [Link](thisArg, [args]), bind: returns a new function
permanently bound to thisArg.

15. Explain Prototypes and Prototype Chain


Objects inherit properties via prototype chain. Every object has __proto__ pointing to prototype of
constructor function.

16. Difference between classical OOP and prototypal OOP


Classical uses classes/instances, prototypal uses objects cloning objects. ES6 class is syntactic
sugar over prototypes.

17. Explain class and constructor in JS


class is blueprint for objects, constructor is special method called when creating instance.

18. Explain Inheritance in JS


Implemented via prototype chain or ES6 extends keyword. Enables child class to inherit parent
properties/methods.

19. Explain Encapsulation in JS


Achieved using closures or private class fields (#field). It hides internal implementation details.

20. Explain Polymorphism in JS


Different objects can share same method name but implement differently. Achieved using method
overriding.

21. Explain Abstraction in JS


Hide implementation details and expose only essential features. Achieved via modules, closures,
private fields.

22. Difference between function constructor and class


Class syntax is cleaner, supports extends/super, while function constructors use prototype
manually.

23. What is super keyword?


Used in class to call constructor or methods of parent class.

24. Explain [Link]()


Creates new object with specified prototype object and properties.

25. Explain [Link]()


Copies properties from source objects to target object (shallow copy).
26. Difference between shallow copy and deep copy
Shallow copy copies references of nested objects, deep copy creates full independent copy.

27. What is event delegation?


Attaching a single event listener to parent element to handle events of child elements using event
bubbling.

28. Explain bubbling and capturing


Bubbling: event propagates child → parent. Capturing: parent → child. useCapture flag decides
phase.

29. What is a generator function?


Function that can be paused/resumed using yield keyword. Useful for lazy evaluation and async
flow control.

30. Explain Symbol type


Unique and immutable primitive used as object keys to avoid name collisions.

31. Explain Set and Map


Set: collection of unique values. Map: key-value pairs where keys can be any type.

32. Difference between WeakMap and Map


WeakMap keys must be objects and are garbage collected if no reference remains.

33. Explain garbage collection in JS


Automatic memory management using reference counting and mark-and-sweep algorithm.

34. What causes memory leaks?


Uncleared timers, detached DOM nodes, global variables, event listeners not removed.

35. Explain typeof and instanceof


typeof checks data type of variable, instanceof checks if object is instance of a constructor.

36. Explain IIFE


Immediately Invoked Function Expression used to create private scope and avoid polluting global
scope.

37. Explain Module Pattern


Uses IIFE + closures to create private/public members.

38. Explain Currying


Transforming function of multiple arguments into nested unary functions. Example: f(a,b) -> f(a)(b).

39. Explain Composition over Inheritance


Favor combining small reusable functions/objects rather than deep class hierarchies.

40. Explain [Link] and [Link]


Used to convert object to JSON string and back respectively.

41. Explain strict mode


Adds stricter parsing and error handling. Example: prevents accidental globals, disallows duplicate
params.

42. What is Temporal Dead Zone?


Phase between hoisting and initialization of let/const where accessing variable throws
ReferenceError.

43. Explain ES6 Destructuring


Allows unpacking values from arrays/objects into distinct variables.

44. Explain Spread and Rest operators


... used to spread elements or collect remaining arguments into array.

45. Explain Optional Chaining


?. operator allows safe access to nested properties without throwing errors if undefined/null.

46. Explain Nullish Coalescing


?? returns right-hand operand only if left is null or undefined, not falsy like 0 or ''.

47. Explain Fetch API


Modern interface for making HTTP requests. Returns promises.

48. Explain Async Iterators


Use for-await-of loop to consume data from async sources like streams.

49. Explain Microtasks vs Macrotasks


Microtasks (Promise callbacks) executed before next render cycle. Macrotasks (setTimeout) after
rendering.

50. Explain Service Workers


Background scripts for caching, push notifications, offline support.

You might also like