Skip to content

Instantly share code, notes, and snippets.

@theasta
Created March 29, 2015 16:39
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save theasta/dd1ee953d234e8bad9bb to your computer and use it in GitHub Desktop.
Save theasta/dd1ee953d234e8bad9bb to your computer and use it in GitHub Desktop.
Decimal, Hexadecimal, Binary Conversion in JavaScript
// Convert from decimal to binary
(11).toString(2) // “1011"
// Convert from decimal to hexadecimal
(255).toString(16) // ‘ff'
// Convert from binary to decimal
parseInt("1011", 2); // 11
// Convert from binary to hexadecimal
parseInt("ff", 16); // 255
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment