codejump

watch & Composables

Preview — 3 of 10 questions

What is the primary difference between watch and watchEffect in Vue 3?

Awatch is asynchronous; watchEffect is synchronous
BwatchEffect only works with reactive; watch only works with ref
CwatchEffect tracks dependencies automatically; watch requires explicitly specifying sources
Dwatch runs immediately on mount; watchEffect does not

What does the { immediate: true } option do in watch?

AMakes the watcher run synchronously instead of asynchronously
BMakes watch behave identically to watchEffect
CPrevents the watcher from being stopped when the component unmounts
DRuns the callback immediately when the watcher is created, before any change

What is the correct usage of provide and inject in Vue 3 Composition API?

AA parent component uses provide to share data; descendant components use inject to receive it
BBoth provide and inject must be used in the same component
Cprovide is used in child components; inject is used in parent components
Dprovide/inject only works between direct parent-child components, not deeper descendants

Sign up free to play

Answer all 10 questions (7 more), see explanations for every answer, and track your score.