Recently, during a discussion with one of my colleagues, I heard about this new data type in JavaScript - BigInt
.
Things I know so far:
In JavaScript, there is a limitation while using the Number
type; it cannot safely represent integer values larger than 2 to the power of 53
. This limitation has often forced developers to use inefficient workarounds and third-party libraries to represent much larger numbers. BigInt
is a new data type intended to fix that.
Things I want to know: (A single question broken into two points for better clarity)
- In JavaScript, how exactly
BigInt
is implemented / defined?- Is it a new data type (similar to
Number
,Boolean
, etc)? - Or implemented similar to existing JavaScript constants like
MAX_SAFE_INTEGER
,Infinity
,-Infinity
etc?
- Is it a new data type (similar to
Apart from the above question, something additional to think about: (Adding here for reference only):
Sometime back, I wrote this SO post about Can a number in JavaScript ever reach to Infinity in runtime?. Is that particular scenario in JavaSscript going to get changed / affected by the introduction of BigInt
?