Returns the 'minimum' point from an array of points, using a comparison function.
const points = [...];const center = {x: 100, y: 100};const closestToCenter = findMinimum((a, b) => { const aDist = distance(a, center); const bDist = distance(b, center); if (aDistance < bDistance) return a; return b;}, points); Copy
const points = [...];const center = {x: 100, y: 100};const closestToCenter = findMinimum((a, b) => { const aDist = distance(a, center); const bDist = distance(b, center); if (aDistance < bDistance) return a; return b;}, points);
Compare function returns the smallest of a or b
a
b
Rest
Returns the 'minimum' point from an array of points, using a comparison function.
Example: Find point closest to a coordinate
Param: comparer
Compare function returns the smallest of
a
orb
Param: points
Returns