The Element.childElementCount read-only property returns the number of child elements of this element.
Element.childElementCount
let sidebar = document.getElementById("sidebar"); if (sidebar.childElementCount > 0) { // Do something }
Document.childElementCount
DocumentFragment.childElementCount