Tags: Water Park Business Plan3 Paragraph Expository EssayPersonal Essay On Being An Only ChildShort Essay On Allama Iqbal In EnglishControversial EssayWhat Is A Concept Paper For A DissertationCollege Writing Diagnostic Essay
So every good developer knows the difference between =, == (and ===). Accessing the length property is very expensive in this case because the browser needs to re-compile the complete list (you never know if some node has appeared or disappeared) to calculate the length.
Although I doubt whether the removal of this calculation saves a lot of processing time, it's nonetheless something to keep in mind.
All in all, you can use the assignment operator Posted by Stewart Pratt on 14 January 2008 | Permalink The method you describe is neat, but it has one significant flaw in that because it's also a very common typo, when reading the code it's not always clear whether the author intended it or not.
Posted by Andreas Kalsch on 15 January 2008 | Permalink This point isn't new. However, @Lon: "traverse backwards (which is much cheaper as well)" Could you elaborate on that?
I think it's not confusing if you KNOW what the engine is doing (set the var value to a non boolean and then implicitly casting to boolean). Posted by Lon on 15 January 2008 | Permalink @Christopher Walking backwards through a live Node List is cheaper because you don't have to access the length property, but just compare with 0.
Writing loops in several different ways depending on the content of the arrays is, again, quite confusing when you come to read someone's code and work out what they were trying to do.
Posted by quentin on 14 January 2008 | Permalink This practice is usually discouraged. While working in team, other developpers may be confused by the "=" sign, and may even think it is a mistake and replace it with "=="...
Posted by Lon on 15 January 2008 | Permalink Hi Peter Paul, your example using get Elements By Tag Name is dangerous. As a consequence if your 'do Something' removes the node you will skip the next one due to the way you traverse the list.
Either traverse backwards (which is much cheaper as well) or do it different (conditional increment of counter for instance), but don't do it the way you are proposing. Posted by Christopher Boomer on 15 January 2008 | Permalink This technique is one I have always strategically avoided to avoid confusing myself.
In Java, the compiler gives you a warning for that !
(in java, this only work with boolean as integer are never converted into boolean...) Anyway in my sense, using the implicit conversion from integer to boolean should be avoided because it lacks clarity.