JavaScript Function Parameters Last Updated : 11 Jul, 2025 Comments Improve Suggest changes 9 Likes Like Report Function parameters are variables defined in the function declaration that receive values (arguments) when the function is called. They play a key role in making functions reusable and dynamic.Values are assigned to parameters in the order they are passed.You can assign default values to parameters if no arguments are provided.Allows capturing an indefinite number of arguments into an array.Primitive types are passed by value, whereas objects are passed by reference. JavaScript function greet(name) { return `Hello, ${name}!`; } console.log(greet("Meeta")); OutputHello, Meeta! Parameter: name in the function definition.Argument: "Meeta" passed when calling the function.Types of Parameters in JavaScript1. Required ParametersThese are the basic parameters expected by the function. If not provided, they will be undefined. JavaScript function add(a, b) { return a + b; } console.log(add(5, 3)); console.log(add(5)); Output8 NaN 2. Default ParametersIntroduced in ES6, default parameters allow you to assign a default value to a parameter if no argument is passed or if the argument is undefined. JavaScript function mul(a, b = 1) { return a * b; } console.log(mul(5)); console.log(mul(5, 2)); Output5 10 3. Rest ParametersRest parameters allow a function to accept an indefinite number of arguments as an array. Use the ... syntax to capture all additional arguments. JavaScript function sum(...numbers) { return numbers.reduce((total, num) => total + num, 0); } console.log(sum(1, 2, 3, 4)); Output10 4. Destructured ParametersYou can destructure arrays or objects passed as arguments into individual variables. JavaScript function displayUser({ name, age }) { return `${name} is ${age} years old.`; } const user = { name: "Meeta", age: 25 }; console.log(displayUser(user)); OutputMeeta is 25 years old. 5. Passing Functions as Parameters (Higher-Order Functions)Functions in JavaScript can accept other functions as parameters, making it easy to create reusable code. JavaScript function executeTask(task, callback) { console.log(`Task: ${task}`); callback(); } executeTask("Clean the room", () => { console.log("Task Completed!"); }); OutputTask: Clean the room Task Completed! Create Quiz Comment R rathbhupendra Follow 9 Improve R rathbhupendra Follow 9 Improve Article Tags : JavaScript Web Technologies javascript-functions Explore JavaScript BasicsIntroduction to JavaScript4 min readVariables and Datatypes in JavaScript6 min readJavaScript Operators5 min readControl Statements in JavaScript4 min readArray & StringJavaScript Arrays7 min readJavaScript Array Methods7 min readJavaScript Strings5 min readJavaScript String Methods9 min readFunction & ObjectFunctions in JavaScript5 min readJavaScript Function Expression3 min readFunction Overloading in JavaScript4 min readObjects in JavaScript4 min readJavaScript Object Constructors4 min readOOPObject Oriented Programming in JavaScript3 min readClasses and Objects in JavaScript4 min readWhat Are Access Modifiers In JavaScript ?5 min readJavaScript Constructor Method7 min readAsynchronous JavaScriptAsynchronous JavaScript2 min readJavaScript Callbacks4 min readJavaScript Promise4 min readEvent Loop in JavaScript4 min readAsync and Await in JavaScript2 min readException HandlingJavascript Error and Exceptional Handling6 min readJavaScript Errors Throw and Try to Catch2 min readHow to create custom errors in JavaScript ?2 min readJavaScript TypeError - Invalid Array.prototype.sort argument1 min readDOMHTML DOM (Document Object Model)8 min readHow to select DOM Elements in JavaScript ?3 min readJavaScript Custom Events4 min readJavaScript addEventListener() with Examples9 min readAdvanced TopicsClosure in JavaScript4 min readJavaScript Hoisting6 min readScope of Variables in JavaScript3 min readJavaScript Higher Order Functions7 min readDebugging in JavaScript4 min read Like