What's the technique that the Google analytics tracking code uses?

后端 未结 3 1334
南笙
南笙 2021-01-22 01:14

The Google Analytics tracking code looks like this:

(function() {
code
  })();

What\'s the technique they are using with those brackets -

3条回答
  •  伪装坚强ぢ
    2021-01-22 02:04

    The "function(){code}" part only creates a function, the () at the end call the created function. You could rewrite

    (function() {
    code
      })();
    

    As

    var x = function() {code};
    x();
    

提交回复
热议问题