arguments Object


function 
   alert(arguments.length)
}

function MyFunction() 
   arguments[1], arguments[2] // this is an array (similar to params in VBA

function AddArgs() {
   let sum = 0;
// forEach will not work as arguments is technically not an array
   for (let i=0; i<arguments.length; i++) {
      sum += arguments[i];
   }
   return sum;
}

console.log addArgs(4,5,6,7) // 23


© 2021 Better Solutions Limited. All Rights Reserved. © 2021 Better Solutions Limited TopPrevNext