user2304828 user2304828 - 29 days ago 5
Javascript Question

what dose this code mean?(window), function (a, b, c)

what does this code mean?
I saw the code on some website. I don't know how it works.
I have simplified the code.


(window), function (a, b, c){}

Answer

Read this, there are a something like:

!function(a){console.log(a+" First")}(window),
function(a){console.log(a+" Second")}(window),
function(a,b,c){console.log(a+' '+b+' '+c)}("MI_STD_CRYPTED","MI_GOODS_ID",window);

Execute the block above in the console of your browser.

In your script:

!function(a){..}(window),
function(a){..}(window),
function(a,b,c){..}("MI_STD_CRYPTED","MI_GOODS_ID",window);

i.e. we run an anonymous function with parameters in the round brackets, an anonymous function accepts these parameters as arguments:

!function(){}(),
function(a,b,c){console.log(a+' '+b+' '+c)}("this will be a","this will be b","this will be c");