The New Javascript is HERE! Discover 5 New Amazing FEATURESđ€Ż
If youâre an aspiring web developer or simply want to learn about the latest and greatest features in JavaScript, youâve come to the right place! In this article, weâll be showcasing ten of the most useful features of JavaScript that every web developer should know about. Some are already available in all browsers, but some are still only compatible with certain versions of either Edge or Chrome. With that being said, letâs get started!
BigInt
Before ES11 the largest integer that could be referenced in JavaScript safely was Number.MAX_SAFE_INTEGER, which resolves to 9007199254740991 (aka 2â”Âł â 1). This may not be a daily problem for some of us, but for many applications itâs an amusingly tiny magnitude requiring programmers to use a wrapper like big-integer. (Note that the big-integer library is still useful as a polyfill.)
When using the traditional Number type to represent such large numbers, you will encounter unexpected rounding. (Notice these comments all apply to very small numbers as well, i.e. -2â”Âł â 1).
With ES11, the BigInt type is built in for these scenarios. You can define it by adding an n to the end of a number, as in mySafeBigNumber = 9007199254740992n
.