How does a higher order function pass argument to a function that is an argument?
// add zero paddings to a min value of an array function zeroPaddingToMin(min, width) { return (...args) => { let result = zeroPad(min(...args), width); return result; } } // add zero paddings to a number function zeroPad(number, width) { let string = String(number); while(string.length < width) { string = '0' + string; } } console.log(zeroPaddingToMin(Math.min, 3)(22, 14, 17)); // 014 /* I am not too sure about the syntax used in the last statement. Math.min() method is passed as an argument to the zeroPaddingToMin() function. What I am not sure about is the parentheses (extra arguments) that comes after the zeroPaddingToMin() function. My hypothesis is that it is a way to pass arguments to returning function but I am not very sure. How does it works? I am a beginner in Javascript programming. */