<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>移出数组arr中与2相等的元素,并生成一个新数组,不改变原数组。</title>
</head>
<body>
<script>
var arr = [1,2,3,4,2,5,6,2,7,2];
var str4 = arr.slice(1,2);
var str1 = arr.slice(4,5);
var str2 = arr.slice(7,8);
var str3 = arr.slice(9);
str = str1.concat(str2,str3,str4);
document.write("原数组arr:<br/>" + arr);
document.write("<br/>");
document.write("移出数组arr中与2相等的元素,并生成一个新数组str:<br/>" + str);
document.write("<br/>");
document.write("没有改变原数组arr:<br/>" + arr);
</script>
</body>
</html>