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

164
Visualizações
Non Predefined Javascript Function Names and their execution

I'm not sure this kind of feature is available in Javascript. Here is what I wanted to archive.

Let's say we have an object instance called obj and I want to call any function in this object instance but I'm not defining the function name at the beginning.

const obj = {};

obj.functionOne({id: 1}); // execution 1
obj.functionTwo({id: 1}); // execution 2

I wanted to execute one single function (_default) for both execution 1 and execution 2. withing that function I need to know what is the function name actually executed.

eg:


obj = {

  _default: (params) {
    console.log('Function Name is', Function.name); // will be print `functionOne` or `functionTwo`
    console.log(params); // will be print {id: 1} for both cases.
  }

}

Can someone give me some insight on how to archive this kind of requirement?

Thanks in advance.

about 4 years ago · Juan Pablo Isaza
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