fn decleration VS expression

by bhupendra negi

JavaScript

/* this fiddle compares fn decleration and expression */

foo();
foo1(); /*throws error */

function foo()
{
 alert("HI");   
}


var foo1 = function() 
{
    alert("bye");
}

//foo1(); need to be declared here
// js function hoisted up not in case of expressions.