3
I have the hypothetical situation:
function fTeste2(valor) {
setTimeout(function() {
alert("Hello");
}, 3000);
return valor + 5;
}
function fTeste1(valor) {
return fTeste2(valor);
}
alert(fTeste1(10));
Note that function 2 sends the sum without having finished the entire internal process, I know that if I put the sum within the settimeout it will wait and give me the result, but function 2 exemplifies a function with various operations, this in another language would wait for the end of function 2, already in javascript this does not occur, how to solve?
You’re doing something asynchronous. Behold
– Marconi