How to convert a RGBA color like rgba(0, 0, 0, 0.86) to a RGB hex value that takes the alpha component into account?

SO question link here. Code for my answer given here.

Live demo (requires Javascript enabled)