I have a global object abc with the following structure
abc = {
dir_content: {
dir: [
"hi"
]
files: [
"1.txt",
"2.txt"
]
}
directory: "greeting"
}
hope I got the notations correct.
dir_content has its values passed from a JSON object by abc.dir_content = data;
I have a function as below
function show_dir() {
console.log(abc.dir_content.dir);
console.log(abc.directory);
}
I am expecting console.log(abc.dir_content.dir) to show hi. But its saying its undefined instead. console.log(abc.directory) shows greeting just fine.
Adding: I can print the correct results in the console with console.log(abc.dir_content.dir) . But it says undefined when called in the function.
I need to loop through the arrays of dir and files in the function. But now I stuck at getting js to read the values in the function.
Edit: I found something wrong this my global object declaration. fiddle link http://jsfiddle.net/xh5YH/ . Whats wrong with the anonymous function declaration?
dirsupposed to be an array?