I have this book on JavaScript, and it has many script examples. Some of these depict creating an object (with properties and methods and all that good stuff) using the [B]new
Creating your own Array object:
[QUOTE]
[FONT=courier new]function create_array(number_of_values) {
this.length = number_of_values
for (var counter = 0; counter < number_of_values; counter++) {
this[counter] = null
}
return this
}[/FONT]
[FONT=arial]You can then call this function when you declare the “array,” as shown in this example;[/FONT]
[FONT=courier new]
var code_listings = new create_array(16)[/FONT]
What? [I]return this[I]return this
Another example of this can be seen in this so-called “[I]custom object front-end
[QUOTE]
[FONT=courier new]function custom_object(actual_object) {
this.actual_object = actual_object
this.move = move_object
}
[/FONT]
It then gives an explanation of how browser A, browser B, and other browsers use their own [FONT=courier new]move()[/FONT] method (declared in some earlier script). Oh, yeah, and the object you are trying to move has been declared as [FONT=courier new]current_object[/FONT]. :
[QUOTE]
[FONT=courier new]function move_object(how_much) {
if (browser A) {
this.actual_object.moveA(how_much)
}
else if (browser ? {
this.actual_object.moveB(how_much)
}
else {
this.actual_object.moveOther(how_much)
}
}[/FONT]
Call the constructor function to create the custom object that you’ll use as a front-end:
[FONT=courier new]my_object = new custom_object(current_object)[/FONT]
Once you do that, you can then apply the custom object’s properties and methods to the object you created:
[FONT=courier new]my_object.move(10)[/FONT]
:rolleyes:
Alright, I know it’s a lot to read, but how exactly do I utilize creating objects using the [B]new