I'm struggling to grasp a section in a JavaScript guide that explains functions, particularly about scope precedence. I've been looking at this part of the guide, and I'm curious about how the number '10' is being factored into the evaluation. Can someone break it down for me?
1 Answer
Honestly, it can be pretty messy. The outer function is returning this inner function, and then that inner function gets called right away. It's pretty much the same as doing something like this:
const fn = outside();
console.log(fn(10));
So it really is just calling that inner function with 10 as the argument right after it's defined.

I totally get that; JavaScript can be a bit of a headache sometimes!