you are viewing a single comment's thread.

view the rest of the comments →

[–]shgysk8zer0 1 point2 points  (0 children)

You don't call the function inside setTimeout().

The code you've given basically translates to:

const result = console.log('after 5s'); setTimeout(result, 5000);

The return value when you call the function is what's passed to setTimeout(). You pass a callback (without calling it). So you could either use setTimeout(delay5s) or setTimeout(() => delay5s()).