Categories
JavaScript Answers

How to go from Blob to ArrayBuffer with JavaScript?

Spread the love

Sometimes, we want to go from Blob to ArrayBuffer with JavaScript.

In this article, we’ll look at how to go from Blob to ArrayBuffer with JavaScript.

How to go from Blob to ArrayBuffer with JavaScript?

To go from Blob to ArrayBuffer with JavaScript, we can use the Response constructor.

For instance, we write

const arrayBuffer = await new Response(blob).arrayBuffer();

to create a Response object from blob.

And then we call arraybuffer to return a promise with the array buffer converted from the blob.

Conclusion

To go from Blob to ArrayBuffer with JavaScript, we can use the Response constructor.

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 *