0

I'm not familiar with modern JS and tooling to even try something.

References:

https://github.com/tc39/proposal-bigint

2
  • 2
    MDN BigInt#browser_compatibility what's your target audience/device that you think it might not be available? Commented Nov 16, 2023 at 7:04
  • @Thomas 1. I use really old browsers sometimes. 2. ActionScript won't get updates any time soon. Commented Nov 16, 2023 at 7:35

4 Answers 4

2

Simply invoke BigInt and catch a possible exception:

let BigIntSupported = true

try {
    BigInt(1)
} catch (e) {
    BigIntSupported = false

}
Sign up to request clarification or add additional context in comments.

Comments

1

if('BigInt' in window) (or if(window.BigInt)) should suffice.

2 Comments

0

globalThis.BigInt === BigInt without any polyfill.

console.log(globalThis.BigInt === BigInt);
    

I did just 2 tests with Firefox 119.1.1 and it seems to work... Second test had intentional typo and failed as expected.

References:

https://github.com/tc39/proposal-global

I can't edit my older answer for some reason...

Comments

-1

globalThis.BigInt === BigInt

core-js's polyfill requires Chrome 71 or Firefox 65.

References:

https://github.com/tc39/proposal-global

http://zloirock.github.io/core-js/compat/

2 Comments

This won't do what you want – you'll get either a NameError if Foo is not defined, or if Foo is undefined, you'll get true when they're both undefined.
@AKX I did just 2 tests with Firefox 119.1.1 and it seems to work... Second test had intentional typo and failed as expected.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.