atob编码
时间: 2023-06-28 11:15:16 浏览: 110
`atob` 是 JavaScript 中的一个函数,用于将 base64 编码的字符串解码为原始的字符串数据。例如,下面的代码将一个 base64 编码的字符串解码为原始的字符串数据:
```javascript
const base64String = 'SGVsbG8gV29ybGQh';
const decodedString = atob(base64String);
console.log(decodedString); // 输出 "Hello World!"
```
需要注意的是,`atob` 函数只能解码 base64 编码的字符串。如果传入的字符串不是 base64 编码的,或者包含非法字符,`atob` 函数将会抛出一个异常。因此,在使用 `atob` 函数时,需要确保传入的字符串是合法的 base64 编码字符串。
相关问题
atob
atob() 是一个 JavaScript 的内置函数,用于将一个 base-64 编码的字符串解码成原始的 ASCII 字符串。函数的语法如下:
```
atob(encodedString)
```
其中,encodedString 是一个 base-64 编码的字符串。函数返回解码后的字符串。例如:
```
atob("SGVsbG8gV29ybGQh")
```
将返回字符串 "Hello World!"。
js atob方法
`atob()` 方法是 JavaScript 中的一个内置函数,用于将经过 base64 编码的字符串解码为原始字符串。它返回一个解码后的字符串。
使用方法如下:
```javascript
let encodedString = 'SGVsbG8gd29ybGQ='; // 经过 base64 编码的字符串
let decodedString = atob(encodedString); // 解码后的字符串
console.log(decodedString); // 输出:Hello world
```