I found myself in the situation where I wanted to convert a BigInt
value to a Number
value. Knowing that my value is a safe integer, how can I convert it?
Turns out it's as easy as passing it to the Number
constructor:
const myBigInt = BigInt(10); // of course, `10n` also works
const myNumber = Number(myBigInt);