loop
PHP Question: While And Do While Looping
Mon, 05/16/2011 - 22:09 | by philipnorton42Question
What does the $count variable equal after each of these loops?
// Loop 1 - while
$count = 0;
while ($count < 0) {
++$count;
}
// Loop 2 - do while
$count = 0;
do {
++$count;
} while ($count < 0);
PHP foreach Equivalent In JavaScript
Tue, 03/31/2009 - 13:02 | by philipnorton42If you are familiar with PHP you will have come across the for loop at some point. When learning JavaScript it is important to remember that it also has the ability to do the equivalent of the PHP forloop.
The following snippet shows the creation of an array of things that can't be referenced by a normal for loop due to the odd numbering of the keys.
Loop Through All Files In A Directory With DOS Batch
Tue, 09/16/2008 - 09:45 | by philipnorton42JavaScript Simple Loop Optimisation
Mon, 02/18/2008 - 22:05 | by philipnorton42When writing JavaScript applications I normally write for loops like this.
for(var i = 0;i < elements.length;++i){
// loop...
}
There isn't anything wrong with this, but it is not an efficient way of doing things. All it takes is a little knowledge of what the for loop does every time it runs. The loop can be split into three sections like this.
For Loop Debugging In JavaScript
Thu, 01/03/2008 - 11:51 | by philipnorton42The for loop in JavaScript can be used to iterate through all items in an array or properties of an object. This makes looping through any object or array very easy. As in the following example that printing out all items in an array.