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.