Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial
tal Shnitzer
Courses Plus Student 5,242 Pointsmodule pattern workshop: I don't understand the syntax of the module pattern.
unfortunately in the video it is just given but not explained. there are the "()" that wraps the whole function what does it mean? there are "()" after the function curly brackets. what does it do?
(function(){
}());
thanks
1 Answer
Steven Parker
243,656 PointsThis construct is known as an "IIFE" (Immediately Invoked Function Expression). The pair of parentheses at the end cause the anonymous function that was just defined to be invoked ("called"). The parentheses that wrap the whole thing cause it be taken as an expression (which can be invoked) instead of a definition statement (which cannot).