What is the main difference in how Svelte works compared to React and Vue?
Svelte compiles your code to efficient JavaScript at build time, so it updates the DOM directly without a virtual DOM. React and Vue use a virtual DOM to update the UI at runtime.
Click to reveal answer
beginner
How does React manage component state compared to Svelte?
React uses hooks like useState to manage state inside components, while Svelte uses reactive assignments and special syntax ($:) to update state automatically.
Click to reveal answer
beginner
What makes Vue's template syntax different from React's JSX?
Vue uses an HTML-based template syntax that feels like writing regular HTML with special directives, while React uses JSX which mixes JavaScript and HTML-like code inside components.
Click to reveal answer
intermediate
Which framework is known for having the smallest bundle size and why?
Svelte usually produces the smallest bundle size because it compiles away the framework code at build time, leaving only the minimal JavaScript needed to run your app.
Click to reveal answer
intermediate
How do React, Vue, and Svelte handle reactivity differently?
React re-renders components when state changes via hooks, Vue tracks dependencies reactively using proxies, and Svelte compiles reactive code that updates the DOM directly without extra runtime overhead.
Click to reveal answer
Which framework compiles your code at build time to optimize performance?
AAngular
BReact
CVue
DSvelte
✗ Incorrect
Svelte compiles your code at build time, unlike React and Vue which use runtime virtual DOM.
What syntax does React use to write UI components?
AJSX
BXML
CSvelte syntax
DHTML templates
✗ Incorrect
React uses JSX, which mixes JavaScript and HTML-like syntax.
Which framework uses a virtual DOM to update the UI?
ASvelte
BNone
CReact
DAll
✗ Incorrect
React uses a virtual DOM. Vue also uses a virtual DOM, but the question asks for one correct answer.
Vue's template syntax is closest to which of these?
AHTML with special directives
BPlain JavaScript
CJSX
DCSS
✗ Incorrect
Vue uses HTML templates with special directives like v-if and v-for.
Which framework typically results in the smallest JavaScript bundle size?
AReact
BSvelte
CVue
DEmber
✗ Incorrect
Svelte compiles away framework code, leading to smaller bundles.
Explain how Svelte's approach to updating the UI differs from React and Vue.
Think about when and how the UI changes happen.
You got /4 concepts.
Compare the template or syntax styles used by React, Vue, and Svelte.
Focus on how you write the UI code in each.
You got /3 concepts.
Practice
(1/5)
1. Which framework compiles your code to efficient JavaScript at build time, reducing runtime overhead?
easy
A. Svelte
B. React
C. Vue
D. Angular
Solution
Step 1: Understand Svelte's compilation approach
Svelte compiles components to optimized JavaScript during build, so no virtual DOM at runtime.
Step 2: Compare with React and Vue runtime behavior
React and Vue use virtual DOM diffing at runtime, adding overhead compared to Svelte.
Final Answer:
Svelte -> Option A
Quick Check:
Compile-time optimization = Svelte [OK]
Hint: Svelte compiles away framework code before running [OK]
Common Mistakes:
Thinking React compiles away virtual DOM
Confusing Vue's runtime with compile-time
Assuming Angular behaves like Svelte
2. Which syntax is correct for creating a reactive variable in Svelte?
easy
A. var count = 0; function doubled() { return count * 2; }
B. const [count, setCount] = useState(0);
C. data() { return { count: 0 } }
D. let count = 0; $: doubled = count * 2;
Solution
Step 1: Identify Svelte reactive syntax
Svelte uses $: label to declare reactive statements that update when dependencies change.
Step 2: Check other options for framework syntax
const [count, setCount] = useState(0); is React useState, C is Vue data option, D is plain JS function.
Final Answer:
let count = 0; $: doubled = count * 2; -> Option D
Quick Check:
Svelte reactive label = $: [OK]
Hint: Svelte uses $: for reactive declarations [OK]
Common Mistakes:
Using React or Vue syntax in Svelte
Forgetting the $: label for reactivity
Using var instead of let/const in Svelte
3. Given this Svelte code snippet, what will be displayed when count is 3?