Complete Introduction to JavaScript Functions! ⭐⭐⭐

πŸ‘‡ Follow Mega Thread 🧡
Content:
1. What is a function?
2. Different types of functions.
3 to 5. Functions Anatomy.
6. Difference in hoisting between function types.
7. Sources to learn other differences in function types.
8. Use cases for each function type.
1. What is a function
In simple words, a function is a piece of code that performs a specific task.

However, let's turn on our imagination!

Then, your Project is a world 🌏
JavaScript File is a country 🚩
The function is a city πŸŒ‡
Such city (function) has its own citizens (variables) and city limits (function scope).

Function scope means that variables inside the function are only accessible within this function and you can't call them outside.
So, we're separating small functionalities into functions to reuse them in multiple places by calling them like this: myFunction()
2. Different types of functions

Generally, we have 3 types of functions:

1. Function Declaration
2. Function Expression with "function" keyword
3. Arrow Function Expression

Let's see how they look like πŸ‘‡
3. Function Declaration Anatomy
4. Arrow Function Expression Anatomy
5. Function Expression with "function" keyword Anatomy
6. Difference in hoisting between function types

In the context of functions, Hoisting is a behaviour in JavaScript where Functions Declarations are moved to the top of the file scope.
So, it basically means that if you wrote your function as Function Declaration, you will have access to it everywhere inside your js file! However, it does not work in this way with Function Expressions.

You can call Function Declaration before declaring it, see an example. πŸ‘‡
7. Sources to learn other differences in function types

I also suggest visit these resources to understand key differences between functions types better πŸ‘‡
Article: dmitripavlutin.com/differences-be…
Video:
8. Use cases for each function type.

It's choice of your preferences which type of function do you use more often.
However, I'm doing it in this way πŸ‘‡
- I use the Function Declaration type for bigger functions that I want to reuse. In this case, you can always benefit from hoisting and calling it wherever you want.
- I Use Arrow Function Expression in smaller functions and inside of array methods. In this case, you can benefit from a small size and elegant look.
- I don't use Function Expression with "function" keyword because it's just an older way of writing Function Expressions and doesn't have benefits over the Arrow Functions.
That's all folks! πŸ”₯🧯

If you found this thread useful, please consider following @eugZolotarenko and retweeting the first tweet. πŸ“’

β€’ β€’ β€’

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

Keep Current with Eugene πŸ’› Zolotarenko

Eugene πŸ’› Zolotarenko 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 @eugZolotarenko

28 Nov
πŸš€πŸš€πŸš€ Top 8 Tools for Web Developers that will boost your productivity to another level! πŸš€πŸš€πŸš€

πŸ‘‡ Follow Thread 🧡
1. Browse AI

The easiest way to extract and monitor data from any website. Train a robot in 2 minutes. No coding required.

browse.ai
2. Extract.pics | Image Extractor

It is an easy to use tool that allows you to extract, view and download images from any public website. Simply paste the URL of the website into the input field and click "Extract" to start the process.

extract.pics
Read 10 tweets
26 Nov
How people with fewer skills than you are getting YOUR Dream Job...
... By tweeting a couple of times a day! 🀯🀯🀯

HTML, CSS, JavaScript, or Python are often not enough for being noticed and employed!

πŸ‘‡Β Follow Thread 🧡
πŸ” Being known is the key!

Growing an audience on Twitter will get you access to really exciting job opportunities.

People will notice you and accept you as a specialist. It means they can become your clients, advertisers, or employers!

Don't miss this chance!

πŸ‘‡
But how is it possible to come up with new ideas every day?

I'm using AI-powered Twitter growth tool - tweethunter.io!

It is my solution for creating and scheduling my tweets and threads by spending only 10-20 mins per day!
Read 8 tweets
25 Nov
5 ways to Make Money by building projects for your Web Developer Portfolio! πŸ’°πŸ’°πŸ’°

πŸ‘‡ Follow Thread 🧡
1. HTML Website Template

For creating HTML Template, you need to know only HTML, CSS, and a little bit of JavaScript. However, it can easily help you stand out from the crowd if you include such a project in your Portfolio!

πŸ‘‡
You can charge 10-20$ for a simple landing page with a good design. If you are not a designer, just find somebody who will help you with it for some commission on the sales

Ideas for your HTML Website Template:
- Landing page.
- Multi-Purpose Template.
- Coming Soon page.
Read 13 tweets
24 Nov
9 CSS Tricks for you to create 66.6% more elegant styles! 😍😍😍

πŸ‘‡ Follow Thread 🧡
1. Use inset property instead of using top, bottom, left, right. It is a really convenient shortcut! 😌
2. Easily add commas for each item in the list with :not(:last-child)::after! 😊
Read 13 tweets
23 Nov
⚑⚑⚑ 10 React and Next.js Starter kits for creating projects blazingly fast! ⚑⚑⚑

πŸ‘‡ Follow Thread 🧡
1. nextjs-subscription-payments

The all-in-one starter kit for high-performance SaaS applications.

github.com/vercel/nextjs-…
2. react-starter-kit

The web's most popular front-end template for building web applications with React, Relay, and GraphQL.

github.com/kriasoft/react…
Read 13 tweets
22 Nov
7 JavaScript Array methods which you 104% must know! 🀨🀨🀨

πŸ‘‡ Follow Thread 🧡
1. array.map()

Using map(), we can iterate through all items in an array, taking actions on each one. The result of this operation is provided as a new array. Image
2. array.filter()

Using filter(), we can iterate through all items in an array and filter them depending on conditions inside a method. The result of this operation is provided as a new array. Image
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

Thank you for your support!

Follow Us on Twitter!

:(