Javascript IIFE (e.g. Syntax clarification needed)

While I was reading more info on Javascript IIFE, so as to get a better understanding, I came across the following piece of code as an example.
I’m a little confused as to the syntax and need help clarifying what I’m looking at.

let paintColor = 'red';

const paint = (() => {
    return = {
       changeColorToBlue: () => {
          paintColor: 'Blue';
          return paintColor;
    },
    changeColorToGreen: () => {
        paintColor: 'Green';
        return paintColor;
    }
  }
}) ();

console.log( paint.changeColorToBlue() );

So as I’m still new to programming, I try my best to make sure I can identify what everything is in code examples as I read documentation. So what I’m confused about within the above code is the Colon’s are throwing me off.

1.) I see paintColor is a declared Global variable.
2.) I see a declared arrow function called paint which is an IIFE I believe.
3.) However, why is there a colon after changeColorToBlue arrow function and changeColorToGreen arrow function?
4.) Also, is that an object inside the arrow functions changeColorToBlue?
I’m referring to:

paintColor: 'Blue';

and

paintColor: 'Green';

Thanks,
Shawn Wright

No I did not. I came across it in this article:

I was reading the article under IIFE and was confused at the code due to the syntax did not look like any examples I have been learning.

That’s what was confusing me, was the colons

I believe in both the arrow functions and inside the code block it should have been the assignment operator.

=

Which would make those variables inside the both arrow functions

Forgive me if I did not use the proper terminology and I appreciate the correction as I’m still learning.
As far as what I was referring to was inside the arrow functions:

changeColorToBlue {
/*
*  the variable paintColor: 'Blue'; 
*  should have been paintColor = 'Blue';
*  and inside arrow function changeColorToGreen
* the variable paintColor: 'Green';
* should have been paintColor = 'Green';
*/ 
}

SInce those variables are inside the the Curly Brackets of the 2 functions, I thought it was proper to say inside the code block. But I will not refer to it this way if this is not correct.

As always @RandellDawson , Thank you very much for your help!

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.