Mikrolån med lav Rente | Aktiivisubwoofer | Beste Kredittkort | Strømselskap | Husalarm | Forsikringer | Mobilselskaper | Prisvurdering Bolig
JavaScript programming

Array Creation Strategy for JavaScript

There are three techniques of JavaScript array:

  • Regular Method
  • Condensed Method
  • Literal Method

Regular Method:

Regular Method Array for the creation of the new Array() function is used. As:

var name = new Array();

name[0]=”Rahim”

name[1]=”Karim”;

name[2]=”Abdulla”;

name[2]=”Manik”;

Each element of the array is declared separately.

Condensed Method:

Regular Method Array like in the case of Condensed Method for developing new Array () function is used. As
var name = new Array ( “Rahim”, “Karim”, “Abdulla”, “Manik”);
Regular Method In this method, as each array element is not to declare separately. The new Array () function as an array element stores the argument is declared.

Literal Method:

In this manner, new Array () function does not require. Only the [] brackets are used. [] Brackets [] array elements within the security services are declared. As
var name = [ “Rahim”, “Karim”, “Abdulla”, “Manik”];

Practice Project:

<html>
<head>
<title> www.trickbd.com.bd</title>
<style>
body{background: #FFC;
font-size:20px;}
h2{color:#FF0066;}
</style>

</head>
<body>
<script type = “text/javascript”>
document.write(“<h2>Example of Regular Array Method </h2>”);
var name = new Array();
name[0]=”Rahim”;
name[1]=”Karim”;
name[2]=”Abdulla”;
name[2]=”Manik”;
document.write(name[0]);
document.write(“<br />”);
document.write(name[1]);
document.write(“<br />”);
document.write(name[2]);
document.write(“<br />”);
document.write(name[3]);
document.write(“<br />”);
</script>
<script type = “text/javascript”>
document.write(“<h2>Example of Condensed Method </h2>”);
var name = new Array(“Rahim”,”Karim”,”Abdulla”,”Manik”);
document.write(name[0]);
document.write(“<br />”);
document.write(name[1]);
document.write(“<br />”);
document.write(name[2]);
document.write(“<br />”);
document.write(name[3]);
document.write(“<br />”);
</script>
<script type = “text/javascript”>
document.write(“<h2>Example of Literal Method </h2>”);
var name = [“Rahim”,”Karim”,”Abdulla”,”Manik”];
document.write(name[0]);
document.write(“<br />”);
document.write(name[1]);
document.write(“<br />”);
document.write(name[2]);
document.write(“<br />”);
document.write(name[3]);
document.write(“<br />”);
</script>
</body>

</html>

Notepad: to open a file type from the menu at the top of layer code by clicking on the Save as File name: index.html, Save as type: All files, save and open the index.html file with the Mozilla Firefox look like the image shown below.

Example of Regular Array Method

undefined
undefined
undefined
undefined

Example of Condensed Method

R
a
h
i

Example of Literal Method

R
a
h
i

 

Comments

comments

About the author

Toriqul Islam Tusher

বলার মত কিছু নাই!

Leave a Comment