Pergunta de entrevista da empresa Glassdoor

A page uses 2 js files. Script1.js has a login function in a pop-up, script2.js contains event handlers for certain clicks on a page. If the user is logged in, the click event is processed in script2.js. If they aren't they get the pop up from script1.js and if/when they login in, whatever they clicked goes thru in script2.js. How do you do this?

Resposta da entrevista

Sigiloso

7 de fev. de 2013

Callbacks. You check if the user is logged in at the click, if they aren't you call script2, with a callback to the event/function to fire in script1 if the login is successful.