Interview Questions Answers
Interview Questions Answers
- A closure is a function that retains access to its lexical scope even when the function is executed
- Example:
```javascript
function outer() {
let count = 0;
count++;
return count;
};
console.log(increment()); // Output: 1
console.log(increment()); // Output: 2
```
### React Questions and Answers
- React Hooks are functions that let you use state and lifecycle methods in functional components.
- Functional components are stateless and simpler, while class components support state and
lifecycle methods.
- The box model includes `margin`, `border`, `padding`, and `content`. It defines how elements are
- `z-index` determines the stacking order of elements. Higher values are displayed on top.