TIL: Native Javascript Bigint
TIL about native Javascript Bigints
While browsing Hacker News, I stumbled upon a blog article about Goja, a JavaScript engine in Go. I don’t think I would have any use for a JavaScript engine in Go programs, but it’s interesting enough.
In the article there was a snippet to explain how error handling in the the Goja runtime works:
const script = `
// Using BigInt notation in JavaScript
const a = 1n / 0n;
`
My immediate response was “heh, I did not know JavaScript has native bigints🤔”. And, lo and behold, it actually is a thing:
typeof 1n
// "bigint"
I guess I’m one of today’s (sidenote: Obligatory XKCD. Yes, I'm fully aware I can not be in the population of 'people in the United States hearing about a topic for the first time'. Thank you for noticing).