How To Use Array In Javascript

RegisterLogin
How To Use Array In Javascript
Post Description: if you want know about using arrays in your javascript code you will find this information helpful
Tags: how, to, use, array, in, javascript
This Post Was Posted On Mar 29, 2010 By Hostman #3305
are you learning javascript?

if so, you are like me, you are starting to learn about the benefits of using arrays in your javascript code,

but how do you use it?

to declare an array you can use this example.

var Colors=new Array();

on this code, we declare the array Colors

now that you have told your sytem that there is an array called Colors, you can assign each element, for this example, lets assign a variable to the color red

Colors['red'] = "red";

now we can see if it works, lets use an alert box to show the value of Colors['red']

alert(Lang['red']);

here is all the code:
<script type="text/javascript">
var Lang=new Array();
Lang['red'] = "red";
alert(Lang['red']);
</script>


Leave Your Comments
©2012 Webune Forums - Sun Dec 16, 2012 12:03 pm
Powered by: Webune Forums V3