K.  _ K. _ - 1 month ago 12
Javascript Question

Why were JavaScript `atob()` and `btoa()` named like that?

In JavaScript,

window.atob()
method decodes a base64 string and
window.btoa()
method encodes a string as base64.

Then why weren't they named like
base64Decode()
and
base64Encode()
?
atob()
and
btoa()
don't make sense because they're not semantic.

I want to know the reason.

Answer

The atob() and btoa() methods allow authors to transform content to and from the base64 encoding.

In these APIs, for mnemonic purposes, the "b" can be considered to stand for "binary", and the "a" for "ASCII". In practice, though, for primarily historical reasons, both the input and output of these functions are Unicode strings.

From : http://www.w3.org/TR/html/webappapis.html#atob

Comments