Copy link to clipboard
Copied
I took over an ActionScript job.
While getting familiar with the style of coding used I came across some syntax I don't quite understand.
I could not find the answer in the forums.
Here is a snippet of code:
(function () {
var __this = {};
createjs.EventDispatcher.initialize(__this);
window.eventSource = __this;
})();
Is this declaring a function as a class?
We are publishing as Canvas/HTML5.
Thank you,
Mike
Hi.
This is not ActionScript. This is JavaScript.
And the code is a Self Executing Anonymous Function.
A JavaScript function that runs as soon as it is defined. Also known as an IIFE (Immediately Invoked Function Expression).
Self-Executing Anonymous Function - MDN Web Docs Glossary: Definitions of Web-related terms | MDN
What are Self-Invoking Anonymous Functions in JavaScript?
Regards,
JC
Copy link to clipboard
Copied
Hi.
This is not ActionScript. This is JavaScript.
And the code is a Self Executing Anonymous Function.
A JavaScript function that runs as soon as it is defined. Also known as an IIFE (Immediately Invoked Function Expression).
Self-Executing Anonymous Function - MDN Web Docs Glossary: Definitions of Web-related terms | MDN
What are Self-Invoking Anonymous Functions in JavaScript?
Regards,
JC