有没有办法在 JavaScript 中读取二进制数据? [英] Is there a way to read binary data in JavaScript?

查看:16
本文介绍了有没有办法在 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 中读取二进制数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆