You can't use two different variables with the same name from different scopes within the same scope. So when you declare your local global_var with the var keyword, your global becomes inaccessible.
If you need to make a local variable with the same name as a global you can use a closure like:
jQuery(document).ready(function($){
(function(global_var){
// global_var is a local copy of global_var from the outer scope
global_var = typeof global_var == 'undefined' ? {foo:2} : global_var;
console.log(global_var);
})(global_var);
});
You can also refer to it as a property of the window object if you know it's global:
jQuery(document).ready(function($){
var global_var = typeof window.global_var == 'undefined' ?
{foo:2} : window.global_var;
console.log(global_var);
});
Finally, if you don't want a local copy and just want to access the variable from the outer scope, then do not use the var keyword, since the purpose of that keyword is declaring a new variable:
jQuery(document).ready(function($){
global_var = typeof global_var == 'undefined' ? {foo:2} : global_var;
console.log(global_var);
});