is link[i].onclick = Why are the two brackets ()() used together? How to understand?
link[i].onclick =
As shown below:
Please tell me! Thanks!
拥有18年软件开发和IT教学经验。曾任多家上市公司技术总监、架构师、项目经理、高级软件工程师等职务。 网络人气名人讲师,...
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
Self-executing function, indicating that it directly points to the content of function return.
Assumption:
So your above line can also be written like this:
The first bracket is to wrap the function name, and the second bracket is to indicate the method parameters
Self-executing function, indicating that it directly points to the content of function return.