Search code examples
javascriptlanguage-featuresarbitrary-precisionecma262

How to feature test for BigInt support?


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

References:

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


Solution

  • Simply invoke BigInt and catch a possible exception:

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