UNPKG

antd-mobile

Version:
5 lines 154 B
export function nearest(arr, target) { return arr.reduce((pre, cur) => { return Math.abs(pre - target) < Math.abs(cur - target) ? pre : cur; }); }