Skip to main content
Participant
August 20, 2019
Answered

function syntax

  • August 20, 2019
  • 1 reply
  • 411 views

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

This topic has been closed for replies.
Correct answer JoãoCésar17023019

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

1 reply

JoãoCésar17023019
Community Expert
JoãoCésar17023019Community ExpertCorrect answer
Community Expert
August 21, 2019

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