When converting Javascript values and strings, you can operate on different bases.
An example of conversion is as follows:
Copy the code code as follows:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>Convert between decimal values and strings</title>
</head>
<body>
<script language="javascript">
//Conversion from numbers to strings: toString(), which can be converted into different bases
function test1(){
var f = [1,2,3,4,5,6,7,8];
alert(f.reverse().join("")); //Reverse function of array, connection function test
var b = parseInt(f.reverse().join("")).toString(2);
alert(b);
}
//Character to numerical conversion: parseInt(), which can convert data in different bases
function test2(){
vars = '10101010';
var b = parseInt(s,2);
alert(b);
}
test2();
</script>
</body>
</html>