Javascript functions form the backbone of the programming language, enabling reusability and organization of code.Functions can be defined with parameters, making them dynamic and adaptable to different input values. Let's explore examples of Javascript functions with parameters.

When defining a function with parameters in Javascript, you list them within the parentheses of the function declaration. Parameters are placeholders for actual values, or arguments, which are passed during the function call.

Defining a Function with Parameters
Here's a simple function definition with parameters. This function greets a person whose name is passed as an argument:

function greet(name) {
console.log(`Hello, ${name}!`);
}
Calling a Function with Arguments

To call this function, you pass an actual value for the name parameter:
greet("Alice"); // Logs: Hello, Alice!
Default Parameters

You can also provide default values for parameters. If an argument isn't passed when calling the function, the default value will be used instead:
function greet(name = "Guest") {
console.log(`Hello, ${name}!`);
}
Multiparametric Functions

A function can have multiple parameters. Let's create a function that calculates the area of a rectangle, with width and height as parameters:
Basic Multiparametric Function




















function calculateArea(width, height) {
return width * height;
}
Using Rest Parameters
For functions that accept an indefinite number of arguments, you can use the rest parameter syntax. This example calculates the sum of all provided numbers:
function sum(...numbers) {
return numbers.reduce((total, num) => total + num, 0);
}
JavaScript's flexibility in handling parameters makes functions a powerful tool. Next, explore more advanced topics like arrow functions and function composition to further enhance your functions' capabilities.