How to convert hexadecimal to binary in javascript
This article focuses on "how javascript converts hexadecimal to binary". Interested friends may wish to take a look. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn how javascript converts hexadecimal to binary.
Js hexadecimal to binary method: 1, use parseInt () method to convert hexadecimal value to decimal value, syntax "parseInt (hexadecimal value, 16)"; 2, use toString () method to convert decimal value to binary value, syntax "decimal value .toString (2)".
The operating environment of this tutorial: windows7 system, javascript1.8.5 version, Dell G3 computer.
If you want to convert hexadecimal to binary, you can use an intermediate system, decimal:
Convert hexadecimal to binary first-- use the parseInt () method
Then convert the decimal to binary-- use the toString () method
Implementation method:
Var x = "6e"; / / this is a hexadecimal string representing var y=parseInt (x, 16); / / hexadecimal to decimal var z=y.toString (2); / / decimal to binary console.log (z)
At this point, I believe you have a deeper understanding of "how javascript converts hexadecimal to binary". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!