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

204
Visualizações
How to know if a value its an element in JavaScript?

as much as the question seems silly (and in fact it is) I didn't find the answer anywhere, only what I find is answers to know if the element already exists in the DOM (which would solve my problem, but that would be a way unprofessional to solve).

Here is my code ex :

function randomName(element) {
// Im trying to find some method like this:
  const result = isElement(element) ? true : false
}
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

You might want to check if the variable is an instance of HTMLElement. So basically

function isElement(element){
    return element instanceof HTMLElement;
}

Also check the mdn-docs, because it's possible that you want to check if your element is a Node (would include text-only nodes) or just an Element (that would include XML-tags in an XML document).

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