Message from JavaScript discussions

October 2017

— I see


For example:

function myFunc1() {
console.log('This is myFunc1');
setTimeout(function () {
console.log('Timeout within myFunc1');
}, 1000);

function myFunc2() {
console.log('This is myFunc2');

myFunc1(); myFunc2();

Will produce:
This is myFunc1
(myFunc1 has registered a timeout and FINISHED executing and returned, myFunc2 starts running)
This is myFunc2
(myFunc2 is now done, ... the javascript application is now 'idle', waiting for events, timeouts, etc)
(After 1 second:)
Timeout within myFunc1
(The function within the timeout has now FINISHED executing)

— Same thing happens for callbacks to ajax requests, event listeners, promises, etc

— Hmm i see. i know about setTimeout but dont know about ajax. thanks

— If ajax was synchronous it would freeze your page while a request was loading

— And two requests at the same time would be impossible

— Vim

— WebStorm // Nano

— Inefficient

— Bad probably, "all possible pages" is probably alot of ui code

— ?

— Https://