1

Is there a way to check if something is bigint type?

I would like to check this:

99999999999999999999999999999999999999999999999999

I know this number can't be represented as an Integer. How can I check if it can be represented as a bigint?

If I use the typeof on it, it says number.

Also is there any way to specify a type with a decimal at the end?

example: 99999999999999999999999999999999999999999999999999.99

2

1 Answer 1

1

You can use Number.MAX_SAFE_INTEGER to check if is a bigint or not. Link below: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/MAX_SAFE_INTEGER

or a better way: Number.isSafeInteger() https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/isSafeInteger

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

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.