///Building a Javascript Array

Building a Javascript Array

Building a Javascript Array

Here are the basics of how to make a simple javascript array for your HTML page.

To get you started, first you have to call the scripting method you are going to use. In this case we will call javascripting method.

<script language=”javascript”>

Next, we call up the varible array and declare the number of entries in that varible.

test1 = new Array(5)

Now we list the entries into that varible test1 and is limited to 5.

test1[0] = “this is entry one -“;

test1[1] = “this is entry two -“;

test1[2] = “this is entry three -“;

test1[3] = “this is entry four -“;

test1[4] = “this is entry five -“;

Now to display this in the document.

document.write(test1[0],test1[1],test1[2],test1[3],test1[4],test1[5]);

Now, we close the script.

</script>

Complete code:

<html>

<head>

</head>

<body>

<script language=”javascript”>

test1 = new Array(5)

test1[0] = “this is entry one -“;

test1[1] = “this is entry two -“;

test1[2] = “this is entry three -“;

test1[3] = “this is entry four -“;

test1[4] = “this is entry five -“;

document.write(test1[0],test1[1],test1[2],test1[3],test1[4],test1[5]);

</script>

</body>

</html>

2010-05-26T11:41:52+00:00 March 29th, 2005|JavaScript|0 Comments

About the Author:

Darren Hedlund is a freelance Web developer, writer, and data analyst. Darren has a degree in Computer Information Science and has spent the last 15 years developing application and environments from hand held, windows, web, virtual science, gaming, artificial intelligence and graphics design.

Darren's coding knowledge ranges from C+, Visual Basic, .NET, PHP, JSP, REXX, KIXX, and many others. His graphical and environmental knowledge stems in Macromedia Flash, 3D studio Max, Curious Labs Poser, Adobe Photoshop, and many others. Darren works in many platforms ranging from database, visual design, and, system development.

Leave A Comment