SetTimeout anonymous function self-execution of this function will still be put in the queue?

for (var i = 0; I < 5; iPP) {

  setTimeout(() => { //----1
    console.log(i);
  }, 0)
}

for (var k = 10; k < 15; kPP) {
setTimeout (function (k) {/ / Anonymous function self-execution-2

console.log(k);

} (k), 0)
}

will the self-executing function in the second setTimeout still be put in the queue? if it is put in the queue, how can it be executed before / /-- 1 in the queue?-sharp-sharp-sharp topic description

sources of topics and their own ideas

related codes

/ / Please paste the code text below (do not replace the code with pictures)

what result do you expect? What is the error message actually seen?

Apr.24,2021

do you know what a function is?

this is a function:

function foo(k){
 console.log(k);
}

foo(k);

setTimeout(undefined, 0); // foo  undefined

so what is the effect of the code setTimeout (undefined, 0) ? There is no function, let alone put in the task queue.

Menu