What are props in Vue?
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
Props (properties) are custom attributes registered on a component that allow a parent to pass data down to a child component. Props flow unidirectionally — from parent to child. Declaring props (Composition API with script setup): const props = defineProps({ title: String, count: { type: Number, required: true, default: 0 }, user: { type: Object, validator: (val) => val.age >= 0 } });. With TypeScript: const props = defineProps<{ title: string; count?: number }>();. With defaults: const props = withDefaults(defineProps<{ count?: number }>(), { count: 0 });. Options API: props: { title: String, count: { type: Number, default: 0, required: true } }. Using props in parent: <UserCard :title="post.title" :count="post.views" :user="currentUser" />. Static prop (no colon): <UserCard title="Hello" /> — always a string. Prop types: String, Number, Boolean, Array, Object, Date, Function, Symbol, or custom class. Prop mutation: never mutate props directly — they are read-only in the child. To "mutate," emit an event to the parent or create a local copy. Prop case: camelCase in JS (firstName), kebab-case in templates (:first-name="value") — Vue auto-converts.
Pro Tip
This topic has Vue.js-specific nuances that differ from general programming. Highlighting those nuances in your answer shows expertise rather than generic knowledge.