Categories
JavaScript Answers

How to delete “px” from 245px with JavaScript?

Spread the love

Sometimes, we want to delete "px" from 245px with JavaScript.

In this article, we’ll look at how to delete "px" from 245px with JavaScript.

How to delete "px" from 245px with JavaScript?

To delete "px" from 245px with JavaScript, we can use the parseInt function.

For instance, we write

const size = parseInt("245px", 10);

to call parseInt with '245px' and 10 to parse the numerical part of "245px"` into a decimal integer.

10 is the radix to parse the number as.

The parsed number is returned.

Conclusion

To delete "px" from 245px with JavaScript, we can use the parseInt function.

Leave a Reply

Your email address will not be published.

If you like the content of this blog, subscribe to my email list to get exclusive articles not available to anyone else.