1.倒序打印数组;
function print(arr,index){ if(index === arr.length) return; print(arr,index+1); console.log(arr[index]); }
2.顺序打印数组;
function print(arr, index){ if(index === arr.length) return false; console.log( arr[ index ] ); print( arr, index + 1 ); }
3.打乱一个数组
function chaos ( arr ){ arr.sort(function(){return Math.random() > 0.5 ? 1 : -1 }); }