I have a binary string like "11100011"
and I want to convert it into a byte. I have a working example in Java like below:
byte b1 = (byte)Integer.parseInt("11100011", 2);
System.out.println(b1);
Here the output will be -29
. But if I write some similar code in JavaScript like below:
parseInt('11100011', 2);
I get an output of 227
.
What JavaScript code I should write to get the same output as Java?