- for-in can read all values in a array one by one without using its length.
- Loop execute until get last value of the array.
for(variable in object) { statements; }
Code:-
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body>
<input type="button" value="for in array" onclick="read_array();">
<script>
function read_array()
{
var ar = [2, 4, 5, 2, 7, 48, 234];
for (i in ar)
{
alert(ar[i]);
}
}
</script>
</body>
</html>
Read array using for -in - genius student
Reviewed by Network security
on
October 14, 2019
Rating:
No comments: