DEV Community

loading...

Discussion on: I Built an App That Uses All 7 New Features in JavaScript ES2020

Collapse
thawkin3 profile image
Tyler Hawkins Author

Right?? Nullish coalescing and optional chaining have been the ones I've been most excited about.

For BigInt, you're right, you can't mix a BigInt with a normal number. So if you want to do some operation on a BitInt and a number, you need to convert one of them to the other format.

So for instance, you can't do:

const aBigInt = BigInt(100)
const aNumber = 50
const result = aBigInt + aNumber // incorrect!

But you could do:

const result = aBigInt + BigInt(aNumber)

Or:

const result = Number(aBigInt) + aNumber