Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

223
Visualizações
What happens with this use of the .map() function from Javascript/Typescript

I have a question about the .map() function which can be used on arrays.

The normal usage I know is like:

function myFunction(num) {
  return num * 2;
}

const numbers = [1, 2, 3, 4];
const newArr = numbers.map((element) => myFunction(element))

But in a code sample I saw the following usage:

const resultToRow = (r: MyProductsDto) => ({
  rowData: tableColumns.map(() => r),
});

In this example MyProductsDto is an Interface and tableColumns is an Array. But what exactly does .map(() => r) ?

r is not a function but a Interface and why is the arrow function empty without any arguments?

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

As length as of tableColumns, there will be r[] in rowData

also it all the value of r[] will be same because it has one reference address.

r[0] === r[1] === [r2] === [r(n)]

map makes new array from original array each element will pass as argument but accept it (the argument that tossed by map) or not is not consideration of map it just makes new array with return value of given function.

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda