<!DOCTYPE HTML>
<html >
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>流程控制语句</title>
<script type="text/javascript">
var infos = [["namea","女","25","大一"],["nameb","男","24","大四"],["namec","男","23","大三"],["named","女","24","大一"]];
//第1种方式
for(var count = 0;count< infos.length;count++){
//infos[count].indexOf:数组中是否 包含指定字符串
var isindexOf = infos[count].indexOf("大一");
var isindexOf2 = infos[count].indexOf("女");
//结果!-1说明包含
if(isindexOf!=-1 && isindexOf2!=-1){//说明包含大一女
document.write(infos[count]+"<br/>");
}
}
//第2种方式
for(var count2 = 0;count2< infos.length;count2++){
if(infos[count2][1]=="女" && infos[count2][3]=="大一"){
document.write(infos[count2]+"<br/>");
}
}
</script>
</head>
<body>
</body>
</html>
<!DOCTYPE HTML>
<html >
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title>
<script type="text/javascript">
var infos = [
['小A','女',21,'大一'],
['小B','男',23,'大三'],
['小C','男',24,'大四'],
['小C','男',24,'大四'],
['小D','女',21,'大一'],
['小E','女',22,'大四'],
['小F','男',21,'大一'],
['小G','女',22,'大二'],
['小H','女',20,'大三'],
['小I','女',20,'大一'],
['小J','男',20,'大三']
];
for(var i = 0; i < infos.length; i++) {
if(infos[i][3] === "大一" && infos[i][1] === "女") {
document.write(infos[i][0] + "<br />");
}
}
</script>
</head>
<body>
</body>
</html>