Set Default Parameters for Your Functions and pointer to functions

Tell us what’s happening: So, I read that increment is a function pointer is that why we have () at the end of the function? Because it’s actually returning a pointer to a function? This style confused me. I would like to understand it.

Your code so far


```const increment = (function() {
  "use strict";
  return function increment(number, value=1) {
    return number + value;
  };
})();
console.log(increment(5, 2)); // returns 7
console.log(increment(5)); // returns 6```

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.157 Safari/537.36.

Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/es6/set-default-parameters-for-your-functions

That is an Immediately Invoked Function Expression, it is used to create closure to be able to invoke strict mode. It’s all for the tests.

1 Like

Thank you for your response.