var array = [];
obj = {"a": 'a1值', "b": 'a2值', "c": 'a3值'};
for (i in obj) { console.log(obj[i]) }
for (i in obj) { array.push(obj[i]) }
console.log(arrar)
js操作,应该可以达到你想要的效果。
果您知道对象中的最大索引,则可以执行以下操作:
var myObj = {
1: ['c', 'd'],
2: ['a', 'b']
},
myArr;
myObj.length = 3; //max index + 1
myArr = Array.prototype.slice.apply(myObj);
console.log(myArr); //[undefined, ['c', 'd'], ['a', 'b']]
var myObj = {
1: [1, 2, 3],
2: [4, 5, 6]
};
var array = $.map(myObj, function(value, index) {
return [value];
});
console.log(array);
输出:
[[1, 2, 3], [4, 5, 6]]