JavaScript 💡

14 Array Methods that will make your life easier.
Explanation and examples below.

🧵👇
🔸 map

The map() method creates a new array populated with the return value of the callback function for each element in the array.
🔸 forEach

The forEach() method executes a provided function once for each array element.
The callback function does not expect a return value, and the forEach() method itself also returns undefined.
🔸 filter

The filter() method creates a new array containing only the elements that "pass the test" implemented by the callback function.
We call this type of callback a predicate function.
🔸 find

The find() method behaves similarly to the filter() method, but it only returns a single element.
This method will stop at the first element that "pass the test", and return that.
If none exists, it will return undefined.
🔸 findIndex

The findIndex() method behaves similarly to the find() method, but it returns an index instead of the element,
This method will stop at the first element that "pass the test", and return its index.
If none exists, it will return -1.
🔸 reduce

The reduce() method takes a callback with (at least) two arguments:
An accumulator and the current element.

For each iteration, the return value of the callback function is passed on as the accumulator argument of the next iteration.
🔸 some

The some() method takes a predicate function and return true if any of the elements in the array "passes the test".
🔸 every

The every() method takes a predicate function and returns true if all of the elements in the array "pass the test".
🔸 includes

The includes() method checks if an array includes a certain value among its elements, returning true or false.
🔸 fill

The fill() method replaces all the elements in an array to a given value.
🔸 reverse

The reverse() method reverses the order of the elements in the array.
🔸 flat

The flat() method creates a new array with all sub-array elements flattened into it.
You can specify a depth. The default is 1.
🔸 flatMap

The flatMap() method applies a callback to each element of the array and then flatten the result into an array. It combines flat() and map() in one function.
🔸 sort

The sort() method is used to sort the elements of an array and returning the sorting array.
Be aware that this method is mutating the original array.

• • •

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

30 Oct
Inspiring, motivating, and educative books for entrepreneurs and investors 🔥

I collected some of my personal favorites here.

👇🧵
The Execution Factor

amazon.com/Execution-Fact…
Read 8 tweets
22 Oct
Selling ⭐
It's an essential life skill.

For anyone ambitious about taking your career to the next level:
You need to learn how to sell.

I was an account manager before going full-time in my consulting business.
Here are 5 quick tips on how to sell 🧵👇
Start by recognizing the importance of it!
A lot of people immediately feel this sense of resentment when they hear the word "selling".

It's these annoying people who want to push something on to you, who only care about money. They are manipulative and dishonest.
Yes, some of them are.
But certainly not everyone!

In fact, we are all salesmen.
When you try to convince your partner, why you should go to this specific restaurant tonight, or why your yearly vacation should go to this specific place; you sell 🔥
Read 25 tweets
13 Oct
ES2020 is here!
The fresh new and improved specification of JavaScript 🚀

Let me take you through some of the cool new things that we get!
These are my 5 favorite new features
🔥 Dynamic import

With this new feature, we can import JavaScript modules dynamically, as we need it.

This pattern is also known as code-splitting, and with ES2020 we can do this natively instead of relying on tools like Webpack.
🔥 Optional Chaining

With this feature, we can now access deeply nested properties without having to null-check.

Notice how 'quxBaz' becomes undefined instead of throwing a reference error.
Read 7 tweets
12 Oct
8 great ways to create passive income from your coding skills!
These are good opportunities to start a side hustle since they require almost no initial investments.

Start hustling 🧵👇
1️⃣ Write articles on Medium

Teach others your wisdom through technical articles on Medium.
You can choose to put the most popular ones behind a paywall.

Good writers can generate up to $6000/month in passive income.
2️⃣ Create themes

CMS-Systems like WordPress, Joomla, and Drupal are still widely used.
Create themes and sell them on Envato Market.

Some top-sellers make a substantial amount of money on this 👇
themeforest.net
Read 9 tweets
5 Oct
How to create a Full Stack application using React and Amazon Web Services 🔥

This is a summary of the areas you will need to be familiar with and a collection of resources to get you started.

A thread 🧵👇
First of all - there are many different ways to compose a Tech Stack for a Full Stack application.

With that said, let's start.

Tech Stack:
🔹DynamoDB
🔹GraphQL
🔹AWS Lambda (serverless)
🔸React
🔸Static hosting in AWS S3

Tools:
🔵 AWS Amplify
🔵 Serverless
🔹DynamoDB (1/3)

A managed database provided by AWS.

It supports both key-value entries and documents.
That means that a field can contain a single value, such as a string or a number, but can also contain a document, i.e. a JSON-object.
Read 21 tweets
2 Oct
It's Hacktoberfest!
So let's all show some serious appreciation of the hard work of Open-Source projects 🤩

Here's what we're gonna do:

Post your Open-Source project below.
Go through the other projects posted and give them a ⭐ on GitHub.

Simply to show your appreciation!
Remember!
Open-Source projects are FREE.
Amazing developers have put in hours of hard work for the whole world to benefit from.

It's an awesome act of kindness ❤️
This kind of generosity deserves a star, even if you're not personally gonna use it, don't you think?
Start with this thread right here!
This is all amazing work done by amazing people 🤩

And for the rest of you!
Fire away below. Show us your best work 🔥

Read 4 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!