\n\nBenefits of Composition API:\n• Better logic reuse and composition\n• More flexible code organization\n• Superior TypeScript integration\n• Smaller bundle size with tree-shaking"}},{"@type":"Question","acceptedAnswer":{"@type":"Answer","text":"Vuex is a state management pattern + library for Vue.js applications. It serves as a centralized store for all components.\n\nCore Concepts:\n1. State: Single source of truth - the data\n2. Getters: Computed properties for the store\n3. Mutations: Synchronous state changes (commit)\n4. Actions: Asynchronous operations (dispatch)\n5. Modules: For organizing large stores\n\nComplete Example:\n// store/index.js\nimport Vue from 'vue'\nimport Vuex from 'vuex'\n\nVue.use(Vuex)\n\nexport default new Vuex.Store({\n state: {\n count: 0,\n user: null\n },\n getters: {\n doubleCount: state => state.count * 2,\n isAuthenticated: state => !!state.user\n },\n mutations: {\n INCREMENT(state, payload) {\n state.count += payload.amount\n },\n SET_USER(state, user) {\n state.user = user\n }\n },\n actions: {\n incrementAsync({ commit }, payload) {\n setTimeout(() => {\n commit('INCREMENT', payload)\n }, 1000)\n },\n async login({ commit }, credentials) {\n const user = await api.login(credentials)\n commit('SET_USER', user)\n }\n },\n modules: {\n cart: cartModule,\n products: productsModule\n }\n})\n\nComponent Usage:\n// In component\ncomputed: {\n count() {\n return this.$store.state.count\n },\n doubleCount() {\n return this.$store.getters.doubleCount\n }\n},\nmethods: {\n increment() {\n this.$store.commit('INCREMENT', { amount: 1 })\n },\n incrementAsync() {\n this.$store.dispatch('incrementAsync', { amount: 1 })\n }\n}\n\nVuex Best Practices:\n• Use mutations for synchronous state changes\n• Use actions for asynchronous operations\n• Keep mutations simple and focused\n• Use getters for computed state\n• Organize large stores with modules"}},{"@type":"Question","acceptedAnswer":{"@type":"Answer","text":"Vue Router is the official router for Vue.js applications, enabling Single Page Application (SPA) navigation.\n\nBasic Setup:\nimport Vue from 'vue'\nimport Router from 'vue-router'\nimport Home from './views/Home.vue'\n\nVue.use(Router)\n\nexport default new Router({\n mode: 'history', // Remove hash from URL\n routes: [\n {\n path: '/',\n name: 'home',\n component: Home\n },\n {\n path: '/about',\n name: 'about',\n component: () => import('./views/About.vue') // Lazy loading\n },\n {\n path: '/user/:id',\n name: 'user',\n component: User,\n props: true // Pass route params as props\n }\n ]\n})\n\nNavigation Guards:\n1. Global Guards:\nrouter.beforeEach((to, from, next) => {\n if (to.meta.requiresAuth && !isAuthenticated) {\n next('/login')\n } else {\n next()\n }\n})\n\n2. Per-Route Guards:\n{\n path: '/admin',\n component: Admin,\n beforeEnter: (to, from, next) => {\n if (!isAdmin()) next('/login')\n else next()\n }\n}\n\n3. In-Component Guards:\nexport default {\n beforeRouteEnter(to, from, next) {\n // Cannot access 'this'\n next(vm => {\n // Access component instance via 'vm'\n })\n },\n beforeRouteUpdate(to, from, next) {\n // React to route changes for same component\n this.fetchData(to.params.id)\n next()\n },\n beforeRouteLeave(to, from, next) {\n const answer = window.confirm('Do you really want to leave?')\n if (answer) next()\n else next(false)\n }\n}\n\nRoute Meta Fields:\n{\n path: '/profile',\n component: Profile,\n meta: {\n requiresAuth: true,\n title: 'User Profile'\n }\n}\n\nLazy Loading (Code Splitting):\nconst About = () => import('./views/About.vue')\n// Or with webpack magic comments\nconst About = () => import(/* webpackChunkName: \"about\" */ './views/About.vue')\n\nDynamic Route Matching:\n{\n path: '/user/:userId/post/:postId',\n component: UserPost\n}\n// Access via this.$route.params.userId and this.$route.params.postId"}},{"@type":"Question","acceptedAnswer":{"@type":"Answer","text":"Directives are special attributes with the v- prefix that apply reactive behavior to the DOM.\n\nCommonly Used Directives:\n\n1. v-text: Updates element's textContent\n \n\n2. v-html: Updates element's innerHTML (use carefully - XSS risk)\n
\n\n3. v-show: Toggles display CSS property\n
Visible or hidden
\n\n4. v-if / v-else-if / v-else: Conditional rendering\n
A
\n
B
\n
Not A/B
\n\n5. v-for: List rendering\n
  • \n {{ index }} - {{ item.name }}\n
  • \n\n6. v-on (@): Attaches event listeners\n \n
    Submit
    \n\n7. v-bind (:): Dynamically binds attributes\n \n
    \n\n8. v-model: Two-way binding for form inputs\n \n \n \n\n9. v-pre: Skip compilation for this element and children\n {{ this will not be compiled }}\n\n10. v-cloak: Hide uncompiled templates until Vue is ready\n [v-cloak] { display: none; }\n
    {{ message }}
    \n\n11. v-once: Render element/component once\n This will never change: {{ msg }}\n\n12. v-slot (#): Named slots (shorthand: #)\n \n \n\nCustom Directives:\n// Global custom directive\nVue.directive('focus', {\n inserted: function (el) {\n el.focus()\n }\n})\n// Usage: "}},{"@type":"Question","acceptedAnswer":{"@type":"Answer","text":"Vue provides multiple ways for components to communicate:\n\n1. Props Down (Parent to Child):\n// Parent\n\n\n// Child\nexport default {\n props: {\n message: String,\n user: Object\n }\n}\n\n2. Events Up (Child to Parent):\n// Child\nthis.$emit('update', newValue)\n\n// Parent\n\n\n3. v-model (Two-way binding):\n// Custom component with v-model\nexport default {\n model: {\n prop: 'value',\n event: 'input'\n },\n props: ['value'],\n methods: {\n updateValue(newVal) {\n this.$emit('input', newVal)\n }\n }\n}\n\n4. Provide/Inject (Ancestor to Descendant):\n// Ancestor\nexport default {\n provide() {\n return {\n theme: this.themeData\n }\n }\n}\n\n// Descendant\nexport default {\n inject: ['theme']\n}\n\n5. Event Bus (Global communication):\n// event-bus.js\nimport Vue from 'vue'\nexport const EventBus = new Vue()\n\n// Component A\nEventBus.$emit('user-logged-in', userData)\n\n// Component B\nEventBus.$on('user-logged-in', (userData) => {\n // Handle event\n})\n\n6. Vuex (Centralized state management):\n// Store mutations/actions for global state\n\n7. $refs (Direct component access):\n\n\n// Parent\nthis.$refs.childRef.someMethod()\n\n8. $parent / $children (Direct hierarchy access):\n// Access parent component\nthis.$parent.parentMethod()\n\n// Access child components\nthis.$children[0].childMethod()\n\nBest Practices:\n• Use props/events for parent-child communication\n• Use Vuex for complex application state\n• Use provide/inject for deeply nested components\n• Avoid $parent/$children for maintainability\n• Use event bus sparingly for global events"}},{"@type":"Question","acceptedAnswer":{"@type":"Answer","text":"Mixins are a way to distribute reusable functionality for Vue components.\n\nBasic Mixin Example:\n// mixins/logger.js\nexport const loggerMixin = {\n created() {\n console.log('Component created:', this.$options.name)\n },\n methods: {\n logMessage(message) {\n console.log('Log:', message)\n }\n }\n}\n\n// Using the mixin\nimport { loggerMixin } from './mixins/logger.js'\n\nexport default {\n mixins: [loggerMixin],\n created() {\n this.logMessage('Hello from component!')\n }\n}\n\nGlobal Mixin:\nVue.mixin({\n created() {\n console.log('Global mixin - created hook')\n }\n})\n\nAdvantages:\n• Code reuse across multiple components\n• Separation of concerns\n• Easy to maintain and update\n\nDisadvantages:\n• Name conflicts between mixin and component options\n• Implicit dependencies - hard to track where functionality comes from\n• Global mixins affect every component (use sparingly)\n\nMerging Strategies:\n• Data objects: Deep merged, component takes priority\n• Hook functions: Both called, mixin hooks called first\n• Methods/components/directives: Component takes priority\n\nVue 3 Alternative - Composables:\nWith Composition API, use composable functions instead:\n\n// composables/useLogger.js\nexport function useLogger() {\n const logMessage = (message) => {\n console.log('Log:', message)\n }\n \n onMounted(() => {\n console.log('Component mounted')\n })\n \n return { logMessage }\n}\n\n// Using composable\nimport { useLogger } from './composables/useLogger'\n\nexport default {\n setup() {\n const { logMessage } = useLogger()\n logMessage('Hello from component!')\n }\n}\n\nBest Practices:\n• Use mixins for cross-cutting concerns\n• Prefer local mixins over global ones\n• Use clear naming conventions to avoid conflicts\n• Consider Composition API composables for new projects"}},{"@type":"Question","acceptedAnswer":{"@type":"Answer","text":"Vue 3 introduced two powerful new features: Teleport and Suspense.\n\nTeleport:\nAllows you to render a component's content in a different part of the DOM, outside the component's hierarchy.\n\nUse Cases:\n• Modals\n• Tooltips\n• Notifications\n• Any content that needs to break out of container constraints\n\nExample:\n\n\n\nMultiple Teleports:\n\n
    First Modal
    \n
    \n\n
    Second Modal
    \n
    \n\nSuspense:\nHandles asynchronous dependencies in a declarative way, showing fallback content while waiting.\n\nBasic Usage:\n\n\nWith Async Setup:\n// AsyncComponent.vue\n\n\nWith Async Components:\nconst AsyncComponent = defineAsyncComponent({\n loader: () => import('./MyComponent.vue'),\n loadingComponent: LoadingSpinner,\n errorComponent: ErrorComponent,\n delay: 200, // Delay before showing loading\n timeout: 3000 // Timeout before error\n})\n\nEvent Handling:\n\n\nCombined Example:\n\n\nBenefits:\n• Teleport: Solves z-index and overflow issues\n• Suspense: Simplifies async component handling\n• Better user experience with proper loading states"}},{"@type":"Question","acceptedAnswer":{"@type":"Answer","text":"Server-Side Rendering (SSR) generates HTML on the server and sends it to the client, rather than rendering in the browser.\n\nBenefits of SSR:\n• Better SEO - search engines can crawl content\n• Faster initial page load\n• Better performance on slow devices\n• Social media meta tags work correctly\n\nVue SSR Basics:\n// server.js (Express example)\nconst Vue = require('vue')\nconst server = require('express')()\n\nconst renderer = require('vue-server-renderer').createRenderer()\n\nserver.get('*', (req, res) => {\n const app = new Vue({\n data: { url: req.url },\n template: '
    Visiting: {{ url }}
    '\n })\n\n renderer.renderToString(app, (err, html) => {\n if (err) {\n res.status(500).end('Internal Server Error')\n return\n }\n res.end(html)\n })\n})\n\nUniversal Code Requirements:\n• No platform-specific APIs in lifecycle hooks\n• No global state singletons\n• Proper data pre-fetching\n\nNuxt.js - The Vue SSR Framework:\nNuxt.js simplifies SSR with conventions and built-in features:\n\nKey Features:\n• Automatic code splitting\n• File-based routing\n• Static site generation\n• Auto-imported components\n• SEO optimization\n\nBasic Nuxt Structure:\npages/\n index.vue\n about.vue\n users/\n index.vue\n _id.vue\n\nAsync Data Fetching in Nuxt:\n// pages/posts.vue\nexport default {\n async asyncData({ $http }) {\n const posts = await $http.$get('/api/posts')\n return { posts }\n }\n}\n\nStatic Site Generation (SSG):\n// nuxt.config.js\nexport default {\n target: 'static',\n generate: {\n routes: ['/users/1', '/users/2', '/users/3']\n }\n}\n\nDeployment:\n• SSR: Node.js server required\n• SSG: Static files can be hosted on CDN\n• Hybrid: Some pages SSR, others static\n\nWhen to Use SSR:\n• SEO-critical applications\n• Social media sharing requirements\n• Slow client devices\n• Content-heavy sites\n\nWhen to Use SPA:\n• Dashboard applications\n• Authenticated user areas\n• Interactive applications where SEO isn't critical"}},{"@type":"Question","acceptedAnswer":{"@type":"Answer","text":"Vue 3 introduced significant performance improvements and new features:\n\nPerformance Improvements:\n\n1. Tree-shaking:\n • Only includes used features in final bundle\n • Reduces bundle size by 41% compared to Vue 2\n • Example: If you don't use v-model, it's not included\n\n2. Faster Virtual DOM:\n • Compiler-informed optimizations\n • Hoists static nodes out of render function\n • Patch flag optimization\n • Cache event handlers\n\n3. Proxy-based Reactivity:\n • Faster component instance initialization\n • Better memory usage\n • Full observation of new properties\n\n4. Composition API:\n • Better TypeScript support\n • Smaller bundles with tree-shaking\n • More efficient code organization\n\nNew Features:\n\n1. Composition API:\n setup() function for better logic reuse\n\n2. Multiple v-models:\n \n\n3. Multiple Root Elements:\n \n\n4. Fragments:\n Components can have multiple root nodes\n\n5. Teleport:\n Render content in different part of DOM\n\n6. Suspense:\n Handle async component dependencies\n\n7. Better TypeScript Support:\n • Written in TypeScript\n • Better type inference\n • Composition API designed with TS in mind\n\n8. Custom Renderer API:\n Create custom renderers for different platforms\n\n9. Global API Changes:\n // Vue 2\n Vue.component('comp', component)\n \n // Vue 3\n const app = createApp(App)\n app.component('comp', component)\n\n10. Emits Option:\n export default {\n emits: ['submit', 'update'],\n methods: {\n handleSubmit() {\n this.$emit('submit', data)\n }\n }\n }\n\nMigration Benefits:\n• Up to 2x faster rendering\n• Up to 3x smaller bundle sizes\n• Better developer experience\n• Future-proof architecture"}},{"@type":"Question","acceptedAnswer":{"@type":"Answer","text":"Plugins are self-contained code that add global-level functionality to Vue.\n\nCommon Use Cases for Plugins:\n• Add global methods or properties\n• Add global assets (directives, filters, components)\n• Add Vue instance methods\n• Add library functionality\n\nCreating a Custom Plugin:\n// plugins/my-plugin.js\nexport default {\n install(app, options) {\n // 1. Add global method or property\n app.config.globalProperties.$myMethod = (value) => {\n console.log('My method:', value)\n }\n\n // 2. Add global directive\n app.directive('focus', {\n mounted(el) {\n el.focus()\n }\n })\n\n // 3. Add global component\n app.component('my-component', {\n template: '
    My Component
    '\n })\n\n // 4. Inject provider\n app.provide('myService', {\n doSomething: () => console.log('Service method')\n })\n\n // 5. Add instance method\n app.config.globalProperties.$api = options.api\n }\n}\n\nUsing the Plugin:\n// main.js\nimport { createApp } from 'vue'\nimport MyPlugin from './plugins/my-plugin'\n\nconst app = createApp(App)\n\napp.use(MyPlugin, {\n api: 'https://api.example.com'\n})\n\napp.mount('#app')\n\nUsing Plugin Features in Components:\n// In component\nexport default {\n mounted() {\n this.$myMethod('Hello') // Global method\n this.$api.get('/users') // Injected API\n },\n setup() {\n // Using provide/inject in Composition API\n const myService = inject('myService')\n myService.doSomething()\n }\n}\n\nPopular Vue Plugins Examples:\n\n1. Vue Router:\n import Router from 'vue-router'\n app.use(Router)\n\n2. Vuex:\n import Vuex from 'vuex'\n app.use(Vuex)\n\n3. Vue I18n:\n import { createI18n } from 'vue-i18n'\n app.use(i18n)\n\n4. Vuetify:\n import Vuetify from 'vuetify'\n app.use(Vuetify)\n\nPlugin Best Practices:\n• Keep plugins focused and single-purpose\n• Provide good documentation\n• Use TypeScript for better type safety\n• Handle errors gracefully\n• Consider tree-shaking compatibility\n\nPlugin vs Mixin:\n• Plugins: Global functionality\n• Mixins: Component-level functionality\n• Use plugins for app-level features\n• Use mixins for reusable component logic"}},{"@type":"Question","acceptedAnswer":{"@type":"Answer","text":"Vue provides several ways to handle forms and validation:\n\n1. Basic Form Handling with v-model:\n\n\n\n\n2. Custom Validation:\n\n\n\n\n3. Using Vuelidate (Validation Library):\nimport { required, email, minLength } from 'vuelidate/lib/validators'\n\nexport default {\n data() {\n return {\n form: { name: '', email: '' }\n }\n },\n validations: {\n form: {\n name: { required, minLength: minLength(2) },\n email: { required, email }\n }\n },\n methods: {\n handleSubmit() {\n this.$v.$touch()\n if (!this.$v.$invalid) {\n // Submit form\n }\n }\n }\n}\n\nTemplate with Vuelidate:\n\n
    \n Name is required\n Name is too short\n
    \n\n4. Using VeeValidate (Another Popular Library):\n\n\n\n\n5. File Upload Handling:\n\n\n\n\nBest Practices:\n• Use prevent modifier to prevent page reload\n• Validate on blur and submit\n• Show clear error messages\n• Disable submit button when invalid\n• Consider using validation libraries for complex forms\n• Handle file uploads with FormData"}},{"@type":"Question","acceptedAnswer":{"@type":"Answer","text":"Vue provides a transition wrapper component for adding enter/leave animations.\n\nBasic Transition:\n\n\n\n\nTransition Classes:\n• v-enter-from: Starting state for enter\n• v-enter-active: Active state for enter\n• v-enter-to: Ending state for enter\n• v-leave-from: Starting state for leave\n• v-leave-active: Active state for leave\n• v-leave-to: Ending state for leave\n\nCSS Transitions Example:\n\n
    Sliding content
    \n
    \n\n\n\nCSS Animations Example:\n\n

    Bouncing text

    \n
    \n\n\n\nJavaScript Hooks:\n\n
    Animated with JavaScript
    \n\n\n\n\nTransition Modes:\n\n \n\n\nList Transitions with transition-group:\n\n
  • \n {{ item.text }}\n
  • \n
    \n\n\n\nStaggered List Transitions:\n\n
  • \n {{ item.text }}\n
  • \n
    \n\n\n\nThird-party Animation Libraries:\n\n1. Anime.js:\n\n
    Animated with Anime.js
    \n\n\n\n\n2. GreenSock (GSAP):\nimport { gsap } from 'gsap'\n\nexport default {\n methods: {\n enter(el, done) {\n gsap.from(el, {\n duration: 1,\n opacity: 0,\n y: 50,\n onComplete: done\n })\n }\n }\n}\n\nBest Practices:\n• Use CSS transitions for simple animations\n• Use JavaScript for complex animations\n• Consider performance on mobile devices\n• Use will-change property for better performance\n• Test animations across different browsers"}},{"@type":"Question","acceptedAnswer":{"@type":"Answer","text":"Render functions provide an alternative to templates for creating component markup using JavaScript.\n\nBasic Render Function:\nexport default {\n data() {\n return { message: 'Hello Vue!' }\n },\n render(h) {\n return h('div', this.message)\n }\n}\n\nUsing createElement (h) function:\nexport default {\n render(h) {\n return h(\n 'div',\n {\n class: { 'active': this.isActive },\n style: { color: 'red' },\n on: {\n click: this.handleClick\n }\n },\n [\n h('h1', 'Title'),\n h('p', 'Content')\n ]\n )\n }\n}\n\nJSX in Vue:\n// With JSX (needs Babel plugin)\nexport default {\n data() {\n return { count: 0 }\n },\n methods: {\n increment() {\n this.count++\n }\n },\n render() {\n return (\n
    \n

    Count: {this.count}

    \n \n
    \n )\n }\n}\n\nWhen to Use Render Functions/JSX:\n\n1. Dynamic Component Creation:\nexport default {\n props: ['type'],\n render(h) {\n const tag = this.type || 'div'\n return h(tag, this.$slots.default)\n }\n}\n\n2. Programmatic Component Rendering:\nexport default {\n render(h) {\n const children = this.items.map(item => \n h('li', { key: item.id }, item.name)\n )\n return h('ul', children)\n }\n}\n\n3. Higher-Order Components:\nfunction withLoading(WrappedComponent) {\n return {\n props: WrappedComponent.props,\n render(h) {\n if (this.loading) {\n return h('div', 'Loading...')\n }\n return h(WrappedComponent, {\n props: this.$props\n })\n }\n }\n}\n\n4. Complex Conditional Rendering:\nexport default {\n render(h) {\n let child\n if (this.error) {\n child = h(ErrorDisplay, { props: { error: this.error } })\n } else if (this.loading) {\n child = h(LoadingSpinner)\n } else {\n child = h(DataDisplay, { props: { data: this.data } })\n }\n return h('div', [child])\n }\n}\n\nJSX with Composition API:\nimport { ref, defineComponent } from 'vue'\n\nexport default defineComponent({\n setup() {\n const count = ref(0)\n \n const increment = () => {\n count.value++\n }\n \n return () => (\n
    \n

    Count: {count.value}

    \n \n
    \n )\n }\n})\n\nFunctional Components with Render Functions:\n// Functional component (stateless, no instance)\nexport default {\n functional: true,\n props: ['item'],\n render(h, { props, children }) {\n return h('div', { class: 'item' }, [\n h('h3', props.item.title),\n h('p', props.item.description)\n ])\n }\n}\n\nJSX Functional Component:\nexport default {\n functional: true,\n props: ['item'],\n render(h, context) {\n const { item } = context.props\n return (\n
    \n

    {item.title}

    \n

    {item.description}

    \n {context.children}\n
    \n )\n }\n}\n\nSetup Required for JSX:\n// babel.config.js\nmodule.exports = {\n presets: ['@vue/cli-plugin-babel/preset'],\n plugins: [\n '@vue/babel-plugin-jsx'\n ]\n}\n\nWhen to Use Templates vs Render Functions:\n\nUse Templates When:\n• Most of your use cases\n• Better readability\n• Better tooling support (IDE, Vue DevTools)\n• Easier for designers to understand\n\nUse Render Functions/JSX When:\n• You need full programmatic control\n• Dynamic component structures\n• Higher-order components\n• Complex conditional logic\n• Team is comfortable with JSX\n\nBest Practices:\n• Start with templates, move to render functions only when needed\n• Use JSX for better readability in complex cases\n• Keep render functions pure and predictable\n• Use functional components for presentational components"}},{"@type":"Question","acceptedAnswer":{"@type":"Answer","text":"\n\n\n\nKey Features:\n\n1. Automatic Top-Level Bindings:\n\n\n2. Component Registration:\n\n\n3. Props Declaration:\n\n\n4. Emits Declaration:\n\n\n5. Default Slots and Named Slots:\n\n\n6. Use with TypeScript:\n\n\n7. Async Setup:\n\n\n8. Exposing Components to Parents:\n\n\n9. Use with Composables:\n\n\nBenefits of Script Setup:\n\n1. Less Boilerplate:\n// Before\n\n\n// After\n\n\n2. Better TypeScript Support:\n• Full type inference\n• No need for type assertions\n• Better IDE support\n\n3. Improved Performance:\n• Better compile-time optimizations\n• Smaller bundle size\n\n4. Better Readability:\n• Less indirection\n• Clearer code organization\n\n5. Automatic Reactivity:\n• All top-level bindings are reactive\n• No need to explicitly return\n\nComparison with Regular Composition API:\n\nRegular Setup:\n\n\nScript Setup:\n\n\nBest Practices:\n\n1. Use for New Components:\n• Prefer \n\nLimitations:\n• No ability to use 'this'\n• Different learning curve for Options API users\n• Some advanced patterns require regular setup function\n\nMigration Path:\n1. Start with new components using
    Back to Tech Interviews

    Vue.js Interview Master (Vue 2 & Vue 3)

    Comprehensive collection of 100+ Vue.js interview questions covering Composition API, Reactivity (Proxy vs Object.defineProperty), Pinia, Vue Router, and SSR.

    Total: 25 QuestionsLearned: 0 / 25 (0%)
    Difficulty Filters

    Tools & Options
    Showing 25 of 25 questions
    beginner

    Vue.js is a progressive JavaScript framework for building user interfaces. Unlike other monolithic frameworks, Vue is designed from the ground up to be incrementally adoptable.

    Key Features:

    • Reactive Data Binding: Automatic synchronization between data and DOM

    • Component System: Reusable, self-contained components with props and events

    • Virtual DOM: Efficient rendering and performance optimization

    • Directives: Special attributes (v-bind, v-model, v-for) for template functionality

    • Computed Properties: Cached derived data that updates reactively

    • Watchers: React to data changes with custom logic

    • Lifecycle Hooks: Methods that execute at specific component stages

    • Single-File Components: .vue files with template, script, and style in one file

    • Vue Router: Official router for single-page applications

    • Vuex: State management pattern + library

    • Vue DevTools: Browser extension for debugging Vue applications

    Vue is particularly known for its gentle learning curve, excellent documentation, and flexibility.

    beginner

    The Vue instance is the root of every Vue application, created with the Vue constructor.

    Lifecycle Hooks (Vue 2):

    1. beforeCreate: Called immediately after instance initialization, before data observation

    2. created: After instance creation - data is reactive, computed properties are set up

    3. beforeMount: Before initial render and when the template is compiled

    4. mounted: After the instance has been mounted and the DOM is rendered

    5. beforeUpdate: When data changes, before the DOM is re-rendered and patched

    6. updated: After data changes and the DOM has been re-rendered

    7. beforeDestroy: Before instance is destroyed - instance is still fully functional

    8. destroyed: After instance is destroyed - all directives unbound, event listeners removed

    Vue 3 Composition API Lifecycle:

    • setup(): Replaces beforeCreate and created

    • onBeforeMount, onMounted, onBeforeUpdate, onUpdated, onBeforeUnmount, onUnmounted

    Example:

    new Vue({

    el: '#app',

    data: { message: 'Hello Vue!' },

    beforeCreate() { console.log('beforeCreate') },

    created() { console.log('created') },

    mounted() { console.log('mounted - DOM ready') }

    })

    beginner

    v-if vs v-show:

    v-if:

    • Conditionally renders the element in the DOM

    • Adds/removes element completely from DOM

    • Supports v-else and v-else-if

    • Higher toggle cost but better initial load performance

    • Use when: The condition changes infrequently, or you need conditional rendering with else blocks

    v-show:

    • Always renders the element in the DOM

    • Uses CSS display property to show/hide (display: none)

    • Does not support else blocks

    • Higher initial render cost but better toggle performance

    • Use when: You need frequent toggling, or the content is expensive to re-render

    Example:

    <!-- v-if - element removed from DOM when false -->

    <div v-if="isVisible">This may not be in DOM</div>

    <div v-else>Else content</div>

    <!-- v-show - always in DOM, just hidden -->

    <div v-show="isVisible">Always in DOM, just hidden</div>

    Performance Considerations:

    • Use v-if when the condition is unlikely to change at runtime

    • Use v-show for elements that need to be toggled frequently

    • v-if has higher toggle costs, v-show has higher initial render costs

    advanced
    intermediate
    intermediate
    intermediate
    intermediate
    beginner
    intermediate
    intermediate
    intermediate
    advanced
    intermediate
    intermediate
    intermediate
    intermediate
    advanced
    intermediate
    advanced
    beginner
    intermediate
    beginner
    intermediate
    intermediate

    Technical Interview Mastery Blueprint

    Proven methodologies and frameworks to succeed in technical and architecture rounds.

    1. The Engineering STAR Technique

    When responding to architectural or situational questions, structure your answer using Situation, Technical Constraint, Action, and Measurable Result. Rather than jumping straight to syntax, articulate the business problem, why certain patterns (e.g. caching, queuing, immutability) were selected over alternatives, and what latency or throughput improvements were achieved.

    2. Defending Architectural Trade-Offs

    Senior interviewers evaluate how you weigh trade-offs. Always explain why you chose an approach: e.g., memory overhead vs CPU cycle speed, consistency vs availability (CAP theorem), or normalized schemas vs denormalized fast reads. Stating the drawbacks of your own proposal demonstrates maturity and production experience.

    3. Clean Code & Edge-Case Proactivity

    In live-coding rounds, communicate your thinking aloud before typing. State edge cases explicitly: null or undefined inputs, extreme boundary values, concurrency races, and network timeouts. Writing modular, well-named functions with deterministic unit tests separates junior candidates from staff-level engineers.

    4. Antipatterns to Avoid

    Avoid reciting memorized definitions without practical context. Never dismiss non-functional requirements such as security (CSRF, injection, token rotation), observability (logging, metrics), and accessibility (ARIA, semantic standards). Always ask clarifying scope questions before writing complex implementations.

    Continuous learning: Practice daily, mark completed questions as learned, and revisit difficult concepts.Explore All Interview Tracks →

    Explore Related Tools

    Hand-picked utilities and calculators related to this tool.

    Related Tools