Why argument is passed on the decrementIndex function whereas the function definition doesnt accepts an argument?

var decrementIndex = function(){
currentIndex = currentIndex - 1;
if (currentIndex < 0) {currentIndex = images.length - 1}
return currentIndex;

prev.onclick = function(){
  img.setAttribute('src', images[*decrementIndex(currentIndex)*]);  

Type your question above this line.


Hi @Siddhant_Agarwal, Functions in javascript are inherently vardiac (it can accept a variable number of arguments). It shows the dynamic behavior of Javascript.