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? :)

2

3 Answers 3

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.

Sign up to request clarification or add additional context in comments.

Comments

0

You need to acces the first array as well

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

console.log(example.one[0].test[0]);

1 Comment

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
0

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.