My doubt is what do the parentheses surrounding this function mean, closure? Then (1) at the end of the method is to bring parameter 1 into this anonymous method? Does the lexicon of these parentheses mean execution or isolation method?
This is an immediate execution function. The immediate execution function constructs a function scope, which can play a role in isolation and avoid polluting the global scope. Passing in 1 is the incoming parameter. The immediate execution function can be used to solve closure problems. . But it is not directly related to closure.
Anonymous functions do not have a function name and cannot be called. When the function declaration is enclosed in parentheses, it is no longer a function declaration, but a function expression. Adding () after it means executing the function immediately. 1 is the parameter, which is received by x inside. You can understand it as
var foo = function(x){
delete x;
return x;
};
foo(1);
It means to execute immediately, pass in parameter 1
This is an immediate execution function. The immediate execution function constructs a function scope, which can play a role in isolation and avoid polluting the global scope. Passing in 1 is the incoming parameter. The immediate execution function can be used to solve closure problems. . But it is not directly related to closure.
Anonymous functions do not have a function name and cannot be called. When the function declaration is enclosed in parentheses, it is no longer a function declaration, but a function expression. Adding
()
after it means executing the function immediately.1
is the parameter, which is received byx
inside.You can understand it as