JS - Calling an Object by one of it's properties

47 views Asked by At

I'm making a new object so that I can associate one of the properties to the object itself:

 var byVert = {};
 verticesClosest3.forEach(function (x){
     byVert[x.vertix] = x;
  });

The first object in byVert corresponds to the first object of verticesClosest3 as one would expect.
But from the second object on only the vertex property corresponds while other properties don't.

fiddle

The problem probably lies in how I'm building the original-object, in the fiddle you can see that.

1

There are 1 answers

0
pinturic On BEST ANSWER

Maybe I understood the problem: there are a lot of vertices in verticesClosest3 that have the same vertix value; so simply the byVert shows all the same data that are in verticesClosest3 but in different order. Look at the image to see a couple of them. same index vertices