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
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
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 🔥
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.