Vue Interview Master

Curated 200+ Questions to Crack Your Next Vue.js Interview

0 / 200 LearnedComposition API FocusVue 3 Updated
Showing 200 results in All Questions category.
1
What is Vue.js?
Beginner

Vue.js is a progressive JavaScript framework for building user interfaces. It is designed from the ground up to be incrementally adoptable, and can ea...

Comprehensive Answer:

Vue.js is a progressive JavaScript framework for building user interfaces. It is designed from the ground up to be incrementally adoptable, and can easily scale between a library and a full-featured framework.

Copy Text Beginner
2
What are the core features of Vue?
Beginner

Core features include Reactive Data Binding, Components, Directives (v-if, v-for, etc.), Templates, and the Virtual DOM.

Comprehensive Answer:

Core features include Reactive Data Binding, Components, Directives (v-if, v-for, etc.), Templates, and the Virtual DOM.

Copy Text Beginner
3
What is the Vue Instance?
Beginner

Every Vue application starts by creating a new Vue instance with the `Vue` function (in Vue 2) or `createApp` (in Vue 3).

Comprehensive Answer:

Every Vue application starts by creating a new Vue instance with the `Vue` function (in Vue 2) or `createApp` (in Vue 3).

Copy Text Beginner
4
Explain Reactive Data Binding in Vue.
Beginner

Vue's reactivity system automatically tracks dependency changes and updates the DOM when the underlying data changes, typically using a Model-View-Vie...

Comprehensive Answer:

Vue's reactivity system automatically tracks dependency changes and updates the DOM when the underlying data changes, typically using a Model-View-ViewModel (MVVM) pattern.

Copy Text Beginner
5
What is the difference between Vue 2 and Vue 3?
Beginner

Vue 3 introduced the Composition API, better TypeScript support, Fragments, Teleport, and significant performance improvements through a faster Virtua...

Comprehensive Answer:

Vue 3 introduced the Composition API, better TypeScript support, Fragments, Teleport, and significant performance improvements through a faster Virtual DOM and better tree-shaking.

Copy Text Beginner
6
What are Directives in Vue?
Beginner

Directives are special attributes with the `v-` prefix. They apply special reactive behavior to the rendered DOM (e.g., `v-bind`, `v-model`, `v-on`).

Comprehensive Answer:

Directives are special attributes with the `v-` prefix. They apply special reactive behavior to the rendered DOM (e.g., `v-bind`, `v-model`, `v-on`).

Copy Text Beginner
7
What is `v-model`?
Beginner

`v-model` provides two-way data binding on form input, textarea, and select elements. It automatically picks the correct way to update the element bas...

Comprehensive Answer:

`v-model` provides two-way data binding on form input, textarea, and select elements. It automatically picks the correct way to update the element based on the input type.

Copy Text Beginner
8
What is the difference between `v-if` and `v-show`?
Beginner

`v-if` is 'real' conditional rendering; it ensures that event listeners and child components inside the conditional block are properly destroyed and r...

Comprehensive Answer:

`v-if` is 'real' conditional rendering; it ensures that event listeners and child components inside the conditional block are properly destroyed and re-created. `v-show` is much simpler—the element is always rendered and remains in the DOM; it simply toggles the `display` CSS property.

Copy Text Beginner
9
What are Components in Vue?
Beginner

Components are reusable Vue instances with a name. They allow you to divide your UI into independent, reusable pieces.

Comprehensive Answer:

Components are reusable Vue instances with a name. They allow you to divide your UI into independent, reusable pieces.

Copy Text Beginner
10
What are Props in Vue?
Beginner

Props are custom attributes you can register on a component. When a value is passed to a prop attribute, it becomes a property on that component insta...

Comprehensive Answer:

Props are custom attributes you can register on a component. When a value is passed to a prop attribute, it becomes a property on that component instance.

Copy Text Beginner
11
How do you handle events in Vue?
Beginner

You use the `v-on` directive (shorthand `@`) to listen to DOM events and run some JavaScript when they're triggered.

Comprehensive Answer:

You use the `v-on` directive (shorthand `@`) to listen to DOM events and run some JavaScript when they're triggered.

Copy Text Beginner
12
What is Computed Property?
Beginner

Computed properties are functions used to handle complex logic that depends on other reactive data. They are cached based on their reactive dependenci...

Comprehensive Answer:

Computed properties are functions used to handle complex logic that depends on other reactive data. They are cached based on their reactive dependencies.

Copy Text Beginner
13
What is the difference between Computed and Methods?
Beginner

Computed properties are cached based on their dependencies. A computed property will only re-evaluate when some of its reactive dependencies have chan...

Comprehensive Answer:

Computed properties are cached based on their dependencies. A computed property will only re-evaluate when some of its reactive dependencies have changed. In contrast, a method invocation will always run the function whenever a re-render happens.

Copy Text Beginner
14
What are Watchers in Vue?
Beginner

Watchers allow you to perform asynchronous or expensive operations in response to changing data. Use `watch` when you need to perform an action based ...

Comprehensive Answer:

Watchers allow you to perform asynchronous or expensive operations in response to changing data. Use `watch` when you need to perform an action based on a data change.

Copy Text Beginner
15
What is the `key` attribute in `v-for`?
Beginner

The `key` attribute is used as a hint for Vue's virtual DOM algorithm to identify VNodes when diffing the new list of nodes against the old list. It s...

Comprehensive Answer:

The `key` attribute is used as a hint for Vue's virtual DOM algorithm to identify VNodes when diffing the new list of nodes against the old list. It should be unique and stable.

Copy Text Beginner
16
What are Life Cycle Hooks in Vue?
Beginner

Lifecycle hooks are functions that give you the opportunity to add code at specific stages of a component's life (e.g., `created`, `mounted`, `updated...

Comprehensive Answer:

Lifecycle hooks are functions that give you the opportunity to add code at specific stages of a component's life (e.g., `created`, `mounted`, `updated`, `unmounted`).

Copy Text Beginner
17
Explain the `created` hook.
Beginner

The `created` hook is called synchronously after the instance is created. At this stage, data observation and events are set up, but the mount hasn't ...

Comprehensive Answer:

The `created` hook is called synchronously after the instance is created. At this stage, data observation and events are set up, but the mount hasn't started yet ($el is not available).

Copy Text Beginner
18
Explain the `mounted` hook.
Beginner

The `mounted` hook is called after the instance has been mounted to the DOM. You can access the DOM elements at this stage.

Comprehensive Answer:

The `mounted` hook is called after the instance has been mounted to the DOM. You can access the DOM elements at this stage.

Copy Text Beginner
19
What is a Template in Vue?
Beginner

A template is an HTML-based syntax that allows you to declaratively bind the rendered DOM to the underlying Vue instance's data.

Comprehensive Answer:

A template is an HTML-based syntax that allows you to declaratively bind the rendered DOM to the underlying Vue instance's data.

Copy Text Beginner
20
What is Single File Component (SFC)?
Beginner

An SFC is a file with a `.vue` extension that contains the template, logic, and styles of a component in a single file.

Comprehensive Answer:

An SFC is a file with a `.vue` extension that contains the template, logic, and styles of a component in a single file.

Copy Text Beginner
21
What is `v-bind` used for?
Beginner

`v-bind` (shorthand `:`) is used to dynamically bind one or more attributes, or a component prop, to an expression.

Comprehensive Answer:

`v-bind` (shorthand `:`) is used to dynamically bind one or more attributes, or a component prop, to an expression.

Copy Text Beginner
22
How to pass data from Child to Parent?
Beginner

Children communicate to parents by emitting events using `$emit` (Options API) or `emit` (Composition API).

Comprehensive Answer:

Children communicate to parents by emitting events using `$emit` (Options API) or `emit` (Composition API).

Copy Text Beginner
23
What is the Virtual DOM in Vue?
Beginner

The Virtual DOM is a lightweight JavaScript object representation of the actual DOM. Vue handles updates by comparing changes in the Virtual DOM and o...

Comprehensive Answer:

The Virtual DOM is a lightweight JavaScript object representation of the actual DOM. Vue handles updates by comparing changes in the Virtual DOM and only applying necessary changes to the real DOM.

Copy Text Beginner
24
What are Filters in Vue (Vue 2)?
Beginner

Filters were used to apply common text formatting. Note: Filters are removed in Vue 3; use computed properties or methods instead.

Comprehensive Answer:

Filters were used to apply common text formatting. Note: Filters are removed in Vue 3; use computed properties or methods instead.

Copy Text Beginner
25
What is `v-text`?
Beginner

`v-text` updates the element's text content. It is similar to using mustache tags (`{{ }}`).

Comprehensive Answer:

`v-text` updates the element's text content. It is similar to using mustache tags (`{{ }}`).

Copy Text Beginner
26
What is `v-html`?
Beginner

`v-html` updates the element's `innerHTML`. Careful with XSS vulnerabilities!

Comprehensive Answer:

`v-html` updates the element's `innerHTML`. Careful with XSS vulnerabilities!

Copy Text Beginner
27
What is `v-once`?
Beginner

`v-once` renders the element and component once only. On subsequent re-renders, the element/component and all its children will be treated as static c...

Comprehensive Answer:

`v-once` renders the element and component once only. On subsequent re-renders, the element/component and all its children will be treated as static content and skipped.

Copy Text Beginner
28
What is `v-cloak`?
Beginner

`v-cloak` is used to hide un-compiled mustache bindings until the Vue instance is ready.

Comprehensive Answer:

`v-cloak` is used to hide un-compiled mustache bindings until the Vue instance is ready.

Copy Text Beginner
29
How to define global components?
Beginner

In Vue 3, you use `app.component('my-component', { ... })` on the app instance.

Comprehensive Answer:

In Vue 3, you use `app.component('my-component', { ... })` on the app instance.

Copy Text Beginner
30
What is the use of `ref` in Vue?
Beginner

`ref` is used to register a reference to an element or a child component. In Composition API, it's also used to create reactive variables.

Comprehensive Answer:

`ref` is used to register a reference to an element or a child component. In Composition API, it's also used to create reactive variables.

Copy Text Beginner
31
What is the difference between `ref` and `reactive` in Vue 3?
Beginner

`ref` can hold primitives or objects and requires `.value` to access/mutate (in JS). `reactive` only holds objects and does not require `.value`.

Comprehensive Answer:

`ref` can hold primitives or objects and requires `.value` to access/mutate (in JS). `reactive` only holds objects and does not require `.value`.

Copy Text Beginner
32
What is the `setup` function in Vue 3?
Beginner

The `setup` function is the entry point for using the Composition API in components. It's executed before the component is created.

Comprehensive Answer:

The `setup` function is the entry point for using the Composition API in components. It's executed before the component is created.

Copy Text Beginner
33
How to handle forms in Vue?
Beginner

Forms are handled using `v-model` for two-way binding and `@submit.prevent` for handling form submission while preventing page reload.

Comprehensive Answer:

Forms are handled using `v-model` for two-way binding and `@submit.prevent` for handling form submission while preventing page reload.

Copy Text Beginner
34
What is `@` in Vue?
Beginner

`@` is a shorthand for `v-on`, used for event listening.

Comprehensive Answer:

`@` is a shorthand for `v-on`, used for event listening.

Copy Text Beginner
35
What is `:` in Vue?
Beginner

`:` is a shorthand for `v-bind`, used for attribute binding.

Comprehensive Answer:

`:` is a shorthand for `v-bind`, used for attribute binding.

Copy Text Beginner
36
What is `v-pre`?
Beginner

`v-pre` skips compilation for this element and all its children. You can use this for displaying raw mustache tags.

Comprehensive Answer:

`v-pre` skips compilation for this element and all its children. You can use this for displaying raw mustache tags.

Copy Text Beginner
37
What is the purpose of `target="_blank"` in Router-Link?
Beginner

`router-link` doesn't support `target` directly for internal navigation, but you can use an `<a>` tag or handle it manually if you need to open in a n...

Comprehensive Answer:

`router-link` doesn't support `target` directly for internal navigation, but you can use an `<a>` tag or handle it manually if you need to open in a new tab.

Copy Text Beginner
38
What is `slot` in Vue?
Beginner

Slots are a mechanism for content distribution, allowing parents to pass HTML or components into a child component's template.

Comprehensive Answer:

Slots are a mechanism for content distribution, allowing parents to pass HTML or components into a child component's template.

Copy Text Beginner
39
What is Named Slot?
Beginner

Named slots allow you to have multiple slots in a single component by assigning a name to the `<slot>` element.

Comprehensive Answer:

Named slots allow you to have multiple slots in a single component by assigning a name to the `<slot>` element.

Copy Text Beginner
40
What is Scoped Slot?
Beginner

Scoped slots allow the child component to pass data back to the parent for it to use within the slotted content.

Comprehensive Answer:

Scoped slots allow the child component to pass data back to the parent for it to use within the slotted content.

Copy Text Beginner
41
What is Vue CLI?
Beginner

Vue CLI is a standard tooling for Vue.js development, providing project scaffolding, dev server, and build chain.

Comprehensive Answer:

Vue CLI is a standard tooling for Vue.js development, providing project scaffolding, dev server, and build chain.

Copy Text Beginner
42
What is Vite?
Beginner

Vite is a modern build tool that provides a faster development experience. It is now the recommended tool for Vue projects instead of Vue CLI.

Comprehensive Answer:

Vite is a modern build tool that provides a faster development experience. It is now the recommended tool for Vue projects instead of Vue CLI.

Copy Text Beginner
43
How to do CSS nesting in Vue SFC?
Beginner

You can use pre-processors like Sass, Less, or Stylus by adding `lang="scss"` to the `<style>` tag.

Comprehensive Answer:

You can use pre-processors like Sass, Less, or Stylus by adding `lang="scss"` to the `<style>` tag.

Copy Text Beginner
44
What is Scoped CSS?
Beginner

By adding the `scoped` attribute to a `<style>` tag, the CSS will only apply to elements of the current component.

Comprehensive Answer:

By adding the `scoped` attribute to a `<style>` tag, the CSS will only apply to elements of the current component.

Copy Text Beginner
45
What is `nextTick`?
Beginner

`nextTick` allows you to execute code after the next DOM update cycle. Use it when you need to wait for the DOM to update after a data change.

Comprehensive Answer:

`nextTick` allows you to execute code after the next DOM update cycle. Use it when you need to wait for the DOM to update after a data change.

Copy Text Beginner
46
Difference between `v-on:click.stop` and `v-on:click.prevent`?
Beginner

.stop` stops event propagation (bubble up). `.prevent` calls `event.preventDefault()` (stops default browser behavior).`

Comprehensive Answer:

.stop` stops event propagation (bubble up). `.prevent` calls `event.preventDefault()` (stops default browser behavior).`

Copy Text Beginner
47
What are Mixins?
Beginner

Mixins are a flexible way to distribute reusable functionalities for Vue components (mainly used in Options API; Composition API is preferred in Vue 3...

Comprehensive Answer:

Mixins are a flexible way to distribute reusable functionalities for Vue components (mainly used in Options API; Composition API is preferred in Vue 3).

Copy Text Beginner
48
How to handle 404 routes in Vue Router?
Beginner

By adding a catch-all route at the end of your routes array: `{ path: '/:pathMatch(.*)*', component: NotFound }`.

Comprehensive Answer:

By adding a catch-all route at the end of your routes array: `{ path: '/:pathMatch(.*)*', component: NotFound }`.

Copy Text Beginner
49
What is the use of `v-bind="$attrs"`?
Beginner

It allows a component to pass all non-prop attributes down to a child element or component.

Comprehensive Answer:

It allows a component to pass all non-prop attributes down to a child element or component.

Copy Text Beginner
50
What is `defineProps` and `defineEmits` in Vue 3?
Beginner

These are compiler macros used in `<script setup>` to declare props and emits without needing to import them.

Comprehensive Answer:

These are compiler macros used in `<script setup>` to declare props and emits without needing to import them.

Copy Text Beginner
51
Explain the Composition API in depth.
Experience

Composition API is a set of APIs that allows us to author Vue components using imported functions instead of declaring options. It provides better log...

Comprehensive Answer:

Composition API is a set of APIs that allows us to author Vue components using imported functions instead of declaring options. It provides better logic reuse, better code organization, and full TypeScript support.

Copy Text Experience
52
What is Provide / Inject?
Experience

A pair of options/functions used for deep-level dependency injection, allowing a grandparent to pass data to a grandchild without prop drilling.

Comprehensive Answer:

A pair of options/functions used for deep-level dependency injection, allowing a grandparent to pass data to a grandchild without prop drilling.

Copy Text Experience
53
What is Teleport?
Experience

Teleport is a built-in component that allows us to 'teleport' a part of a component's template into a DOM node that exists outside the component hiera...

Comprehensive Answer:

Teleport is a built-in component that allows us to 'teleport' a part of a component's template into a DOM node that exists outside the component hierarchy (e.g., Modals at the end of <body>).

Copy Text Experience
54
How to use `toRefs` and `toRef`?
Experience

`toRefs` converts a reactive object to a plain object where each property is a ref. `toRef` creates a ref for a specific property on a source reactive...

Comprehensive Answer:

`toRefs` converts a reactive object to a plain object where each property is a ref. `toRef` creates a ref for a specific property on a source reactive object.

Copy Text Experience
55
Explain Vue Router Navigation Guards.
Experience

Navigation guards are used to guard navigations either by redirecting it or canceling it. Types include Global (beforeEach), Per-route (beforeEnter), ...

Comprehensive Answer:

Navigation guards are used to guard navigations either by redirecting it or canceling it. Types include Global (beforeEach), Per-route (beforeEnter), and In-component (beforeRouteLeave).

Copy Text Experience
56
What is Pinia?
Experience

Pinia is the recommended store library for Vue apps. It provides a simpler API than Vuex, is fully type-safe, and works well with both Options and Com...

Comprehensive Answer:

Pinia is the recommended store library for Vue apps. It provides a simpler API than Vuex, is fully type-safe, and works well with both Options and Composition APIs.

Copy Text Experience
57
Difference between Pinia and Vuex?
Experience

Pinia removes Mutations, provides flat store structure (no nested modules), and has better TypeScript inference. Vuex is the older standard.

Comprehensive Answer:

Pinia removes Mutations, provides flat store structure (no nested modules), and has better TypeScript inference. Vuex is the older standard.

Copy Text Experience
58
Explain Async Components.
Experience

Async components are loaded only when they are needed, which helps in code-splitting and reducing the initial bundle size.

Comprehensive Answer:

Async components are loaded only when they are needed, which helps in code-splitting and reducing the initial bundle size.

Copy Text Experience
59
How to implement custom directives?
Experience

Custom directives are defined with hooks like `mounted`, `updated`, etc., to perform low-level DOM manipulations.

Comprehensive Answer:

Custom directives are defined with hooks like `mounted`, `updated`, etc., to perform low-level DOM manipulations.

Copy Text Experience
60
What is `suspense` in Vue 3?
Experience

Suspense is a built-in component used to coordinate multiple primitive async dependencies (like async components or data fetching) and show a loading ...

Comprehensive Answer:

Suspense is a built-in component used to coordinate multiple primitive async dependencies (like async components or data fetching) and show a loading state.

Copy Text Experience
61
Explain Plugin system in Vue.
Experience

Plugins add global-level functionality to Vue. They are usually installed via `app.use(plugin)`.

Comprehensive Answer:

Plugins add global-level functionality to Vue. They are usually installed via `app.use(plugin)`.

Copy Text Experience
62
How to handle error handling in Vue globally?
Experience

Using `app.config.errorHandler` for global error catching or `errorCaptured` hook for component-level catching.

Comprehensive Answer:

Using `app.config.errorHandler` for global error catching or `errorCaptured` hook for component-level catching.

Copy Text Experience
63
What is logic reuse in Composition API?
Experience

Using 'Composables'—functions that encapsulate logic (using refs, computed, hooks) and return state/methods for components to use.

Comprehensive Answer:

Using 'Composables'—functions that encapsulate logic (using refs, computed, hooks) and return state/methods for components to use.

Copy Text Experience
64
Explain `shallowRef` and `shallowReactive`.
Experience

These are versions of `ref` and `reactive` that only track changes at the top level, ignoring nested property changes for performance optimization.

Comprehensive Answer:

These are versions of `ref` and `reactive` that only track changes at the top level, ignoring nested property changes for performance optimization.

Copy Text Experience
65
What is `watchEffect`?
Experience

`watchEffect` immediately runs a function while reactively tracking its dependencies and re-runs it whenever the dependencies change.

Comprehensive Answer:

`watchEffect` immediately runs a function while reactively tracking its dependencies and re-runs it whenever the dependencies change.

Copy Text Experience
66
Difference between `watch` and `watchEffect`?
Experience

`watch` is lazy (runs only when watched source changes), gives access to old/new values, and specifies exactly what to watch. `watchEffect` runs immed...

Comprehensive Answer:

`watch` is lazy (runs only when watched source changes), gives access to old/new values, and specifies exactly what to watch. `watchEffect` runs immediately and tracks all reactive properties used inside it automatically.

Copy Text Experience
67
How to optimize Vue performance?
Experience

Using `v-show` for frequent toggles, `v-once` for static content, `shallowRef` for large immutable datasets, and code splitting via async components.

Comprehensive Answer:

Using `v-show` for frequent toggles, `v-once` for static content, `shallowRef` for large immutable datasets, and code splitting via async components.

Copy Text Experience
68
What is the purpose of `inheritAttrs: false`?
Experience

It prevents the component's root element from automatically inheriting attributes passed to the component, allowing you to manually bind them using `v...

Comprehensive Answer:

It prevents the component's root element from automatically inheriting attributes passed to the component, allowing you to manually bind them using `v-bind="$attrs"`.

Copy Text Experience
69
Explain HOC (Higher Order Components) in Vue.
Experience

A pattern where a function takes a component and returns a new one with additional props or logic (less common in Vue than React, but possible).

Comprehensive Answer:

A pattern where a function takes a component and returns a new one with additional props or logic (less common in Vue than React, but possible).

Copy Text Experience
70
What is Functional Component in Vue?
Experience

A component that has no state and no instance. In Vue 3, they are just plain functions that return VNodes.

Comprehensive Answer:

A component that has no state and no instance. In Vue 3, they are just plain functions that return VNodes.

Copy Text Experience
71
How to use `markRaw`?
Experience

`markRaw` marks an object so that it will never be converted to a reactive proxy, useful for large non-reactive objects (like third-party maps).

Comprehensive Answer:

`markRaw` marks an object so that it will never be converted to a reactive proxy, useful for large non-reactive objects (like third-party maps).

Copy Text Experience
72
Explain `computed` getter and setter.
Experience

Computed properties can have a setter by providing an object with `get` and `set` functions instead of just a function.

Comprehensive Answer:

Computed properties can have a setter by providing an object with `get` and `set` functions instead of just a function.

Copy Text Experience
73
What is SSR (Server Side Rendering) with Vue?
Experience

Rendering the component tree into an HTML string on the server and sending it to the client for hydration (usually via Nuxt.js).

Comprehensive Answer:

Rendering the component tree into an HTML string on the server and sending it to the client for hydration (usually via Nuxt.js).

Copy Text Experience
74
Explain `static` vs `dynamic` components.
Experience

Static components are declared in the template. Dynamic components use the `<component :is="..." />` syntax to switch between components.

Comprehensive Answer:

Static components are declared in the template. Dynamic components use the `<component :is="..." />` syntax to switch between components.

Copy Text Experience
75
What is `keep-alive`?
Experience

`keep-alive` is a built-in component that caches component instances when switching between them, preserving their state.

Comprehensive Answer:

`keep-alive` is a built-in component that caches component instances when switching between them, preserving their state.

Copy Text Experience
76
How to handle Cross-Component Communication?
Experience

Props/Events (Parent-Child), Provide/Inject (Ancestors), Global Store (Pinia/Vuex), or Event Bus (using Mitt library in Vue 3).

Comprehensive Answer:

Props/Events (Parent-Child), Provide/Inject (Ancestors), Global Store (Pinia/Vuex), or Event Bus (using Mitt library in Vue 3).

Copy Text Experience
77
Explain `v-slot` shorthand.
Experience

`v-slot:header` can be shortened to `#header`.

Comprehensive Answer:

`v-slot:header` can be shortened to `#header`.

Copy Text Experience
78
What is `uncontrolled` component in Vue?
Experience

A component where the DOM handles the data (using refs to read values) instead of Vue state.

Comprehensive Answer:

A component where the DOM handles the data (using refs to read values) instead of Vue state.

Copy Text Experience
79
How to use CSS Variables with Vue?
Experience

Vue 3 supports `v-bind` in CSS, allowing you to link CSS properties directly to reactive component variables.

Comprehensive Answer:

Vue 3 supports `v-bind` in CSS, allowing you to link CSS properties directly to reactive component variables.

Copy Text Experience
80
What is the role of `vue-loader`?
Experience

It's a loader for Webpack that allows you to author Vue components in SFC format.

Comprehensive Answer:

It's a loader for Webpack that allows you to author Vue components in SFC format.

Copy Text Experience
81
Explain `dependency tracking` in Vue.
Experience

Vue uses a `Dep` class to keep track of watchers that depend on a reactive property, triggering them when the property changes.

Comprehensive Answer:

Vue uses a `Dep` class to keep track of watchers that depend on a reactive property, triggering them when the property changes.

Copy Text Experience
82
How to use `useAttrs` and `useSlots`?
Experience

These hooks allow access to attributes and slots inside the `setup` function or `<script setup>`.

Comprehensive Answer:

These hooks allow access to attributes and slots inside the `setup` function or `<script setup>`.

Copy Text Experience
83
What is `emits` validation?
Experience

You can validate the arguments passed to emitted events by defining `emits` as an object with validation functions.

Comprehensive Answer:

You can validate the arguments passed to emitted events by defining `emits` as an object with validation functions.

Copy Text Experience
84
Explain Vue's `patching` process.
Experience

The process of updating the real DOM by comparing the old VNode tree with the new one and applying minimal changes.

Comprehensive Answer:

The process of updating the real DOM by comparing the old VNode tree with the new one and applying minimal changes.

Copy Text Experience
85
How to implement Middleware in Vue Router?
Experience

By using `beforeEach` guard and attaching metadata to routes via the `meta` field.

Comprehensive Answer:

By using `beforeEach` guard and attaching metadata to routes via the `meta` field.

Copy Text Experience
86
What is `defineExpose`?
Experience

In `<script setup>`, components are closed by default. `defineExpose` is used to explicitly declare which properties/methods are available when the pa...

Comprehensive Answer:

In `<script setup>`, components are closed by default. `defineExpose` is used to explicitly declare which properties/methods are available when the parent uses a `ref` on the component.

Copy Text Experience
87
How to use `provide/inject` with Reactivity?
Experience

Pass a `ref` or a `reactive` object to `provide` to ensure the injected value stays reactive in child components.

Comprehensive Answer:

Pass a `ref` or a `reactive` object to `provide` to ensure the injected value stays reactive in child components.

Copy Text Experience
88
Explain `dynamic` route matching.
Experience

Routes with params like `/user/:id`, where `id` can be accessed via `route.params.id`.

Comprehensive Answer:

Routes with params like `/user/:id`, where `id` can be accessed via `route.params.id`.

Copy Text Experience
89
What is `v-on` native modifier (Vue 2)?
Experience

`.native` was used to listen to native DOM events on component root. In Vue 3, this is removed; all events not declared in `emits` are treated as nati...

Comprehensive Answer:

`.native` was used to listen to native DOM events on component root. In Vue 3, this is removed; all events not declared in `emits` are treated as native events.

Copy Text Experience
90
How to implement Breadcrumbs with Vue Router?
Experience

By iterating through `route.matched` array to get the hierarchy of nested routes.

Comprehensive Answer:

By iterating through `route.matched` array to get the hierarchy of nested routes.

Copy Text Experience
91
What is `vue-cli-service`?
Experience

An executable that provides internal build commands for Vue CLI projects.

Comprehensive Answer:

An executable that provides internal build commands for Vue CLI projects.

Copy Text Experience
92
Difference between `export default` and `defineComponent`?
Experience

`defineComponent` is a type helper for better TypeScript support, whereas `export default` is standard JS.

Comprehensive Answer:

`defineComponent` is a type helper for better TypeScript support, whereas `export default` is standard JS.

Copy Text Experience
93
How to use `onBeforeRouteUpdate` hook?
Experience

Used to handle cases where the route changes but the component is reused (e.g., from `/user/1` to `/user/2`).

Comprehensive Answer:

Used to handle cases where the route changes but the component is reused (e.g., from `/user/1` to `/user/2`).

Copy Text Experience
94
What is `transition-group`?
Experience

Used for animating transitions of multiple elements (e.g., items in a list) using `v-for`.

Comprehensive Answer:

Used for animating transitions of multiple elements (e.g., items in a list) using `v-for`.

Copy Text Experience
95
How to handle API call cancellation on component unmount?
Experience

Using `AbortController` and calling `.abort()` in the `onUnmounted` hook.

Comprehensive Answer:

Using `AbortController` and calling `.abort()` in the `onUnmounted` hook.

Copy Text Experience
96
Explain `shallowSfc` concept.
Experience

Actually not a standard term, but usually refers to testing only the current component without its children.

Comprehensive Answer:

Actually not a standard term, but usually refers to testing only the current component without its children.

Copy Text Experience
97
How to use `v-memo` (Vue 3.2+)?
Experience

Speeds up rendering for large lists by skipping re-renders if a specific dependency array hasn't changed.

Comprehensive Answer:

Speeds up rendering for large lists by skipping re-renders if a specific dependency array hasn't changed.

Copy Text Experience
98
What is `custom elements` support in Vue?
Experience

Vue allows compiling components into standard Web Components using `defineCustomElement`.

Comprehensive Answer:

Vue allows compiling components into standard Web Components using `defineCustomElement`.

Copy Text Experience
99
Explain `Hydration Error` in Vue.
Experience

Occurs in SSR when the server-rendered HTML doesn't match the client-side initial render (e.g., due to random numbers or dates).

Comprehensive Answer:

Occurs in SSR when the server-rendered HTML doesn't match the client-side initial render (e.g., due to random numbers or dates).

Copy Text Experience
100
How to use `useCssModule` hook?
Experience

Used to access CSS Module classes in the Composition API.

Comprehensive Answer:

Used to access CSS Module classes in the Composition API.

Copy Text Experience
101
How does Vue's Reactivity System work under the hood?
Advanced

Vue 3 uses `Proxy` to intercept property access and mutation. When a property is accessed, a dependency is 'tracked'. When mutated, the dependencies a...

Comprehensive Answer:

Vue 3 uses `Proxy` to intercept property access and mutation. When a property is accessed, a dependency is 'tracked'. When mutated, the dependencies are 'triggered' to re-run.

Copy Text Advanced
102
Explain Virtual DOM's `Diffing Algorithm` in Vue 3.
Advanced

Vue 3 uses a 'Blocked' Virtual DOM which analyzes templates at build time to mark dynamic parts. During patching, it only visits the dynamic nodes, si...

Comprehensive Answer:

Vue 3 uses a 'Blocked' Virtual DOM which analyzes templates at build time to mark dynamic parts. During patching, it only visits the dynamic nodes, significantly improving performance ('compiler-informed virtualization').

Copy Text Advanced
103
Deep Dive: Proxy vs Object.defineProperty.
Advanced

`Proxy` can detect property addition/deletion and array index changes, which `defineProperty` couldn't. `Proxy` is also faster and doesn't require pre...

Comprehensive Answer:

`Proxy` can detect property addition/deletion and array index changes, which `defineProperty` couldn't. `Proxy` is also faster and doesn't require pre-traversing the object.

Copy Text Advanced
104
Explain Custom Renderers in Vue 3.
Advanced

Using `@vue/runtime-core`, you can create custom renderers for non-DOM environments like Canvas, Terminal, or Mobile (e.g., Vue Native, TresJS).

Comprehensive Answer:

Using `@vue/runtime-core`, you can create custom renderers for non-DOM environments like Canvas, Terminal, or Mobile (e.g., Vue Native, TresJS).

Copy Text Advanced
105
What is Compiler-Informed Fast Path?
Advanced

Vue 3 compiler analyzes the template and adds 'Patch Flags' to VNodes (e.g., TEXT, CLASS). The runtime then uses these flags to skip unnecessary check...

Comprehensive Answer:

Vue 3 compiler analyzes the template and adds 'Patch Flags' to VNodes (e.g., TEXT, CLASS). The runtime then uses these flags to skip unnecessary checks.

Copy Text Advanced
106
How to implement Micro-frontends with Vue?
Advanced

Using Webpack Module Federation, single-spa, or Vite's module-based approach with iframes or shared runtimes.

Comprehensive Answer:

Using Webpack Module Federation, single-spa, or Vite's module-based approach with iframes or shared runtimes.

Copy Text Advanced
107
Explain `Effect Scope` API.
Advanced

Allows creating a scope that can collect reactive effects (like watchers and computed) and dispose of them all at once, useful for build-time abstract...

Comprehensive Answer:

Allows creating a scope that can collect reactive effects (like watchers and computed) and dispose of them all at once, useful for build-time abstractions or complex composables.

Copy Text Advanced
108
What is the difference between `Runtime-Only` vs `Runtime + Compiler`?
Advanced

Runtime-only is smaller but requires pre-compilation of templates. Runtime+Compiler allows compiling templates in the browser but adds ~10KB overhead.

Comprehensive Answer:

Runtime-only is smaller but requires pre-compilation of templates. Runtime+Compiler allows compiling templates in the browser but adds ~10KB overhead.

Copy Text Advanced
109
Explain `Tree-shaking` in Vue 3.
Advanced

Vue 3 is written in a way that if you don't use a feature (like `Teleport` or `v-model`), it won't be included in the final production bundle.

Comprehensive Answer:

Vue 3 is written in a way that if you don't use a feature (like `Teleport` or `v-model`), it won't be included in the final production bundle.

Copy Text Advanced
110
What is `Hoisting` in Vue templates?
Advanced

The compiler hoists static VNodes outside of the render function so they are created only once and reused across renders.

Comprehensive Answer:

The compiler hoists static VNodes outside of the render function so they are created only once and reused across renders.

Copy Text Advanced
111
How does `Transition` work internally?
Advanced

Vue detects CSS transitions/animations on the element and automatically adds/removes CSS classes (`v-enter-from`, `v-enter-to`, etc.) at the right tim...

Comprehensive Answer:

Vue detects CSS transitions/animations on the element and automatically adds/removes CSS classes (`v-enter-from`, `v-enter-to`, etc.) at the right time.

Copy Text Advanced
112
Explain `Reactive` object unwrapping.
Advanced

Refs are automatically unwrapped when accessed as properties of a reactive object or in the template, so you don't need `.value`.

Comprehensive Answer:

Refs are automatically unwrapped when accessed as properties of a reactive object or in the template, so you don't need `.value`.

Copy Text Advanced
113
Deep Dive: Scoped CSS implementation.
Advanced

Vue adds a unique `data-v-xxxx` attribute to elements and modifies CSS selectors to target that attribute (`.my-class[data-v-xxxx]`).

Comprehensive Answer:

Vue adds a unique `data-v-xxxx` attribute to elements and modifies CSS selectors to target that attribute (`.my-class[data-v-xxxx]`).

Copy Text Advanced
114
How to build a Design System with Vue?
Advanced

Creating a package of atomic components using SFCs, documenting with Storybook, and distributing via NPM with types.

Comprehensive Answer:

Creating a package of atomic components using SFCs, documenting with Storybook, and distributing via NPM with types.

Copy Text Advanced
115
Explain `Vite`'s Hot Module Replacement (HMR).
Advanced

Vite uses ES Modules in development. When a file changes, it only replaces the module in the browser without reloading the page, preserving state.

Comprehensive Answer:

Vite uses ES Modules in development. When a file changes, it only replaces the module in the browser without reloading the page, preserving state.

Copy Text Advanced
116
What is `Static Site Generation` (SSG) with Nuxt?
Advanced

Generating every route of your application as a static HTML file at build time for maximum speed and SEO.

Comprehensive Answer:

Generating every route of your application as a static HTML file at build time for maximum speed and SEO.

Copy Text Advanced
117
How to handle large scale state with Pinia?
Advanced

By modularizing stores, using getters for derived state, and leveraging Pinia's subscription API for side effects.

Comprehensive Answer:

By modularizing stores, using getters for derived state, and leveraging Pinia's subscription API for side effects.

Copy Text Advanced
118
Explain `Functional` components performance.
Advanced

In Vue 2, functional components were significantly faster. In Vue 3, regular components are so fast that functional components offer minimal benefit.

Comprehensive Answer:

In Vue 2, functional components were significantly faster. In Vue 3, regular components are so fast that functional components offer minimal benefit.

Copy Text Advanced
119
How to use `useAsyncData` and `useFetch` in Nuxt 3?
Advanced

These are composables designed for Universal data fetching, ensuring data is fetched once on the server and hydrated on the client.

Comprehensive Answer:

These are composables designed for Universal data fetching, ensuring data is fetched once on the server and hydrated on the client.

Copy Text Advanced
120
What is `Reactive Transform` (Experimental)?
Advanced

A compiler-time transformation that allowed using `$ref` instead of `ref` to avoid `.value` (deprecated/removed in later versions in favor of standard...

Comprehensive Answer:

A compiler-time transformation that allowed using `$ref` instead of `ref` to avoid `.value` (deprecated/removed in later versions in favor of standard refs).

Copy Text Advanced
121
Security: `v-html` and CSRF protection.
Advanced

Always sanitize HTML using DOMPurify before using `v-html`. Ensure your API uses CSRF tokens if it relies on cookie-based auth.

Comprehensive Answer:

Always sanitize HTML using DOMPurify before using `v-html`. Ensure your API uses CSRF tokens if it relies on cookie-based auth.

Copy Text Advanced
122
How to implement `Custom Event Modifiers`?
Advanced

Actually Vue doesn't officially support custom modifiers, but you can wrap logic in a function or handle it in a custom directive.

Comprehensive Answer:

Actually Vue doesn't officially support custom modifiers, but you can wrap logic in a function or handle it in a custom directive.

Copy Text Advanced
123
Deep Dive: `v-model` on custom components.
Advanced

By default uses `modelValue` prop and `update:modelValue` event. Can be customized with different prop/event names in Vue 3.

Comprehensive Answer:

By default uses `modelValue` prop and `update:modelValue` event. Can be customized with different prop/event names in Vue 3.

Copy Text Advanced
124
How to use `Web Workers` with Vue Composition API?
Advanced

By offloading heavy logic into a worker file and communicating via `postMessage` encapsulated within a Composable.

Comprehensive Answer:

By offloading heavy logic into a worker file and communicating via `postMessage` encapsulated within a Composable.

Copy Text Advanced
125
Explain `Module Federation` with Vite.
Advanced

Using the `vite-plugin-federation` to share modules between independent builds at runtime.

Comprehensive Answer:

Using the `vite-plugin-federation` to share modules between independent builds at runtime.

Copy Text Advanced
126
Architecture: `Feature Slicing Design` in Vue.
Advanced

Organizing the project into Layers (app, processes, pages, features, entities, shared) to improve maintainability.

Comprehensive Answer:

Organizing the project into Layers (app, processes, pages, features, entities, shared) to improve maintainability.

Copy Text Advanced
127
How to unit test `Composables`?
Advanced

By testing the logic in isolation, occasionally using a dummy component if the composable relies on lifecycle hooks.

Comprehensive Answer:

By testing the logic in isolation, occasionally using a dummy component if the composable relies on lifecycle hooks.

Copy Text Advanced
128
Explain `Hydration Error` debugging.
Advanced

Checking for browser-specific APIs (window, document) used during the first render, or mismatched data between sever/client.

Comprehensive Answer:

Checking for browser-specific APIs (window, document) used during the first render, or mismatched data between sever/client.

Copy Text Advanced
129
How to implement `Role Based Access Control` (RBAC) in Vue?
Advanced

Using Vue Router Meta fields and a global `beforeEach` guard to check user roles against required permissions.

Comprehensive Answer:

Using Vue Router Meta fields and a global `beforeEach` guard to check user roles against required permissions.

Copy Text Advanced
130
Deep Dive: `Suspense` and data fetching patterns.
Advanced

Coordinating top-level loading states by making `setup` async or using `await` in `<script setup>`.

Comprehensive Answer:

Coordinating top-level loading states by making `setup` async or using `await` in `<script setup>`.

Copy Text Advanced
131
What is `Static Content Hoisting`?
Advanced

Compiler optimization where static HTML parts are stringified and created via `innerHTML` for massive speedups in heavy static templates.

Comprehensive Answer:

Compiler optimization where static HTML parts are stringified and created via `innerHTML` for massive speedups in heavy static templates.

Copy Text Advanced
132
How to use `provide/inject` for state management?
Advanced

As a 'light' alternative to Pinia for feature-scoped or module-scoped state sharing.

Comprehensive Answer:

As a 'light' alternative to Pinia for feature-scoped or module-scoped state sharing.

Copy Text Advanced
133
What is `Patch Flag` enumerate?
Advanced

Integers representing different types of dynamic content (e.g., 1 for text, 2 for class) used by the patcher.

Comprehensive Answer:

Integers representing different types of dynamic content (e.g., 1 for text, 2 for class) used by the patcher.

Copy Text Advanced
134
How to implement `Double-Click` directive?
Advanced

A custom directive that tracks time between clicks and triggers a callback if the interval is small.

Comprehensive Answer:

A custom directive that tracks time between clicks and triggers a callback if the interval is small.

Copy Text Advanced
135
Explain `Transition` vs `TransitionGroup` hooks.
Advanced

`Transition` is for a single element. `TransitionGroup` is for multiple elements, requiring a `tag` prop and unique `key` for each item.

Comprehensive Answer:

`Transition` is for a single element. `TransitionGroup` is for multiple elements, requiring a `tag` prop and unique `key` for each item.

Copy Text Advanced
136
How to scale Vue applications to millions of users?
Advanced

Using SSR/SSG for fast initial load, aggressive caching, CDN distribution, and optimized bundle fragmentation.

Comprehensive Answer:

Using SSR/SSG for fast initial load, aggressive caching, CDN distribution, and optimized bundle fragmentation.

Copy Text Advanced
137
What is `unmount` vs `destroy`?
Advanced

`destroy` was used in Vue 2; it was renamed to `unmount` in Vue 3 to better match the lifecycle of many modern frameworks.

Comprehensive Answer:

`destroy` was used in Vue 2; it was renamed to `unmount` in Vue 3 to better match the lifecycle of many modern frameworks.

Copy Text Advanced
138
How to use `@vue/compiler-sfc` directly?
Advanced

Used by build tools to parse, template-compile, and style-compile SFC files programmatically.

Comprehensive Answer:

Used by build tools to parse, template-compile, and style-compile SFC files programmatically.

Copy Text Advanced
139
Explain `VNode` structure.
Advanced

An object with `type`, `props`, `children`, `key`, `el`, and other management properties.

Comprehensive Answer:

An object with `type`, `props`, `children`, `key`, `el`, and other management properties.

Copy Text Advanced
140
How to handle `Reactivity Leak`?
Advanced

Ensuring watchers and event listeners are properly stopped/removed when no longer needed (Vue 3 handles most of this automatically in `onUnmounted`).

Comprehensive Answer:

Ensuring watchers and event listeners are properly stopped/removed when no longer needed (Vue 3 handles most of this automatically in `onUnmounted`).

Copy Text Advanced
141
What is `Slots` implementation in VNode?
Advanced

Slots are passed as an object of functions (`children` property in VNode) that return arrays of VNodes.

Comprehensive Answer:

Slots are passed as an object of functions (`children` property in VNode) that return arrays of VNodes.

Copy Text Advanced
142
Deep Dive: `v-memo` vs `v-once`.
Advanced

`v-once` never updates. `v-memo` only updates when its dependencies change, allowing partial reactivity.

Comprehensive Answer:

`v-once` never updates. `v-memo` only updates when its dependencies change, allowing partial reactivity.

Copy Text Advanced
143
How to use `defineComponent` with Generics?
Advanced

Through complex TypeScript typings or using the `<script setup lang="ts" generic="T">` feature in Vue 3.3+.

Comprehensive Answer:

Through complex TypeScript typings or using the `<script setup lang="ts" generic="T">` feature in Vue 3.3+.

Copy Text Advanced
144
Explain `Plugin` vs `Composable` usage.
Advanced

Plugins are for global configuration or app-wide services. Composables are for shared logic and state between components.

Comprehensive Answer:

Plugins are for global configuration or app-wide services. Composables are for shared logic and state between components.

Copy Text Advanced
145
How to manage `Third-party Map` (Google/Leaflet) in Vue?
Advanced

Use `ref` to target a container, initialize in `mounted`, and use `markRaw` to prevent Vue from trying to make the map object reactive.

Comprehensive Answer:

Use `ref` to target a container, initialize in `mounted`, and use `markRaw` to prevent Vue from trying to make the map object reactive.

Copy Text Advanced
146
What is `defineOptions`?
Advanced

A macro in Vue 3.3+ to define component options (like `name`, `inheritAttrs`) directly inside `<script setup>`.

Comprehensive Answer:

A macro in Vue 3.3+ to define component options (like `name`, `inheritAttrs`) directly inside `<script setup>`.

Copy Text Advanced
147
Explain `Slots` type checking in Vue 3.3.
Advanced

Using `@slots` or `defineSlots` to provide type safety for scoped slots in external component usage.

Comprehensive Answer:

Using `@slots` or `defineSlots` to provide type safety for scoped slots in external component usage.

Copy Text Advanced
148
How to handle `Large Form` partial validation?
Advanced

Using libraries like Vuelidate or VeeValidate which allow validating specific fields or groups of fields.

Comprehensive Answer:

Using libraries like Vuelidate or VeeValidate which allow validating specific fields or groups of fields.

Copy Text Advanced
149
Deep Dive: `Vue Router` History Modes.
Advanced

HTML5 (`createWebHistory`), Hash (`createWebHashHistory`), and Memory (`createMemoryHistory`) modes and how each interacts with the server.

Comprehensive Answer:

HTML5 (`createWebHistory`), Hash (`createWebHashHistory`), and Memory (`createMemoryHistory`) modes and how each interacts with the server.

Copy Text Advanced
150
What is the future of Vue (Vapor Mode)?
Advanced

Vapor mode is an upcoming compiler that generates zero-virtual-DOM code, resulting in even smaller and faster apps.

Comprehensive Answer:

Vapor mode is an upcoming compiler that generates zero-virtual-DOM code, resulting in even smaller and faster apps.

Copy Text Advanced
151
How to implement a `useFetch` composable?
Experience

Create a function that returns reactive `data`, `error`, and `loading` states.

Comprehensive Answer:

Create a function that returns reactive `data`, `error`, and `loading` states.

Vue Snippet:
export function useFetch(url) {
  const data = ref(null);
  const error = ref(null);
  const loading = ref(true);

  fetch(url)
    .then(res => res.json())
    .then(json => (data.value = json))
    .catch(err => (error.value = err))
    .finally(() => (loading.value = false));

  return { data, error, loading };
}
Copy Text Programming
152
Create a simple Toggle button with Vue 3.
Beginner

Use a simple ref and toggle it with a click.

Comprehensive Answer:

Use a simple ref and toggle it with a click.

Vue Snippet:
<script setup>
const active = ref(false);
</script>
<button @click="active = !active">
  {{ active ? 'ON' : 'OFF' }}
</button>
Copy Text Programming
153
How to implement a Search Filter on a list?
Beginner

Use a computed property that filters the array based on a query ref.

Comprehensive Answer:

Use a computed property that filters the array based on a query ref.

Vue Snippet:
const query = ref('');
const filtered = computed(() => {
  return items.value.filter(item => item.name.includes(query.value));
});
Copy Text Programming
154
Implement a Countdown Timer.
Experience

Use `setInterval` and `onUnmounted` for cleanup.

Comprehensive Answer:

Use `setInterval` and `onUnmounted` for cleanup.

Vue Snippet:
const count = ref(60);
let timer;
onMounted(() => {
  timer = setInterval(() => count.value--, 1000);
});
onUnmounted(() => clearInterval(timer));
Copy Text Programming
155
How to create a `useLocalStorage` composable?
Experience

A function that syncs a reactive ref with a localStorage key.

Comprehensive Answer:

A function that syncs a reactive ref with a localStorage key.

Vue Snippet:
export function useLocalStorage(key, val) {
  const storage = ref(JSON.parse(localStorage.getItem(key)) || val);
  watchEffect(() => localStorage.setItem(key, JSON.stringify(storage.value)));
  return storage;
}
Copy Text Programming
156
Implement a deep copy in JavaScript.
Beginner

Use JSON parse/stringify for simple objects or structuredClone for modern browsers.

Comprehensive Answer:

Use JSON parse/stringify for simple objects or structuredClone for modern browsers.

Vue Snippet:
const copy = obj => JSON.parse(JSON.stringify(obj));
Copy Text Programming
157
How to debounce a search input in Vue?
Experience

Watch the input and use a timeout.

Comprehensive Answer:

Watch the input and use a timeout.

Vue Snippet:
watch(input, (val) => {
  clearTimeout(timeout);
  timeout = setTimeout(() => search(val), 500);
});
Copy Text Programming
158
Create a `useMouse` composable.
Beginner

Track mouse coordinates globally.

Comprehensive Answer:

Track mouse coordinates globally.

Vue Snippet:
export function useMouse() {
  const x = ref(0);
  const y = ref(0);
  const update = e => { x.value = e.pageX; y.value = e.pageY; };
  onMounted(() => window.addEventListener('mousemove', update));
  onUnmounted(() => window.removeEventListener('mousemove', update));
  return { x, y };
}
Copy Text Programming
159
Check if a string is a palindrome.
Beginner

Reverse and compare.

Comprehensive Answer:

Reverse and compare.

Vue Snippet:
const isPal = s => s === s.split('').reverse().join('');
Copy Text Programming
160
Implement a simple `v-focus` directive.
Beginner

Focus the element when it is mounted.

Comprehensive Answer:

Focus the element when it is mounted.

Vue Snippet:
const vFocus = {
  mounted: (el) => el.focus()
};
Copy Text Programming
161
How to handle multiple models with `v-model` in Vue 3?
Experience

Use arguments like `v-model:title` and `v-model:content`.

Comprehensive Answer:

Use arguments like `v-model:title` and `v-model:content`.

Vue Snippet:
defineProps(['title', 'content']);
const emit = defineEmits(['update:title', 'update:content']);
Copy Text Programming
162
Flatten a nested array without .flat().
Experience

Use recursion with reduce.

Comprehensive Answer:

Use recursion with reduce.

Vue Snippet:
const flatten = arr => arr.reduce((acc, val) => 
  Array.isArray(val) ? acc.concat(flatten(val)) : acc.concat(val), []);
Copy Text Programming
163
Sum of all even numbers in an array.
Beginner

Filter and then reduce.

Comprehensive Answer:

Filter and then reduce.

Vue Snippet:
const sumEven = arr => arr.filter(n => n % 2 === 0).reduce((a, b) => a + b, 0);
Copy Text Programming
164
How to use `Suspense` and handle errors?
Advanced

Wrap `Suspense` with an `onErrorCaptured` component.

Comprehensive Answer:

Wrap `Suspense` with an `onErrorCaptured` component.

Vue Snippet:
<Suspense>
  <AsyncComponent />
  <template #fallback>Loading...</template>
</Suspense>
Copy Text Programming
165
Remove duplicates from an array.
Beginner

Use a Set.

Comprehensive Answer:

Use a Set.

Vue Snippet:
const unique = arr => [...new Set(arr)];
Copy Text Programming
166
Implement a generic `useToggle` hook.
Beginner

A function that returns a boolean and a toggle function.

Comprehensive Answer:

A function that returns a boolean and a toggle function.

Vue Snippet:
export function useToggle(init = false) {
  const state = ref(init);
  const toggle = () => (state.value = !state.value);
  return [state, toggle];
}
Copy Text Programming
167
How to use `nextTick` for DOM access?
Beginner

Wait for DOM updates after state changes.

Comprehensive Answer:

Wait for DOM updates after state changes.

Vue Snippet:
count.value++;
await nextTick();
console.log(el.value.textContent);
Copy Text Programming
168
Capitalize the first letter of each word.
Beginner

Map through words and capitalize.

Comprehensive Answer:

Map through words and capitalize.

Vue Snippet:
const cap = s => s.split(' ').map(w => w[0].toUpperCase() + w.slice(1)).join(' ');
Copy Text Programming
169
Implement Fibonacci sequence.
Beginner

Standard recursive or iterative approach.

Comprehensive Answer:

Standard recursive or iterative approach.

Vue Snippet:
const fib = n => n <= 1 ? n : fib(n-1) + fib(n-2);
Copy Text Programming
170
Find the longest word in a string.
Beginner

Split and reduce to find max length.

Comprehensive Answer:

Split and reduce to find max length.

Vue Snippet:
const longest = s => s.split(' ').reduce((a, b) => b.length > a.length ? b : a);
Copy Text Programming
171
How to create a Custom SVG Loader component?
Beginner

Pass SVG paths as props.

Comprehensive Answer:

Pass SVG paths as props.

Vue Snippet:
<template>
  <svg><path :d="iconPath" /></svg>
</template>
Copy Text Programming
172
Implement a Drag and Drop logic (Basic).
Advanced

Use `draggable` attribute and `dragstart/drop` events.

Comprehensive Answer:

Use `draggable` attribute and `dragstart/drop` events.

Vue Snippet:
<div draggable="true" @dragstart="handleDrag">
Copy Text Programming
173
Check if two objects are equal (Deep Equality).
Advanced

Recursive comparison of keys and values.

Comprehensive Answer:

Recursive comparison of keys and values.

Vue Snippet:
const isEqual = (a, b) => JSON.stringify(a) === JSON.stringify(b);
Copy Text Programming
174
How to use `toRef` on a reactive object property?
Beginner

Link a single property to a new ref.

Comprehensive Answer:

Link a single property to a new ref.

Vue Snippet:
const name = toRef(user, 'name');
Copy Text Programming
175
Implement an Infinite Scroll (Intersection Observer).
Advanced

Observe a sentinel element at the bottom of the list.

Comprehensive Answer:

Observe a sentinel element at the bottom of the list.

Vue Snippet:
new IntersectionObserver(([e]) => {
  if(e.isIntersecting) loadMore();
}).observe(sentinel.value);
Copy Text Programming
176
Find the maximum number in an array.
Beginner

Use `Math.max` with spread.

Comprehensive Answer:

Use `Math.max` with spread.

Vue Snippet:
const max = arr => Math.max(...arr);
Copy Text Programming
177
Create a simple Pinia store.
Experience

Define state, getters, and actions.

Comprehensive Answer:

Define state, getters, and actions.

Vue Snippet:
export const useStore = defineStore('main', {
  state: () => ({ count: 0 }),
  actions: { increment() { this.count++ } }
});
Copy Text Programming
178
How to handle file upload in Vue?
Beginner

Access files from a file input change event.

Comprehensive Answer:

Access files from a file input change event.

Vue Snippet:
const onFile = e => { const file = e.target.files[0]; };
Copy Text Programming
179
Implement a simple `v-ripple` directive effect.
Advanced

Click listener that adds a temporary expanding circle to the DOM.

Comprehensive Answer:

Click listener that adds a temporary expanding circle to the DOM.

Vue Snippet:
mounted(el) { el.onclick = e => { ... } }
Copy Text Programming
180
Calculate the average of an array of numbers.
Beginner

Sum divided by length.

Comprehensive Answer:

Sum divided by length.

Vue Snippet:
const avg = arr => arr.reduce((a, b) => a + b, 0) / arr.length;
Copy Text Programming
181
How to use `useAsyncState` in VueUse?
Experience

Handle non-blocking data fetching easily.

Comprehensive Answer:

Handle non-blocking data fetching easily.

Vue Snippet:
const { state, isReady } = useAsyncState(fetchData());
Copy Text Programming
182
Generate a random Hex color.
Beginner

Random number to hex string.

Comprehensive Answer:

Random number to hex string.

Vue Snippet:
const color = () => '#' + Math.floor(Math.random()*16777215).toString(16);
Copy Text Programming
183
Reverse a number in JS.
Beginner

Convert to string, reverse, and back to number.

Comprehensive Answer:

Convert to string, reverse, and back to number.

Vue Snippet:
const rev = n => parseFloat(n.toString().split('').reverse().join('')) * Math.sign(n);
Copy Text Programming
184
How to use `teleport` for a notification toast?
Beginner

Teleport to a dedicated container outside the app overflow.

Comprehensive Answer:

Teleport to a dedicated container outside the app overflow.

Vue Snippet:
<Teleport to="body"><Toast /></Teleport>
Copy Text Programming
185
Implement a simple `Pub/Sub` pattern in JS.
Experience

An object with events and subscribe/publish methods.

Comprehensive Answer:

An object with events and subscribe/publish methods.

Vue Snippet:
const bus = { events: {}, emit(n, d) { ... }, on(n, f) { ... } };
Copy Text Programming
186
Find the missing number in an array (1-100).
Experience

Subtract actual sum from expected sum.

Comprehensive Answer:

Subtract actual sum from expected sum.

Vue Snippet:
const missing = arr => (100 * 101 / 2) - arr.reduce((a,b)=>a+b);
Copy Text Programming
187
How to use `provide/inject` for a Theme Switcher?
Experience

Provide the theme ref at the top and inject it in components.

Comprehensive Answer:

Provide the theme ref at the top and inject it in components.

Vue Snippet:
provide('theme', themeRef);
Copy Text Programming
188
Implement a simple `v-lazy` image loader.
Experience

Use Intersection Observer to swap data-src to src.

Comprehensive Answer:

Use Intersection Observer to swap data-src to src.

Vue Snippet:
mounted(el) { observer.observe(el); }
Copy Text Programming
189
FizzBuzz problem implementation.
Beginner

Modulo for 3, 5, or both.

Comprehensive Answer:

Modulo for 3, 5, or both.

Vue Snippet:
for(let i=1;i<=15;i++) console.log((i%3?'':'Fizz')+(i%5?'':'Buzz')||i);
Copy Text Programming
190
Count vowels in a string.
Beginner

Regex match length.

Comprehensive Answer:

Regex match length.

Vue Snippet:
const count = s => (s.match(/[aeiou]/gi) || []).length;
Copy Text Programming
191
How to use `AbortController` in `fetch`?
Experience

Pass the signal to fetch and call abort on unmount.

Comprehensive Answer:

Pass the signal to fetch and call abort on unmount.

Vue Snippet:
const ctrl = new AbortController(); fetch(u, { signal: ctrl.signal });
Copy Text Programming
192
Check if an object is empty.
Beginner

Object.keys length check.

Comprehensive Answer:

Object.keys length check.

Vue Snippet:
const empty = o => Object.keys(o).length === 0;
Copy Text Programming
193
Implement a sorting function for a table.
Beginner

Re-order the array based on a key and direction.

Comprehensive Answer:

Re-order the array based on a key and direction.

Vue Snippet:
const sort = (key) => items.value.sort((a,b) => a[key] > b[key] ? 1 : -1);
Copy Text Programming
194
How to use `useVModel` from VueUse?
Experience

Easily sync a prop with a local ref for `v-model` binding.

Comprehensive Answer:

Easily sync a prop with a local ref for `v-model` binding.

Vue Snippet:
const data = useVModel(props, 'modelValue', emit);
Copy Text Programming
195
Shuffle an array randomly.
Beginner

Fisher-Yates shuffle algorithm.

Comprehensive Answer:

Fisher-Yates shuffle algorithm.

Vue Snippet:
const shuffle = arr => arr.sort(() => Math.random() - 0.5);
Copy Text Programming
196
Detect prime numbers.
Beginner

Check divisibility up to sqrt(n).

Comprehensive Answer:

Check divisibility up to sqrt(n).

Vue Snippet:
const isPrime = n => { for(let i=2; i<=Math.sqrt(n); i++) if(n%i===0) return false; return n > 1; };
Copy Text Programming
197
How to create a `useWindowResize` composable?
Beginner

Watch window resize event and update width/height refs.

Comprehensive Answer:

Watch window resize event and update width/height refs.

Vue Snippet:
window.onresize = () => { w.value = window.innerWidth; };
Copy Text Programming
198
Convert Snake Case to Camel Case in JS.
Beginner

Regex string replacement.

Comprehensive Answer:

Regex string replacement.

Vue Snippet:
const toCamel = s => s.replace(/_([a-z])/g, m => m[1].toUpperCase());
Copy Text Programming
199
Implement a simple `v-tooltip` directive (title based).
Experience

Create and position a floating div on mouseover.

Comprehensive Answer:

Create and position a floating div on mouseover.

Vue Snippet:
mounted(el) { el.onmouseenter = ... }
Copy Text Programming
200
How to use `defineExpose` for a Modal component?
Experience

Expose 'open' and 'close' methods to the parent.

Comprehensive Answer:

Expose 'open' and 'close' methods to the parent.

Vue Snippet:
defineExpose({ open: () => (show.value = true) });
Copy Text Programming

Master Vue.js in 2026

Get weekly deep dives into Vue 3.4 features and Pinia best practices.

\n"}},{"@type":"Question","name":"How to implement a Search Filter on a list?","acceptedAnswer":{"@type":"Answer","text":"Use a computed property that filters the array based on a query ref.\n\nCode:\nconst query = ref('');\nconst filtered = computed(() => {\n return items.value.filter(item => item.name.includes(query.value));\n});"}},{"@type":"Question","name":"Implement a Countdown Timer.","acceptedAnswer":{"@type":"Answer","text":"Use `setInterval` and `onUnmounted` for cleanup.\n\nCode:\nconst count = ref(60);\nlet timer;\nonMounted(() => {\n timer = setInterval(() => count.value--, 1000);\n});\nonUnmounted(() => clearInterval(timer));"}},{"@type":"Question","name":"How to create a `useLocalStorage` composable?","acceptedAnswer":{"@type":"Answer","text":"A function that syncs a reactive ref with a localStorage key.\n\nCode:\nexport function useLocalStorage(key, val) {\n const storage = ref(JSON.parse(localStorage.getItem(key)) || val);\n watchEffect(() => localStorage.setItem(key, JSON.stringify(storage.value)));\n return storage;\n}"}},{"@type":"Question","name":"Implement a deep copy in JavaScript.","acceptedAnswer":{"@type":"Answer","text":"Use JSON parse/stringify for simple objects or structuredClone for modern browsers.\n\nCode:\nconst copy = obj => JSON.parse(JSON.stringify(obj));"}},{"@type":"Question","name":"How to debounce a search input in Vue?","acceptedAnswer":{"@type":"Answer","text":"Watch the input and use a timeout.\n\nCode:\nwatch(input, (val) => {\n clearTimeout(timeout);\n timeout = setTimeout(() => search(val), 500);\n});"}},{"@type":"Question","name":"Create a `useMouse` composable.","acceptedAnswer":{"@type":"Answer","text":"Track mouse coordinates globally.\n\nCode:\nexport function useMouse() {\n const x = ref(0);\n const y = ref(0);\n const update = e => { x.value = e.pageX; y.value = e.pageY; };\n onMounted(() => window.addEventListener('mousemove', update));\n onUnmounted(() => window.removeEventListener('mousemove', update));\n return { x, y };\n}"}},{"@type":"Question","name":"Check if a string is a palindrome.","acceptedAnswer":{"@type":"Answer","text":"Reverse and compare.\n\nCode:\nconst isPal = s => s === s.split('').reverse().join('');"}},{"@type":"Question","name":"Implement a simple `v-focus` directive.","acceptedAnswer":{"@type":"Answer","text":"Focus the element when it is mounted.\n\nCode:\nconst vFocus = {\n mounted: (el) => el.focus()\n};"}},{"@type":"Question","name":"How to handle multiple models with `v-model` in Vue 3?","acceptedAnswer":{"@type":"Answer","text":"Use arguments like `v-model:title` and `v-model:content`.\n\nCode:\ndefineProps(['title', 'content']);\nconst emit = defineEmits(['update:title', 'update:content']);"}},{"@type":"Question","name":"Flatten a nested array without .flat().","acceptedAnswer":{"@type":"Answer","text":"Use recursion with reduce.\n\nCode:\nconst flatten = arr => arr.reduce((acc, val) => \n Array.isArray(val) ? acc.concat(flatten(val)) : acc.concat(val), []);"}},{"@type":"Question","name":"Sum of all even numbers in an array.","acceptedAnswer":{"@type":"Answer","text":"Filter and then reduce.\n\nCode:\nconst sumEven = arr => arr.filter(n => n % 2 === 0).reduce((a, b) => a + b, 0);"}},{"@type":"Question","name":"How to use `Suspense` and handle errors?","acceptedAnswer":{"@type":"Answer","text":"Wrap `Suspense` with an `onErrorCaptured` component.\n\nCode:\n\n \n \n"}},{"@type":"Question","name":"Remove duplicates from an array.","acceptedAnswer":{"@type":"Answer","text":"Use a Set.\n\nCode:\nconst unique = arr => [...new Set(arr)];"}},{"@type":"Question","name":"Implement a generic `useToggle` hook.","acceptedAnswer":{"@type":"Answer","text":"A function that returns a boolean and a toggle function.\n\nCode:\nexport function useToggle(init = false) {\n const state = ref(init);\n const toggle = () => (state.value = !state.value);\n return [state, toggle];\n}"}},{"@type":"Question","name":"How to use `nextTick` for DOM access?","acceptedAnswer":{"@type":"Answer","text":"Wait for DOM updates after state changes.\n\nCode:\ncount.value++;\nawait nextTick();\nconsole.log(el.value.textContent);"}},{"@type":"Question","name":"Capitalize the first letter of each word.","acceptedAnswer":{"@type":"Answer","text":"Map through words and capitalize.\n\nCode:\nconst cap = s => s.split(' ').map(w => w[0].toUpperCase() + w.slice(1)).join(' ');"}},{"@type":"Question","name":"Implement Fibonacci sequence.","acceptedAnswer":{"@type":"Answer","text":"Standard recursive or iterative approach.\n\nCode:\nconst fib = n => n <= 1 ? n : fib(n-1) + fib(n-2);"}},{"@type":"Question","name":"Find the longest word in a string.","acceptedAnswer":{"@type":"Answer","text":"Split and reduce to find max length.\n\nCode:\nconst longest = s => s.split(' ').reduce((a, b) => b.length > a.length ? b : a);"}},{"@type":"Question","name":"How to create a Custom SVG Loader component?","acceptedAnswer":{"@type":"Answer","text":"Pass SVG paths as props.\n\nCode:\n"}},{"@type":"Question","name":"Implement a Drag and Drop logic (Basic).","acceptedAnswer":{"@type":"Answer","text":"Use `draggable` attribute and `dragstart/drop` events.\n\nCode:\n
"}},{"@type":"Question","name":"Check if two objects are equal (Deep Equality).","acceptedAnswer":{"@type":"Answer","text":"Recursive comparison of keys and values.\n\nCode:\nconst isEqual = (a, b) => JSON.stringify(a) === JSON.stringify(b);"}},{"@type":"Question","name":"How to use `toRef` on a reactive object property?","acceptedAnswer":{"@type":"Answer","text":"Link a single property to a new ref.\n\nCode:\nconst name = toRef(user, 'name');"}},{"@type":"Question","name":"Implement an Infinite Scroll (Intersection Observer).","acceptedAnswer":{"@type":"Answer","text":"Observe a sentinel element at the bottom of the list.\n\nCode:\nnew IntersectionObserver(([e]) => {\n if(e.isIntersecting) loadMore();\n}).observe(sentinel.value);"}},{"@type":"Question","name":"Find the maximum number in an array.","acceptedAnswer":{"@type":"Answer","text":"Use `Math.max` with spread.\n\nCode:\nconst max = arr => Math.max(...arr);"}},{"@type":"Question","name":"Create a simple Pinia store.","acceptedAnswer":{"@type":"Answer","text":"Define state, getters, and actions.\n\nCode:\nexport const useStore = defineStore('main', {\n state: () => ({ count: 0 }),\n actions: { increment() { this.count++ } }\n});"}},{"@type":"Question","name":"How to handle file upload in Vue?","acceptedAnswer":{"@type":"Answer","text":"Access files from a file input change event.\n\nCode:\nconst onFile = e => { const file = e.target.files[0]; };"}},{"@type":"Question","name":"Implement a simple `v-ripple` directive effect.","acceptedAnswer":{"@type":"Answer","text":"Click listener that adds a temporary expanding circle to the DOM.\n\nCode:\nmounted(el) { el.onclick = e => { ... } }"}},{"@type":"Question","name":"Calculate the average of an array of numbers.","acceptedAnswer":{"@type":"Answer","text":"Sum divided by length.\n\nCode:\nconst avg = arr => arr.reduce((a, b) => a + b, 0) / arr.length;"}},{"@type":"Question","name":"How to use `useAsyncState` in VueUse?","acceptedAnswer":{"@type":"Answer","text":"Handle non-blocking data fetching easily.\n\nCode:\nconst { state, isReady } = useAsyncState(fetchData());"}},{"@type":"Question","name":"Generate a random Hex color.","acceptedAnswer":{"@type":"Answer","text":"Random number to hex string.\n\nCode:\nconst color = () => '#' + Math.floor(Math.random()*16777215).toString(16);"}},{"@type":"Question","name":"Reverse a number in JS.","acceptedAnswer":{"@type":"Answer","text":"Convert to string, reverse, and back to number.\n\nCode:\nconst rev = n => parseFloat(n.toString().split('').reverse().join('')) * Math.sign(n);"}},{"@type":"Question","name":"How to use `teleport` for a notification toast?","acceptedAnswer":{"@type":"Answer","text":"Teleport to a dedicated container outside the app overflow.\n\nCode:\n"}},{"@type":"Question","name":"Implement a simple `Pub/Sub` pattern in JS.","acceptedAnswer":{"@type":"Answer","text":"An object with events and subscribe/publish methods.\n\nCode:\nconst bus = { events: {}, emit(n, d) { ... }, on(n, f) { ... } };"}},{"@type":"Question","name":"Find the missing number in an array (1-100).","acceptedAnswer":{"@type":"Answer","text":"Subtract actual sum from expected sum.\n\nCode:\nconst missing = arr => (100 * 101 / 2) - arr.reduce((a,b)=>a+b);"}},{"@type":"Question","name":"How to use `provide/inject` for a Theme Switcher?","acceptedAnswer":{"@type":"Answer","text":"Provide the theme ref at the top and inject it in components.\n\nCode:\nprovide('theme', themeRef);"}},{"@type":"Question","name":"Implement a simple `v-lazy` image loader.","acceptedAnswer":{"@type":"Answer","text":"Use Intersection Observer to swap data-src to src.\n\nCode:\nmounted(el) { observer.observe(el); }"}},{"@type":"Question","name":"FizzBuzz problem implementation.","acceptedAnswer":{"@type":"Answer","text":"Modulo for 3, 5, or both.\n\nCode:\nfor(let i=1;i<=15;i++) console.log((i%3?'':'Fizz')+(i%5?'':'Buzz')||i);"}},{"@type":"Question","name":"Count vowels in a string.","acceptedAnswer":{"@type":"Answer","text":"Regex match length.\n\nCode:\nconst count = s => (s.match(/[aeiou]/gi) || []).length;"}},{"@type":"Question","name":"How to use `AbortController` in `fetch`?","acceptedAnswer":{"@type":"Answer","text":"Pass the signal to fetch and call abort on unmount.\n\nCode:\nconst ctrl = new AbortController(); fetch(u, { signal: ctrl.signal });"}},{"@type":"Question","name":"Check if an object is empty.","acceptedAnswer":{"@type":"Answer","text":"Object.keys length check.\n\nCode:\nconst empty = o => Object.keys(o).length === 0;"}},{"@type":"Question","name":"Implement a sorting function for a table.","acceptedAnswer":{"@type":"Answer","text":"Re-order the array based on a key and direction.\n\nCode:\nconst sort = (key) => items.value.sort((a,b) => a[key] > b[key] ? 1 : -1);"}},{"@type":"Question","name":"How to use `useVModel` from VueUse?","acceptedAnswer":{"@type":"Answer","text":"Easily sync a prop with a local ref for `v-model` binding.\n\nCode:\nconst data = useVModel(props, 'modelValue', emit);"}},{"@type":"Question","name":"Shuffle an array randomly.","acceptedAnswer":{"@type":"Answer","text":"Fisher-Yates shuffle algorithm.\n\nCode:\nconst shuffle = arr => arr.sort(() => Math.random() - 0.5);"}},{"@type":"Question","name":"Detect prime numbers.","acceptedAnswer":{"@type":"Answer","text":"Check divisibility up to sqrt(n).\n\nCode:\nconst isPrime = n => { for(let i=2; i<=Math.sqrt(n); i++) if(n%i===0) return false; return n > 1; };"}},{"@type":"Question","name":"How to create a `useWindowResize` composable?","acceptedAnswer":{"@type":"Answer","text":"Watch window resize event and update width/height refs.\n\nCode:\nwindow.onresize = () => { w.value = window.innerWidth; };"}},{"@type":"Question","name":"Convert Snake Case to Camel Case in JS.","acceptedAnswer":{"@type":"Answer","text":"Regex string replacement.\n\nCode:\nconst toCamel = s => s.replace(/_([a-z])/g, m => m[1].toUpperCase());"}},{"@type":"Question","name":"Implement a simple `v-tooltip` directive (title based).","acceptedAnswer":{"@type":"Answer","text":"Create and position a floating div on mouseover.\n\nCode:\nmounted(el) { el.onmouseenter = ... }"}},{"@type":"Question","name":"How to use `defineExpose` for a Modal component?","acceptedAnswer":{"@type":"Answer","text":"Expose 'open' and 'close' methods to the parent.\n\nCode:\ndefineExpose({ open: () => (show.value = true) });"}}]}