This question has already been answered:

there is a variable when outputting it to the console

console.log(filters); 

The following is reflected: enter image description here

How to get only data from this array? field_price_auto

tried this: console.log(filters.field_price_auto); , but undefined , what is wrong, maybe you need to address it like that?

maybe it can be converted to some other data type so that you can search through the tree?

Reported as a duplicate by Darth , Grundy javascript Mar 21 '18 at 10:23 .

A similar question was asked earlier and an answer has already been received. If the answers provided are not exhaustive, please ask a new question .

  • 2
    There is a vague suspicion that you are receiving data ajax-ом , most likely at the time of the request console.log(filters.field_price_auto); data is not loaded yet ... try using setInterval() - Air
  • if it’s so strange that when I output filters to the console, then there is this data in the array, and if there is, then in theory I can access them, otherwise the array would be empty - user9113950
  • I won't argue, but setInterval helped, although I thought that the variable was already formed by username - user9113950
  • I didn’t have an urgent need, poking around in more detail ... But I had the same with DOM-элементами that were loaded with ajax-ом , so forgive me, I can’t specifically help, as in this situation I need to competently do ... Air

1 answer 1

You have written that this is an object. I suppose that if the name is a filters , it will be

console.log(filters['field_price_auto']['id']);

for example

  • even tried just like this console.log (filters ['field_price_auto']); but still undefined - user9113950
  • and if filters-> field_price_auto - Paul Wall
  • one
    or even try filters [0] I don’t know where the variable is being built from, so I can only guess)) - Paul Wall
  • as far as I know this is no longer js, I tried - user9113950
  • then insert in the message that generates this variable, and very little information is available - Paul Wall