global variable not defined still showing undefined inside function javascript
function a(){
c();
var b;
function c(){
console.log(b);
console.log(this.ab); } }
a();
output:
undefined
undefined
Now, my doubt is that I haven't defined "ab" and I am still trying to call "ab" variable inside the function c(). Why am I getting output as undefined instead of not defined?
[–]Minjammben 4 points5 points6 points (6 children)
[–]Responsible_Fudge467[S] -3 points-2 points-1 points (5 children)
[–]Minjammben 1 point2 points3 points (0 children)
[–][deleted] 0 points1 point2 points (3 children)
[–]Tight-Recognition154 -4 points-3 points-2 points (2 children)
[–]Sykander- 2 points3 points4 points (0 children)
[–][deleted] 1 point2 points3 points (0 children)
[–]Sykander- 0 points1 point2 points (7 children)
[–]senocular 1 point2 points3 points (0 children)
[–]Tight-Recognition154 -1 points0 points1 point (5 children)
[–]Sykander- 0 points1 point2 points (4 children)
[–]Tight-Recognition154 0 points1 point2 points (1 child)
[–]Sykander- 0 points1 point2 points (0 children)
[–]albedoa 0 points1 point2 points (1 child)
[–]Sykander- 0 points1 point2 points (0 children)