javascript - How to make function wait for another? -
i have function, call function:
function_name(1) function function_name (i) { multiply(i) console.log(i); // 1 } function multiply (i) { = i*2 }
when it's executing, console.log(i)
return "1". need console.log(i) return "2". how can make wait till multiply()
executed?
there no need wait, methods synchronous console.log()
executing after multiply()
executed. problem updating local scoped variable i
in multiply locally scoped variable i
in function_name
not modified actions in multiply
you can return result multiply , use value in calling function like
function_name(1); function function_name(i) { = multiply(i); console.log(i); // 1 } function multiply(i) { return * 2; }
Comments
Post a Comment