Skip to content
← All cheat sheets

Cheat sheet

JavaScript & TypeScript

Core language behaviour, async, and the type-system bits that trip people up in interviews.

Equality & types

  • Strict vs loose

    0 == '' // false, 0 == '0' // true

    Always use === / !==; == coerces.

  • typeof null

    typeof null === 'object'

    Historic bug; use === null.

  • NaN check

    Number.isNaN(x)

    NaN !== NaN, so x === x is false for NaN.

  • Array check

    Array.isArray(x)

    typeof [] === 'object'.

Scope & closures

  • let / const

    Block-scoped, TDZ before init; const binds, not deep-immutable.

  • var

    Function-scoped, hoisted, initialised undefined.

  • Closure

    Inner fn keeps access to outer vars after the outer returns.

  • this

    Set by call-site; arrow fns inherit `this` lexically.

Async

  • Microtask vs macrotask

    Promises (microtasks) run before setTimeout (macrotask).

  • Parallel awaits

    await Promise.all([a(), b()])

    Start both, then await — don't serialise.

  • Error handling

    try { await x() } catch (e) {}

    Unhandled rejections crash Node.

TypeScript essentials

  • unknown vs any

    unknown forces a check before use; any disables checking.

  • Utility types

    Partial<T> Pick<T,K> Omit<T,K> Record<K,V>
  • Narrowing

    if (typeof x === 'string') …

    Type guards refine within a block.

  • as const

    Freezes literal types — great for tuples and enums-as-objects.

Aevrofy · aevrofy.com — free interview prep