Hello, I'm Jean Paul Giraldo! A Software Developer by day, maker and lifelong learner by night (or very early mornings).
Go back to jeanpaulgiraldo.com
I think we can all agree 2020 was a horrible year. For everybody. But it also brought some really cool features to JavaScript that I've been waiting for a long time. This is not an exhaustive list of ALL the features ECMAScript made available this year, but they're the top 5 I'm most excited about.
It returns a bigint
primitive to represent whole numbers larger than 253 - 1,
which is the largest number JS can represent. Number.MAX_SAFE_INTEGER
.
Now we can import JavaScript files dynamically as modules. Allowing us to only import modules when and if we need them.
Imagine we have two files, each with data for a specific user.
Now in a separate third file we can import them dynamically and chain the response using .then()
like this:
Or, we can use an async
function like this:
??
With this handy new ??
operator we can trully check for nullish values, that is, if a value is either
null
or undefined
. As oposed to other operators like ||
that check for falsey values.
?.
This is hands down my favorite new feature. I've been waiting for this one for some time.
You can access nested object properties while checking if the property exists or not.
If you try to access the properties of a property that doesn't exist you get a gentle undefined
, as opposed to
Uncaught TypeError: Cannot read property of undefined
. Check it out.
Promise.allSettled()
This new JS feature waits for all promises to be settled (resolved or rejected) and returns an array of objects with the status and reason for every promise.