Highlighted

function syntax

New Here ,
Aug 20, 2019

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

Adobe Community Professional
Correct answer by JoãoCésar | Adobe Community Professional

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

TOPICS
ActionScript

Views

160

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

function syntax

New Here ,
Aug 20, 2019

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

Adobe Community Professional
Correct answer by JoãoCésar | Adobe Community Professional

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

TOPICS
ActionScript

Views

161

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Aug 20, 2019 1
Adobe Community Professional ,
Aug 20, 2019

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

__________________________________________
HTML5, JSFL, and AS3 samples: http://bit.ly/2mJgDoG

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Aug 20, 2019 0