How to check minimize or make if-condition on object loop more correct? I am looping through an object and finding whether or not the object has the "key," along with some further stuff.

I feel that there is some other correct way to do this apart from this:

var initialLocalesGen = function(data){

    var status;


    if(!$.isEmptyObject(data)){

        console.log(data);

        if(data.hasOwnProperty("username") &amp;&amp; data.hasOwnProperty("name")){ 
            var headerHtml = Handlebars.compile($("#header-template").html());
            $("#userInfoBar").append(headerHtml({"username" : data["username"], "name" : data["name"]}));
        }

        if(data.hasOwnProperty("allLocales")){
            var formHtml = Handlebars.compile($("#locale-template").html());
            $("form legend").after(formHtml(data["allLocales"])).end().find("span.submit").css({display:"block"});  
        }

        if(data.hasOwnProperty("status") &amp;&amp; parseInt(data["status"]) === 0){
                currentStatus = 0;
                var object1 = {"status" : data["status"] , "userLocales": data["userLocales"]}
                userLocalesProcess(object1);    
        }

        if(data.hasOwnProperty("status") &amp;&amp; parseInt(data["status"]) === 1){
                currentStatus = 1;      
                userChangeProcess({"changeLocales" : data["changeLocales"],"userLocales" : data["userLocales"] });
                popupMaker({"message":data["message"],"status":data["status"]});
        }

        if(data.hasOwnProperty("status") &amp;&amp; parseInt(data["status"]) === 2){
                currentStatus = 2;          
        }

    }

    console.log("currentStatus:", currentStatus);

}


Could anyone help me minimize the condition or show me an even better way of doing it?
You could merge the last three ifs. (I assume there are no other states.)   

if(data.hasOwnProperty("status")){
        currentStatus =  parseInt(data["status"]);
        switch(currentStatus ) {
             case 0:
                  var object1 = {"status" : data["status"] , "userLocales": data["userLocales"]}
                  userLocalesProcess(object1);    
                  break;
             case 1:  
                  userChangeProcess({"changeLocales" : data["changeLocales"],"userLocales" : data["userLocales"] });
                  popupMaker({"message":data["message"],"status":data["status"]});
                  break;
             default:
                  break;
        }

}


I think there is nothing else you can do here. All other ifs are totally different. Maybe you could extract method or variables do communicate the meaning of every branch, but beside that I thing we are done.



Of course, if is also suitable

...
if (currentStatus ==0) {
    var object1 = {"status" : data["status"] , "userLocales": data["userLocales"]}
    userLocalesProcess(object1);    
} else if (currentStatus ==1){
    userChangeProcess({"changeLocales" : data["changeLocales"],"userLocales" : data["userLocales"] });
    popupMaker({"message":data["message"],"status":data["status"]});
}
...




Maybe you should just stay with obj.property == null. According to the link above it seems to be faster, but at least it is easier to read.