Function declaration and expression
by Mohan[ Edit ] 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