Function expression and Function declaration in JavaScript
In JavaScript a function can be declared in two ways.
The first way is to simply declare the
function via function, immediately
giving its name:
javascriptfunction func() {
console.log('!');
}
func(); // shows '!'
The second way is to make an unnamed function and write it to some variable:
javascriptlet func = function() {
console.log('!');
};
func(); // shows '!'
Scientifically, the first method is called Function Declaration, and the second - Function Expression.
Задание 1
Determine if the presented function is a Function Declaration or a Function Expression:
javascriptfunction func() {
console.log('!');
}
Задание 2
Determine if the presented function is a Function Declaration or a Function Expression:
javascriptlet func = function() {
console.log('!');
}