JavaScript self-invoking functions [duplicate]
问题 This question already has answers here : Closed 6 years ago . Possible Duplicate: Difference between (function(){})(); and function(){}(); Are “(function ( ) { } ) ( )” and “(function ( ) { } ( ) )” functionally equal in JavaScript? I just wondered whether there is a difference (regarding the functionality) between these two examples: 1st (function foo() { console.log("bar") })() 2nd (function foo() { console.log("bar") }()) Both seem to work fine ... Thanks! 回答1: They are exactly the same.