Quantcast
Channel: Adobe Community: Message List
Viewing all articles
Browse latest Browse all 85594

Re: Scope Issues.

$
0
0

Hi there,

 

Great question. Using the examples above:

 

  • function handleClick(){}  - is scoped to the element event on which it exists. You can only call this from the same element event - anywhere else is out of scope.
  • window.handleClick = function (){}  - is scoped to Javascript's browser window object (global). Best practices are to not attach variables or functions to a global object. This would also include declaring a variable without the var keyword not recommended.
  • sym.handleClick = function(){}  - is scoped to the symbol. Any element/handler within the same symbol can call it. Outside of the symbol, you can get to it using getSymbol. This is the safest "global" variable to use.

 

If anything's unclear, feel free to ask.

 

hth,

Joe


Viewing all articles
Browse latest Browse all 85594

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>