V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
推荐关注
Meteor
JSLint - a JavaScript code quality tool
jsFiddle
D3.js
WebStorm
推荐书目
JavaScript 权威指南第 5 版
Closure: The Definitive Guide
flowfire
V2EX  ›  JavaScript

atob 和 btoa 方法名是不是反了。。。。

  •  
  •   flowfire · 2017-12-22 16:44:54 +08:00 · 2469 次点击
    这是一个创建于 2289 天前的主题,其中的信息可能已经有所发展或是发生改变。

    按我的理解
    atob => ascii to base64 => input ascii output base64
    btoa => base64 to ascii => input base64 output ascii

    2 条回复    2017-12-23 08:12:19 +08:00
    koebehshian
        1
    koebehshian  
       2017-12-22 16:54:20 +08:00
    https://stackoverflow.com/questions/33854103/why-were-javascript-atob-and-btoa-named-like-that

    b 是 binary,a 是 ascii,因为 base 的字符串表示是用 ascii 编码的。

    atob()
    Decodes a string of data which has been encoded using base-64 encoding.
    btoa()
    Creates a base-64 encoded ASCII string from a "string" of binary data.
    DevilBin
        2
    DevilBin  
       2017-12-23 08:12:19 +08:00 via Android
    😝我也是这么想的
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   5414 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 40ms · UTC 09:00 · PVG 17:00 · LAX 02:00 · JFK 05:00
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.