An example analysis of Javascript base conversion
- 2020-06-12 08:29:15
- OfStack
An example of Javascript conversion is given in this article. Share to everybody for everybody reference. The details are as follows:
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title> Hexadecimal conversion </title>
<script type="text/javascript">
var x = 6;
var num = x.toString(2);
// Convert an integer to 2 Into the system , Pay attention to toString In the method 2 Said" 2 Into the system"
//alert("num=" + num);
var z = "110";
var num2 = parseInt(z, 2);
// Pay attention to parseInt Methods the first 2 Is the number of parameters z is 1 a 2 Hexadecimal number ,
// So the conversion to integer becomes zero 6
alert("num2=" + num2);
</script>
</head>
<body>
</body>
</html>
Hopefully, this article has been helpful in your javascript programming.