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

274
Views
Overwritting function identifiers while registering identifiers (difference between var and let?)

I'm currently reading the book Secrets of the Javascript Ninja and I do not understand the following behaviour based on an example from chapter 5 explaining how function identifiers are overwritten:

code example from the book:

console.log(typeof fun);

var fun = 3;

console.log(typeof fun);

function fun() {}

console.log(typeof fun);

Output as expected: function / number / number

console.log(typeof fun);

let fun = 3;

console.log(typeof fun);

function fun() {}

console.log(typeof fun);

But when I change the definition to let I get the error that fun has already been decleared. When the lexical environment is created why can I override var but let already blocks the definition of the function declaration?

The attached question, was also answered with "let variables are not initialized until their definition is evaluated." What's the difference between using "let" and "var"?

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