Javascript – way to read binary data in JavaScript


I would like to inject binary data into an object in JavaScript. Is there a way to do this?


var binObj = new BinaryObject('101010100101011');

Something to that effect. Any help would be great.

Best Answer

You can use parseInt:

var bin = parseInt('10101010', 2);

The second argument (the radix) is the base of the input.