Skip to content

Instantly share code, notes, and snippets.

@samme
Last active April 26, 2024 15:47
Show Gist options
  • Save samme/af3dbb5aaee5d44cec3d86eedb6894fa to your computer and use it in GitHub Desktop.
Save samme/af3dbb5aaee5d44cec3d86eedb6894fa to your computer and use it in GitHub Desktop.
Hexadecimal number/string conversions
// 0x00000f (15) to '#00000f'
'#' + (0x00000f).toString(16).padStart(6, '0')
// '#00000f' to 0x00000f (15)
parseInt('0x' + '#00000f'.slice(1))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment