<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<script>
var arr=['red','green','blue','black','pink']
// 此案例:翻转的不是数组,二十数组里面元素
// 2.定义一个新的空数组
var newArr = new Array();
// 1,循环应该根据索引倒着写
for(var i =arr.length-1;i>=0;i--){
// console.log(arr[i]);
// 2.把这些倒过来的值,放到新数组里面
newArr[newArr.length]=arr[i];
}
console.log(newArr);
</script>
</body>
</html>