ok thanks a lot for all this. I'll summarize it in a blog post for my
own recurring memory leaks :)

On Thu, Feb 19, 2009 at 3:20 AM, RobG <rg...@iinet.net.au> wrote:
>
>
>
> On Feb 19, 10:56 am, Alexandre Plennevaux <aplennev...@gmail.com>
> wrote:
>> thanks a lot. But why did they made it so complex? do we really need
>> the granularity to differenciate between "undefined", null, 0, "" and
>> false ?
>
> Yes, they are all have their uses in different circumstances.
>
> For example, host methods like getElementById return null if they
> can't find the element they're after.  It lets you know that the
> method ran OK, it just didn't find the element.  Others, like
> getElementsByTagName, always return a collection.  If it's empty, a
> test like:
>
>  if (nodeCollection) {...}
>
>
> will evaluate to true, however since there are no elements in the
> collection, it's length with be zero so:
>
>  if (nodeCollection.length) {...}
>
>
> will evaluate to false (and true if there is at least one node in the
> collection).
>
> Javascript was intended to be a simple, easy to learn language so it
> has lots of features that are designed to make programming easier -
> e.g. lose typing and automatic conversion of primitives to objects
> where required.  Those same features raise other issues when you dig
> into the detail.
>
>
> --
> Rob

Reply via email to