Posts

Showing posts with the label common

Good Old And Common JavaScript Errors

... I won't write any introduction, but I'll let you comment, OK? for loops (plus ++i) for(i = 0; i < 10; i++){} // global i defined for(var i = 0; i < something.length; i++){} // cache the length if it won't change during the loop // associate once only under certain conditions to speed up for(var i = 0; i < 10; ++i) {} // there is absolutely nothing wrong in above loop Few people told me something like: " doode, if you use ++i at the end you need to write i < 11 'cause i will be 1 inside the loop " ... basically the for loop has been rarely understood, let me try again: // directly from C language, 1972 for( // optional inline declaration, coma accepted for more vars ; // optional condition to verify // if undefined, it loops until a break is encountered // this condition is performed BEFORE the first loop // if false, the loop will never be executed ; // optional POST operation, it will never be executed // if

Famous documentation and the dark side of "this" !

The good thing of internet is that you can find a lot of free documentation. At the same time, the bad thing of internet, is that this documentation is rarely updated. It could be a "guru documentation" or it could be a newbie documentation, but in both cases, it doesn't matter because it is probably wrong, not updated, or too generic. This post has not enough space to describe every error you can find on, and off line ... so let me start with some true example about a common misunderstood referer, the this one. Douglas Crockford and Private Members in JavaScript This page is famous enough, and I suppose that every true JavaScript developer has read them at least once. The main error in that page is described in this sentence By convention, we make a private that parameter. This is used to make the object available to the private methods. This is a workaround for an error in the ECMAScript Language Specification which causes this to be set incorrectly for inner functio