Let Bindings
You can use the let keyword to bind a value to some name so it can be referenced withing a closure.
info
Variables in Knot are immutable except for within the scope of state entities (coming soon!).
Scope-Local
Since these bindings are local to a closure they can be re-used in different scopes without conflict.
- Knot
- TypeScript
knotconst foo = {let x = 10;x + x;};const bar = {let x = 10;x / x;};
knotconst foo = {let x = 10;x + x;};const bar = {let x = 10;x / x;};
tsxconst foo = (function () {let x = 10;return x + x;})();const bar = (function () {let x = 10;return x / x;})();
tsxconst foo = (function () {let x = 10;return x + x;})();const bar = (function () {let x = 10;return x / x;})();