DEV Community

Discussion on: JavaScript Secrets

Collapse
 
denicmarko profile image
Marko Denic

Hi Nikola, thanks for reading. Yes, these two are tricks definitely. But, I saw both on MDN docs and w3docs, so I would consider them a legit tricks. :)

How do you like the rest?

Collapse
 
olgagnatenko profile image
Olga Gnatenko

What about explicit conversion from string to number: str => Number(str)? I think this one is clearer and easier to understand/note for other developers.

Thread Thread
 
abourass profile image
Antonio B.

parseInt(str, 10)

Thread Thread
 
denicmarko profile image
Marko Denic • Edited

Hi Olga. Hi Antonio.
Thanks for reading and taking the time to comment.

There is at least 10 different ways to convert a string to number. Maybe I create a dedicated post about this topic.