I am already prepared for downvoters sitting in front of the screen waiting for the perfect moment. I also know this will be marked as duplicate by someone but if there are 1000s of duplicates for this question, then there must be some more things to be clarified for the subject.. So my question is for those who can emphatise that I have tried most of the solutions for the duplicate questions and still did not achieve a desired result..
var myobj = {};
var objpromise = $.getJSON('path_to.json');
objpromise.done(function(result) {
myobj = result;
console.log(myobj.someproperty) // {"key": "value"} it is the desired result
});
console.log(myobj) // undefined.
now, many examples and suggestions say I should do my work within the .done callback. however, the result is an object where I will be using it throughout many places down below in my code.
In this case "yet again" how can I store the result in a global variable and ensure it is set before using it down below the code?