January 2019
Beginner
210 pages
4h 47m
English
In the preceding section, we introduced the possibility of declaring functions with (a named function) or without (an unnamed or anonymous function) explicitly indicating their name, but we didn't mention that we were also using two different types of function.
In the following example, the named function, greetNamed, is a function declaration while greetUnnamed is a function expression. For the time being, please ignore the first two lines, which contain two console.log statements:
console.log(greetNamed("John")); // OKconsole.log(greetUnnamed("John")); // Errorfunction greetNamed(name: string): string { return 'Hi! ${name}';}let greetUnnamed = function(name: string): string { return 'Hi! ${name}'; ...Read now
Unlock full access