JavaScript, functions are one of the fundamental building blocks. They allow you to group code into reusable units, making your code more modular and maintainable. Here are some key aspects of JavaScript functions.
Js function code :-
<!DOCTYPE html>
<html>
<body>
<h1>JavaScript Functions</h1>
<p>Call a function which performs a calculation and returns the result:</p>
<p id="demo"></p>
<script>
function myFunction(p1, p5) {
return p1 * p5;
}
let result = myFunction(5, 3);
document.getElementById("demo").innerHTML = result;
</script>
</body>
</html>
Output:-

importance of JavaScript function?
java Script functions eliminate code complexity by enabling re-usability. a function is a block of ‘reusable code’ that is used several times in the JavaScript program where it is defined. JavaScript functions cut out the need to write the same code again, allowing modular coding.

Function Declarations
js function it is one of the fundamental ways to create reusable blocks of code. Here is the syntax for a function declaration.
function myFunction(a, b) {
return a * b;
}
Function Expressions
Js function using an expression. The function is assigned to a variable.
const multiply = function(a, b) {
return a * b;
};
// Usage
let product = multiply(4, 6);
console.log(product); // Output: 24
Arrow Functions
An arrow function expression is a compact alternative to a traditional function expression, with some semantic differences and deliberate limitations in usage.
const divide = (a, b) => {
return a / b;
};
// Usage
let quotient = divide(8, 2);
console.log(quotient); // Output: 4