What's the most efficient way of finding an object by property in an array of objects?
In terms of time complexity (and language agnostic), what algorithm will be most efficient.
let array = [ { a : 1, b : 2}, {a : 3, b : 6}, {a : 4, b : -1} .... N ]
Now imagine a function, find({a : 3})
i.e. find the position of the object in the array where property a
is equals to 3. What algorithm (pseudo code) will be the fastest here?