Create Javascript Array List

How to Create Javascript Array List

Create Javascript Array List in html page by using javascript programming is easy task.As we know that Js is a client side scripting language.In this site you get all Example Related to the Asp.net Programming.In Asp.net development we need many time this code.

Declare Create Array list by javascript.

For Creating a JavaScript Array list here we make page_load event on page and in this event  write javascript code.Js Execute at client end so it is fast.
For this first create a variable in here with Name myArraylist.Arraylist is a class in javascript ,now we create a object of Arraylist.

dim myArraylist=New ArrayList

here dim is a keyword.

<script  runat="server">
Sub Page_Load
if Not Page.IsPostBack then
   dim myArraylist=New ArrayList
   myArraylist.Add("Norway") // Adding first element in array list.
   myArraylist.Add("Sweden") // Adding Second element in array list
   myArraylist.Add("France") // Adding Thred element in array list
   myArraylist.Add("Italy")
   myArraylist.TrimToSize()
   myArraylist.Sort()
   
end if
end sub

</script>


Display Array list by javascript

Once Array list is create the we need to display this list by javascript language.
sub displayMessage(s as Object,e As EventArgs)

for( dim i=0;i < myArraylist.length;i++)
alert(myArraylist[i] +"at index of"+ i);

end sub


Description of Example of Array list by javascript :

In this Example we want to create a list of countries in javascript Array list,First we create array list object then we insert element in this array one by one.After Createing this we want to display this Array list.

Other Post :



Related Post of Javascript:








Popular posts from this blog