I'm stuck in small problem where I'm trying to convert String to number but that String number is huge due to which it is not properly converting to number type.
str = "6145390195186705543"
num = Number(str)
digits = [6,1,4,5,3,9,0,1,9,5,1,8,6,7,0,5,5,4,3]
let str = String(Number(digits.join(''))+1).split('')
after performing above operation the value of num is 6145390195186705000 which is not what I was expecting. It should be 6145390195186705543.
It would be very helpful if someone can explain this and tell if there is any alternative way.
- I have tried parseInt() and '+' as well but nothing is working.
BigInt("6145390195186705543")BigInt("6145390195186705543")returns the correct value.