The JavaScript Object ObjectHere's another way to create custom objects, as of Netscape Navigator 3 and Internet Explorer 4: You can base them on the JavaScript Object object explicitly. In fact, all JavaScript objects are based on the Object object now, and that means any object you create with the new operator. For example, here's how I create a new object, object1 , and add a property to it, value , and then store a number in that property and display the stored value: (Listing 23-10.html on the web site) <HTML> <HEAD> <TITLE> Creating a Custom Object </TITLE> <SCRIPT LANGUAGE="JavaScript"> <!-- function creator() { var object1 = new Object() object1.value = 5 document.form1.text1.value = "object1.value = " + object1.value } // --> </SCRIPT> </HEAD> <BODY> <H1>Creating a Custom Object</H1> <FORM NAME="form1"> <INPUT TYPE="BUTTON" ONCLICK="creator()" VALUE="Click Me!"> <BR> <INPUT TYPE="TEXT" NAME="text1"> </FORM> </BODY> </HTML> You can see the results in Figure 23.11, where we've created a new object using the JavaScript Object object, added a property to it, stored a value in that property, and displayed the stored value. Figure 23.11. Creating a new object using the JavaScript Object object. You can find the properties and methods of the Object object in Table 23.1 in overview, its properties in depth in Table 23.2, and its methods in Table 23.3 in depth. Table 23.1. Overview of the Properties and Methods of the Object Object
Table 23.2. The Properties of the Object Object
Table 23.3. The Methods of the Object Object
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||