JavaScript 100 Interview Questions & Answers
Core JavaScript
Q1. What is JavaScript?
A scripting language used to create dynamic web content.
Q2. Is JavaScript compiled or interpreted?
Interpreted (JIT compiled in modern engines).
Q3. What are JavaScript data types?
String, Number, Boolean, Undefined, Null, Object, Symbol, BigInt
Q4. Difference between null and undefined?
Undefined means variable declared but not assigned; null is assigned empty value.
Q5. What is NaN?
Not a Number – result of invalid numeric operation.
Q6. What is type coercion?
Automatic conversion of data types.
Q7. == vs === ?
== checks value, === checks value and type.
Q8. What is hoisting?
Moving declarations to the top during execution.
Q9. What is scope?
Accessibility of variables.
Q10. Types of scope?
Global, Function, Block
Q11. let vs var vs const?
var is function scoped; let/const are block scoped.
Q12. What is strict mode?
Enforces secure and optimized JavaScript.
Q13. What is this keyword?
Refers to execution context object.
Q14. What is closure?
Function accessing outer variables.
Q15. What is lexical scope?
Scope determined by code position.
Q16. Primitive vs Non-primitive?
Primitive stores value; Non-primitive stores reference.
Q17. What is truthy/falsy?
Values evaluated as true/false.
Q18. What is event?
User or browser action.
Q19. Event bubbling?
Event moves from child to parent.
Q20. Event capturing?
Event moves from parent to child.
Q21. What is DOM?
Document Object Model.
Q22. How to select element?
document.querySelector(".box");Q23. What is window object?
Global browser object.
Q24. setTimeout vs setInterval?
setTimeout runs once, setInterval runs repeatedly.
Q25. What is alert?
Displays popup message.
ES6 & Functions
Q26. What is ES6?
Modern JavaScript version (2015).
Q27. Arrow function?
const add = (a,b) => a+b;
Q28. Difference arrow vs normal function?
Arrow has no this binding.
Q29. Template literals?
`Hello ${name}`Q30. Default parameters?
function add(a=0,b=0){}Q31. Spread operator?
const arr2 = [...arr1];
Q32. Rest operator?
function sum(...nums){}Q33. Destructuring?
const {name} = user;Q34. What is callback?
Function passed as argument.
Q35. Callback hell?
Nested callbacks.
Q36. What is promise?
Handles async operations.
Q37. Promise states?
Pending, Fulfilled, Rejected
Q38. async/await?
Simplifies promise handling.
Q39. What is fetch?
API call method.
Q40. Map vs forEach?
map returns array, forEach doesn’t.
Q41. Filter?
Filters array based on condition.
Q42. Reduce?
Reduces array to single value.
Q43. What is immutability?
Data cannot be changed.
Q44. Shallow vs deep copy?
Shallow copies reference.
Q45. JSON?
Data interchange format.
Q46. JSON.parse?
Converts JSON string to object.
Q47. JSON.stringify?
Converts object to JSON.
Q48. LocalStorage?
Stores data permanently.
Q49. SessionStorage?
Stores data per session.
Q50. Cookies?
Small data stored in browser.
Advanced & Interview Level
Q51. What is prototype?
Mechanism for inheritance.
Q52. Prototype chain?
Linked prototypes.
Q53. Class vs function?
Classes are syntactic sugar.
Q54. What is IIFE?
Immediately Invoked Function Expression.
Q55. What is module?
Reusable code unit.
Q56. CommonJS vs ES Modules?
require vs import/export.
Q57. What is bundler?
Combines files (Webpack).
Q58. What is transpiler?
Converts modern JS to old JS.
Q59. What is Babel?
JavaScript transpiler.
Q60. Tree shaking?
Removes unused code.
Q61. What is event delegation?
Using parent for child events.
Q62. Throttling?
Limits function execution.
Q63. Debouncing?
Delays function execution.
Q64. Memory leak?
Unused memory not released.
Q65. Garbage collection?
Automatic memory cleanup.
Q66. What is call/apply/bind?
Controls function context.
Q67. Shadow DOM?
Encapsulated DOM.
Q68. Web workers?
Background thread execution.
Q69. Service workers?
Offline & caching support.
Q70. What is SPA?
Single Page Application.
Q71. CSR vs SSR?
Client vs Server rendering.
Q72. What is virtual DOM?
JS representation of DOM.
Q73. Framework vs library?
Framework controls flow.
Q74. What is React?
UI library.
Q75. What is state?
Component data.
Q76. Props?
Data passed to component.
Q77. What is Redux?
State management.
Q78. REST API?
Web service architecture.
Q79. GET vs POST?
Fetch vs send data.
Q80. CORS?
Cross-Origin Resource Sharing.
Q81. HTTP status codes?
200, 404, 500 etc.
Q82. Web security?
XSS, CSRF protection.
Q83. What is XSS?
Cross Site Scripting.
Q84. What is CSRF?
Cross Site Request Forgery.
Q85. Code splitting?
Load code on demand.
Q86. Lazy loading?
Load resources when needed.
Q87. Performance optimization?
Minify, cache, async.
Q88. JS testing?
Jest, Mocha.
Q89. Unit testing?
Testing small units.
Q90. Clean code?
Readable, maintainable code.
Q91. JavaScript advantages?
Fast, flexible, everywhere.
Q92. JavaScript disadvantages?
Security, single thread.
Q93. JS future?
Very strong.
Q94. Node.js?
JS runtime.
Q95. npm?
Package manager.
Q96. What is Express?
Node.js framework.
Q97. Middleware?
Function between request & response.
Q98. Why hire JS developer?
Full-stack capability.
Q99. Interview focus?
Concepts + async + DOM.
Q100. Best JS practices?
ES6+, clean code, performance.
No comments:
Post a Comment