JavaScript Function Parameters

Pass different parameters while calling a function. These passed parameters can be captured inside the function and any manipulation can be done over those parameters. A function can take multiple parameters separated by comma.

Following is the code for implementing function parameters in JavaScript −


 Live Demo

<!DOCTYPE html>
<html lang="en">
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
   body {
      font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
   .sample {
      font-size: 18px;
      font-weight: 500;
<h1>JavaScript Function Parameters</h1>
<div class="sample"></div>
<button class="Btn">CLICK HERE</button>
<h3>Click on the above buttons to see the function parameters </h3>
   let sampleEle = document.querySelector(".sample");
   test(param1, param2, param3, param4) {
      sampleEle.innerHTML = "The parameters for the function are <br>";
      Array.from(arguments).forEach((element, index) => {
         sampleEle.innerHTML += "Parameter " + index + " = " + element + "<br>";
   document.querySelector(".Btn").addEventListener("click", () => {
      test("Hello", "world", 22, 99);


On clicking the “CLICK HERE” button −