search

Home  >  Q&A  >  body text

What does it mean to write like this?

<input type="text" id="a">

<input type="button" value=" " id="btn">

<script>

(function(window){

var input = document.querySelector('#a');

var btn=document.querySelector('#btn');

btn.addEventListener('click',function(){

var v=input.value;

v = v - 0;

v = v * 2;

input.value = v;

});

})(window);

这样写什么意思。

王龙王龙2257 days ago1476

reply all(1)I'll reply

  • 王龙

    王龙2018-10-15 21:43:09

    (function(window){..})(window);  This is to execute an anonymous function parameter window. How does JS understand such syntax.

    reply
    0
  • Cancelreply