📚 TypeScript Basics
⚠️
This section is a work in progress.
💡
This guide is not meant to be an introduction to programming in general, and assumes you have some baseline familiarity with other languages.
Literals
// number123
// string"abc"'def'`ghi ${ /* supports interpolation */ } jkl`
// booleantruefalse
// null & undefinednullundefined
Arrays
const strArr: string[] = ['a', 'b', 'c']
// (arrays are 0-indexed)
strArr[0] // => 'a'strArr[1] // => 'b'
Objects
const obj: Record<string, number> = { a: 1, b: 2, c: 3,}
obj.a // => 1obj['b'] // => 2
Functions
// function-stylefunction square(x: number): number { return x * x}
// arrow-styleconst square = (x: number): number => { return x * x}
// inline arrow-styleconst square = (x: number): number => x * x
// without types (JavaScript-like)const square = (x) => x * x