JSFiddle - React, Tailwind, and code Playground

HTML

<div id="test"></div>
<div id="output"></div>

CSS

#test {
    background-color: red;
}

JavaScript

var c1 = getComputedStyle(test);
var c2 = getComputedStyle(test.cloneNode(true));
output.innerHTML = "test  backgroundColor: \"" + c1.backgroundColor + "\"<br>" +
    "clone backgroundColor: \"" + c2.backgroundColor + "\"";

var c3 = document.createElement('div');
c3.setAttribute('id', 'test');
c3 = getComputedStyle(c3);
output.innerHTML += "<br>new  backgroundColor: \"" + c3.backgroundColor + "\"";


var el = document.createElement('div');
el.setAttribute('id', 'test');
c4 = getComputedStyle(el);
output.innerHTML += "<br>non-existing backgroundColor: \"" + c4.backgroundColor + "\"";