r/javascript • • May 28 '19

What are some JavaScript things beginners don't know?

333 Upvotes

383 comments sorted by

View all comments

Show parent comments

15

u/ergnui34tj8934t0 May 28 '19

That's in the definition of const and let...

1

u/Aswole May 29 '19

(Copied from another reply) I definitely didn't word that well. To illustrate:

const functionToDebug = params => {
  const myDog = 'Fido';
  var yourDog = 'Fido';
  const someClosure = () => {
    debugger
    //While debugging from browser, console.log(myDog) throws an error and will say myDog is not defined whereas console.log(yourDog) will work just fine and log 'Fido'
  };
};