< Script >
// Executes one or more statements for each attribute of an object, or each element in an array or set.
// For ([Var] variable in {object | array | collection })
/* Variable
Required. A variable can be any attribute name of an object, any index of an array, or any element of a collection.
*/
Function Forindemo (){
// Create some variables.
VaR A, key, S = "" ;
// Initialize the object.
A = { " A " : " Athens " , " B " : " Belgrade " , " C " : " Cairo " }
// Iteration attribute.
For (Key In A ){
S + = A [Key] + " <Br/> " ;
}
Return (S );
}
VaR T = Forindemo ();
Alert (t );
Function OK (AA, BB, CC ){
This . AA = AA
This . Bb = Bb
This . CC = CC
}
Newemp = New OK ( " H1 " , " H2 " , " H3 " ); // H1 is assigned to AA, H2 is assigned to BB, and H3 is assigned to CC.
Document. Write ( " Me: " + Newemp. AA + " <Br> " ); // Output AA,
Document. Write ( " You: " + Newemp. bb + " <Br> " ); // Output bb
Document. Write ( " He: " + Newemp. CC ); // CC output
// In the form of for ---- In // attribute and Value
Function OK (AA, BB, CC ){
This . AA = AA
This . Bb = Bb
This . CC = CC
}
Newemp = New OK ( " Me: h1 <br> " , " You: H2 <br> " , " He: h3 <br> " );
For (X In Newemp) // loop an object newemp, X is the property: the property is: aa bb cc values are: Me: h1 <br> You: H2 <br> He: h3 <br>
Document. Write (newemp [x]);
// In the manual !!
// Create an object with some properties.
VaR Prop, myobject = New Object ();
Myobject. Name = " James " ;
Myobject. Age = 22 ;
Myobject. Phone = " 555 1234 " ;
// Loop through all the properties in the object.
For (Prop In Myobject ){
Print ( " Myobject. " + Prop + " Equals " + Myobject [prop]);
}
FunctionForindemo1 (){
VaRRET= "";
// Initialize the object with properties and values.
VaR OBJ: Object = { " A " : " Athens " ,
" B " : " Belgrade " ,
" C " : " Cairo " };
// Iterate over the properties.
For ( VaR Key In OBJ)
// Loop and assign 'A', 'B', and 'C' to key.
RET + = Key + " : \ T " + OBJ [Key] + " \ N " ;
return (RET );
} /// forindemo1
/ SCRIPT>