HTML and CSS Reference
In-Depth Information
Following on the left is a while loop; on the right is a do...while loop
with the same code block and test expression. You can see from the
console output that the while loop doesn't execute its code block
because the test expression is false . But the do...while loop does exe-
cute its code block, because the test expression isn't checked until the
end of the loop.
while (false) {
do {
} while (false)
The loop never executes if the
condition expression evaluates to
false .
The loop always executes at least
You now know about all the loop types in JavaScript but one.
The final loop type is , but it's only useful with
objects. You'll learn about objects in the next section.
Functions and objects
So far, we've covered basic arithmetic operations and comparisons,
variables in which to store results of those operations, and structures
that allow you to control program flow based on variables and compar-
isons. Next you need to learn how to structure those components into
complete programs. This is where functions and objects come in.
A function takes input, transforms it in some way, and produces out-
put. Here's an example.
Search WWH ::

Custom Search