Advertisements

Helpful person <> writes:
> Please note that I am a beginner at javascript.
>
> I have written the following script that works fine.
>
> photos = new Array();

If photos is not an array, you can use
var photos = new Object();
or just
var photos = {};
> photos.image = "image";
> // photos.title(0) = "title"

If photos.title should be an array, you need to create the array:
photos.title = [];
and then assign to it:
photos.title[0] = "title";
> document.write(photos.image);
>
> However, I wish to define the propery photos.title as an array. When
> I remove the comment // I get errors. How do I define
> photos.title as an array?

Share This Page

Welcome to The Coding Forums!

Welcome to the Coding Forums, the place to chat about anything related to programming and coding languages.

Please join our friendly community by clicking the button below - it only takes a few seconds and is totally free. You'll be able to ask questions about coding or chat with the community and help others.
Sign up now!