Categories
JavaScript Answers

How to convert a string to long in JavaScript?

Spread the love

Sometimes, we want to convert a string to long in JavaScript.

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

How to convert a string to long in JavaScript?

To convert a string to long in JavaScript, we can convert it to a bigint.

For instance, we write

const bi = BigInt("1274836528318476135");

to convert the "1274836528318476135" string to a bigint with the BigInt function.

Conclusion

To convert a string to long in JavaScript, we can convert it to a bigint.

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 *