Recall & Review
beginner
What are rest parameters in Svelte?
Rest parameters allow a component to collect all extra props passed to it into a single object. This helps to pass down or handle unknown or additional attributes easily.
Click to reveal answer
beginner
How do you declare rest parameters in a Svelte component?
You use the
$$restProps variable inside the component script. It automatically contains all props not explicitly declared.Click to reveal answer
intermediate
Why use rest parameters instead of declaring all props explicitly?
Rest parameters let you handle extra or unknown props without listing them all. This is useful for forwarding attributes like <code>class</code>, <code>id</code>, or event handlers.Click to reveal answer
beginner
How can you apply rest parameters to an HTML element inside a Svelte component?
You spread
$$restProps on the element using {...$$restProps}. This passes all extra props to that element.Click to reveal answer
intermediate
What happens if you pass a prop to a Svelte component that is not declared and you do not use rest parameters?
The extra prop is ignored and not accessible inside the component. Using
$$restProps lets you capture those props.Click to reveal answer
In Svelte, which variable holds all extra props passed to a component?
✗ Incorrect
The special variable
$$restProps contains all props not explicitly declared in the component.How do you pass all extra props to an HTML element inside a Svelte component?
✗ Incorrect
You spread
$$restProps on the element like {...$$restProps} to forward all extra props.What is a common use case for rest parameters in Svelte components?
✗ Incorrect
Rest parameters help collect unknown or extra props so you can forward or handle them flexibly.
If a prop is not declared and
$$restProps is not used, what happens to that prop?✗ Incorrect
Props not declared and not captured by
$$restProps are ignored inside the component.Which of these is NOT true about
$$restProps in Svelte?✗ Incorrect
$$restProps is a built-in variable and does not need manual declaration.Explain how rest parameters work in Svelte components and why they are useful.
Think about how you can pass extra HTML attributes without declaring each one.
You got /4 concepts.
Describe how to use $$restProps to forward all extra props to a button element inside a Svelte component.
Remember the spread syntax inside the element tag.
You got /4 concepts.