I have two versions of the code. Can someone let me know which is optimal and faster?
Version 1:
function showMsg(a)
{
alert(a);
}
function invokeShowMsg()
{
var msg = 'hi';
showMsg(msg);
}
window.setTimeout(invokeShowMsg,1000);
Version 2:
function showMsg(a)
{
alert(a);
}
window.setTimeout(function(){showMsg('hi');},1000);
One more doubt, is the Version 2 way of calling called "Closure"?