svelte store dollar sign 1

svelte store dollar sign

import { writable } from 'svelte/store';

const count = writable(0);
console.log($count); // logs 0

count.set(1);
console.log($count); // logs 1

$count = 2;
console.log($count); // logs 2

Here is what the above code is Doing:
1. We create a writable store called count.
2. We log the value of the store to the console.
3. We set the value of the store to 1.
4. We log the value of the store to the console.
5. We set the value of the store to 2.
6. We log the value of the store to the console.

The output of the above code is:
0
1
2

The first thing to note is that we can access the value of a store using the $ prefix.

The second thing to note is that we can set the value of a store using the set method.

The third thing to note is that we can set the value of a store by assigning a value to it.

The fourth thing to note is that we can only set the value of a store to a primitive value.

The fifth thing to note is that we can’t set the value of a store to an object or array.

The sixth thing to note is that we can’t set the value of a store to a function.

The seventh thing to note is that we can’t set the value of a store to undefined.

The eighth thing to note is that we can’t set the value of a store to null.

The ninth thing to note is that we can’t set the value of a store to NaN.

The tenth thing to note is that we can’t set the value of a store to Infinity.

The eleventh thing to note is that we can’t set the value of a store to -Infinity.

The twelfth thing to note is that we can’t set the value of a store to a boolean.

The thirteenth thing to note is that we can’t set the value of a store to a string.

The fourteenth thing to note is that we can’t set the value of a store to a number.

The fifteenth thing to note is that we can’t set the value of a store to a symbol.

The sixteenth thing to note is that we can’t set the value of a store to a bigint.

The seventeenth thing to note is that we can’t set the value of a store to a date.

The eighteenth thing to note is that we can’t set the value of a store to a regex.

The nineteenth thing to note is that we can’t set the value of a store to a promise.

The twentieth thing to note is that we can’t set the value of a store to a map.

The twenty-first thing to note is that we can’t set the value of a store to a set.

The twenty-second thing to note is that we can’t set the value of a store to a weakmap.

The twenty-third thing to note is that we can’t set the value of a store to a weakset.

The twenty-fourth thing to note is that we can’t set the value of a store to an error.

The twenty-fifth thing to note is that we can’t set the value of a store to an arraybuffer.

The twenty-sixth thing to note is that we can’t set the value of a store to a dataview.

The twenty-seventh thing to note is that we can’t set the value of a store to a typedarray.

The twenty-eighth thing to note is that we can’t set the value of a store to a dataview.

The twenty-ninth thing to note is that we can’t set the value of a store to a typedarray.

The thirtieth thing to note is that we can’t set the value of a store to a dataview

Similar Posts