javascript check if dom element exists

JavaScript
var myElement = document.getElementById("myElementID");

if(!myElement){
    //#myElementID element DOES NOT exist
}

if(myElement){
    //#myElementID element DOES exists
}
Source

Also in JavaScript: