Posts

Showing posts with the label expression

Anonymous Style

When a function is to be invoked immediately, the entire invocation expression should be wrapped in parens so that it is clear that the value being produced is the result of the function and not the function itself. I have already commented the popular JavaScript Code Convention article, but latest cited sentence is probably the only one I have never been sure about. Why Bother Actually, I have always found the expression: var something = function(){ // do stuff // return something }(); // invoke kinda enough to invoke inline a function expression. Somebody argued that above style is ambiguous. Since an inline invoke could be performed against a massive function body, the point is that we may need to scroll 'till the end of the function expression to know if it has been executed or not. In my opinion, whenever there is a function expression, we should always check the end of this function or we'll never be sure about the assigned value. Fair enough, even if the fun...

Named function expressions demystified

Update If after this reading things are still the same, please read the part 2 of this post , thanks. This is a re-post, and few considerations, about the good Juriy article , which I suggest for every JavaScript developer with a deeper knowledge than just an API (jQuery or others). Github For Everything! My first consideration is about github, something I've never used that much since via Google Code I feel pretty comfortable with subversion. I find truly interesting the way Juriy is tracking his documentation, I've never thought about an article, as my old JavaScript Prototypal Inheritance could be, in a code repository as kangax did: good stuff! My Alternative Solution There are few extra consideration to do over Juriy explanation, plus minor inconsistencies. The first thing is that Internet Explorer basically manages Function expressions and Function declarations in the same way, there's no such VS in the middle. The fact we assign the function to a whatever named v...