Closed cameronbourke closed 8 years ago
Hi, while if you define a function using function statement, it return undefined
function a(){}
but when you put this code in a console.log
as parameter, it become a function expression, not statement anymore.
anyfunction(function a(){})
//=> function a is expression
a= function b(){}
//=> function b is expression
but
function a(){}
// function a is statement
function(){}
// SyntaxError: function statement requires a name
because it's expect to be a statement, but statement must have a name
Yeah you are right. I think I confused myself between a function statement and a named function expression.
let foo = function foo() {}
While the above is a named function, it is not a function statement. Is that correct?
yeah, that is correct. whenever a function is placed in a value's place, it's a expression, no matter it's named or anonymous function
Really cool book! Just wanted to point out something I don't think is true. In chapter 1.1 you say
Both a named function and anonymous function have a return value. Consider the following:
Both of these functions would return
What are your thoughts?