为什么我的json数组没有反转?
var arr = [{"myId":"7d8f72c3f070736caf399df0a8211f5ei324410"},
{"myId":"963d01cfa92a4f9d3cb755c7d3822e68i1744695"},
{"myId":"5994f40a1b2fd9ff69d4e4551d18766ci2977900"},
{"myId":"25bb4db94056ec38ba7ed1ee96e90006i2956275"},
{"myId":"7720ec9200d5a6f5d16a447bc5ff7f2ci1080950"},
{"myId":"f8a21d90a3adb464e7c3782471e1455bi3087305"}];
console.log(arr);
arr.reverse();
console.log(arr); // not reversing :-(
任何人都可以建议我为什么我的阵列没有倒车?
答案 0 :(得分:0)
工作正常,请参阅下面的输出
var arr = [{"myId":"7d8f72c3f070736caf399df0a8211f5ei324410"},{"myId":"963d01cfa92a4f9d3cb755c7d3822e68i1744695"},{"myId":"5994f40a1b2fd9ff69d4e4551d18766ci2977900"},{"myId":"25bb4db94056ec38ba7ed1ee96e90006i2956275"},{"myId":"7720ec9200d5a6f5d16a447bc5ff7f2ci1080950"},{"myId":"f8a21d90a3adb464e7c3782471e1455bi3087305"}];
console.log(arr);
arr.forEach(function(e){
document.body.innerHTML+=e.myId+"<br/>";
})
arr.reverse();
document.body.innerHTML+="----------------<br/>";
arr.forEach(function(e){
document.body.innerHTML+=e.myId+"<br/>";
})