Do you mean how would you pass in an array of objects? I modified the function a bit here to allow you to input a sorted array of objects, the key you are targeting, and the value you are searching for. (This assumes that the array is already sorted by the specific key you're looking at).
I'm a very straightforward data science student in last year before master graduation. I like to learn bottom-up step by step and go through the logical discovery process myself as much as possible
I fully agree, nonetheless that would require using typescript, I had thought about making use of the valueOf function, however I like the way @stepho
did it since it is easier to reuse, even more for js newcomers.
Nice implementation, and thanks for the book recommendation, I just have one question, how would you implement that with objects?
Do you mean how would you pass in an array of objects? I modified the function a bit here to allow you to input a sorted array of objects, the key you are targeting, and the value you are searching for. (This assumes that the array is already sorted by the specific key you're looking at).
The clean way to extend function to generic types is to override a compare function I'd say
I fully agree, nonetheless that would require using typescript, I had thought about making use of the
valueOf
function, however I like the way @stepho did it since it is easier to reuse, even more for js newcomers.Nice function, I'm looking forward to your next post.