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

Popular posts from this blog

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

linux - disk space limitation when creating war file -