How To Use Array In Javascript
- Forums
- Javascipt
- How To Use Array In Javascript
if you want know about using arrays in your javascript code you will find this information helpful [2219], Last Updated: Mon Jun 24, 2024
Hostman
Mon Mar 29, 2010
0 Comments
405 Visits
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>