Assignment function to a variable in JavaScript
Now let our locally called function doesn't
display something to the console, but
returns it via return:
javascript+function() {
return '!';
}();
Let's assign the result of our function to a variable and print it to the console. Since in this case there is an assignment to a variable, the plus is no longer needed:
javascriptlet result = function() {
return '!';
}();
console.log(result); // shows '!'
Задание 1
Determine what will be output to the console without running the code:
javascriptlet result = function() {
return '!';
}();
console.log(result);
Задание 2
Determine what will be output to the console without running the code:
javascriptlet result = function() {
return '!';
};
console.log(result);
Задание 3
Determine what will be output to the console without running the code:
javascriptlet result = function() {
return '!';
};
console.log(result());