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

150
Views
for const of minification

I have the following typescript:

var mynames = new Array<string>();
mynames.push("Currency");
mynames.push("School_Id");
for (const mn of mynames) {
    console.log(mn);
}

Which is compiled into javascript:

var mynames = new Array();
mynames.push("Currency");
mynames.push("School_Id");
for (const mn of mynames) {
    console.log(mn);
}

Which is minified to:

n = [
];
n.push('Currency');
n.push('School_Id');
for (const n of n) console.log(n);

Which causes the exception:

Uncaught ReferenceError: can't access lexical declaration 'n' before initialization

Why am I getting an error when the code has been minified and not before?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

You are defining a variable with the same name with the array variable. use another name like:

for (const m of n) console.log(n);
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!