Photo by Tim Mossholder on Unsplash

Didn’t get it huh? Let’s see the code below.

CODE:
var x = 7;
function greet() {
console.log("Hello");
}
greet();
console.log(x);
OUTPUT:
Hello
7

Yes, I know it was pretty simple to understand code. Now let’s just tweak it a bit.

CODE:
greet();
console.log(x);
var x = 7;
function greet() {
console.log("Hello");
}
OUTPUT:
Hello
undefined

Rajesh Bhattarai

TECH || PRODUCTIVITY

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store