Converting a JS object to an array using jQuery

后端 未结 18 3062
鱼传尺愫
鱼传尺愫 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:11

    ES8 way made easy:

    The official documentation

        const obj = { x: 'xxx', y: 1 };
        let arr = Object.values(obj); // ['xxx', 1]
        console.log(arr);

提交回复
热议问题