Skip to content

Instantly share code, notes, and snippets.

@Elshaman
Created April 8, 2023 19:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Elshaman/f749edbf1a7792156f526168dd8c96b7 to your computer and use it in GitHub Desktop.
Save Elshaman/f749edbf1a7792156f526168dd8c96b7 to your computer and use it in GitHub Desktop.
Array of objects in typescript
let myArray: Array<Post> = [{
id: 1,
text: "Carlos"
},
{
id: 2,
text: "Zarta"
}
];
interface Post{
id:number;
text: string;
}
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