reverse颠倒会改变原来的数组,那有没有办法倒回去?
只要将返回的结果在调用一次reverse()方法就实现
这是在原变量上修改的,你不用重新定义变量,直接写就行
<!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>