alstorx
alstorx

Reputation: 111

JavaScript Immediately Invoked Function - Distinguishing Between JavaScript Function Expressions and Declarations

In my journey of learning JavaScript, I encountered my first practical use case for an Immediately Invoked Function Expression (IIFE).

However, I'm struggling to understand the distinction between a function declaration and an expression in this specific context.

Could someone clarify why one is considered a declaration and the other an expression?

Declaration:

function pushToColorArray() {
    // Function body
};

Expression:

(function pushToColorArray() {
    // Function body
})();

Upvotes: 1

Views: 36

Answers (0)

Related Questions