functions Flashcards
what type of statement is this
var awesomeFunction = function(coolThings) { // .. return amazingStuff; };
anonymous function expression
no identifier betwen function and (). gets an inferred name from assignment.
This function is an expression that is assigned to the variable awesomeFunction. Different from the function declaration form, a function expression is not associated with its identifier until that statement during runtime.
what type of statement is this
function awesomeFunction(coolThings) { // .. return amazingStuff; }
function declaration
This is called a function declaration because it appears as a statement by itself, not as an expression in another statement. The association between the identifier awesomeFunction and the function value happens during the compile phase of the code, before that code is executed.
what type of statement is this
var awesomeFunction = function someName(coolThings) { // .. return amazingStuff; };
awesomeFunction.name;
named function expression
// “someName”
someName is directly associated with the function expression at compile time
what type of statement is this
*two() { .. }
generator function declaration function
what type of statement is this
async function three() { .. }
async function declaration
what type of statement is this
async function *four() { .. }
async generator function declaration
what type of statement is this
export function five() { .. }
named function export declaration (ES6 modules)
what type of statement is this
(function(){ .. })();
immediately invoked function expresion
what type of statement is this
(async function(){ .. })();
async immediately invoked function expresion
what type of statement is this
(async function myname(){ .. })();
named async immediately invoked function expresion
what type of statement is this
(function myname(){ .. })();
named immediately invoked function expresion
what type of statement is this
const f = () => 42;
arrow function
what type of statement is this
const f = async () => 42;
async arrow function
what type of statement is this
const obj = { oldSchool: function() { .. } }
(anonymous) function expression property
what type of statement is this
const obj = { boringMethod() { .. }, }
object method