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
knot
const foo = {let x = 10;x + x;};const bar = {let x = 10;x / x;};
knot
const foo = {let x = 10;x + x;};const bar = {let x = 10;x / x;};
tsx
const foo = (function () {let x = 10;return x + x;})();const bar = (function () {let x = 10;return x / x;})();
tsx
const foo = (function () {let x = 10;return x + x;})();const bar = (function () {let x = 10;return x / x;})();