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

220
Vistas
Stricter than strict mode?

I recently produced a stupid bug:

"use strict";

function doSomething() {
    let testObject = {a: "foo", b: "bar", parent: "bla"};

    if (parent in testObject) {
        console.log("has a parent")
    }
    else {
        console.log("does not have a parent")
    }
}

doSomething();

Due to the missing quotes around the literal parent, the interpreter accessed window.parent and there was no ReferenceError as there would have been had I written a in testObject.

Obviously, JavaScript could not know that I my intention was not to access window.parent and thus could not have thrown an error. But I wonder whether there is some sort of debugging mode that would output a warning to the console in such cases, something along the line: "parent is not defined in this scope, accessing the global variable instead".

over 4 years ago · Santiago Trujillo
2 Respuestas
Responde la pregunta

0

No, JavaScript doesn't have a "stricter" mode that would have warned you of this. Some linters might (though ESLint doesn't seem to, at least with the demo page's default settings).

TypeScript would have, though (example), since window.parent isn't a string or Symbol, so doesn't make sense as the left-hand operand of in. Adopting TypeScript has costs, of course, but it does have benefits like this.

over 4 years ago · Santiago Trujillo Denunciar

0

No, there isn't anything anything stricter than strict mode.

over 4 years ago · Santiago Trujillo Denunciar
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