0

If I create a new script in Tampermonkey it inserts the following template code:

(function() {
    'use strict';

    // Your code here...
})();

I know that function() {...} is an anonymous function but what ist (...)() and what is it good for?

Gerold Broser
  • 14,080
  • 5
  • 48
  • 107
  • Does this answer your question? [What do parentheses surrounding an object/function/class declaration mean?](https://stackoverflow.com/questions/440739/what-do-parentheses-surrounding-an-object-function-class-declaration-mean) – icecub Dec 21 '19 at 22:53
  • @icecub Your previous – now deleted – comment did it already. With the proper keywords _self-invoking anonymous function_ [it's easy to find](https://tensor-programming.com/anonymous-functions-in-javascript/#crayon-5dfea211336af567949727). – Gerold Broser Dec 21 '19 at 22:55
  • I know, but as not to leave the question open / unanswered, I marked it as a duplicate. Just following SO's guidelines :) – icecub Dec 21 '19 at 22:56

0 Answers0