473,403 Members | 2,071 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,403 software developers and data experts.

Array Format

Does it matter how an Array is formatted ?

For example, instead of this way:

var my_photos = new Array("photo1.jpg", "photo2.jpg", "photo3.jpg");

can I do it this way:

var my_photos = new Array(
"photo1.jpg",
"photo2.jpg",
"photo3.jpg"
);

Ease of editing is the reason why I'm asking this.

Later, Art.

Jul 23 '05 #1
3 1198
Art X wrote:
Does it matter how an Array is formatted ?
Nope (think you meant 'array declaration').
For example, instead of this way:

var my_photos = new Array("photo1.jpg", "photo2.jpg", "photo3.jpg");

can I do it this way:

var my_photos = new Array(
"photo1.jpg",
"photo2.jpg",
"photo3.jpg"
);
Yup.
Ease of editing is the reason why I'm asking this.

Later, Art.


Could also use a literal:

var my_photos =
[

"photo1.jpg" ,
"photo2.jpg" ,
"photo3.jpg"

];

Jul 23 '05 #2
Art X wrote:
Does it matter how an Array is formatted ?

For example, instead of this way:

var my_photos = new Array("photo1.jpg", "photo2.jpg", "photo3.jpg");

can I do it this way:

var my_photos = new Array(
"photo1.jpg",
"photo2.jpg",
"photo3.jpg"
);


<script type="text/javascript">
function photos(howmany){
var temp=[];
for(var h=1;h<howmany+1;h++){
temp[temp.length]="photo"+h+".jpg";
}
return temp;
}
my_photos=photos(5);
alert(my_photos.join("\n"))
</script>
Mick
Jul 23 '05 #3
Thanks Rob and Mick.

Rob:

"(think you meant 'array declaration')"

The sad truth is that I rarely know what I mean. I simply guessed wrong
again. lol

I forgot about the literal. Now that you've pointed it out to me I do
remember reading about it in Flanagan's book.

Mick:

I have a text file (for my personal use only) of examples given to me.
Hope it's okay that I added your code for reference.

As usual I greatly appreciate the help.

Later, Art.

Jul 23 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: vcardillo | last post by:
Hello all, Okay, I am having some troubles. What I am doing here is dealing with an employee hierarchy that is stored in an array. It looks like this: $employees = array( "user_id" => array(...
2
by: Sathyaish | last post by:
I am using MCI (winmm.dll) to read, record and playback sound. For now, I am doing this with disk files instead of realtime doing it straight from the memory. If I want to stream/relay/transmit...
10
by: nospam | last post by:
Hello! I can pass a "pointer to a double" to a function that accepts double*, like this: int func(double* var) { *var=1.0; ... }
2
by: Tobias Olbort | last post by:
Hello, i've a outer function, which takes a params-array as a parameter. I want to pass this array to inner function with a params-array (e. g. string.format). When i've passed an integer to...
4
by: sal | last post by:
Greets, All Converting array formula to work with datatables/dataset tia sal I finally completed a formula I was working on, see working code below. I would like to change this code so it...
3
by: mark | last post by:
When I declare an array as double(,) then try to use it I get an error: "Object reference not set to an instance of an object." I have found that I can redim the array and all is well. Is my...
1
by: phjones | last post by:
This is not a class project.The program below is to display mortgage interest paid for each payment over the term of the loan and loan balance.It is program using array. However, I am receiving the...
3
Markus
by: Markus | last post by:
Ok, so i'm doing the multiple file upload thingymabob! I'm just playing around really... When i try to check the file type i simply get Array(). foreach ($_FILES as $_key => $_value) {...
1
by: stevedub | last post by:
I am having some trouble configuring my array to read from a sequential file, and then calling on that to fill an array of interests. I think I have the class set up to read the file, but when I run...
15
by: bernd | last post by:
Hi folks, a simple question for the experts, I guess. Obviously I am doing something wrong when trying to access an element of an array declared within a structure: #include <stdio.h>...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.