javascript - named function vs expression function

named function vs expression function

articles

hoisting

Hoisting : developer.mozilla.org

variable and function declarations are put into memory during the compile phase

Hoisting is not available with expression function where the declaration order impact function usage.

function catName(name) {
  console.log("My cat's name is " + name);
}

catName("Tigger");
/*
The result of the code above is: "My cat's name is Tigger"
*/
catName("Chloe");

function catName(name) {
  console.log("My cat's name is " + name);
}
/*
The result of the code above is: "My cat's name is Chloe"
*/

results for ""

    No results matching ""