Categories
JavaScript Answers

How to convert byte array to string in JavaScript?

Spread the love

Sometimes, we want to convert byte array to string in JavaScript.

In this article, we’ll look at how to convert byte array to string in JavaScript.

How to convert byte array to string in JavaScript?

To convert byte array to string in JavaScript, we can use the String.fromCharCode method.

For instance, we write

const s = String.fromCharCode(...[102, 111, 111]);

to call String.fromCharCode with a number array with the character codes spread as arguments of it.

It returns string s with the characters that correspond to the character codes.

Conclusion

To convert byte array to string in JavaScript, we can use the String.fromCharCode method.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published. Required fields are marked *