首先,将十六进制字符串转换为字节数组。可以使用以下代码:
```javascript
const hexString = '31363833333638383534323337303030';
const bytes = new Uint8Array(hexString.match(/.{1,2}/g).map(byte => parseInt(byte, 16)));
```
接下来,使用 TextDecoder API 将字节数组转换为 UTF-8 编码的字符串。可以使用以下代码:
```javascript
const decoder = new TextDecoder('utf-8');
const utf8String = decoder.decode(bytes);
console.log(utf8String); // 输出:1683368854237000
```
完整代码如下:
```javascript
const hexString = '31363833333638383534323337303030';
const bytes = new Uint8Array(hexString.match(/.{1,2}/g).map(byte