FirePHP4Chrome icon indicating copy to clipboard operation
FirePHP4Chrome copied to clipboard

Associative arrays are being shown in the console as objects

Open nicoladj77 opened this issue 8 years ago • 3 comments

If I log an associative array, the output is

Object {add: Object, first: Object, second: Object, fourth: Object, third: Object}

I would have expected it to be logged as arrays are.

nicoladj77 avatar May 22 '16 23:05 nicoladj77

Unfortunately, since there is "no such thing" in javascript as an associative array, so I can't do this. The reason is not so much as I couldn't use an indicator with the output (meaning, I could transmit an object but flag it as an array), but that the console only logs things that are possible in javascript. Since there is no such thing in javascript, it will create is an object instead.

With this in mind, though, if you have an alternative that I'm not considering, I'm open to input :)

aaronsaray avatar May 22 '16 23:05 aaronsaray

Thanks for the answer, I have just recently switched over from using FirePHP on Firefox, but didn't consider the fact that here we are logging to Chrome Console. On firefox, FirePHP leverages Firebug, I don't know if integrating somehow with Firebug lite ( which works on every browser ) would help, as I don't know if it gives you more control on what you can log.

I've read that you can style logs with CSS, what about using a different color for associative arrays? Not the best solution but a hack that could work :smile:

If they added support for some basic sort of markup in the console, my idea would be to create the markup that represents the logged object and then log the markup.

I'm just throwing random ideas at the problem :smile:

nicoladj77 avatar May 23 '16 00:05 nicoladj77

Ok - awesome - thanks for the suggestions. I'll see what I can come up with - its been a while since I've looked at this code. I'll update this ticket when I come up with a good solution. Thanks again!

aaronsaray avatar May 25 '16 00:05 aaronsaray