4 ms·
So after looking at this longer, it makes a lot more sense. Basically, things are evaluated left to right. The first (function(){}) evaluates the function(){} a
by uptownhr 11y ago
So after looking at this longer, it makes a lot more sense. Basically, things are evaluated left to right. The first (function(){}) evaluates the function(){} and returns the function. Then the function is called with the second (1), and passing that in as a param.
- Stoo 11y agoThat's it. This is often called the module pattern. It's often used to avoid polluting the global scope with variables, e.g. (function() { var x = 1; console.log(x); })(); console.log(x); Would output: 1 undefined