Is scope of variables same in both Java and JavaScript. I have a variable in javascript and assigned when onLoad Page. but while keep on adding functions in my project, I got this variable as NULL. I checked multiple times this variable not assigned again but few places (In functions) used local variables with the same name. I am doubt that this will effect my global variable value. I have now huge functions I don't want to touch them. Please help me to resolve.
Code here: in
 <script>
// other variables goes here.
    var BUSINESS_CODE_CUSEUR = "<%=BusinessLine.BUSINESS_LINE_CODE_GLOBAL_CUSTODY_UK%>";
    var branchId = null;
//on Refresh branch,
function refreshByBranch(){
            branchId = dijit.byId("branchList").attr("value");
         // other functions calling here who ever is depending on branch.
                        searchTeamList(branchId);
            searchCustomer(branchId);
            searchClientRelationshipFsList();
//and so on.
}
//my function is here: calling on an image click.
function showSelectRootCauseDialog(){
    var br = dijit.byId("branchList").attr("value");
    console.info("showSelectRootCauseDialog - branchId:" + branchId);
    console.info("showSelectRootCauseDialog - br:" + br);
// getting null on line 2.
}
 </script>
-- Problem solved here like this. we made changes in every function.
    function refreshByBranch(){
                branchId = dijit.byId("branchList").attr("value");
                var url = contextPath + "/" + servlet + "?cmd_query_for_user=1&branchId=" + branchId;
                originatorUserStore.url = url;
                ownerUserStore.url = url;
                resolverUserStore.url = url;
                searchTeamList(branchId);
                searchCustomer(branchId);
                searchClientRelationshipFsList();
                if(currentBusinessLineCde == gcBusinessLineCde){
                //  var branchId = dijit.byId("branchList").attr("value");
////-- Problem solved here. by making comment. 
                    searchGroupList(branchId);  
                    searchLocationList(branchId);
                    searchClientList(branchId);
                    searchAccountManagerList(branchId);
                }
            }
 
     
    