Very good, Suppose we have a class Car with the properties license plate, brand and color. If in an array we have 50 instances of that class
Is there any tool that allows to obtain all the data of an object knowing only its plate?
And if not, how do you think would be the most appropriate way to do it?
Thank you very much
If you have an array of objects representing cars and you want to find the object with a certain license plate, you can use filter :
However, if you know in advance that the license plate is going to act as a unique identifier for the objects, it is more efficient (and the code will be clearer) if instead of an array of objects you compose from the beginning an object whose keys are the license plates. and the values are the objects:
This way you can find your object simply with
vehiculos["1234ABC"]
.