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.
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:
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!