Interview Questions and Answers
JavaScript Questions and Answers
1. What is the difference between `var`, `let`, and `const`?
`var` is function-scoped and hoisted, `let` is block-scoped and not hoisted, and `const` is
block-scoped and its value cannot be reassigned.
2. Explain closures in JavaScript with an example.
A closure is a function that retains access to its lexical scope even when the function is executed
outside that scope. Example: function outer() { let count = 0; return function inner() { count++; return
count; } }.
React Questions and Answers
1. What are React Hooks?
Hooks let you use state and other React features in functional components. Examples include
`useState`, `useEffect`.
2. What is the virtual DOM?
The virtual DOM is a lightweight representation of the actual DOM. React uses it to optimize
updates by comparing the virtual DOM with the actual DOM.
CSS Questions and Answers
1. What is the box model in CSS?
The box model includes `margin`, `border`, `padding`, and `content`, defining how elements are
spaced and displayed.
2. How does Flexbox work?
Flexbox is a layout model for 1-dimensional layouts. Key properties include `justify-content`,
`align-items`, and `flex-wrap`.
Backend & API Questions and Answers
1. What is REST?
REST is an architectural style that uses standard HTTP methods like GET, POST, PUT, DELETE
for API interactions.
2. What is the purpose of API authentication?
API authentication ensures secure access to resources using methods like JWT, OAuth, and API
keys.