How to get CSS custom property in JavaScript

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