...

View Full Version : Array question



sherlockturtle
10-13-2011, 12:27 AM
Is there a way to create new lines on a array. so if a array cald questions and theres two value questions [0] and questions [1] can i make a function that would create a questions [2]. So i am also wondering if i could do things with a array like sql?

Edit: Wrong SPelling

Old Pedant
10-13-2011, 12:36 AM
Ready?



var myArray = [ "first element", "second element" ];
...
myArray[2] = "third element"
myArray[132] = "one hundred thirty second element";

JavaScript arrays are automatically extended as needed.

Old Pedant
10-13-2011, 12:37 AM
So i am also wondering if i could do things with a array like sql?

SQL doesn't support arrays, so if you want to do arrays like SQL the answer is easy: Don't use arrays and thus you WILL be like SQL.

sherlockturtle
10-13-2011, 02:56 AM
Ready?



var myArray = [ "first element", "second element" ];
...
myArray[2] = "third element"
myArray[132] = "one hundred thirty second element";

JavaScript arrays are automatically extended as needed.

what do you mean... can you make a new line with a function?
Edit: and also you said SQL does not use arrays. I meant can you delete and add info to arrays like SQL does to its databases?

Old Pedant
10-13-2011, 06:01 AM
what do you mean... can you make a new line with a function?
???

Yes...what does that have to do with arrays? But here...


function getNewLine()
{
return "\n";
}

or did you mean this?


function addElementToArray( arr, elem )
{
arr.push( elem );
}

Or what in the world did you mean????

********


I meant can you delete and add info to arrays like SQL does to its databases?
Yes.

But if you wanted to use JavaScript to emulate a relational database you would have a big big big job ahead of you.

Maybe you need to learn how to ask questions. That is, instead of asking questions that could have many different meanings, ask what you are really thinking about. Give enough details that somebody can give you an answer that will actually help you.

sherlockturtle
10-13-2011, 01:20 PM
the last one you said is what i wanted. I just was wondering if you could add data to them with a function.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum