Although the topic of converting JS objects to JS arrays as long been dealt with here, my question is about algorithm optimization.
Let my object be
myObject = {
"key q": "value q",
"key p": "value p",
"key g": "value g" };
to be converted into an JS array, including both keys and values. So far, I have devised this:
var myArr = [];
var aString = JSON.stringify(myObject);
aString = aString.substring (1, (aString.length-1)); // let's get rid of the braces
myArr = aString.replace (/\:/gi, ',');
It all works smoothly, but is there some faster way than undergoing these (allegedly) slow string methods?