function main() {
a = 5;
b = 10;
console.log(a + b);
}
main(); //prints 15
console.log(a + b); //prints 15
JavaScript supports functional and global scoping yet the second console.log statement prints the output 15. If i use var to declare the variables then the second console.log throws error. I am still learning JavaScript coming from a c++/java background this seems very confusing.