If I have an object that looks like the following:
{
a: "String",
b: [1, 2, 3],
c: ["a", "b", "c"]
}
…meaning it contains one or more arrays and sometimes some other stuff like strings as well. With Object.values(myObject) I can get the values, but what would be the best way to get all the arrays - but not the other stuff, if there is any - inside of an object? I should clarify: I don’t know the property names beforehand, if that makes any difference.
This uses Object.entries to convert the object to an array, then Array.map to create a new array containing either the value if it is an array or null. Finally, the filter(Boolean) removes all of the null values you don’t care about.