RE: RE: JavaScript - var, let, const
You are viewing a single comment's thread from:

RE: JavaScript - var, let, const

Words
41
Reading
1 min
Listen
Play
9y

OMG!
I didn't know that this would work:

function a() {
  var a = 5;
  if (true) {
    var a = 10;
  }
  console.log(a); // prints 10
}

Does it work same in NodeJS as well?
Usually I don't reuse variables in the same function, but it could mess up my code if I'm not careful!

Extremely valuable, thanks for sharing!

@neander-squirrel: OMG! I didn't | Ecency