Use “+” to convert string to number
Amr Ataa
Posted on January 11, 2023
You might be using Number() and parseInt() to convert string to number.
// ❌
let str = '123'
let num = Number(str) // 123
let num2 = parseInt(str) // 123
// ✅
let str = '123'
let num = +str // 123
💖 💪 🙅 🚩
Amr Ataa
Posted on January 11, 2023
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.