The following prints my message straight away
setTimeout(console.log('delayed hello world'), 10000);
It's a little bit counterintuitive. And since my message print straight away what happens at the end of 10 seconds?
The following prints my message straight away
setTimeout(console.log('delayed hello world'), 10000);
It's a little bit counterintuitive. And since my message print straight away what happens at the end of 10 seconds?
You are running console.log (because you have ()
on the end of it) and passing its return value to setTimeout
instead of passing a function.
var myFunction = function () { console.log('delayed hello world'); }
setTimeout(myFunction, 10000);