here i didn't understand what happen when i use var
before variable in function it give me different out put and with out using var
also i got a different output
here is a code that you can easily figure out whats going on
function value() {
var m = 8; //here i am using var as a datatype
console.log(m)
}
m = 7
console.log(m);
value();
console.log(m);
and also when i removing var or not using any data type from value function then i got different out put here is a code
function value() {
m = 8; //here i am not using var as a datatype
console.log(m)
}
m = 7
console.log(m);
value();
console.log(m);
can any one can tell me whats going on thanks for your time