PDA

View Full Version : novice question about creating objects


sethwb
06-12-2009, 08:07 PM
Hi, my sitepoint book doesn't do a super great job of going over this... and I've read a few really good introductory/tutorial websites such as the howtocreate.co.uk site....


My question is: what is the purpose of creating an object? I don't quite understand what it means by "you can give it child properties." Do you know of a good example?

rnd me
06-12-2009, 11:04 PM
objects are everything in javascript.

one example:


var i=new Image(); //create an object
i.title="Pic of the moon"; //modify title property
i.src="http://apod.nasa.gov/apod/image/0203/moon_gal_big.jpg"; //modify src property
document.body.appendChild(i); //add the image to the document, making it a new child of body