What is the difference between Vue 2 and Vue 3?
Why Interviewers Ask This
Foundational questions like this help interviewers calibrate the rest of the interview. A confident, accurate answer signals that you have solid Vue.js basics — a prerequisite for any developer role.
Answer
Vue 3 is a major rewrite with significant improvements: Composition API: Vue 3 introduced the Composition API (setup() function) as an alternative to Options API — enables better code organization, TypeScript integration, and logic reuse via composables. Vue 2 only had Options API. Reactivity system: Vue 2 used Object.defineProperty for reactivity — couldn't detect property addition/deletion, required Vue.set(). Vue 3 uses ES2015 Proxy — detects all mutations including property addition and deletion, works on arrays natively. Performance: Vue 3 is significantly faster — smaller virtual DOM, compiler optimizations (static tree hoisting, patch flags), tree-shakeable core (~20KB gzipped vs ~30KB for Vue 2). TypeScript: Vue 3 was written in TypeScript and has excellent TS support. Vue 2's TS support required decorators and was clunky. Multiple root elements: Vue 3 supports multiple root elements (fragments) in templates. Vue 2 required a single root element. Teleport: Vue 3 has a built-in Teleport component (like React portals). Suspense: experimental async component loading with loading/error states. Breaking changes: lifecycle hook renames (destroyed → unmounted), v-model changes, filter removal. Vue 2 reached end-of-life December 31, 2023.
Pro Tip
Demonstrate both theoretical understanding and practical experience. Say what it is, then give an example of how you actually used it in a Vue.js codebase.