data = {1:{name:sjc},2:{name:nih}},用JS实现data的内容倒序
时间: 2023-11-23 16:56:22 浏览: 85
BikeSJC:Bike Go SJC项目
以下是用JS实现data内容倒序的代码:
```javascript
var data = {1:{name:'sjc'},2:{name:'nih'}};
var keys = Object.keys(data);
var reversedData = {};
for (var i = keys.length - 1; i >= 0; i--) {
reversedData[keys[i]] = data[keys[i]];
}
console.log(reversedData); // 输出:{2:{name:'nih'},1:{name:'sjc'}}
```
阅读全文