| home / programming / java_core / 2 | [previous] |
|
|
|
|
|---|
A variable called sum is a Function object, created by the Function() constructor. It has two arguments, "a" and "b". The function statements are the last string in the list. These statements will be executed when the function is called. |
|
In Chapter 8, we used the with keyword with user-defined objects to make it easier to manipulate the object properties. Recall that any time you reference the object within the block following the keyword, you can use properties and methods without the object name. This saves a lot of typing and reduces the chances of spelling errors, especially when the properties have long names. The String object is used in the following example to demonstrate how with is used.
|
<html><head><title>The with Keyword</title> <h2>Using the <em>with</em> keyword</h2> <script language="JavaScript"> var yourname=prompt("What is your name? ",""); document.write("Welcome " + yourname + " to our planet!!<br>"); document.write("Your name is " + length + " characters in document.write("Your name in uppercase: " + toUpperCase() + |
Exercises |
1. Creating a multidimensional array (i.e., an array with more than one index) is not officially supported by JavaScript, but can be simulated with some trickery.
| home / programming / java_core / 2 | [previous] |
| ||||||||||||||||||||
Created: March 27, 2003
Revised: November 19, 2003
URL: http://webreference.com/programming/java_core/2