I have a script like this
function innerfunc(){
console.log(msg);
}
function showmsg(){
var msg= "This is somthing"
innerfunc();
}
showmsg();
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
As you can see I am calling a function innerfunc()
after declaring the msg
but I am getting the
Uncaught ReferenceError: msg is not defined
error! As you can see I never call the method before declaring and assigning the msg
so why this is happening?!