JavaScript 数字 字符 转换

  1. 数字进制转换
    (10).toString(8) //10进制到8进制
    (077).toString() //8进制到10进制
    (0x11).toString(8) //16进制到8进制
    (0x11).toString(10) //16进制到10进制
    (0x11).toString(2) //16进制到2进制
    (0x11).toString(3) //16进制到3进制

    3进制转换为16进制
    parseInt("122", 3).toString(16); 先要转换为10进制, 然后再通过10进制转换为16进制

  2. 字符-数字 转换
    String.charCodeAt()
    String.fromCharCode()
    String.prototype.charAt()
    String.fromCodePoint()
    String.prototype.codePointAt()

标签: none

添加新评论