0

I am trying to access certain values in an array, using developer console I have printed out the array and looked at the structure of the array, however I am unsure as to how I can access these values.

var position = ctrack.getCurrentPosition();
console.log(position);

Below you can see a close up from my console output:

The console message

The array

The developer console looks like this. So say I wanted to access the third entry which is open on the image and get out the values of 0 and 1 and print just them to console. How would I achieve this?

3
  • Your console screen capture is much too small to read. Try using a jsFiddle to allow us to see all of your JS. Commented May 16, 2014 at 21:33
  • 5
    Have you tried position[3][0], position[3][1]? Commented May 16, 2014 at 21:33
  • DevLshOne - Right click copy image Location i.sstatic.net/1bpyV.png Ismail - are you suggesting this : console.log(position[3][0] + position[3][1]); Commented May 16, 2014 at 21:44

1 Answer 1

3

You should be able to access it by

  position[3][0] // and 
  position[3][1];
Sign up to request clarification or add additional context in comments.

2 Comments

This structure did the job with "position" instead of "array"
Yes I'm sorry for the confusion, I didn't notice, my intention was to say something like arrayName[3][0], it's a more clear example

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.