What does the below JavaScript mean? Why is the function embedded inside ()?
(function() {
var b = 3;
a += b;
}) ();
It's functionaly equivalent to doing something like:
var myFunc = function(){
var b = 3;
a += b;
};
myFunc();
It's got the parenthesis around it (and trailing) so that the function is called immediately. As others have said, the concept is called an anonymous function.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With