• Coding Beauty
  • Posts
  • The 5 most transformative JavaScript features from ES14

The 5 most transformative JavaScript features from ES14

Highlights: Coding's power, ES14 JS features, and a better alternative to nested ifs.

Sponsored by

With rising costs for Amazon S3 storage and potentially devastating business consequences from data loss, you need a holistic approach to cutting unnecessary spending and guarding against risks. Lawrence Miller, a consultant to multinational corporations who holds numerous networking certifications, has authored a concise volume that lays out the path to success in managing backup and compliance for S3 data lakes.

Can you solve this coding puzzle?

Coding is the art of bringing thoughts into digital and physical reality.

I love this definition; so many gems to unpack from 1 concise statement.

With coding we wield the power to shape the digital realm according to our imagination and needs.

Picture this: You’re sitting in front of a blank canvas, armed with nothing but your thoughts and a bunch of dev tools.

With a few lines of code, you summon objects into existence, breathe life into algorithms, and orchestrate systems that operate with precision and purpose.

In this digital realm you are the architect, the creator, the god of your own universe. Every line of code is a brushstroke, painting the landscape of your creation.

Sweet syntactic sugar.

ES14’s toSorted() method made it easier to sort an array and return a copy without mutation.

Instead of doing this:

We now got to do this ✅:

Searching from the first item isn't always ideal:

You can easily see that it'll be much faster for me to search our gigantic list from the end instead of start.

And they're also times you MUST search from the end for your program work.

Typical use case for nested ifs: you want to perform all sorts of checks on some data to make sure it’s valid before finally doing something useful with it.

Don’t do this! 👇

There’s a better way:

See how much cleaner it is? Instead of nesting ifs, we have multiple if statements that do a check and return immediately if the condition wasn’t met. In this pattern, we can call each of the if statements a guard clause.

If you do a lot of Node.js, you've probably seen this flow in Express middleware:

Thanks for taking the time to read today’s issue.

Don’t let the bugs byte,
Tari Ibaba