// var set up globally OR locally depending on your requirements
var hC;
function(el) {
var $this = el;
hC = $this.hasClass("test");
// use the variable in the conditional statement
if (!hC) {
//
}
}
<div id="div1" class="myClass">there is a class</div>
<div id="div2"> there is no class2 </div>
$(document).ready(function(){
$("#div2").not('.myClass'); // do not have `myClass` class.
});