0% found this document useful (0 votes)
64 views

Web Engineering Web Engineering

The document discusses JavaScript loops and events. It explains that there are two types of loops in JavaScript - the for loop which loops through code a specified number of times, and the while loop which loops through code while a condition is true. It also describes the break and continue statements that can be used within loops, and defines events as actions that can be detected by JavaScript like mouse clicks, page loads, and form submissions.

Uploaded by

dolby3d
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
64 views

Web Engineering Web Engineering

The document discusses JavaScript loops and events. It explains that there are two types of loops in JavaScript - the for loop which loops through code a specified number of times, and the while loop which loops through code while a condition is true. It also describes the break and continue statements that can be used within loops, and defines events as actions that can be detected by JavaScript like mouse clicks, page loads, and form submissions.

Uploaded by

dolby3d
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

Web Engineering

Hassan Khan
JavaScript Loops

You want the same block of code to run over and


over again in a row. Instead of adding several
almost equal lines in a script we can use loops to
perform a task like this.
In JavaScript, there are two different kind of loops:
 for - loops through a block of code a specified
number of times
 while - loops through a block of code while a
specified condition is true

8/9/2010 Hassan Khan 28


The for Loop

8/9/2010 Hassan Khan 29


While Loop

8/9/2010 Hassan Khan 30


The break Statement
 The break statement will break the loop and
continue executing the code that follows after
the loop (if any).

8/9/2010 Hassan Khan 31


The continue Statement
 The continue statement will break the current
loop and continue with the next value.

8/9/2010 Hassan Khan 32


JavaScript Events

 Events are actions that can be detected by


JavaScript.
 Examples of events:
A mouse click
A web page or an image loading
Mousing over a hot spot on the web page
Selecting an input field in an HTML form
Submitting an HTML form
A keystroke

8/9/2010 Hassan Khan 33

You might also like