Skip to content

Instantly share code, notes, and snippets.

@kiinlam
Last active September 7, 2020 02:51
Show Gist options
  • Save kiinlam/419b5d31d973dd7ce85595c00adff69b to your computer and use it in GitHub Desktop.
Save kiinlam/419b5d31d973dd7ce85595c00adff69b to your computer and use it in GitHub Desktop.
[js进制转换]
// toString(radix)
// 任意数值转为指定进制
0x6600.toString(2) // "110011000000000"
// parseInt(value, radix)
// 将value作为指定进制radix来解析,得到10进制结果
parseInt("110011000000000",2) // 26112
// 任意进制相互转换
// 先转10进制,再换成目标进制
parseInt('ff',16).toString(2) // "11111111"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment