DEV Community

Discussion on: What Did you Learn this week --March 20?

Collapse
 
iamkalai profile image
Kalaiarasan Pushpanathan

That local variable takes precedence over global.

var variable = 'global';
function testFunction() {
var variable = 'local';
console.log(variable);
}
testFunction();
console.log(variable);

Collapse
 
waylonwalker profile image
Waylon Walker

The power of scoping. I saw this and had to try it out with const. You can redefine const inside of a function as well.