You can find here how to convert between bin, dec, hex values in JavaScript programming language with examples.
Bin to Dec in JavaScript
Function parseInt()
parses a string argument and returns an integer of the specified radix (the base in mathematical numeral systems). [reference]
Example
How to convert value 11111111 in bin to dec in JavaScript.
var dec = parseInt("11111111", 2);
Output: 255
Dec to Bin in JavaScript
Function toString()
returns a string representing the specified Number object. [reference]
Example
How to convert value 185 in dec to bin in JavaScript.
var bin = (185).toString(2);
Output: "10111001"
Bin to Hex in JavaScript
Function parseInt()
parses a string argument and returns an integer of the specified radix (the base in mathematical numeral systems). [reference]
Function toString()
returns a string representing the specified Number object. [reference]
Example
How to convert value 101011 in bin to hex in JavaScript.
var hex = parseInt("101011", 2).toString(16);
Output: "2b"
Hex to Bin in JavaScript
Function parseInt()
parses a string argument and returns an integer of the specified radix (the base in mathematical numeral systems). [reference]
Function toString()
returns a string representing the specified Number object. [reference]
Example
How to convert value 3ef in hex to bin in JavaScript
var bin = parseInt("3ef", 16).toString(2);
Output: "1111101111"
Dec to Hex in JavaScript
Function toString()
returns a string representing the specified Number object. [reference]
Example
How to convert value 185 in dec to hex in JavaScript.
var hex = (185).toString(16);
Output: "b9"
Hex to Dec in JavaScript
Function parseInt()
parses a string argument and returns an integer of the specified radix (the base in mathematical numeral systems).[reference]
Example
How to convert value 3ef in hex to dec in JavaScript.
var dec = parseInt("3ef", 16);
Output: 1007