const arr1 = [{a:1},{b:2},{c:3},{d:4}];
const arr2 = [1,2,3,4,5,6,7];
console.log('倒序前',arr1,arr2);
arr1.reverse();
arr2.reverse();
console.log('倒序后',arr1,arr2);
JS实现数组和数组对象倒序(reverse方法)
最新推荐文章于 2024-08-05 15:45:51 发布
const arr1 = [{a:1},{b:2},{c:3},{d:4}];
const arr2 = [1,2,3,4,5,6,7];
console.log('倒序前',arr1,arr2);
arr1.reverse();
arr2.reverse();
console.log('倒序后',arr1,arr2);