Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
@theuser the ending non-numeric values are handled like units, as in “32cm” gives you 32.
-
@theuser As far as I know it just parses the string until it encounters the first non-numerical symbol and ignores the rest.
-
@010001111 From what I've seen, it doesn't matter if it's a unit or not, the string would just be left out so the result would always be the first number if it's in the index 0 of the string (no matter if you have other numbers after some non-numeric characters).
-
Note that if you have a hexadecimal string and want to parse it to an int, remember that the second argument to parseInt is an optional radix (in case you were looking at the parsing of “1a” and sad that it didn’t come out as 26).
-
@Berkmann18 that’s the intend, you can’t standardize every possible unit there is, besides, there are some self made or non-related units from completely different sectors. That’s why it doesn’t care about the end, but does for the beginning.
Every damn day I learn something new in javascript.
joke/meme
javascript