How to detect if there is a scroll bar in a browser window


I'm trying to detect if there actually is a scrollbar being shown in the browser window. Answers to questions like this detect wether the content can be scrolled, but given modern os's and browsers, that doesn't always mean that there actually and constantly is a scrollbar. Does anyone know if/how that is possible?

function getScrollBarState() {
    var result = {vScrollbar: true, hScrollbar: true};
    try {
        var root = document.compatMode=='BackCompat'? document.body : document.documentElement;
        result.vScrollbar = root.scrollHeight > root.clientHeight;
        result.hScrollbar = root.scrollWidth > root.clientWidth;
    } catch(e) {}

Response from : How do I detect if there are scrollbars on a browser window?