Convert string to any number
Way 1
console.log(+"3")
Way 2
console.log("3" * 1)
Way 3
console.log(~~ "3")
Way 4
console.log(parseInt("3"))
console.log(parseFloat("3"))
All the above results are providing same results. But individually it may give some additional functionalities. But I want to know which one is best for performance?
I think "1"*1
(way-2) is one of the best way to convert string to int. Is it correct? If I am wrong, then please let me know which one is best and why?