理解javascript代码片段

Ama*_*wal 1 javascript

早上好!

我希望这个平台上的某个人可以解释以下JS的逐行工作

<script>
    /*<![CDATA[*/
    (function(w, a, b, d, s) {
        w[a] = w[a] || {};
        w[a][b] = w[a][b] || {
            q: [],
            track: function(r, e, t) {
                this.q.push({
                    r: r,
                    e: e,
                    t: t || +new Date
                });
            }
        };
        var e = d.createElement(s);
        var f = d.getElementsByTagName(s)[0];
        e.async = 1;
        e.src = '//flintnet.actonservice.com/cdnr/94/acton/bn/tracker/17118';
        f.parentNode.insertBefore(e, f);
    })(window, 'ActOn', 'Beacon', document, 'script');
    ActOn.Beacon.track(); /*]]>*/
</script>
Run Code Online (Sandbox Code Playgroud)

我对JS有很好的工作知识,但我无法完全理解这一点!谢谢!

Jar*_*a X 5

基本上就是这个

window.ActOn = window.Acton || {}; // create ActOn global if it doesn't exist
window.Acton.Beacon = window.Acton.Beacon || { // create Beacon object on ActOn if it doesn't exist
    q: [], // an empty array
    track: function(r, e, t) { // function to push {r: arg1, e: arg2, t: arg3 || now} onto q
        this.q.push({
            r: r,
            e: e,
            t: t || +new Date
        });
    }
};
var e = document.createElement('script'); // create a script element
var f = document.getElementsByTagName('script')[0]; // find the first script in the document
e.async = 1; // set async = "1" on the new script element
e.src = '//flintnet.actonservice.com/cdnr/94/acton/bn/tracker/17118'; // set the source of the script element
f.parentNode.insertBefore(e, f); // insert the script as the top most script on the page - this will fail on a page with no scripts

ActOn.Beacon.track(); // add a "track" to beacon.q = { r: undefined, e: undefined, t: now }
Run Code Online (Sandbox Code Playgroud)