The array is populated with elements, yet the size remains zero

In my code, I utilize an array that consists of multiple subarrays and then push objects into it.

The pushing process looks like this:

this.storeFilesService.base64files.filetype1.push({name: file.name, base64: str});

Once I push an object into a subarray, I log the entire array to the console using console.log.

(this.storeFilesService.base64files.filetype1);

The console output appears as follows:


[]
|-> 0: {name: "filename.pdf", base64: "JVBERi"}

However, despite having objects in the subarray, when I check the length of the array by logging it to the console, the output shows 0.

console.log(this.storeFilesService.base64files.filytype1.length);  -> 0

I am attempting to verify if there are indeed objects in the subarray, but my conditional statement based on the length seems to fail.

The mentioned code is being executed within an Angular onInit or constructor method. Prior to this, I handle an async promise in the previous component's onDestroy method. I expect all promises to be resolved before reaching the above code.

Why does this behavior occur?

Update: I attempted a JSON console log:

console.log('Array : ', this.storeFilesService.base64files.filytype1, JSON.stringify(this.storeFilesService.base64files.filytype1));

JSON -> [] Object -> same as above, containing the object.

How can this situation even arise?

Answer №1

It appears to be connected to the live console feature in Chrome. The data was modified by Chrome within the console even after it had been initially displayed.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Issue encountered: "TypeError: .... is not a function" arises while attempting to utilize a component function within the template

Within my component, I am attempting to dynamically provide the dimensions of my SVG viewBox by injecting them from my bootstrap in main.ts. import {Component} from 'angular2/core'; import {CircleComponent} from './circle.component'; i ...

Retrieve a collection of Firebase records using a specific query parameter

I'm currently developing a web app with Angular 2 and facing an issue with retrieving data from Firebase based on specific conditions in the child node. Here's how my Firebase structure looks like: I need to extract the entry for the one with app ...

Faulty selection sort program in C

I've been tasked with implementing a selection sort. The challenge I'm facing is that when I remove all the code from the "void sort" function, the program runs fine. However, as soon as I add the code back in, the program gets stuck before even ...

Loop through the XML string inside a for loop using Javascript

Hey everyone, I'm having some trouble with looping through strings for XML inside a for loop. I've attempted the following code but the loop doesn't seem to be working: var data = [{"name": "Tom", age: "20"}, {& ...

The program crashed after attempting to write a char** into a file and resulted in a core

I am encountering an issue with accessing a char ** in one of my structs. uint64_t id; struct timing timing; //command *command; uint32_t argc; char ** argv; } taskR; I have stored everything correctly in my struct, however when trying ...

The property 'supabaseUrl' cannot be destructured from 'getConfig(...)' because it is not defined

I recently went through the tutorial provided by @supabase/auth-helpers-sveltekit on integrating supabase-auth helpers with sveltekit. However, upon running the development server, I encountered an internal error. Cannot destructure property 'supabas ...

What is the best way to access a populated array in VBA without using arguments in another subroutine?

I'm feeling lost and frustrated after countless searches online have failed to provide a solution. I wrote a sub routine that gathered unique values from Column C and stored them in an array. Now, I need to utilize this array in another sub routine t ...

Unable to bring in Angular2 bootstrap function

I am currently setting up a basic Angular 2 (beta 2) app using TypeScript. I have the code for app.ts file taken from Angular's most recent setup guide import {Component, View, bootstrap} from 'angular2/angular2'; @Component({ selector: ...

Determining the type of a utilized generic function

When working with TypeScript, it is possible to determine the type of a function by using the following method: function exampleFunc(param: number) {} type ExampleFuncType = typeof exampleFunc; // RESULT: (param: number) => void If the function is gen ...

What could be causing input to be blocked in certain situations while using my Angular directive with compile function?

Recently, I created a directive that adds a class based on a certain condition. You can find the code snippet at the end of this question. The directive functions as expected in a simple use case where it's applied to a required field: <input typ ...

Generating a pool of p_threads

Currently, I'm delving into the realm of threads in C programming. My goal is to create an array of pthread structures that will each execute a function and then be joined together. To achieve this, I followed these steps: 1. Declare a pointer to an ...

What is the most efficient method for converting a large file into a byte array using C#?

My current web server is tasked with reading large binary files, some several megabytes in size, and converting them into byte arrays. Since multiple files may be read simultaneously due to different page requests, I am seeking the most efficient method ...

use php code to dynamically populate a select dropdown element with jquery

Here's my query: Array ( [0] => Array ( [idCustomer] => 2553 [session] => [noMobil] => 666 [keterangan] => Sistem [tahun] => 2012 [merk] => Sist ...

Error: The default export is not a component compatible with React in the specified page: "/"

I'm facing an issue while building my next app. Despite using export default, I keep encountering an error that others have mentioned as well. My aim is to create a wrapper for my pages in order to incorporate elements like navigation and footer. vi ...

Send an array of objects to another class

I have created an array called achievementArray using my custom class AchievementObject and added all the necessary values to it. To test, I manually set the first index of the array. My goal is to pass this array to the AchievementDatabase class in order ...

What is the process for arranging the elements of a one-dimensional array in a two-dimensional array in descending reverse order using Java?

Struggling with my class assignment, I find myself at a crossroads. While I'm gaining a better understanding of how everything fits together, I can't seem to pinpoint exactly what needs to be changed. Despite trying numerous variations, none have ...

Tips for dynamically calling a property member of a function type in Typescript

How can I determine if a member is a function in TypeScript? Is dynamic typing discouraged in TypeScript? function checkIfFunction<T, K extends keyof T>(obj: T, propName: K) { if (typeof obj[propName] === "function") { obj[p ...

Adding an anchor tag to an ngx-datatable-column can be done by utilizing the properties

My task involves loading data from the server and populating the ngx-datatable. When a specific column is clicked (with either a link <a href="randomurl"/> or [routerLink]="randomcomponent"), it should redirect to a different page or display a modal ...

What is the best way to invoke a function in a specific child component from its parent component?

It seems that I might have provided too much information, but the main question remains: how can I call a method in the child component from the parent template's click() event. <button(click)='get()'>GET</button> In my case, th ...

Exploring methods to modify the Discord scopes in the upcoming Auth v5 update

image description placeholder I'm trying to modify the scope, remove the email and include guilds in my project. I searched for a solution but couldn't find one that worked. Can anyone help me figure out how to change the scopes? I attempted to ...