var jsonObj= [{}]
function read_directory(){
foreach files in directory{
//do stuff to file
jsonObj.push(newdata) //newdata is also an json object
console.log(jsonObj) //this returns the current object after each push
}
console.log(jsonObj) //this returns an empty json object
}
Why does the object appear to be empty when it is called outside of the loop. When it is called inside of the loop, the data is pushed correctly. But when I want to save the complete object after the loop it is empty.