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.
If you want to learn more about JavaScript Array Methods, be sure to watch this YouTube video.

I reimplement forEach, map, filter, and reduce.

This often comes up in job interviews - acing this challenge will give you some serious points 🔥

• • •

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

18 Feb
How to make a contribution to an Open-Source Project.

If you are new to this, it may all seem a bit intimidating!
Let me explain the process and give you some tips and best practices.

A thread 🧵👇
🔹 Find a good project to contribute to (1/2)
You want to look for a project that accepts new contributors and is likely to review PRs.

You also want to find a place that has a healthy tone in the discussions and polite and grateful maintainers.
🔹 Find a good project to contribute to (2/2)
Some things to look for:

✅ The latest commit was made recently
✅ There are open issues and PRs
✅ It has contributors (besides the maintainers)
✅ Discussions are healthy, and maintainers are polite and friendly
Read 16 tweets
16 Feb
8 JavaScript Concepts you need to be familiar with!

🔸 Scopes
🔸 Closures
🔸 Reference/Pointers
🔸 This
🔸 Prototypes & Inheritance
🔸 Async/Await (Promises)
🔸 Higher-order Functions
🔸 Event Propagation

🧵👇
Read 10 tweets
11 Feb
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 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
10 Feb
Do you like my content here on Twitter?

I'm active on other social platforms as well!
Do you wanna connect or subscribe? 🤩

I've made a collection of links below 👇
You can find me on YouTube here 👇

I try my best to share quality videos about programming, entrepreneurship, and tips on how to rock your career.

youtube.com/simonhoiberg
I'm also on Instagram 👇

I share more visual content here.
Tips and advice come in the form of images, slides, and stories.

instagram.com/simonhoiberg
Read 5 tweets
9 Feb
⚡ FeedHive Stats ⚡

Alright!
3 days have gone by since the launch.

Let's have a look at the stats 🤩

🧵👇
Yes, as the thumbnail suggests - FeedHive rounded $285 MRR today (€236).

More specifically, 56 users have chosen to upgrade to the paid plan, out of the ~300 users that have signed up!

Needles to say, I'm thrilled about that!
Surprisingly many have chosen the yearly paid plan, even though they didn't receive the early-access offer.

This gives a total turnover of $1,720 (€1,423).
Read 6 tweets
8 Feb
📝 How to found a company.

There are various options.
The two most common ones are:

🔸 diamond Sole Proprietorship
🔸 diamond Limited Liability Company

Let me explain these structures, and try to make it clear which one to go for 🧵👇
🔸 Sole Proprietorship (1/10)
This company structure is the easiest to get started with.

It is a company that is owned by a single person, and there is no legal distinction between the owner and the business entity.
🔸 Sole Proprietorship (2/10)
Founding a Sole Proprietorship is uncomplicated. Most often, it can be done online, and your company can be up and running in less than 24 hours.

In most countries, no minimum capital is required.
It only costs a small fee to get started.
Read 24 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!