I am new to javascript so please understand if the question is a bit naive. I have heard that functions are also objects in javascript . So that means functions can also have properties like objects. So I tried this :
var foo=function(){
var v1=1;
console.log(foo.v1);
};
foo();
The output of this is undefined
. I dont understand what is happening. So when I declare the variable v1
in the function foo
,according to the result v1
is not a property of the function-object foo
.If it is not the former then what is it a property of ? Could some one explain to me what is happening ?