ThanhLoyal
ThanhLoyal

Reputation: 393

Can not access and change property of a variable

I am trying to modify a property of an object.

console.log(dataset); 
// -> This shows object with an 'ids' property, and it is an array with 7 elements.

But

console.log(dataset.ids); //shows an empty array

Please take a look at this image, it describles how 'dataset' look like: weired js

Can you explain why?

Thank you!

Upvotes: 0

Views: 304

Answers (1)

Julien Leray
Julien Leray

Reputation: 1687

It's probably because your dataset.ids array isn't filled yet on the init.

Why?

When your open your panel from the Chrome console to inspect in details of dataset, Chrome console just recall a console log on the reference object.

At this time, the array is filled.

You should probably search a hook from your KanbanView object where you are sure this array is filled if you want to access it.

This console behavior could be confusing the first time when you face such case!

Upvotes: 1

Related Questions