Converting a JS object to an array using jQuery

后端 未结 18 3068
鱼传尺愫
鱼传尺愫 2020-11-22 01:37

My application creates a JavaScript object, like the following:

myObj= {1:[Array-Data], 2:[Array-Data]}

But I need this object as an array.

18条回答
  •  不知归路
    2020-11-22 02:08

    ECMASCRIPT 5:

    Object.keys(myObj).map(function(x) { return myObj[x]; })
    

    ECMASCRIPT 2015 or ES6:

    Object.keys(myObj).map(x => myObj[x])
    

提交回复
热议问题