closestTo method

E closestTo(
  1. E target, [
  2. num difference(
    1. E a,
    2. E b
    ) = _difference
])

The closest element E to target.

Example:

const [2, 5, 6, 8, 10].closestTo(7) == 6

Implementation

E closestTo(E target, [num Function(E a, E b) difference = _difference]) =>
    _closestTo(target, difference);