Svelte · Junior · Question 44 of 76

What does the $ prefix do with a store in a component?

<script>
  import { count } from "./stores.js";
</script>

<p>{$count}</p>

Explanation

Assigning $count = 1 calls count.set(1) on a writable store. The store must be declared at the top level of the component.

Further reading

Problem with a question

Svelte · Junior · question 44

Test yourself

Take the Svelte · Junior quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz