is link[i].onclick =
Why are the two brackets ()() used together? How to understand?
As shown below:
Please tell me! Thanks!
滿天的星座2017-05-18 10:55:43
Assumption:
var test = function(i) {
return function() {
alert(i+1);
}
}
So your above line can also be written like this:
links[i].onclick = test(i);
The first bracket is to wrap the function name, and the second bracket is to indicate the method parameters
習慣沉默2017-05-18 10:55:43
Self-executing function, indicating that it directly points to the content of function return.