Take an example...
let a = 0; let b = a + 1; a = 2; b = a + 1;
Here throughout the program
b is supposed to be the successor of a. Each time we reassign
a, we need to explicitly mention
b = a + 1.
Can we have a destiny operator as mentioned in this article that will bind a variable to its dependencies?
let age = 13; const isEligible <= age > 18; // -> False
In the above above code,
isElgible is bound to
age > 18. Instead of storing a boolean, it keeps an expression in memory. Whenever we modify
age and log
isEligible, it should call the stored expression and return the result.
age = 20; isEligible // -> True
Svelte uses a dollar label for this. It'd be nice to have something similar in
JS. This will make variables reactive without needing to explicitly update them.
Thank you .