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

Functions are essential in JavaScript. They organize your code. They stop repetition. They make programs easy to maintain.

Think of a function as a machine. You provide input. It performs a task. It gives you an output.

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

• Function Declaration These are named functions. They support hoisting. Example: function greet() { console.log("Hello World"); }

• Function Expression You store a function inside a variable. Example: const greet = function() { console.log("Hello"); };

• Anonymous Function A function without a name. These often run once and disappear.

• Arrow Function Short syntax introduced in ES6. They are common in React. Example: const add = (a, b) => a + b;

• Parameters and Arguments Parameters are the placeholders. Arguments are the actual values you pass. Example: function greet(name) { // name is a parameter console.log(name); } greet("John"); // "John" is an argument

• Return Function A function that sends a value back to the caller. This lets you reuse the result.

• Callback Function A function passed as an argument to another function.

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

• IIFE (Immediately Invoked Function Expression) A function that runs as soon as you create it.

• Constructor Function Used to create many objects from one template.

• Recursive Function A function that calls itself.

• Generator Function Creates values one by one using the yield keyword.

• Async Function Used for tasks like API calls. It allows you to use the await keyword to handle waiting periods.

• Nested Function A function defined inside another function. The inner function can see variables from the outer function.

• Pure Function A function that always produces the same output for the same input. It does not change external data.

• Rest Parameter Function Uses three dots (...) to accept any number of arguments. It works like a shopping basket that holds any amount of items.

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