hello everyone
this post is about my last post about javascript features in my youtube channel and this this post i'll tell you about number separator in js and also fastest possible way to convert string to number!
Number Separator
when you work large numbers it's hard to read them by eyes so you can use underscore to separate digits in number for example :
let a = 10_000_000 //is equivalent to let a = 10000000 but more readable!
Fastest possible way to convert string to number
as for sure all of you know there are many different ways to convert string to number for example
if we have variable b and c :
let b = '500'
let c
then variable b can convert to number in fallowing ways:
c = Number(b)
//or
c = b - 0
//or
c = parsInt(b)
but the fastest possible way is add + right before string like this:
c = +b
then b converted to number and then assigns to b
hope you enjoy!
Top comments (0)