let box = document.querySelector('.box');
let style = getComputedStyle(box);
let borderTopWidth = parseInt(style.borderTopWidth) || 0;
let borderLeftWidth = parseInt(style.borderLeftWidth) || 0;
let borderBottomWidth = parseInt(style.borderBottomWidth) || 0;
let borderRightWidth = parseInt(style.borderRightWidth) || 0;
Code language: JavaScript (javascript)
const htmlBody = document.getElementByTagName("body")[0];
const htmlStyles = window.getComputedStyle(htmlBody);
console.log(htmlStyles["background-color"]); // rgb(243, 242, 239)
console.log(htmlStyles["font-size"]); // 16px
window.getComputedStyle(element);
window.getComputedStyle(element, pseudoElt);