To array map in TypeScript, you can use the map
method available on arrays. Here is an example:
index.ts164 chars6 lines
In this example, we have an array of numbers. We use the map
method to iterate through each element in the array and double each number, resulting in a new array doubledNumbers
that contains the doubled values of the original array.
Remember that map
does not mutate the original array but instead returns a new array with the modified elements.
gistlibby LogSnag