DEV Community

Heru Hartanto
Heru Hartanto

Posted on

1

How to converting string number to number without parseInt or parseFloat

const num = parseInt("100")
Enter fullscreen mode Exit fullscreen mode

Instead of using parseInt or parseFloat we can use + operator

const num = +"100"
num + 5 
// 105
Enter fullscreen mode Exit fullscreen mode

Top comments (1)

Collapse
 
eric23 profile image
Eric

Number(“100”)
Should also work.

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more