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

200
Visualizações
Proper variable name for find method

I'm Japanese web developer. I'm currently thinking about the proper variable name for the result from javascript find method. I would rather not use "result" because it is too simple and it's hard to understand what's inside. Does anyone have any idea?

const targetChar = 'someName1';

let arrayOfObj = [
  {
    name: 'someName1',
    age: 38
  },
  {
    name: 'someName2',
    age: 24
  }
];

const result = arrayOfObj.find((obj) => {
  return obj.name === targetChar;
});

console.log(result);
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Any name that is in unicode is proper name so don't worry. Maybe you can check out commonly used naming conventions for commonly used javascript libraries or go with foundPeople. But if you are going to use it for an if statement you can choose isFound or hasFound which is shorter and easier to read.

The context, in other words where you are going to use the variable is important when choosing names. If the variable is global, or if you are going to use the found item later, a more descriptive name could be more helpful but if you are merely checking if such a person exist, shorter ones like isFound, hasFound or isExist is better.

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