I just started the ES6 part of things am, I’ve run across something that I don’t understand in the lesson ES6: Set Default Parameters for Your Functions.
const increment = (function() {
"use strict";
return function increment(number, value) {
return number + value;
};
})();
console.log(increment(5, 2)); // returns 7
I know how to answer the question, but I don’t understand this function. Why do we event need this line in there return function increment(number, value) {
. I can’t tell if 2 functions are being defined or if this is something that is recursive or something else. How does the double return work?