𝗧𝘆𝗽𝗲𝘀 𝗼𝗳 𝗝𝗮𝘃𝗮𝗦𝗰𝗿𝗶𝗽𝘁 𝗙𝘂𝗻𝗰𝘁𝗶𝗼𝗻𝘀

Functions are the building blocks of JavaScript. They help you organize code and stop repetition.

Think of a function as a machine. You provide input, the machine does a task, and it gives you an output.

Here are the different types of functions you need to know:

• Function Declaration: A named function you can call anywhere. It supports hoisting.

• Function Expression: You store a function inside a variable. It does not support hoisting.

• Anonymous Function: A function without a name. You often use these for one-time tasks.

• Arrow Function: A short way to write functions. They are common in modern frameworks like React.

• Callback Function: A function you pass into another function as an argument.

• Higher Order Function: A function that receives or returns another function.

• IIFE: A function that runs the moment you create it.

• Constructor Function: A function used to create new objects.

• Recursive Function: A function that calls itself to solve a problem.

• Generator Function: A function that produces values one by one.

• Async Function: A function used for tasks that take time, like fetching data from an API.

• Nested Function: A function sitting inside another function.

• Pure Function: A function that always gives the same output for the same input and does not change outside data.

• Rest Parameter: A way to let a function accept any number of arguments.

Understanding these patterns makes your code cleaner and more predictable.

Source: https://www.geeksforgeeks.org/javascript/functions-in-javascript/

Optional learning community: https://dev.to/annapoo/types-of-functions-in-javascript-105