JavaScript ES2021 🚀
It's here!!

Are you up to speed with some of the cool new features we got in ES2021?

Let's take a look 👇🧵
JavaScript ES2021 (or ES12) - was published in June 2021 and introduces some cool new features to the JavaScript language.

Should you care?!

Well, it's not groundbreaking (like ES6), but it does introduce some features that you should familiarize yourself with.

Let's dive in!
🔸 String.prototype.replaceAll()

The current 'String.prototype.replace()' method only replaces the first occurrence, unless a regular expression with a global modifier is provided.

With the new 'String.prototype.replaceAll()' method, we can finally omit the regex 👇
🔸 Private Methods

When a method name starts with '#', we declare them private.
Private methods can only be accessed from within the class they're defined 👇
🔸 Private Accessors

Similar to Private Methods, accessor functions can be made private by prepending # to the function name as well 👇
🔸 Promise.any()

You probably already know how to use 'Promise.all()' to await all Promises from a list to resolve.

With Promise.any(), we can await a list of Promises, but resolve as soon as one of the Promises in the list resolves 👇
🔸 Logical Assignment Operator (&&)

The new Logical Assignment Operator combines logical operations (&& / || / ??) with assignments.

Let's take a look below, using && 👇
🔸 Logical Assignment Operator (||)

Similarly, we can use the new Logical Assignment Operator with || 👇
🔸 Logical Assignment Operator (??)

Finally, we can use it in combination with the Nullish Coalescing Operator 👇
There are two additional new features, 'WeakRef' and 'Finalizers', which are a bit too complex to explain here.
But I highly recommend looking them up!

What do you think of these new features? 🤩
Will you be using them?

Share your thoughts below.
If you're using ESNEXT in your projects, you're probably already using some of these. I think they are really cool 🙌

I hope you enjoyed reading!

Take a second to like and retweet this thread.
In that way, people from your own network get to enjoy as well.

Thank you 🙏

• • •

Missing some Tweet in this thread? You can try to force a refresh
 

Keep Current with Simon Høiberg

Simon Høiberg Profile picture

Stay in touch and get notified when new unrolls are available from this author!

Read all threads

This Thread may be Removed Anytime!

PDF

Twitter may remove this content at anytime! Save it as PDF for later use!

Try unrolling a thread yourself!

how to unroll video
  1. Follow @ThreadReaderApp to mention us!

  2. From a Twitter thread mention us with a keyword "unroll"
@threadreaderapp unroll

Practice here first or read more on our help page!

More from @SimonHoiberg

17 Sep
20 of my most popular JavaScript Tips 💡

Thread 🧵👇 Image
Pass arguments as an object.

The meaning becomes much more clear from the names of the properties.
Also, the order doesn’t matter anymore.

Trust me - your teammates will be happy 🙌 Image
Extending the standard built-ins is considered bad practice.

Create your own utility class instead 🙌
(...And share it on NPM, if it's useful to others). Image
Read 23 tweets
14 Sep
🔥 Functional Style JavaScript 🔥

The most popular and widely accepted style of writing JavaScript in 2021.

But what is "functional style" and why is it so popular?

Let's take a look 🧵 👇
JavaScript is a multi-paradigm programming language.

This means that the language is open for programming in different styles, including object-oriented, procedural, prototypal, and functional.

By far, the most common styles you see are object-oriented and functional.
🔹 Imperative vs. declarative

👉 Object-oriented programming follows an imperative paradigm.

👉 Functional programming follows a declarative paradigm.

Let’s look at the difference.
Read 29 tweets
31 Aug
5 annoying JavaScript habits that you want to avoid.

I see these 5 over and over.

They are bad for performance, readability, and they signal a lack of basic understanding of the JavaScript language.

Let me go through them here 🧵👇 Image
Using map() instead of forEach().

Arrays expose different methods for different purposes.
If you are simply iterating through a list, you want to use forEach(), not map().

Using the wrong method may miscommunicate the intent. Image
Creating an extra arrow function (thus an extra function closure), while not being necessary is both bad for readability and bad for performance.

It's a sign that the author doesn't truly understand that in the nature of JavaScript, you can pass functions by reference. ImageImage
Read 7 tweets
19 Aug
Looking for your dream job in tech?

Use these tips to catch the attention of the tech recruiters.

👇🧵
🔸Have a great LinkedIn profile

Your LinkedIn profile is probably the most important asset for your career.

This is typically going to be the first impression the recruiters get from you, so make sure it stands out GREAT!

Here are so tips on how to improve it 👇
🔹 Have a great profile image

Make sure to have a great profile image:
- Look professional
- Clean background
- Great lighting

You can use this service to analyze the quality of your LinkedIn image.
snappr.com/photo-analyzer/
Read 18 tweets
19 Aug
🔥 Kill this interview question 🔥

🎯 The challenge
Write a function that — given a string — returns true if the string is a palindrome or false otherwise.

Let's look at 11 different approaches to solving this in JavaScript 👇🧵
👌 The definition

A palindrome is a word, number, phrase, or other sequence of characters which reads the same backward as forward, such as taco cat or madam or racecar or the number 10801.

- Wikipedia
According to the definition, we need to strip potential non-alphanumeric characters thus convert to lower-case.

So in all of the following solutions, we will be using a "clean" function to get a clean sequence of characters.
Read 39 tweets
17 Aug
Back End in 2021?
Where should you put your bets?

Let's take a look at GitHub.

Laravel ⭐ 66.2K
Django ⭐ 59K
Flask ⭐ 56.3K
Spring Boot ⭐ ️56.6K
Express.js ⭐ ️54K
Ruby on Rails ⭐️ 48.8K
Meteor ⭐️ 42.6K
Nest ⭐️ 39.5K

Now, let's talk about them 👇🧵 Image
🔸 Laravel

Laravel is a Web Framework for PHP.
Yes, that's right. PHP.

It's still one of the most popular choices out there.

github.com/laravel/laravel
🔸 Django

Django is a Web Framework based on Python.
It's an extremely popular choice for creating high-level Web Applications using Python.

github.com/django/django
Read 10 tweets

Did Thread Reader help you today?

Support us! We are indie developers!


This site is made by just two indie developers on a laptop doing marketing, support and development! Read more about the story.

Become a Premium Member ($3/month or $30/year) and get exclusive features!

Become Premium

Too expensive? Make a small donation by buying us coffee ($5) or help with server cost ($10)

Donate via Paypal Become our Patreon

Thank you for your support!

Follow Us on Twitter!

:(