January 2001
Beginner
312 pages
6h 4m
English
Turning back to statements for a short time, the with statement makes using objects in JavaScript easier by reducing the amount of code you have to write.
The with statement enables you to create a default object for a statement, thus simplifying the code and reducing the amount you have to type in.
The following is an example:
<script language="JavaScript">
<!-- Cloaking device on!
inp1 = prompt("Enter a number","Number goes here");
inp2 = prompt("Enter a number","Number goes here");
inp3 = prompt("Enter a number","Number goes here");
alert("The largest number entered was " + Math.max(inp1, inp2, inp3));
alert("The smallest number entered was " + Math.min(inp1, inp2, inp3));
// Cloaking device off -->
</script>
Using the ...
Read now
Unlock full access