Why is the parameter of the callback function in Svelte's `derived` function named with dollar sign?

30 views Asked by At

In Svelte tutorial about derived store, the name of the parameter of the callback function (, which itself is the second argument for the derived function) is prefixed with $. This is also the case in the API documentation.

What's the meaning and effect of that dollar sign? I tried removing it from the example code (that is, from

($time) => Math.round(($time - start) / 1000)

to

time => Math.round((time - start) / 1000)

), and it also works. It feels to me that it's not supposed to be with dollar sign since this identifier seems to represent simply a parameter of the callback function, rather than a store object.

The example codes confusing me in the aforementioned links:

export const elapsed = derived(
    time,
    ($time) => Math.round(($time - start) / 1000)
//   ^^^^^                 ^^^^^ Why is it named like this?
);
const doubled = derived(a, ($a) => $a * 2);
//                          ^^     ^^ Why is it named like this?
0

There are 0 answers