In Javascript,
If I have the following, is b called after a has finished or not?
function main() {
a();
b();
}
function a() {
//Processing
}
function b() {
//More Processing
}
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
In that code, nothing happens at all, since none of the functions are actually called.
If the “main()” function were to be called, then it’s guaranteed that the call to “a” would complete before the function “b” was initiated. In the context of a web browser, JavaScript is strictly single-threaded unless you’re delving into the new-ish “web worker” capabilities.