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.

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 *