Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

115
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!