Skip to content

Instantly share code, notes, and snippets.

@TClark1011
Last active March 21, 2023 05:40
Show Gist options
  • Select an option

  • Save TClark1011/38ee54ec69109a433a1e5fd04981617c to your computer and use it in GitHub Desktop.

Select an option

Save TClark1011/38ee54ec69109a433a1e5fd04981617c to your computer and use it in GitHub Desktop.
Random Tidbits

Tidbits

A collection of small things I've learned while working with JS/TS.

  1. Not throwing your own error when something has gone wrong won't actually result in less errors, it will just result in less readable errors
  2. You can store a number in a string but you can't store a string in a number
  3. The blob pattern for matching both '.ts' and '.tsx' files is *.ts?(x)
  4. The blob pattern for matching .ts, .tsx,.js and .jsx files is *.{ts?(x),js?(x)}
  5. If you are ever working with unix timestamps and are using dayjs be VERY careful and look up the documentation for how unix timestamps are handled by it, it can be confusing
  6. Number.MIN_VALUE is not actually the lowest possible number in JS, its the closest number to 0 that isn't zero. If you actually want the minimum JS number you need to use Number.MAX_VALUE * -1
  7. Always be explicit with your boolean checks, even if the language considers 0 as falsey, always do x === 0 instead of !x, ALWAYS. If you only do it here and there, you'll probably forget to do it when its actually important.
  • Isometric: Isometric vectors that are totally free to use
  • Loading.CSS: CSS loading animations that are easily applied with classes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment