๐Ÿ”ฐanonymous function

๐Ÿšง ๆ–ฝๅทฅไธญ

JS โŸฉ value โŸฉ function โŸฉ name โŸฉ anonymous function

a function without a function name.

// โญ๏ธ anonymous functions
// โ•ญโ”€โ”€โ”€ ๐Ÿ”ธ โ”€โ”€โ”€โ•ฎ
  (function(){});    // function expression
                     // โญ๏ธ Note: "()" are requiredโ—๏ธ
// โ•ญโ”€ ๐Ÿ”ธ โ”€โ•ฎ
   () => {};         // arrow function

// โญ๏ธ Note:
//   function declaration, can't be anonymousโ—๏ธ 
function(){}
// โ›” SyntaxError: Function statements require a function name

Last updated