I use an array which contains separate arrays and push objects in it.
My push looks like:
this.storeFilesService.base64files.filetype1.push({name: file.name, base64: str});
After I push an object into the subarray I log the array to the console. console.log
(this.storeFilesService.base64files.filetype1);
Console output is:
[]
|-> 0: {name: "filename.pdf", base64: "JVBERi"}
But when I log the length of the array to the console the output is 0.
console.log(this.storeFilesService.base64files.filytype1.length); -> 0
I am trying to check if the subarray contains objects, but my if clause seem to fail, cause of the length.
The oboce code is set in an angular onInit / constructor method. Befor this i execute an async promise in the last component within the onDestroy method. I think all promises should have been resolved when i reach the above code.
Why is this behaviour?
Update: Tried a JSON console log
console.log('Array : ', this.storeFilesService.base64files.filytype1, JSON.stringify(this.storeFilesService.base64files.filytype1));
JSON -> [] Object -> same as above, contains the object.
How is this even possible?
Seem to be related to the live console by chrome. The value was updated by chrome in the console even after it was already printed.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments