我从本地存储中获取一组对象:
saved_selection = window.localStorage.getItem('match_selection');
console.log('saved selection obj is ');
console.log(saved_selection);
输出是:
{"236":"Forward_2","243":"Forward_1"}
现在我想循环并获取键和值。所以我这样做:
for(var index in saved_selection) {
console.log(index + " -> " + saved_selection[index]);
}
但我得到:
0 -> {
1 -> "
2 -> 2
3 -> 3
等,而不是:
236 -> Forward_2
243 -> Forward_1
如何获得所需的输出?