Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

202
Vistas
A Variable in JS is not deleted but here is no error?

I have a variable. var variable; It is variable="Hello World";. Now, without using var and deleting it:

document.write(myVar);
delete myVar;
console.log("This should be an error because myVar has been deleted: ");
console.log(myVar);
<!--This is my module-->
<script>
  myVar = "Hello";
</script>

But with 'use strict';, there is no error with delete, and no error even though it cannot delete a var?

console.log("My Code Is Running");
delete myVar; 
if (!myVar){
document.write("Var Has Been Deleted");
}
console.log("My Code Is Done");

// Why does it not write "Var Has Been Deleted"?
// There is no 'use strict' to stop the delete.
<script>
'use strict';
var myVar = "Hello World";
</script>
What is happening?

Thanks in advance

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda