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

93
Visualizações
Print name of variable as string without sending curly braces

I've made a function for my own convenience that displays a log of the variable name and what it equals. The only way I've found to do this while retaining its original variable name is to send it with the curly braces, but is there a way to leave that out on the function call, and instead have it somewhere inside the function? I'm asking this because I simply want to type clog(myObj) and not clog({myObj}).

clog({myObj})

function clog(obj)
{
    const varToString = Object.keys(obj)[0];
    console.log(varToString + " = " + obj[varToString])
}
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