Typescript
TypeScript is an open-source language which builds on JavaScript, one of the world’s most used tools, by adding static type definitions. - Home / online
see also
- Deno - Next-generation JavaScript Runtime / Native support for TypeScript and JSX
- TS-PICO-8 - TypeScript for PICO-8
Handbook
Classes
- inheritance:
extends - interface:
implements - Parameter properties - let you create and initialize a member in one place. (
public,protected,private,readonly)
class Octopus {
constructor(readonly name: string) {}
}
let dad = new Octopus("Man with the 8 strong legs");
dad.name;Union Types / Intersection Types / Conditional Types
type-casting
var vs let vs const
var declarations are accessible anywhere within their containing function, module, namespace, or global scope - all which we’ll go over later on - regardless of the containing block. Some people call this var-scoping or function-scoping. Parameters are also function scoped.
When a variable is declared using let, it uses what some call lexical-scoping or block-scoping. Unlike variables declared with var whose scopes leak out to their containing function, block-scoped variables are not visible outside of their nearest containing block or for-loop.
const declarations are like let declarations but, as their name implies, their value cannot be changed once they are bound.
Array / Tuple
Map or Hash (== Indexed Access Types) / SO
code