Created
February 24, 2021 15:27
-
-
Save Juandresyn/966ab10eb9fe7931979ed6f9ba6729fa to your computer and use it in GitHub Desktop.
TypeScript Object to Array {} -> []
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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