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

116
Vistas
Error when redeclaring class in Firefox console but not in Chrome console
class Picture {
    constructor(icon) {
        this.icon = icon

    }
}

When I run this code twice in the Chrome console it doesn't throw any errors. But when I try running it twice in the Firefox console it says Uncaught SyntaxError: redeclaration of let Picture. Why do the browsers behave differently?

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

A class can't be redefined. It is actually a block scoped variable.

If you're experimenting with code in a web browser, such as the Firefox Web Console (Tools > Web Developer > Web Console) and you 'Run' a definition of a class with the same name twice, you'll get a SyntaxError: redeclaration of let ClassName;

MDN docs

Redeclaration of let/const is allowed in chrome console. Run the below statement twice:

let x = 2;

Check this SO answer and this link from Chrome blog

Redeclaration within the same console line is not allowed though.

about 4 years ago · Juan Pablo Isaza 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