To find the closest or similar color in Javascript you will need a comparator. The answer is here on GitHub, as a JavaScript function accepting both RGB and hexadecimal color formats and returning their color difference using the CIE ΔE2000 formula.
// blue compared to darkslateblue
var delta_e = ciede_2000('#00F', '#483D8B')
// ΔE2000 ≈ 15.91 — noticeable difference
// darkslateblue compared to indigo
var delta_e = ciede_2000('#483d8b', 75,0,130)
// ΔE2000 ≈ 12.19 — distinct difference
// indigo compared to darkblue
var delta_e = ciede_2000(75, 0, 130, '#00008b')
// ΔE2000 ≈ 7.72 — moderate difference
// darkblue compared to navy
var delta_e = ciede_2000(0, 0, 139, 0, 0, 128)
// ΔE2000 ≈ 1.56 — slight difference