Created
April 8, 2023 19:59
-
-
Save Elshaman/f749edbf1a7792156f526168dd8c96b7 to your computer and use it in GitHub Desktop.
Array of objects in typescript
This file contains 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
let myArray: Array<Post> = [{ | |
id: 1, | |
text: "Carlos" | |
}, | |
{ | |
id: 2, | |
text: "Zarta" | |
} | |
]; | |
This file contains 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 Post{ | |
id:number; | |
text: string; | |
} |
This file contains 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
myArray.map((post, index)=> ( | |
<h1 key={index}> { post.text} </h1> | |
) ) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment