Nil
Sometimes you need to explicitly not return a value, this is when to use nil
.
It is also what is returned from an empty closure or a closure whose last statement is a let
declaration
- Knot
- TypeScript
knot
const empty = nil;
knot
const empty = nil;
tsx
const empty = undefined;
tsx
const empty = undefined;
Empty Closure
Empty closure expressions evaluate to nil
.
- Knot
- TypeScript
knot
const result = {};
knot
const result = {};
tsx
const result = (function () {})();
tsx
const result = (function () {})();
Implicit Return
Closures that end in a let
declaration implicitly return nil
.
- Knot
- TypeScript
knot
const result = {let foo = "foo";};
knot
const result = {let foo = "foo";};
tsx
const result = (function () {let foo = "foo";})();
tsx
const result = (function () {let foo = "foo";})();