I'm trying to use a variable outside an anonymous function. Not declaring it as var in the function should make it's scope global but it doesnt work in this case. I think you have to call the function first but how do i call this function? PS: I'm just learning js. Thanks.
$(document).ready(function(){
navigator.geolocation.getCurrentPosition(function(position) {
x = position.coords.latitude;
y = position.coords.longitude;
});
console.log(x);}); //end of ready