I am reading a book on javascript and there is a piece of code that I don't understand.
setTimeout( () => setTimeout(console.log, 0 , value *2), 1000);
What exactly is happening here? There are two setTimeout, and I think I only understand the inner one. I don't understand what () => function is doing? Can you explain?
I do follow:
setTimeout(console.log, 0 , value *2)
which is passing the argument 'value*2' to function/method console.log() after 0 milli seconds. I also understand that setTimeout() return the timeoutId.
I don't know the rest.
I see something similar with the following code:
let p1 = new Promise((resolve, reject) => resolve());
setTimeout(console.log, 0, p1); //Promise <resolved>
Don't understand this either.