DEV Community

Discussion on: 5 Ways to Write Functions in JavaScript

Collapse
 
koladev profile image
Mangabo Kolawole

Great Jakub.

I wanted to add this one in the article, but it's not really widely used.

Collapse
 
jcubic profile image
Jakub T. Jankiewicz • Edited

You're right, but to be complete you need to know about it.

Also, you missed named function expressions:

const mul = function recur(a, b){
    if (a === 0) {
       return b;
    }
    return recur(a -1, b + 1);
};
Enter fullscreen mode Exit fullscreen mode

and immedietly invoked function expressions:

(function() {
   const x = 10;
   console.log({x});
})();
Enter fullscreen mode Exit fullscreen mode