Note that the expression in which the function is involved must be to the left of it. If we try to do something to the right of a function, it won't make it a function expression. An example:
function func() { // this is Function Declaration
console.log('!');
} + 1;
Why so: because in this case this +1 is just a new command written after the function. If you write this command from a new line, everything becomes clearer:
function func() {
console.log('!');
}
+1; // just a command
Let's make a Function Expression out of our
function. For example, put +
in front
of the function:
+function func() { // this is Function Expression
console.log('!');
} + 1;
Or let's do the assignment:
let test = function func() { // this is Function Expression
console.log('!');
} + 1;
Or pass as a parameter to alert:
console.log(function func() { // this is Function Expression
console.log('!');
} + 1);
Determine if the presented function is a Function Declaration or a Function Expression:
function func() {
console.log('!');
}
+1;
Determine if the presented function is a Function Declaration or a Function Expression:
function func() {
console.log('!');
} + 1;
Determine if the presented function is a Function Declaration or a Function Expression:
+function func() {
console.log('!');
} + 1;
Determine if the presented function is a Function Declaration or a Function Expression:
+
function func() {
console.log('!');
} + 1;
Determine if the presented function is a Function Declaration or a Function Expression:
+ 1
function func() {
console.log('!');
} + 1;
Determine if the presented function is a Function Declaration or a Function Expression:
function func() {
console.log('!');
} + console.log('!');