JSFiddle - React, Tailwind, and code Playground
JavaScript
function return_value(){x += 100;}
var x = 100;
var timeout = 1000;
var f = function(){
console.log("Start...");
setTimeout( return_value() ,timeout); //долго исполняется
function sleepFor( sleepDuration ){
var now = new Date().getTime();
while(new Date().getTime() < now + sleepDuration){} // do nothing
}
sleepFor(timeout);
return x;
}
console.log( "x = ", x, "modified x = ", f() ); //f() - возвращает именённое x, через время.