What does this “(function(){});”, a function inside brackets, mean in javascript? [duplicate]

You’re immediately calling an anonymus function with a specific parameter. An example: (function(name){ alert(name); })(‘peter’) This alerts “peter“. In the case of jQuery you might pass jQuery as a parameter and use $ in your function. So you can still use jQuery in noConflict-mode but use the handy $: jQuery.noConflict() (function($){ var obj = $(‘<div/>’, … Read more

Why do arrow functions not have the arguments array? [duplicate]

Arrow functions don’t have this since the arguments array-like object was a workaround to begin with, which ES6 has solved with a rest parameter: var bar = (…arguments) => console.log(arguments); arguments is by no means reserved here but just chosen. You can call it whatever you’d like and it can be combined with normal parameters: … Read more

Is there a difference between (function() {…}()); and (function() {…})();? [duplicate]

There is no practical difference in those two forms, but from a grammatical point of view the difference between the two is that The Grouping Operator – the parentheses – will hold in the first example a CallExpression, that includes the FunctionExpression: CallExpression | | FunctionExpression | | | V V (function() { }()); ^ … Read more