React - Graded Quiz
10. What is the purpose of the useEffect Hook in React?
- To handle events in a component.
- To manage state in a component.
- To run side effects in a component.
- To render a component to the DOM.
11. Which lifecycle method in React is equivalent to the useEffect Hook?
- componentDidMount
- componentDidUpdate
- componentWillUnmount
- Both componentDidMount and componentDidUpdate
12. What is the purpose of the dependency array in the useEffect Hook?
- To specify the state variables that should trigger the effect.
- To specify the state variables that the effect depends on.
- To specify the props that the effect depends on.
- Both B and C.
13. What is the purpose of the "querySelector()" method in JavaScript?
- To select and remove an HTML element from the DOM.
- To create a new HTML element based on a CSS selector.
- To select and retrieve the value of an attribute from an HTML element.
- To select and retrieve the first matching HTML element from the DOM based on a CSS selector.
14. Which method is used to add an HTML element to the DOM in JavaScript?
- removeChild()
- createElement()
- replaceChild()
- appendChild()
15. What is the purpose of the useContext hook in React?
- To manage the state of a component.
- To perform side effects in a component, such as fetching data or updating the DOM.
- To provide data to a component from a global state.
- To connect a component to a Redux store.
16. Which hook is used to handle side effects in a React component?
- useState
- useEffect
- useContext
- useReducer
17. Which argument is passed to the useEffect hook to specify when the effect should be run?
- A function to run before the effect is run.
- An object representing the dependencies of the effect.
- A function to run after the effect is run.
- An array of values to be passed to the effect.
18. Which hook is used to connect a React component to a Redux store?
- useState
- useEffect
- useContext
- useDispatch
19. What is the purpose of the "map()" method in JavaScript?
- To iterate over the keys of an object.
- To filter elements of an array based on a condition.
- To sort elements of an array in ascending order.
- To transform each element of an array and create a new array based on the returned values.