Function declaration and expression

by Mohan 2012-09-20 23:06:54


Function declaration and expression
Function declaration:
bar(); // prints: bar
function bar() {

Print('bar');
}

function foo() {

Print('foo');
}
foo(); // prints: foo
Function expression:
(function foo() {
Print( foo.name );
})(); // prints: foo
foo(); // rise a ReferenceError

!function foo() {
}
foo(); // rise a ReferenceError

var bar = function foo() {
}
foo(); // rise a ReferenceError



799
like
0
dislike
0
mail
flag

You must LOGIN to add comments