You are viewing a single comment's thread from:

RE: JavaScript - var, let, const

in #programming7 years ago (edited)

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!

Sort:  

Right!, Thanks for the another cool example!

Coin Marketplace

STEEM 0.25
TRX 0.19
JST 0.035
BTC 92365.70
ETH 3324.40
USDT 1.00
SBD 3.79