对数组进行翻转,即倒序输出数组
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>翻转数组案例</title>
</head>
<body>
<script>
var arr = [1,2,'shuzu','数组'];
var newarr = [];
for (var i = arr.length -1 ; i >= 0; i--) { //翻转
newarr[newarr.length] = arr [i];
}
console.log(newarr);
</script>
</body>
</html>