Given this Object in Javascript
{
"0": "hello",
"1": { text: "world" }
}
What's the shortest way to create this array from that object?
[
"hello",
{ text: "world" }
]
I've seen somebody using Array.prototype.splice(theObject) but it doesn't seem to work for me.
Update:
- Order of output needs to be guaranteed
0and1can be any arbitrary string value and the order at property level needs to be maintained in the corresponding array.- Needs to work with Node.js 6