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.

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay