How to get CSS custom property in JavaScript

DOM
By Jad Joubran · 
Last updated Mar 12, 2018
:root {
  --primary-color: #ececec;
}
const color = getComputedStyle(document.body).getPropertyValue(
  "--primary-color"
);
#ECECEC