My application creates a JavaScript object, like the following:
(我的应用程序创建了一个JavaScript对象,如下所示:)
myObj= {1:[Array-Data], 2:[Array-Data]}
But I need this object as an array.
(但是我需要将此对象作为数组。)
array[1]:[Array-Data]
array[2]:[Array-Data]
So I tried to convert this object to an array by iterating with $.each
through the object and adding the element to an array:
(所以我尝试通过$.each
遍历对象并将元素添加到数组中来将该对象转换为数组:)
x=[]
$.each(myObj, function(i,n) {
x.push(n);});
Is there an better way to convert an object to an array or maybe a function?
(有没有更好的方法将对象转换为数组或函数?)
ask by The Bndr translate from so
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…