D
D
Danil2017-03-14 13:28:48
JavaScript
Danil, 2017-03-14 13:28:48

How to select only "NestedFolder1" and "NestedFolder2" objects?

You need to select "NestedFolder1" and "NestedFolder2" (despite the fact that there can be a lot of them "NestedFolder3" and so on), what is the best way to do it?

[
    [
      "a",
      "v",
      "b",
      "d"
    ],
    {
      "NestedFolder1": [
        "a",
        "s",
        "d",
        "v"
      ],
      "NestedFolder2": [
        "a",
        "v",
        "b",
        "a",
        "b"
      ]
    }
  ]

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Stalker_RED, 2017-03-14
@Stalker_RED

As if:

console.log( x[1]['NestedFolder1'] );
console.log( x[1]['NestedFolder2'] );

https://jsfiddle.net/6fq2Lj4g/
But now you will say "no-no-no, that's not what I wanted", and you will edit the question.

N
Nick8, 2017-03-14
@Nick8

You can make a regular expression and cycle through the keys, checking them for compliance

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question