I have declared two functions and one global variable . i am setting the global variable value in first method and trying to access the value in second method .
var Result=[];
setResult();
getResult();
function setResult(){
var resultJson=[];
resultJson.push({ "param1":"test","result":"success" });
Result=resultJson;
}
function getResult(){
console.log(Result);
}
sometimes i am getting the proper value in console as object=[{ "param1":"test","result":"success" }]
sometimes i am getting only empty array: [] how can i resolve this problem.