0

Well, I'm currently working on a project right now but I have a problem and the problem is that I dont know how to get access to a value inside an object of a variable.

var example= {
            "one": [{
                "test": [15,26,56]
            }]
        }

What can I do to get access into 15, I tried something like:

example.one.test[0]

but it didnt work. any hand? :)

3 Answers3

1

one is an array of objects. So you need

example.one[0].test[0]

You could also just remove the [ ] from the first nest and use it as you were. That's assuming it is an object you've created.

TheValyreanGroup
  • 3,554
  • 2
  • 12
  • 30
0

You need to acces the first array as well

var example= {
            "one": [{
                "test": [15,26,56]
            }]
        };

console.log(example.one[0].test[0]);
Nina Scholz
  • 376,160
  • 25
  • 347
  • 392
  • Thanks. :) It may be probably a dumb question but that's because I'm brand new to this language and it's something new for me. :p – PseudoHuman Nov 02 '16 at 19:05
0

Key one is an array with 1 object.Use example.one[0].test[0]

CDan mbugua
  • 71
  • 1
  • 5