The idiomatic way is to use the logical or
operator:
var breadcrumbBar = null;
function getBreadcrumbBarElement() {
return breadcrumbBar || (breadcrumbBar = document.getElementById(breadcrumbBarElementId));
}
or, to make this a bit more generic:
var elementCache = {}
function getCached(id) {
return elementCache[id] || (elementCache[id] = document.getElementById(id));
}