How to set a timer in JavaScript?

How to set a timer in JavaScript?

Quite often you might come across scenarios wherein you would need to have a timer set in JavaScript. For instance, you might want to call a function after a delay of say 10 seconds or you may want to trigger a function every 15 seconds automatically. A very common...