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

219
Visualizações
JavaScript no elimina automáticamente la variable después de las instrucciones

Hice un script que crea una etiqueta HTML usando JavaScript. Declaré una variable llamada etiqueta, sabiendo específicamente que no puedes delete() let y var variables, pero no la eliminará automáticamente en mi código:

 function(tagType, attr1 = null, value1 = null, attr2 = null, value2 = null, attr3 = null, value3 = null, attr4 = null, value4 = null, attr5 = null, value5 = null, attr6 = null, value6 = null, attr7 = null, value7 = null, attr8 = null, value8 = null, attr9 = null, value9 = null, attr10 = null, value10 = null) { tag = document.createElement(tagType); if (attr1 != null) { tag.setAttribute(attr1, value1) }; if (attr2 != null) { tag.setAttribute(attr2, value2) }; if (attr3 != null) { tag.setAttribute(attr3, value3) }; if (attr4 != null) { tag.setAttribute(attr4, value4) }; if (attr5 != null) { tag.setAttribute(attr5, value5) }; if (attr6 != null) { tag.setAttribute(attr6, value6) }; if (attr7 != null) { tag.setAttribute(attr7, value7) }; if (attr8 != null) { tag.setAttribute(attr8, value8) }; if (attr9 != null) { tag.setAttribute(attr9, value9) }; if (attr10 != null) { tag.setAttribute(attr10, value10) }; document.getElementsByTagName('head')[0].appendChild(tag); if (tag) { delete(this.tag); } },

Al final del código, dije delete(tag) y no funcionó. Entonces traté de verificar si la variable con nombre tag estaba allí. if(tag) { delete(tag) } .

¿Por qué no elimina automáticamente la variable? Si solo escribo delete(tag) en la consola, lo eliminará.


¡Gracias por tu ayuda!

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