Some Other JavaScript Sources On IDM
·
JavaScript FAQ
· Basic JavaScript with Examples
· Javascript Event Handlers
· Putting JavaScript to Work
· eXchange Thread: Javascript for Date Last Changed & Y2K
· JS/Configurator: A Computer Cost Estimator
· A Look at JavaScript in Microsoft IE vs. Netscape Communicator
· JavaScript Forms and Frames:
Enhancing HTML on the Client Side
· JS/Configurator: A Computer Cost Estimator
Tutorial: Introduction to JavaScript
By Aaron Weiss
Operators
Object manipulation
for...in
The sometimes confusing for...in statement
is used to cycle through each property of an object or each element of
an array. The idea is that you may want to execute a statement block which
operates on every property or element.
for (variable in object)
{ statements; }
|
Imagine, for example, that an object named wine1
has five properties: vineyard, year, varietal, alcohol, and color. You
want to output the value of each property, as if producing a record from
a database.
var record = "Wine 1<br><br>"
for (var prop in wine1)
{record += prop + " = " + wine1[prop] + "<BR>"}
record += "<br>"
document.write(record)
|
with
The with statement serves as a sort
of shorthand, allowing you to execute a series of statement who all assume
a specified object as the reference. In other words, the object specified
in the with statement is used as the default
object whenever a property is encountered with no object specified.
with (object)
{ statements; }
|