reverse颠倒会改变原来的数组,那有没有办法倒回去?
reverse颠倒会改变原来的数组,那有没有办法倒回去?
2017-03-25
这是在原变量上修改的,你不用重新定义变量,直接写就行
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Array对象 </title>
<script type="text/javascript">
var myarr1= ["我","爱","你"];
document.write(myarr1);
document.write(myarr1.reverse());
document.write(myarr1.reverse());
</script>
</head>
<body>
</body>
</html>
举报