Is there a way to read binary data in JavaScript?(有没有办法在 JavaScript 中读取二进制数据?)
问题描述
我想将二进制数据注入 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.
推荐答案
可以使用parseInt:
You can use parseInt:
var bin = parseInt('10101010', 2);
第二个参数(基数)是输入的基数.
The second argument (the radix) is the base of the input.
这篇关于有没有办法在 JavaScript 中读取二进制数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!