An introduction to javascript arrays: traversing arrays

Table of contents

        Step 1: Our Framework

        Step 2: We define an array

        Step 3: Traversal Preparation

         Step 4: Traverse each element through the for loop feature


 

 

Step 1: Our Framework

<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
	</head>
	<body>
		 <script>
			
		</script>

	</body>

</html>

        Step 2: We define an array

<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
	</head>
	<body>
		 <script>
			var sex = [1, 2, 3, 4, 5, 6, 7, 8];
		
		</script>

	</body>

</html>

Step 3: Traversal Preparation

<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
	</head>
	<body>
		 <script>
			var sex = [1, 2, 3, 4, 5, 6, 7, 8];
			
				console.log(sex);
			
		</script>

	</body>

</html>

 Step 4: Traverse each element through the for loop feature

<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
	</head>
	<body>
		 <script>
			var sex = [1, 2, 3, 4, 5, 6, 7, 8];
			for (var i = 0; i < sex.length; i++) {
				console.log(sex[i]);
			}
		</script>

	</body>

</html>

 

Guess you like

Origin blog.csdn.net/tea_tea_/article/details/126184850