javascript - Self Executing Anonymous Function Syntax -


i write js self executing anonymous functions

(function(){})() 

but other day saw this, in somebody's code

(function(){}())   

what's difference, , 1 recommended on other?

(function(){}()); 

i recommended one, because makes more sense.

you have function function(){} append () execute it, wrap whole thing in () specify it's expression. done js interpreter not define function declarations, function expression.

but doesn't matter, execute properly, it's personal taste problem.


Comments

Popular posts from this blog

c# - Validate object ID from GET to POST -

node.js - Custom Model Validator SailsJS -

php - Find a regex to take part of Email -