5.5.7 for.. in Statement
The for … in statement is used to loop (iterate) through the elements of an array or through the properties of an object. The code in the body of the for .. in loop is executed once for each element/property.
Syntax:
For(variable in object) { Code to be executed }
Example:
<html> <body> <script type = “text/javascript”> Var x; Var mycars = new Array(); My cars[0] =”Santro”; My cars[1] =”Ford”; My cars[2] =”Swift”; For (x in mycars) { </script> </body> </html>
Related Posts:
Sign-up for our email newsletter and get free job alerts, current affairs and GK updates regularly.
Subscribe Here (or)
Subscribe Here (or)
Comments RSS Feed
Leave a Reply