12.利用函数反转数组
作者:互联网
<script> //利用函数翻转任意数组 reverse 翻转 function reverse(arr) { let newArr = []; for (let i = arr.length - 1; i >= 0; i--) { newArr[newArr.length] = arr[i]; } return newArr; } var arr1 = reverse([1, 3, 5, 6, 9]); console.log(arr1); var arr2 = reverse(["pink", "blue", "red"]); console.log(arr2); </script>
标签:arr,12,console,reverse,反转,数组,newArr,var,log 来源: https://www.cnblogs.com/0722tian/p/16123219.html