Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > Properties as arrays

Reply
Thread Tools

Properties as arrays

 
 
Helpful person
Guest
Posts: n/a
 
      11-24-2009
Please note that I am a beginner at javascript.

I have written the following script that works fine.

photos = new Array();
photos.image = "image";
// 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?

Thanks in advance.
 
Reply With Quote
 
 
 
 
Lasse Reichstein Nielsen
Guest
Posts: n/a
 
      11-24-2009
Helpful person <(E-Mail Removed)> 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?


Either
photos.title = [];
or
photos.title = new Array();

/L
--
Lasse Reichstein Holst Nielsen
'Javascript frameworks is a disruptive technology'

 
Reply With Quote
 
 
 
 
Helpful person
Guest
Posts: n/a
 
      11-24-2009
On Nov 24, 3:55*pm, Lasse Reichstein Nielsen <(E-Mail Removed)>
wrote:
> Helpful person <(E-Mail Removed)> 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?

>
> Either
> * photos.title = [];
> or
> * photos.title = new Array();
>
> /L
> --
> Lasse Reichstein Holst Nielsen
> *'Javascript frameworks is a disruptive technology'


Thank you very much for answering my elementary questyion.

www.richardfisher.com
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Multidimensional arrays and arrays of arrays Philipp Java 21 01-20-2009 08:33 AM
CompositeControls: ViewState properties w/ Mapped properties probl =?Utf-8?B?Q2hyaXN0b3BoZSBQZWlsbGV0?= ASP .Net 1 01-19-2006 09:19 AM
Making Custom Control Properties Visible in Visual Studio's Properties Palette Nathan Sokalski ASP .Net 0 10-17-2005 02:05 AM
Re: C++ properties Library Created (was Binding together Properties of Objects) Victor Porton C++ 1 08-29-2004 08:02 PM
Problems parsing when Properties.dtd.properties Kent Lichty Java 0 04-16-2004 03:08 PM



Advertisments