var arr = [4, 0, 7, 9, 0, 0, 2, 6, 0, 3, 1, 0];
要求将数组中的0项去掉,将不为0的值存入一个新的数组,生成新的数组
p.p1 { margin: 0.0px 0.0px 0.0px 0.0px; font: 31.0px Consolas; color: #2b7ec3 }
p.p2 { margin: 0.0px 0.0px 0.0px 0.0px; font: 31.0px Consolas; min-height: 36.0px }
p.p3 { margin: 0.0px 0.0px 0.0px 0.0px; font: 31.0px Consolas; color: #289c97 }
span.s1 { color: #4f5d66 }
span.s2 { color: #d74200 }
span.s3 { color: #48565d }
span.s4 { color: #289c97 }
span.s5 { color: #2b7ec3 }
span.Apple-tab-span { white-space: pre }
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title></title>
</head>
<body>
</body>
<script type="text/javascript">
var arr = [4, 0, 7, 9, 0, 0, 2, 6, 0, 3, 1, 0];
var pp = [];
for(var i = 0; i < arr.length; i++) {
if(arr[i] != 0) {
pp.push(arr[i]);
}
}
document.write(pp);
p.p1 { margin: 0.0px 0.0px 0.0px 0.0px; font: 31.0px Consolas; color: #2b7ec3 }
p.p2 { margin: 0.0px 0.0px 0.0px 0.0px; font: 31.0px Consolas; min-height: 36.0px }
span.s1 { color: #4f5d66 }
</script>
</html>