I have defined a variable inside a function. Inside that function I have defined another function within which I intend to access the variable I defined earlier.
The variable I declared is of type object
. When I reference the variable in the nested function and try to access it’s properties, it shows me undefined. When I try to log the value of the function to the console it gives me this response [object Object]
. I have done some reading and I have found out that that is a result of the toString()
function.
My question is…
How can I access the variable in in a nested function properly and in a clean way.
If the source code is required I can provide it.