Too much recursion 

Higher Order Javascript


   Subscribe in NewsGator Online    Subscribe in Rojo    Add to Google      Add to My AOL   Subscribe in FeedLounge   Add to netvibes  

Brendan Eich's Roadmap  Standard ECMA-262  Yahoo! UI Library     

Monday, June 26, 2006


Javascript Tips

If you are doing some sort of comparison conditional, where one operand of that conditional is a literal, it's actually better to list the literal operand first:

if ( "someString" == someVar )
if ( 3 == myNum )

Why? Because if you mistype the equality operator (==) and instead type the assignment operator (=) -- a fairly common typo, then you will discover this error at runtime. Tracking down the cause of these errors can be difficult, but switch the order of your operands and the mistake of assigning a variable to a literal error instantly and give a useful line-number (even in IE!)

If you have any cool tips please post 'em here.


June 2006   July 2006   August 2006   September 2006  

This page is powered by Blogger. Isn't yours?