131
rated 0 times
[
136]
[
5]
/ answers: 1 / hits: 22026
/ 11 Years ago, fri, november 1, 2013, 12:00:00
I am new to JavaScript and I was doing some practices on local and global variable scopes. Following is my code(fiddle):
var myname = initial
function c(){
alert(myname);
var myname = changed;
alert(myname);
}
c();
When the first alert is called, it is showing myname
as undefined. So my confusion is why I am not able to access a global instance of myname
and if I don't define myname
within the function then it will work fine.
More From » javascript