Question: I have an array in PHP that I encode to json:

```
$jsonOutput = json_encode($output);

```

Then in my javascript, I use this to parse it:

```
var jsonOutput    = JSON.parse('<?php echo $jsonOutput; ?>');

```

My output looks like this in the Chrome console:

![enter image description here](https://i.stack.imgur.com/FqyD7.png)

Ultimately, I have two arrays, and I'm trying to write a compare between the two to show if there are any items in the first array that aren't in the second, but I'm not sure how to reference `red` and `orange` here. 

I tried `console.log(jsonOutput[0])` but I get `undefined`. 

Also, as a side note, does anyone have any good resources for reading up on arrays in javascript and all their ins-and-outs? It seems to be one aspect that I'm struggling with lately...

Answer: 
The problem is that your jsonOutput is an Object, so in order to access one member of the object you either have to user jsonOutput.red/jsonOutput.orange or jsonOutput["red"], jsonOutput["orange"] to access a member of the object.

More info here [Access / process (nested) objects, arrays or JSON](https://stackoverflow.com/questions/11922383/access-process-nested-objects-arrays-or-json).
```
jsonOutput.red[0]

```

You have an object with two keys. Not an array.