10

The console.log in code snippet currently does not support BigInt. To reproduce this problem, you may simply run this code snippet. The console shows null instead of 42. And it should show something meaningful: Maybe 42n or at least 42.

console.log(42n);
console.log([42n]);

1

1 Answer 1

6

Unfortunately, this isn't an isolated occurrence, since the Stack Snippets console can't output ES6 data types, and BigInt is even newer than ES6 (from ES2020). Stack Snippets (and its console) haven't been updated in a good while.

As far as I can tell, the (virtual) console used by Stack Snippets hasn't been meaningfully updated with new language features since its initial release, based on the then-current version of @canon's stack-snippet-console script on GitHub.

In the answer from that ES6 snippets post from Oct. 2018, @canon revealed an enhanced version of that same script that supports ES6 types, but it was never adopted into Snippets on the site, and it hasn't been updated since, which means it doesn't support any more recent features from 2019 onward, like BigInt.

As a workaround, your browser's console should display these values correctly (as long as it itself supports them), but for now, Snippets are stuck in pre-ES6 land until they get some much-needed TLC (maybe as a plugin for the new editor?).

OP's snippet with browser console pulled up to show that BigInt console output appears correctly

0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .