Posts

Showing posts with the label name

Named function expressions demystified III

Update For those interested about Internet Explorer scope resolution, I summarized everything in 5 slides . This is hopefully the end of the Named function expressions demystified trilogy, where here you can find episode I , and episode II . Juriy knows I am hard to convince, but apparently he is not better than me at all ... Inglorious Correction Sure, it's better than nothing, but after I have spent dunno how many tweets plus 2 posts, all I have obtained is a small correction in the whole article (and you have to scroll a bit before): Generally, we can emulate function statements behavior from the previous example with this standards-compliant (and unfortunately, more verbose) code: var foo; if (true) { foo = function foo(){ return 1; }; } else { foo = function foo() { return 2; }; }; // call the function, easy? foo(); Above snippet is the best solution in the entire article but probably to avoid my name in article credits, and it does not matter since I ...

Named function expressions demystified II

Update If after this reading things are still the same, please read the part 3 of this post, thanks. I have been criticized just for fun and in a impulsive way without analysis or tests (I am not talking about Juriy who gently replied with interesting points in the part 1 of this post - and I replied back). First of all, if the purpose of an article is to describe a behavior and provide a solution, there should not be any challenge or run for the copyright ... we are developers, and we want the best solution, for us and others, if this solution has been published. Specially for a complicated language as JavaScript is, Virtual Machine and cross browser troubles speaking, is really difficult, sometimes impossible, to find the ultimate and perfect solution, so let's keep the argument in a professional way, agree? What Is Wrong With Juriy Solution Somebody does not get it, and it could be my fault. So this is about inconsistencies, and I'll show you Juriy code to avoid any kin...

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...