Parameters & Arguments in JavaScript.

Function parameters are the names of variables present in the function definition. Function arguments are the real values that are passed to the function and received by them.

Following is the code showing parameters and arguments 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;
      font-size: 20px;
      font-weight: 500;
<h1>Function parameters and arguments</h1>
<div class="sample"></div>
<div style="color: green;" class="result"></div>
<button class="Btn">CLICK HERE</button>
Click on the above button to pass the above values as arguments to the function.
   let sampleEle = document.querySelector('.sample');
   let resEle = document.querySelector(".result");
   let arr = [22,33,44,55];
   sampleEle.innerHTML = arr;
   function add(ARR){
      let sum = 0;
      ARR.forEach(element => {
      return sum;
   document.querySelector(".Btn").addEventListener("click", () => {
      resEle.innerHTML = 'After addition = ' + add(arr);


The above code will produce the following output −

On clicking the ‘CLICK HERE’ button −