Explore 100's Of Free Video Tutorials

Keep Learning, Keep Coding & Keep Sharing

Function declaration Vs expression

Notes:

2. Function Expression:
A function defined with function expression, begins with var keyword Syntax: /* function definition */
var functionName = function( [param1,param2,…… paramN] ) //function header
{
statement(s);
[return returningValue;] // by default functions return undefined value
}

Ex: a function without parameters, without returning value
var wishHi = function()
{
document.write("Hi","<br/>");
}

Note: Functions get execute only when we call them

Syntax: /* function call */
functionName([parameters list]);

Ex:
wishHi();

Interview Questions: