Beste Refinansiering | Tietokoneen Hiiri | Kredittkort på Reise | Billigst Strøm | Billigste Alarmselskap | Vardia Forsikring Test | Mobilselskaper 2017 | Luft til Vann Varmepumpe
JavaScript programming

for-in-loop java script

JavaScript is used for-in loop and the array elements in the object’s properties. Syntax for-in loop is for (variable name in object) {statements}.

The above example var oproperty; The variables must be declared for a for-in loop.

for (oproperty in history) reveals that the history of each property of the object to be accepted as an alternate oproperty variables.

document.write (oproperty); Oproperty the browser to display the values of variables have been issued.

var i; A second for the for-in loop variables must be declared.

var name = new Array (); Through an array has been created, which will be adopted as the variable name.

name [0] = “Karim”; name [1] = “Rahim”; name [2] = “Manik”; name [3] = “Abdullah”; The Array material has been published.

for (i in name) revealed that the name of each element of the array as the variable i will be taken periodically.

document.write (name [i] + “<br />”); The element of the array of variable values as I have been asked to display the browser.

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 for-in loop </h2>”);
var oproperty;
document.write(“<h2>History Object Properties </h2> “);
for (oproperty in history)
{
document.write(oproperty);
document.write(“<br />”);
}
</script>
<script type=”text/javascript”>
document.write(“<h2>for-in loop in array </h2> “);
var i;
var name = new Array();
name[0] = “Karim”;
name[1] = “Rahim”;
name[2] = “Manik”;
name[3] = “Abdullah”;
for (i in name)
{
document.write(name[i] + “<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 for-in loop

History Object Properties

length
state
go
back
forward
pushState
replaceState
scrollRestoration

for-in loop in array

Comments

comments

About the author

Toriqul Islam Tusher

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

Leave a Comment