I can't find an answer to this question, sorry if it's a double post. Whenever I search for this, I get AJAX questions. So, are the first
and second
calls synchronous:
function test() {
first();
second();
}
?
I can't find an answer to this question, sorry if it's a double post. Whenever I search for this, I get AJAX questions. So, are the first
and second
calls synchronous:
function test() {
first();
second();
}
?
Sure of not... just try to console.log inside them, an alert between them, and you should see they are synchronous.
They can become like-asynchronous only if the first one is asynchronous also (but it means that it ends before stardting the second).
Following the example provided just after (or synchronously :D) my question, I think it is better this:
function first() {
console.log('1st ');
}
function second() {
console.log('2nd ');
}
function test() {
first();
alert("you see just the first one");
second();
}
They a re synchronous as long as the function first()
and second()
are not asynchronous within their scope.
But first()
will be called before second()
in any case.
You could find that out with a fiddle by logging something to the console with console.log()
.
function first() {
console.log('1st ');
}
function second() {
console.log('2nd ');
}
function test() {
first();
second();
}
// -> 1st 2nd