I am trying to understand JavaScript Async/Await feature.
So I wrote a short code to understand it but it is giving me unusual behaviour/result.
var a = 10;
function load_data(data) {
setTimeout(() => {
a = data
}, 2000);
}
function print() {
console.log(a);
}
async function init() {
await load_data(40);
print();
}
init();
I expect the value logged to be 40, but its logging 10 with async and await.