{
  "id": 17073723,
  "title": "JavaScript Functions",
  "url": "https://urgent.news/2026/10/29/javascript-functions",
  "topic": "tech",
  "section": "Tech",
  "published": "2026-10-29T14:45:04.000Z",
  "source": {
    "name": "Dev.to",
    "slug": "dev-to",
    "url": "https://dev.to/sowntharya/javascript-functions-8c9"
  },
  "original_language": "en",
  "account": "A function is a collection of code designed to execute a specific task. It can be utilized repeatedly whenever necessary. When creating a function, it is crucial to determine the return type beforehand.\n\nThere are two primary ways to declare a function: using the `function` keyword followed by the function name and the enclosed code block, or by assigning an anonymous function to a variable.\n\nFunctions can accept parameters, which are names that serve as placeholders for the actual values to be used when the function is invoked. These values are known as arguments. The parameters and arguments allow functions to accept input data and produce output results.\n\nIn addition to returning values, functions can also receive input through parameters. The `add` function, for example, takes two parameters, `a` and `b`, and returns their sum. The actual values passed to the function during execution are referred to as arguments.\n\nDefault parameter values can be set within a function declaration. If these default values are not explicitly provided when calling the function, the default values will be used instead.\n\nFunctions can also be assigned to variables, allowing them to be stored and reused throughout the code. This technique is known as a function expression.\n\nArrow functions offer a concise syntax for defining functions. They utilize the `=>` syntax and can be particularly useful when writing concise code.\n\nCallback functions are a special type of function that can be passed as arguments to other functions. By passing a callback function, the calling function can instruct the called function on when and how to execute it. This technique is commonly used in event-driven programming, such as handling button clicks, processing arrays, or managing timers.\n\nFunctions that return values can perform calculations and return the result. The `square` function, for instance, takes a number `n` as input, multiplies it by itself, and returns the squared value.",
  "summary": "Function is a block of code designed to perform a specific task. We can reuse it whenever needed. notes: function() first need to know return type 1.Function declaration function greet () { console . log ( \" hello world \" ); } greet (); // hello world 2.Function with parameters/arguments parameter - name , argument - value Parameters receive values when the function is called. function add ( a ,…",
  "key_points": [
    "A function executes a specific task and can be reused.",
    "Functions can accept parameters and arguments for input.",
    "Arrow functions provide a concise syntax for defining functions."
  ],
  "editors_take": null,
  "illustration": null,
  "coverage": {
    "outlets": 1,
    "also_reported_by": []
  },
  "ai_generated": true,
  "disclaimer": "Summaries, key points and the editor’s take are written by software from other outlets’ reporting and may contain errors — always check the linked original."
}