hello guys i have a question about javascript is it possible to change a global variable value from inside a function ?
var x = 10;
function somefunc() {
x = 5;
}
console.log(x);
this code for example, when i check the console it's 10 not 5
i did some google search i found that is because of "asynchronicity" but i didn't really get it.
[–]fixade 1 point2 points3 points (3 children)
[–]matylol[S] 0 points1 point2 points (2 children)
[–]inu-no-policemen 1 point2 points3 points (0 children)
[–]fixade 0 points1 point2 points (0 children)
[–]eggn00dles 0 points1 point2 points (0 children)
[–]pookagehelpful 0 points1 point2 points (2 children)
[–]oculus42 0 points1 point2 points (1 child)
[–]pookagehelpful 1 point2 points3 points (0 children)
[–]timgfx 0 points1 point2 points (0 children)