Skip to content

Instantly share code, notes, and snippets.

@Juandresyn
Created February 24, 2021 15:27
Show Gist options
  • Save Juandresyn/966ab10eb9fe7931979ed6f9ba6729fa to your computer and use it in GitHub Desktop.
Save Juandresyn/966ab10eb9fe7931979ed6f9ba6729fa to your computer and use it in GitHub Desktop.
TypeScript Object to Array {} -> []
interface Map {
[key: string]: string | undefined
}
export const objectToArray = (obj: Map): string[] => {
const tempArray: string[] = [];
const keys = Object.keys(obj);
keys.forEach((i: string): string[] => {
tempArray.push(obj[i]);
return tempArray;
});
return tempArray;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment