Not sure if this is what you want but...
var userData = {
1: true,
2: true,
3: "00QRA10",
4: "slimer42",
5: "FFASN9111871-USN16"
};
var outputArray = [];
for (var i = 0; i < Object.keys(userData).length; i++) {
outputArray.push(userData[Object.keys(userData)[i]]);
}
console.log(outputArray);
taking it apart: Object.keys(userData) is the list (array) of key names. In this case it is 1, 2, 3, 4, and 5. outputArray.push() adds an element to the array. Object.keys(userData)[i] is the name of the object element that we're on, and userData[Object.keys(userData)[i]] is just the element that we're on. So every time we go through the for loop, we add another element to the array.
Your example uses 1, 2, 3, 4, and 5 for their element names though, so something like this might work better:
var userData = {
1: true,
2: true,
3: "00QRA10",
4: "slimer42",
5: "FFASN9111871-USN16"
};
var outputArray = [];
for (var i = 0; i < Object.keys(userData).length; i++) {
outputArray.push(userData[i+1]);
}
console.log(outputArray);
In this example, instead of taking the element name out of the key array we assume that it is a number and that the numbers are in a sequence that starts with 1.
The reason why your solution didn't work
is because you didn't call the numbers from the object. You would've had to use userData.1, userData.2, userData.3, etc.