0

I am using chrome browser inspector to examine some javascript arrays. I notice that certain arrays (that are being generated by a library that I am using - three.js via a-frame) are represented with lowercase letters next to the value.

Please see below an example - you can see the lower case cs that accompany each value;

enter image description here

And here is one that I have generated myself for comparison - rather than these cs there is a generic object representation. This is what I am accustomed to;

enter image description here

Why do those letters appear? What is the difference between these arrays?

I ask because 1. I am curious and 2. I am seeing different behaviour between these 2 types of array and am wondering whether this is an indication of a different format that I am not aware of.

If there is a difference that people are aware of, I wonder whether its possible to convert one to the other quickly? So that I can eliminate that as a reason for any bugs?

Thanks as ever for any advice, If you need more information to answer, please let me know.

Nick
  • 914
  • 1
  • 10
  • 30
  • 2
    The c is because they are instances of a "class" and the ones that show the literal are plain objects. – Ruan Mendes Jan 28 '18 at 20:49
  • Thank you Juan, do you know if there is a way to convert those to plain objects? As I say I am experiencing some differences in behaviour and I would like to rule that difference out – Nick Jan 28 '18 at 20:52

1 Answers1

1

Use JSON.parse(JSON.stringify(array)) on both arrays to convert everything to plain arrays with plain objects.

The only thing to care is that objects don't have circular references but from what I can see yours don't.

smnbbrv
  • 23,502
  • 9
  • 78
  • 109
  • Perfect - thank you so much smnbbrv, it all now works as I would expect, I thought that might be causing the problem. Much appreciated. – Nick Jan 28 '18 at 21:14