I have this string
let a = '1589480087711852280'
How do I convert this to a number?
If I do
let a = '1589480087711852280'
a = Number(a)
console.log(a)
It prints 1589480087711852300
and just rounds it.
How do I get it to print 1589480087711852280
?
It tried BigInt and that just puts an n at the end of the number.
I'm using this to query within mongodb so its not pulling the right search.
Use BigInt
:
let a = '1589480087711852280'
a = BigInt(a)
console.log(a + 1n) // 1589480087711852281n
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.