0% found this document useful (0 votes)
688 views

JavaScript Interview Questions 100+

The document provides a comprehensive list of common JavaScript interview questions and answers, covering topics such as data types, variable declarations (let, const, var), hoisting, equality operators, closures, the DOM, event loops, promises, and asynchronous programming. It also explains concepts like arrow functions, event delegation, callback functions, and JavaScript modules. Each question is succinctly answered, making it a useful resource for interview preparation.

Uploaded by

mahfujapple95
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)
688 views

JavaScript Interview Questions 100+

The document provides a comprehensive list of common JavaScript interview questions and answers, covering topics such as data types, variable declarations (let, const, var), hoisting, equality operators, closures, the DOM, event loops, promises, and asynchronous programming. It also explains concepts like arrow functions, event delegation, callback functions, and JavaScript modules. Each question is succinctly answered, making it a useful resource for interview preparation.

Uploaded by

mahfujapple95
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
You are on page 1/ 14

JavaScript Interview Questions and Answers

1. What are the data types in JavaScript?

JavaScript has the following data types:

- Primitive Types: String, Number, Boolean, undefined, null, BigInt, Symbol

- Non-Primitive Types: Object, Array, Function

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

- var: Function-scoped, can be redeclared, hoisted with undefined.

- let: Block-scoped, can be reassigned but not redeclared.

- const: Block-scoped, cannot be reassigned or redeclared.

3. What is hoisting in JavaScript?

Hoisting is JavaScript's default behavior of moving declarations to the top. Only the declarations are hoisted,

not the initializations.

4. What is the difference between == and ===?

`==` compares values after type conversion (loose equality), while `===` compares both value and type (strict

equality).

5. What are closures in JavaScript?

A closure is a function that has access to its outer function scope even after the outer function has returned.

6. What is the DOM?

The DOM (Document Object Model) represents the structure of an HTML document as a tree of objects that

JavaScript can manipulate.

7. What is an event loop in JavaScript?

The event loop is a mechanism that handles asynchronous callbacks. It ensures that non-blocking operations
JavaScript Interview Questions and Answers

(like setTimeout) are handled properly.

8. Explain the difference between synchronous and asynchronous code.

- Synchronous code is executed line by line.

- Asynchronous code can run in the background and does not block the execution of subsequent code.

9. What is a Promise in JavaScript?

A Promise is an object that represents the eventual completion (or failure) of an asynchronous operation and

its resulting value.

10. What is 'this' keyword in JavaScript?

`this` refers to the object that is executing the current function. Its value depends on how the function is

called.

11. What is the difference between null and undefined?

`undefined` means a variable has been declared but not assigned a value.

`null` is an assignment value that represents no value.

12. What is the use of 'use strict' in JavaScript?

It enables strict mode which catches common coding mistakes and prevents unsafe actions.

13. What are arrow functions?

Arrow functions are a shorter syntax for function expressions and do not bind their own `this`.

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

- `call`: Invokes function with given context and arguments.

- `apply`: Similar to call but arguments are in an array.


JavaScript Interview Questions and Answers

- `bind`: Returns a new function with bound context.

15. What is event delegation?

Event delegation is a technique where a single event listener is added to a parent element to manage events

for its children.

16. What is the difference between slice and splice?

- `slice`: Returns a shallow copy of a portion of an array.

- `splice`: Changes the contents of an array by removing or replacing elements.

17. What are template literals?

Template literals allow embedded expressions using backticks (`) and ${} placeholders.

18. What is a callback function?

A callback is a function passed into another function as an argument, which is then invoked inside the outer

function.

19. Explain async/await in JavaScript.

`async` functions return a promise. `await` pauses the execution until the promise is resolved.

20. What are JavaScript modules?

Modules allow you to split code into reusable files using `export` and `import` keywords.

21. What is the difference between null and undefined?

`undefined` means a variable has been declared but not assigned a value.

`null` is an assignment value that represents no value.


JavaScript Interview Questions and Answers

22. What is the use of 'use strict' in JavaScript?

It enables strict mode which catches common coding mistakes and prevents unsafe actions.

23. What are arrow functions?

Arrow functions are a shorter syntax for function expressions and do not bind their own `this`.

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

- `call`: Invokes function with given context and arguments.

- `apply`: Similar to call but arguments are in an array.

- `bind`: Returns a new function with bound context.

25. What is event delegation?

Event delegation is a technique where a single event listener is added to a parent element to manage events

for its children.

26. What is the difference between slice and splice?

- `slice`: Returns a shallow copy of a portion of an array.

- `splice`: Changes the contents of an array by removing or replacing elements.

27. What are template literals?

Template literals allow embedded expressions using backticks (`) and ${} placeholders.

28. What is a callback function?

A callback is a function passed into another function as an argument, which is then invoked inside the outer

function.

29. Explain async/await in JavaScript.


JavaScript Interview Questions and Answers

`async` functions return a promise. `await` pauses the execution until the promise is resolved.

30. What are JavaScript modules?

Modules allow you to split code into reusable files using `export` and `import` keywords.

31. What is the difference between null and undefined?

`undefined` means a variable has been declared but not assigned a value.

`null` is an assignment value that represents no value.

32. What is the use of 'use strict' in JavaScript?

It enables strict mode which catches common coding mistakes and prevents unsafe actions.

33. What are arrow functions?

Arrow functions are a shorter syntax for function expressions and do not bind their own `this`.

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

- `call`: Invokes function with given context and arguments.

- `apply`: Similar to call but arguments are in an array.

- `bind`: Returns a new function with bound context.

35. What is event delegation?

Event delegation is a technique where a single event listener is added to a parent element to manage events

for its children.

36. What is the difference between slice and splice?

- `slice`: Returns a shallow copy of a portion of an array.

- `splice`: Changes the contents of an array by removing or replacing elements.


JavaScript Interview Questions and Answers

37. What are template literals?

Template literals allow embedded expressions using backticks (`) and ${} placeholders.

38. What is a callback function?

A callback is a function passed into another function as an argument, which is then invoked inside the outer

function.

39. Explain async/await in JavaScript.

`async` functions return a promise. `await` pauses the execution until the promise is resolved.

40. What are JavaScript modules?

Modules allow you to split code into reusable files using `export` and `import` keywords.

41. What is the difference between null and undefined?

`undefined` means a variable has been declared but not assigned a value.

`null` is an assignment value that represents no value.

42. What is the use of 'use strict' in JavaScript?

It enables strict mode which catches common coding mistakes and prevents unsafe actions.

43. What are arrow functions?

Arrow functions are a shorter syntax for function expressions and do not bind their own `this`.

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

- `call`: Invokes function with given context and arguments.

- `apply`: Similar to call but arguments are in an array.

- `bind`: Returns a new function with bound context.


JavaScript Interview Questions and Answers

45. What is event delegation?

Event delegation is a technique where a single event listener is added to a parent element to manage events

for its children.

46. What is the difference between slice and splice?

- `slice`: Returns a shallow copy of a portion of an array.

- `splice`: Changes the contents of an array by removing or replacing elements.

47. What are template literals?

Template literals allow embedded expressions using backticks (`) and ${} placeholders.

48. What is a callback function?

A callback is a function passed into another function as an argument, which is then invoked inside the outer

function.

49. Explain async/await in JavaScript.

`async` functions return a promise. `await` pauses the execution until the promise is resolved.

50. What are JavaScript modules?

Modules allow you to split code into reusable files using `export` and `import` keywords.

51. What is the difference between null and undefined?

`undefined` means a variable has been declared but not assigned a value.

`null` is an assignment value that represents no value.

52. What is the use of 'use strict' in JavaScript?

It enables strict mode which catches common coding mistakes and prevents unsafe actions.
JavaScript Interview Questions and Answers

53. What are arrow functions?

Arrow functions are a shorter syntax for function expressions and do not bind their own `this`.

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

- `call`: Invokes function with given context and arguments.

- `apply`: Similar to call but arguments are in an array.

- `bind`: Returns a new function with bound context.

55. What is event delegation?

Event delegation is a technique where a single event listener is added to a parent element to manage events

for its children.

56. What is the difference between slice and splice?

- `slice`: Returns a shallow copy of a portion of an array.

- `splice`: Changes the contents of an array by removing or replacing elements.

57. What are template literals?

Template literals allow embedded expressions using backticks (`) and ${} placeholders.

58. What is a callback function?

A callback is a function passed into another function as an argument, which is then invoked inside the outer

function.

59. Explain async/await in JavaScript.

`async` functions return a promise. `await` pauses the execution until the promise is resolved.

60. What are JavaScript modules?


JavaScript Interview Questions and Answers

Modules allow you to split code into reusable files using `export` and `import` keywords.

61. What is the difference between null and undefined?

`undefined` means a variable has been declared but not assigned a value.

`null` is an assignment value that represents no value.

62. What is the use of 'use strict' in JavaScript?

It enables strict mode which catches common coding mistakes and prevents unsafe actions.

63. What are arrow functions?

Arrow functions are a shorter syntax for function expressions and do not bind their own `this`.

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

- `call`: Invokes function with given context and arguments.

- `apply`: Similar to call but arguments are in an array.

- `bind`: Returns a new function with bound context.

65. What is event delegation?

Event delegation is a technique where a single event listener is added to a parent element to manage events

for its children.

66. What is the difference between slice and splice?

- `slice`: Returns a shallow copy of a portion of an array.

- `splice`: Changes the contents of an array by removing or replacing elements.

67. What are template literals?

Template literals allow embedded expressions using backticks (`) and ${} placeholders.
JavaScript Interview Questions and Answers

68. What is a callback function?

A callback is a function passed into another function as an argument, which is then invoked inside the outer

function.

69. Explain async/await in JavaScript.

`async` functions return a promise. `await` pauses the execution until the promise is resolved.

70. What are JavaScript modules?

Modules allow you to split code into reusable files using `export` and `import` keywords.

71. What is the difference between null and undefined?

`undefined` means a variable has been declared but not assigned a value.

`null` is an assignment value that represents no value.

72. What is the use of 'use strict' in JavaScript?

It enables strict mode which catches common coding mistakes and prevents unsafe actions.

73. What are arrow functions?

Arrow functions are a shorter syntax for function expressions and do not bind their own `this`.

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

- `call`: Invokes function with given context and arguments.

- `apply`: Similar to call but arguments are in an array.

- `bind`: Returns a new function with bound context.

75. What is event delegation?

Event delegation is a technique where a single event listener is added to a parent element to manage events
JavaScript Interview Questions and Answers

for its children.

76. What is the difference between slice and splice?

- `slice`: Returns a shallow copy of a portion of an array.

- `splice`: Changes the contents of an array by removing or replacing elements.

77. What are template literals?

Template literals allow embedded expressions using backticks (`) and ${} placeholders.

78. What is a callback function?

A callback is a function passed into another function as an argument, which is then invoked inside the outer

function.

79. Explain async/await in JavaScript.

`async` functions return a promise. `await` pauses the execution until the promise is resolved.

80. What are JavaScript modules?

Modules allow you to split code into reusable files using `export` and `import` keywords.

81. What is the difference between null and undefined?

`undefined` means a variable has been declared but not assigned a value.

`null` is an assignment value that represents no value.

82. What is the use of 'use strict' in JavaScript?

It enables strict mode which catches common coding mistakes and prevents unsafe actions.

83. What are arrow functions?


JavaScript Interview Questions and Answers

Arrow functions are a shorter syntax for function expressions and do not bind their own `this`.

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

- `call`: Invokes function with given context and arguments.

- `apply`: Similar to call but arguments are in an array.

- `bind`: Returns a new function with bound context.

85. What is event delegation?

Event delegation is a technique where a single event listener is added to a parent element to manage events

for its children.

86. What is the difference between slice and splice?

- `slice`: Returns a shallow copy of a portion of an array.

- `splice`: Changes the contents of an array by removing or replacing elements.

87. What are template literals?

Template literals allow embedded expressions using backticks (`) and ${} placeholders.

88. What is a callback function?

A callback is a function passed into another function as an argument, which is then invoked inside the outer

function.

89. Explain async/await in JavaScript.

`async` functions return a promise. `await` pauses the execution until the promise is resolved.

90. What are JavaScript modules?

Modules allow you to split code into reusable files using `export` and `import` keywords.
JavaScript Interview Questions and Answers

91. What is the difference between null and undefined?

`undefined` means a variable has been declared but not assigned a value.

`null` is an assignment value that represents no value.

92. What is the use of 'use strict' in JavaScript?

It enables strict mode which catches common coding mistakes and prevents unsafe actions.

93. What are arrow functions?

Arrow functions are a shorter syntax for function expressions and do not bind their own `this`.

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

- `call`: Invokes function with given context and arguments.

- `apply`: Similar to call but arguments are in an array.

- `bind`: Returns a new function with bound context.

95. What is event delegation?

Event delegation is a technique where a single event listener is added to a parent element to manage events

for its children.

96. What is the difference between slice and splice?

- `slice`: Returns a shallow copy of a portion of an array.

- `splice`: Changes the contents of an array by removing or replacing elements.

97. What are template literals?

Template literals allow embedded expressions using backticks (`) and ${} placeholders.

98. What is a callback function?


JavaScript Interview Questions and Answers

A callback is a function passed into another function as an argument, which is then invoked inside the outer

function.

99. Explain async/await in JavaScript.

`async` functions return a promise. `await` pauses the execution until the promise is resolved.

100. What are JavaScript modules?

Modules allow you to split code into reusable files using `export` and `import` keywords.

You might also like